gumcaj Posted October 24, 2011 Share Posted October 24, 2011 Hi, is it possible to abort/cancel specific function which is currently running? Let's say I ran function called "Dance" and then after I pressed a hotkey, the Dance function stopped working. Is it possible? Something like " EndFunc "Dance" " Regards. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 24, 2011 Share Posted October 24, 2011 Hi and Welcome to the forums! You need to use a variable as a flag that the hotkey sets, and that the Dance checks for (and Return if it's set). Example: #include <GUIConstantsEx.au3> Global $iFlag = 0 GUICreate("SomeTitle", 256, 256) $hButton = GUICtrlCreateButton("Press me!", 50, 50, 100, 50) GUISetState() HotKeySet("O", "_Interrupt") While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $hButton _Dance() ToolTip("") EndSwitch WEnd Func _Interrupt() $iFlag = 1 EndFunc Func _Dance() For $iX = 1 To 1000 If $iFlag = 1 Then $iFlag = 0 Return EndIf ToolTip($iX) Sleep(10) Next EndFunc .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
DesireDenied Posted October 24, 2011 Share Posted October 24, 2011 (edited) yes, its very simple ; setup your hotkey HotKeySet("{END}", "MyFunctionOnOFF") ; declare global variable for function state Global $bMyFunction = 0 ; main script loop While 1 MyFunction() Otherfunction() AndAnotherOne() Wend ; then write a function like this Func MyFunction() If $bMyFunction Then ; here goes the rest of your function code ... Endif Endfunc ; MyFunction switch Func MyFunctionOnOFF() $bMyFunction = NOT $bMyFunction Endfunc Edited October 24, 2011 by DesireDenied 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