Harusal Posted November 9, 2008 Share Posted November 9, 2008 (edited) im trying to make so that i press a hotkey and it starts the function, but then when i press a different hotkey it will stop that same function. but i want to be still able to press the first hotkey and start the function again. if someone knows how to do this it will be a great help! Edited November 9, 2008 by Harusal Link to comment Share on other sites More sharing options...
Harusal Posted November 9, 2008 Author Share Posted November 9, 2008 I think it would be something like this but i don't know how to do the function "Stop" HotKeySet("{F4}", "ExitProg") HotKeySet("{F5}", "Start") HotKeySet("{F6}", "Stop") Func ExitProg() Exit 0 ;;Exits the program EndFunc Func Start() While 1 ;;Do Something Wend Func Stop() ;;Stop the Function "Start" Endfunc Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 9, 2008 Share Posted November 9, 2008 You could have a variable like Func Start() $var = 1 While $var = 1 ;start code WEnd EndFunc Func Stop() $var = 0 EndFunc Or for the same key to start/stop Func Start() $var = Not $var While $var ;code func WEnd EndFunc Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Harusal Posted November 9, 2008 Author Share Posted November 9, 2008 (edited) I didn't think of that! Thanks So Much!! Edited November 9, 2008 by Harusal Link to comment Share on other sites More sharing options...
dbzfanatic Posted November 9, 2008 Share Posted November 9, 2008 You're welcome . Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Harusal Posted November 9, 2008 Author Share Posted November 9, 2008 (edited) It's doing the code but it won't end when i press F6 Edited November 9, 2008 by Harusal Link to comment Share on other sites More sharing options...
Demonic Posted November 9, 2008 Share Posted November 9, 2008 Your while statement doesnt go into a function. HotKeySet("{F4}", "ExitProg") HotKeySet("{F5}", "StartStop") $On = False While 1 While $On = True ;Your code you want toggled on and off WEnd Sleep(100) WEnd Func StartStop() If $On = False Then $On = True Else $On = False EndIf EndFunc Func ExitProg() Exit EndFunc Link to comment Share on other sites More sharing options...
Harusal Posted November 9, 2008 Author Share Posted November 9, 2008 (edited) i did this:HotKeySet("{F4}", "ExitProg") HotKeySet("{F5}", "StartStop") Func ExitProg() Exit 0;;Exits the program EndFunc $On = False While 1 While $On = True ;;Do Code WEnd Sleep(100) WEnd Func StartStop() If $On = False Then $On = True Else $On = False EndIf EndFuncand i got this error Edited November 9, 2008 by Harusal Link to comment Share on other sites More sharing options...
system24 Posted November 9, 2008 Share Posted November 9, 2008 HotKeySet("{F4}", "ExitProg") HotKeySet("{F5}", "StartStop") Func ExitProg() Exit 0;;Exits the program EndFunc Dim $On $On = False While 1 While $On = True ;;Do Code WEnd Sleep(100) WEnd Func StartStop() If $On = False Then $On = True Else $On = False EndIf EndFunc [center]It's a question of mind over matter, if I don't mind, it doesn't matter.[/center] Link to comment Share on other sites More sharing options...
Harusal Posted November 9, 2008 Author Share Posted November 9, 2008 i got it working, thanks so much for all of your help! =) Link to comment Share on other sites More sharing options...
Harusal Posted November 10, 2008 Author Share Posted November 10, 2008 (edited) it works fine but when i add a gui and i put the hotkeyset above the gui i get the error again.HotKeySet("!x", "ExitProg") HotKeySet("!s", "StartStop");Shift+s GuiCreate("Program",218,68,332,219) $label1=GuiCtrlCreateLabel("Alt+S",9,30,141,15) $label2=GuiCtrlCreateLabel("Alt+X",115,30,105,15) $label3=GuiCtrlCreateLabel("By Harusal",166,55,55,15) GuiSetState() While 1 $msg=GuiGetMsg() If $msg=-3 Then Exit Wend Func ExitProg() Exit 0;;Exits the program EndFunc Dim $On $On = False While 1 While $On = True ;;Do Code WEnd Sleep(100) WEnd Func StartStop() If $On = False Then $On = True Else $On = False EndIf EndFunc Edited November 10, 2008 by Harusal Link to comment Share on other sites More sharing options...
Harusal Posted November 10, 2008 Author Share Posted November 10, 2008 it works fine but when i add a gui and i put the hotkeyset above the gui i get the error again. HotKeySet("!x", "ExitProg") HotKeySet("!s", "StartStop");Shift+s GuiCreate("Program",218,68,332,219) $label1=GuiCtrlCreateLabel("Alt+S",9,30,141,15) $label2=GuiCtrlCreateLabel("Alt+X",115,30,105,15) $label3=GuiCtrlCreateLabel("By Harusal",166,55,55,15) GuiSetState() While 1 $msg=GuiGetMsg() If $msg=-3 Then Exit Wend Func ExitProg() Exit 0;;Exits the program EndFunc Dim $On $On = False While 1 While $On = True ;;Do Code WEnd Sleep(100) WEnd Func StartStop() If $On = False Then $On = True Else $On = False EndIf EndFunc Nvm i got it working, thanks every 1! 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