 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
a_h_k
Joined: 02 Feb 2008 Posts: 626
|
Posted: Sat Jan 30, 2010 1:12 am Post subject: Script not Exiting |
|
|
I need help in understanding why the script doesn't Exit at the "Exit" command .. but only once Returned from here:
How should i deal with this
| Help..Exit wrote: | | Exits the current thread or (if the script is not persistent contains no hotkeys) the entire script |
| Code: | SetTimer, here, -1000
MsgBox,,,,3
Exit
here:
sleep 5000
msgbox,,,reached here!,2
return |
Last edited by a_h_k on Mon Feb 01, 2010 7:07 am; edited 3 times in total |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Sat Jan 30, 2010 3:03 am Post subject: Re: Script not Exiting |
|
|
| a_h_k wrote: | | Code: | SetTimer, here, -1000
MsgBox,,,test,3
Exit
here:
sleep 5000
msgbox,,,reached here!,2
return |
|
1) Timer is set
2) MsgBox (test) appears
3) when MsgBox (test) has been displayed for 1 second, the trigger for label "here" is fired
4) at this point, MsgBox (test) is still there while Sleep command is being performed
5) "test" MsgBox's timeout is interpreted as still being part of the MsgBox Command, so it will disappear but will not perform the Exit command since the commands from label "here" are being performed
6) after the Sleep command, MsgBox (reached) appears and then times out
7) finnaly, label "here" Returns, allowing the script to continue from where it stopped [right after the first MsgBox] and the Exit command is reached _________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
geekdude
Joined: 23 Nov 2009 Posts: 64
|
Posted: Sat Jan 30, 2010 4:17 am Post subject: |
|
|
http://www.autohotkey.com/docs/commands/ExitApp.htm
try this  _________________ /\ /\ This is Kitty
(>';'<) Cut, copy, and paste kitty onto your sig.
((")(")) Help Kitty gain World Domination.
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Sat Jan 30, 2010 4:18 am Post subject: |
|
|
I suppose he just wants to understand why that doesn't work. _________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
a_h_k
Joined: 02 Feb 2008 Posts: 626
|
Posted: Sat Jan 30, 2010 4:27 am Post subject: Re: Script not Exiting |
|
|
The same happens with sleep
Scenario #1 - 1st Sleep finishes after 2nd Sleep
| Code: | SetTimer, here, -1000
Sleep, 11000 ;MsgBox,,,,11
msgbox,,,next,1
Exit
here:
sleep 5000
msgbox,,,reached here!,2
return |
1) Timer is set
2) Sleeps for 1 second
3) Calls routine "here" (& "Sleep 11000" carries on with it's sleeping)
4) "Sleep 5000" begins it's sleep
5) "Sleep 5000" finishes ("Sleep 11000" down to 5000 left)
6) Msgbox "reached here!" is displayed (for 2 secs)
7) Label "here" Returns to main script (which is still running "Sleep 11000" --> now down to 3000 left)
"Sleep 11000" finishes
9) Msgbox "next" displayed (for 1 sec)
So it can be seen that the label "here" and main script are being executed simulataneously (ie multi-threading)
Scenario #2 - 1st Sleep finishes before 2nd Sleep
| Code: | SetTimer, here, -1000
Sleep, 3000 ;MsgBox,,,,3
msgbox,,,next,1
Exit
here:
sleep 5000
msgbox,,,reached here!,2
return |
1) Timer is set
2) Sleeps for 1 second
3) Calls routine "here" (& "Sleep 3000" carries on with it's sleeping - 2000 left)
4) "Sleep 5000" begins it's sleep (within which "Sleep 3000" times-out)
This where (during above sleep) i think the main should execute the next commnad (the msgbox "next")
As i stated above, the thread "here" & main script = being executed independently, with main running the command after SetTimer (Sleep 3000), so why not also the 2nd command after??
5) "Sleep 5000" finishes ("Sleep 3000" expired)
6) Msgbox "reached here!" is displayed (for 2 secs)
7) Label "here" Returns to main script
Msgbox "next" displayed (for 1 sec)
Last edited by a_h_k on Mon Feb 01, 2010 6:45 am; edited 1 time in total |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Sat Jan 30, 2010 4:34 am Post subject: |
|
|
Yeah. I'm not sure how Sleep and MsgBox are coded (never checked AHK's source code). But I must say original AHK itself can't multithread AFAIK. I'm not an AHK Guru so I can't explain these things for sure. _________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
a_h_k
Joined: 02 Feb 2008 Posts: 626
|
Posted: Mon Feb 01, 2010 7:08 am Post subject: |
|
|
Did a basic test, using a non-modal MsgBox .. worked (as predicted)
| Code: | SetTimer, here, -1000
MsgBoxNonModal("test") ;,,,,3 (haven't incorporated timeout yet)
msgbox reached here first!! ;ie using non-modal msgbox allows code following MsgBox.. line to execute BEFORE returned from here
Exit
here:
sleep 5000
msgbox, reached here!
return |
|
|
| Back to top |
|
 |
a_h_k
Joined: 02 Feb 2008 Posts: 626
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|