AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with hotkey.

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Eedis



Joined: 12 Jun 2009
Posts: 1158
Location: Indianapolis IN, USA

PostPosted: Tue Mar 09, 2010 6:48 pm    Post subject: Problem with hotkey. Reply with quote

Okay, this may sound like a strange question at why I did things the way I did them, just avoid those questions for now. This is more or less a question of curiosity.

While I was programming a rather large program which I don't have on this computer to post at the moment, I ran into a problem. I solved it though, a rather inconvenient way though. I was wondering what're your methods to solving this problem in a better, more efficient way.

I had a loop going, using goto's and labels. What I wanted is for it to go through it with multiple sleeps, but make the lbutton, and other various hotkeys, trigger it to skip to another spot before finishing that loop. I made an example of the same exact problem I had below.

Code:
Gui, add, text, vtesting h100 w100, Testing
gui, show,, test
start:
guicontrol,, Testing, Testing.

sleep 500
guicontrol,, Testing, Testing..

sleep 500
guicontrol,, Testing, Testing...

sleep 500
guicontrol,, Testing, Testing....

stop:
sleep 500
guicontrol,, Testing, Stopped!
sleep 500
goto, start

lbutton::goto stop


It loops through the testing, adds a period to 'testing' every 500 MS's. When you click the lbutton, it skips the rest of the loop and goes to stop like it should. But then renders the lbutton useless. The hotkey never encounters a return to finish the hotkey, so when you press it again, it doesn't work.

What're some of the ways you guys would solve this? Don't sit there and complain because I'm using goto's and labels instead of using a simple loop and getkeystate, I know that, this is a question of more or less curiosity at other ways to 'finish' a hotkey.

Any ideas? Thanks.
_________________
www.AutoHotkey.net/~Eedis
I love my wife and daughter so much.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Leef_me



Joined: 08 Apr 2009
Posts: 5333
Location: San Diego, California

PostPosted: Tue Mar 09, 2010 10:21 pm    Post subject: Reply with quote

Quote:
What I wanted is for it to go through it with multiple sleeps, but make the lbutton, and other various hotkeys, trigger it to skip to another spot before finishing that loop.


Your description does not match the script you posted

I believe a more correct description is:
...to go through it with multiple sleeps, but make the lbutton, and other various hotkeys,
trigger it to skip to another spot instead of finishing that loop.


Another method is to have an other loop that calls (gosub) your start label
and instead of "goto, start" after "Testing, Stopped!" change that to "return"
Back to top
View user's profile Send private message
Eedis



Joined: 12 Jun 2009
Posts: 1158
Location: Indianapolis IN, USA

PostPosted: Tue Mar 09, 2010 10:30 pm    Post subject: Reply with quote

That doesn't work.

I want it to constantly loop. When I press lbutton, it shouldn't finish the loop and go to 'stopped!' instead, but after 500ms's continue to the beginning of the loop.

I tried what you said.

Code:
Gui, add, text, vtesting h100 w100, Testing
gui, show,, test
start:
guicontrol,, Testing, Testing.

sleep 500
guicontrol,, Testing, Testing..

sleep 500
guicontrol,, Testing, Testing...

sleep 500
guicontrol,, Testing, Testing....

stop:
sleep 500
guicontrol,, Testing, Stopped!
sleep 500
Return

Loop
{
   gosub, start
}
Return

lbutton::goto stop


But it indefinitely stops the loop, and...

Code:
Gui, add, text, vtesting h100 w100, Testing
gui, show,, test
start:
guicontrol,, Testing, Testing.

sleep 500
guicontrol,, Testing, Testing..

sleep 500
guicontrol,, Testing, Testing...

sleep 500
guicontrol,, Testing, Testing....

stop:
sleep 500
guicontrol,, Testing, Stopped!
sleep 500

Loop
{
   gosub, start
}
Return

lbutton::goto stop


Does the exact same thing my script does, having the same problem. The mouse button only works once. I understand why it only works once. The hotkey never encounters a return, therefore causing the hotkey to never finish, therefore causing it to not trigger again once pressed.
_________________
www.AutoHotkey.net/~Eedis
I love my wife and daughter so much.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MasterFocus



Joined: 08 Apr 2009
Posts: 3035
Location: Rio de Janeiro - RJ - Brasil

PostPosted: Tue Mar 09, 2010 10:37 pm    Post subject: Reply with quote

Eedis wrote:
The hotkey never encounters a return, therefore causing the hotkey to never finish, therefore causing it to not trigger again once pressed.

Code:
Hotkey:: SetTimer, Label, -10

_________________
"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
View user's profile Send private message Visit poster's website
Eedis



Joined: 12 Jun 2009
Posts: 1158
Location: Indianapolis IN, USA

PostPosted: Tue Mar 09, 2010 10:48 pm    Post subject: Reply with quote

I tried that, it didn't work either.
_________________
www.AutoHotkey.net/~Eedis
I love my wife and daughter so much.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group