Shitobu Posted September 11, 2016 Share Posted September 11, 2016 I have this code: expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> _main() Func _main() Global $resetButton Global $startButton Global $iMsg Global $loop = 0 GUICreate("Startup", 109, 30) $resetButton = GUICtrlCreateButton("Reset", 5, 5, 50, 20) $startButton = GUICtrlCreateButton("Start", 56, 5, 50, 20) GUISetState() While 1 Global $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE $loop = 0 ExitLoop Case $iMsg = $startButton $loop = 1 _loop() Case $iMsg = $resetButton $loop = 0 EndSelect WEnd GUIDelete() Exit EndFunc Func _loop() While $loop == 1 if $iMsg = $resetButton Then $loop = 0 _main() EndIf Send("{1}") sleep(1000) WEnd EndFunc What I'm trying to do is doing a startup program that will open every program I want as soon as I run it. But for now, since it's not complete, I'm facing this problem: I made it spam "1" to be sure it's running, with a delay fo 1 sec. With it, I would like to be able to STOP the while of the function _loop() if I wanted. For example, the script is opening my facebook. But for now it's okay, now I wanna close the script. I press F8 <or any key> and the script will stop the loop like $resetButton was supposed to. But I can't <the script doesn't receive the stop function, it just keeps spamming the while>. What do I do? Link to comment Share on other sites More sharing options...
AutoBert Posted September 11, 2016 Share Posted September 11, 2016 Read: https://www.autoitscript.com/wiki/Interrupting_a_running_function Shitobu 1 Link to comment Share on other sites More sharing options...
careca Posted September 12, 2016 Share Posted September 12, 2016 expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) _main() ;======================================================================================================= Func _main() Global $resetButton Global $startButton Global $iMsg Global $loop = 0 GUICreate("Startup", 109, 30) $resetButton = GUICtrlCreateButton("Reset", 5, 5, 50, 20) GUICtrlSetOnEvent(-1, "Reset") $startButton = GUICtrlCreateButton("Start", 56, 5, 50, 20) GUICtrlSetOnEvent(-1, "Start") HotKeySet('{END}', 'Quit') GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") GUISetState() While 1 If $loop = 1 Then ConsoleWrite('ON - '&@MSEC&@CRLF) ;Send("{1}") Else ;Whatever or nothing EndIf sleep(500) WEnd EndFunc ;======================================================================================================= Func Reset() $loop = 0 ConsoleWrite('Reset - '&@MSEC&@CRLF) EndFunc ;======================================================================================================= Func Start() $loop = 1 ConsoleWrite('Start - '&@MSEC&@CRLF) EndFunc ;====================================================================================== Func Quit() Exit EndFunc ;==>Quit ;======================================================================================================= Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe 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