Guest Execute_Me Posted January 16, 2005 Share Posted January 16, 2005 Hi Dudes, i have a Question about Hotkeys. $count = 8 HotKeySet("{F2}", "MousePos") While $count < 10 $count = $count + 1 Func MousePos() $file = FileOpen("pos.txt",1) $pos = MouseGetPos ( ) FileWrite($file,$pos[0] & "," & $pos[1] & @CRLF) EndFunc WEnd FileClose ($file) This is my little, buggy Script. It doesnt work and i don't know why .. but the main question is -> Is this the right way to use hotkeys? I wanted to make a proggy which saves the Mouse Positions every time a use a hotkey into a .txt File. But i have some problems with holding a window opened to end this. Means -> The Window stays open all the time and ín this time i can make some mousecoords. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 16, 2005 Developers Share Posted January 16, 2005 Func statement cannot be inside a loop. Below script will loop forever and anytime you hit F2 will write the mouse pos at the end of the file : Global $file = "pos.txt" HotKeySet("{F2}", "MousePos") While 1 sleep(10) WEnd ; Func MousePos() $pos = MouseGetPos() FileWriteLine($file, $pos[0] & "," & $pos[1]) EndFunc ;==>MousePos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Guest Execute_Me Posted January 16, 2005 Share Posted January 16, 2005 (edited) Why you did the Func behind the While .. The Func get invoked before its defined ? Anf why Sleep (10) ? The Scripts works well but i don't understand it really Edited January 16, 2005 by Execute_Me Link to comment Share on other sites More sharing options...
MHz Posted January 16, 2005 Share Posted January 16, 2005 While 1 sleep(10) WEndThat While-WEnd loop keeps the script going, the sleep save your CPU working too hard. While this loop is running, your hotkey F2 is always active to call MousePos() function. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 16, 2005 Developers Share Posted January 16, 2005 Why you did the Func behind the While .. The Func get invoked before its defined ?Anf why Sleep (10) ?The Scripts works well but i don't understand it really <{POST_SNAPBACK}>Just read up on Functions in the helpfile or the online manualSee if that explains it for you.... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Guest Execute_Me Posted January 16, 2005 Share Posted January 16, 2005 ahh yeah .... every 10 seconds is writes the koords ! ; bla Global $file = "pos.txt" HotKeySet("{F2}", "MousePos") HotKeySet("{F3}", "End") While 1 sleep(10) WEnd ; Func MousePos() $pos = MouseGetPos() FileWriteLine($file, $pos[0] & "," & $pos[1]) EndFunc ;==>MousePos Func End() Exit EndFunc;==> End With Exit Func.... but i didn't get a Window Work .. if i click on the "OK" button it stops the Script. Somebody could tell me how? something like If MsgBox(0, "bla", "bla") = 1 Then Exit Link to comment Share on other sites More sharing options...
Developers Jos Posted January 16, 2005 Developers Share Posted January 16, 2005 (edited) ahh yeah .... every 10 seconds is writes the koords ! <{POST_SNAPBACK}>Sleep(10) means sleep 10 msec = .01 secWith Exit Func.... but i didn't get a Window Work .. if i click on the "OK" button it stops the Script.Somebody could tell me how? something like If MsgBox(0, "bla", "bla") = 1 Then Exit<{POST_SNAPBACK}>You are talking in riddles here ......Do you main you want to get a prompt when you press F3 ????Like:Func End() If MsgBox(4,"Cancel Execution?","Do you want to cancel the Program?") = 6 Then Exit EndFunc;==> EndEDIT: corrected calculation... tnx slimshady Edited January 16, 2005 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SlimShady Posted January 16, 2005 Share Posted January 16, 2005 (edited) @JdeB and others: 1000 milliseconds = 1 second 100 milliseconds = 0.1 second 10 milliseconds = 0.01 second 1 millisecond = 0.001 second Edited January 16, 2005 by SlimShady Link to comment Share on other sites More sharing options...
ezzetabi Posted January 16, 2005 Share Posted January 16, 2005 Even better, a full list:http://www.simetric.co.uk/siprefix.htmNow you know that a yottasecond is more than 31688764615412794 years. 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