arcker Posted February 21, 2006 Posted February 21, 2006 ok, i've this code (simplified) : i want that when i click on "Stop", the ping stop...but it's impossible the program continues to run =>there is no possibilities until loop finished, even if i want to close the program $annuler=guictrlcreatebutton("stop"...) $start=guictrlcreatebutton("start"....) while 1 $msg = guigetmsg() if $msg = $start then _loop() if $msg = $stop then $stop=1 wend func _loop() while $stop=0 ;ping the machine sleep(1000) wend endfunc thx for any solution -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
ning Posted February 21, 2006 Posted February 21, 2006 The problem you have is that when Start is clicked, the program goes into an infinite loop in _Loop(). So it will never execute the code asking it to stop. What you need is an Adlib function. Look it up in the help, but this _should_ do the trick (untested): If $msg = $start Then AdlibEnable ("_loop", 1000) If $msg = $stop Then AdlibDisable () Don't forget to take out the Sleep (1000) in the function. ben
jaenster Posted February 21, 2006 Posted February 21, 2006 while 1 $msg = guigetmsg() if $msg = $start then _loop() if $msg = $stop then exitloop wend -jaenster
Nuffilein805 Posted February 21, 2006 Posted February 21, 2006 while 1 $msg = guigetmsg() if $msg = $start then _loop() if $msg = $stop then exitloop wendlol you can try stoping it by using a hotkey, but i think thats not what you want anyways here is a code-snippet hotkeyset("!{f6}","stop") while 1 $msg = guigetmsg() if $msg = $start then _loop() wend func _loop() while $stop=0 ;ping the machine if $msg = $stop then stop() sleep(1000) wend endfunc func stop() $stop=1 endfunc if you can't stop your code with the stop-button try alt+f6 my little chatmy little encryption toolmy little hidermy unsafe clickbot
jaenster Posted February 21, 2006 Posted February 21, 2006 hotkeyset("!{f6}","stop") while 1 $msg = guigetmsg() if $msg = $start then _loop() wend func _loop() while $stop=0 ;ping the machine if $msg = $stop then stop() sleep(1000) wend endfunc func stop() $stop=1 endfuncYeah right , $stop must be global hotkeyset("!{f6}","stop") global $stop = 0; <<<<<------ GLOBAL ^^ while 1 $msg = guigetmsg() if $msg = $start then _loop() wend func _loop() while $stop=0 ;ping the machine if $msg = $stop then stop() sleep(1000) wend endfunc func stop() $stop=1 endfunc -jaenster
arcker Posted February 21, 2006 Author Posted February 21, 2006 euh what a noob after 7 hours of work i've forgot to declare $stop as global thx jaenster and others ! i'm building a script that ping the servers given in a list this list can be easily edited i will post my script later thx again c u -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
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