Garanator Posted October 18, 2005 Share Posted October 18, 2005 I want my script only to run when a hotkey is pressed how would i go about doing that? HotkeySey("{F7}, "?") Script I want to run only when f7 is pushed Func ? Also to not have to double post is there a way to make the script only run once. What I mean by that is the script will run but then like gets an error no matter what if ran again? Link to comment Share on other sites More sharing options...
Valuater Posted October 18, 2005 Share Posted October 18, 2005 (edited) maybe like this expandcollapse popup; Press Esc to terminate script, Pause/Break to "pause" Global $Paused, $T = 0 HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("{F9}", "ShowMouse") ;;;; Body of program would go here;;;; While 1 If $T = 1 Then $pos = MouseGetPos() MsgBox(0,"RUNNING", "This Script is now running") $T = 2 EndIf Sleep(10) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMouse() If $T = 0 Then $T = 1 Return EndIf If $T = 2 Then MsgBox(0,"ERROR", "This Script will only run once") Return EndIf EndFunc 8) Edited October 18, 2005 by Valuater Link to comment Share on other sites More sharing options...
CrewXp Posted October 18, 2005 Share Posted October 18, 2005 (edited) yea, valuater's is right on it.Anotherwords though:;Explanation: HotKeySet("{KEY}", "FUNCTION NAME") HotKeySet("{F9}", "ShowMouse") ;Explanation: FUNCTION NAME WITH () BELOW!Func ShowMouse();PLACE YOUR SCRIPT HEREEndFunc ;Ends the Function;Explanation: This loads what needs to be loaded, then pauses it (keeps it running so you can hit hotkeys)While 1WEnd Edited October 18, 2005 by CrewXp Link to comment Share on other sites More sharing options...
LxP Posted October 18, 2005 Share Posted October 18, 2005 Small modification to Crew's code:While 1 Sleep(0x7FFFFFFF) WEndIt's important to have a Sleep() in the loop or else your CPU usage will fly through the roof and slow everything else down. (The 0x7FFFFFFF is just a very large number in hex notation -- the larger the number, the less often the loop has to be looped and therefore the less unnecessary CPU usage.) Link to comment Share on other sites More sharing options...
Garanator Posted October 18, 2005 Author Share Posted October 18, 2005 In this that would mean that the program can be ran only once everytime you run it but you can just re run to have it be ran again. So is it possible to make it only run once forever? unless you have the sorce code? Func ShowMouse() If $T = 0 Then $T = 1 Return EndIf If $T = 2 Then MsgBox(0,"ERROR", "This Script will only run once") Return EndIf Link to comment Share on other sites More sharing options...
Valuater Posted October 18, 2005 Share Posted October 18, 2005 you could use a file to set wether it has ever been used if filexist( @SystemDir & "\Once.dat" )then message box... this file has been ran before exit else fileWrite( @SystemDir & "\Once.dat" ) endif most of it is there... not tested 8) Link to comment Share on other sites More sharing options...
Garanator Posted October 18, 2005 Author Share Posted October 18, 2005 (edited) nvm posted in new topic Edited October 18, 2005 by Garanator 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