ocensound Posted February 19, 2009 Posted February 19, 2009 (edited) Ex.Global $test=1settest()func settest() $test+=1endfuncfunc gettest() return $testendfuncWhen this script end I want restart script.How to restart script ?ps.Don't use loopthank u Edited February 19, 2009 by ocensound
Prab Posted February 19, 2009 Posted February 19, 2009 Lookup OnAutoItExit opt and the Run() function in the help file. FolderLog GuiSpeech Assist
ReaImDown Posted February 19, 2009 Posted February 19, 2009 Lookup OnAutoItExit opt and the Run() function in the help file.I like shellexecute more [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Robjong Posted February 19, 2009 Posted February 19, 2009 Hey, I use this Func _SelfRestart() If @Compiled Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc ;==>_SelfRestart
ocensound Posted February 21, 2009 Author Posted February 21, 2009 (edited) OhOhOh ,I got a problem T^T see this. Opt("OnExitFunc","dorestart") AutoItSetOption ("SendKeyDelay",100) AutoItSetOption ("SendKeyDownDelay",100) HotKeySet("{PAUSE}","dopause") HotKeySet("{END}","doexit") Func dorestart() ConsoleWrite("RESTART"&@CRLF) If @Compiled Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc Func dopause() $paused=Not $paused If $paused=True Then ConsoleWrite("PAUSED"&@CRLF) ElseIf $paused=False Then ConsoleWrite("RESUME"&@CRLF) Else EndIf While $paused Sleep(1000) WEnd EndFunc Func doexit() ConsoleWrite("EXIT"&@CRLF) Exit EndFunc I cann't stop this when I press END clz It away restart -..- Edited February 21, 2009 by ocensound
Robjong Posted February 21, 2009 Posted February 21, 2009 Hey, That is because you set OnExitFunc to the restart function Opt("OnExitFunc","dorestart") Th OnExitFunc function will be called before the script exits, this means in your case that evertime you try to exit the program the restart function gets called.
Developers Jos Posted February 21, 2009 Developers Posted February 21, 2009 Something like this? Global $cancel=0 Opt("OnExitFunc", "dorestart") AutoItSetOption("SendKeyDelay", 100) AutoItSetOption("SendKeyDownDelay", 100) HotKeySet("{PAUSE}", "dopause") HotKeySet("{END}", "doexit") MsgBox(1,"test","restarting in 2 seconds",2) Func dorestart() if $cancel then Exit ConsoleWrite("RESTART" & @CRLF) If @Compiled Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc ;==>dorestart Func dopause() $paused = Not $paused If $paused = True Then ConsoleWrite("PAUSED" & @CRLF) ElseIf $paused = False Then ConsoleWrite("RESUME" & @CRLF) Else EndIf While $paused Sleep(1000) WEnd EndFunc ;==>dopause Func doexit() MsgBox(0,"Cancelled","Cancelled") $cancel=1 Exit EndFunc ;==>doexit 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.
ocensound Posted February 21, 2009 Author Posted February 21, 2009 (edited) Yeah, Thank you looklike easy >,< but after restart HotKeySet("{PAUSE}", "dopause") HotKeySet("{END}", "doexit") This key doesn't work ;( Edited February 21, 2009 by ocensound
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