gamerman2360 Posted July 20, 2005 Share Posted July 20, 2005 (edited) First my script: #include <GUIConstants.au3> GUICreate("MouseRecorder") HotKeySet("{ESC}", "Terminate") $file = FileOpen("C:\Documents and Settings\Administrator\Desktop\New Text document.txt", 2) Global $time While 1 While 1 $i = GUIGetCursorInfo() If $i[2] = 1 Then $dif = TimerDiff($time) FileWriteLine($file, $dif);needs to not write the first time ExitLoop EndIf WEnd While 1 $i = GUIGetCursorInfo() If $i[2] = 0 Then $time = TimerInit() ExitLoop EndIf WEnd WEnd Func Terminate() FileClose($file) Sleep(3000) Run("C:\Documents and Settings\Administrator\Desktop\New Text document.txt");I can't get the run to work. Exit EndFunc ;==>Terminate Now my problem, is there a way to make it not take away all the CPU? If I run it in a lower priorty it works but i dont know if it affects the results. Edited July 20, 2005 by gamerman2360 Link to comment Share on other sites More sharing options...
buzz44 Posted July 20, 2005 Share Posted July 20, 2005 (edited) Try adding a Sleep(1) in the main loop.Edit: Actually make that the loop with FileWriteLine() Edited July 20, 2005 by Burrup qq Link to comment Share on other sites More sharing options...
gamerman2360 Posted July 20, 2005 Author Share Posted July 20, 2005 #include <GUIConstants.au3> GUICreate("MouseRecorder") HotKeySet("{ESC}", "Terminate") $file = FileOpen("C:\Documents and Settings\Administrator\Desktop\New Text document.txt", 2) Global $time While 1 While 1 $i = GUIGetCursorInfo() If $i[2] = 1 Then $dif = TimerDiff($time) ExitLoop EndIf WEnd While 1 $i = GUIGetCursorInfo() If $i[2] = 0 Then $time = TimerInit() ExitLoop EndIf WEnd Sleep(1) FileWriteLine($file, $dif);needs to not write the first time WEnd Func Terminate() FileClose($file) Sleep(3000) Run("C:\Documents and Settings\Administrator\Desktop\New Text document.txt");I can't get the run to work. Exit EndFunc ;==>Terminate So this? I don't see how the FileWriteLine() change helps. Link to comment Share on other sites More sharing options...
buzz44 Posted July 20, 2005 Share Posted July 20, 2005 I mean move the Sleep(1) not FileWriteLine() lol, like this...#include <GUIConstants.au3> GUICreate("MouseRecorder") HotKeySet("{ESC}", "Terminate") $file = FileOpen("C:\Documents and Settings\Administrator\Desktop\New Text document.txt", 2) Global $time While 1 While 1 $i = GUIGetCursorInfo() If $i[2] = 1 Then $dif = TimerDiff($time) FileWriteLine($file, $dif);needs to not write the first time ExitLoop EndIf Sleep(1) WEnd While 1 $i = GUIGetCursorInfo() If $i[2] = 0 Then $time = TimerInit() ExitLoop EndIf WEnd WEnd qq Link to comment Share on other sites More sharing options...
LxP Posted July 20, 2005 Share Posted July 20, 2005 You mat find that a larger Sleep() value may help to further lower CPU usage (from recent posts it appears that Sleep(1) can be as bad as no Sleep() at all...). Link to comment Share on other sites More sharing options...
buzz44 Posted July 20, 2005 Share Posted July 20, 2005 Well I tested first and it drop's the CPU usage dramatically. qq Link to comment Share on other sites More sharing options...
seandisanti Posted July 20, 2005 Share Posted July 20, 2005 You mat find that a larger Sleep() value may help to further lower CPU usage (from recent posts it appears that Sleep(1) can be as bad as no Sleep() at all...).<{POST_SNAPBACK}>Actually i think the most recent stuff on sleep says that sleep(1) = sleep(15) rather than no sleep at all Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now