AutoHotkey Community

It is currently May 27th, 2012, 4:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Problem with hotkey.
PostPosted: March 9th, 2010, 7:48 pm 
Offline

Joined: June 12th, 2009, 11:36 pm
Posts: 1173
Location: Indianapolis IN, USA
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.
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 11:21 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
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"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 11:30 pm 
Offline

Joined: June 12th, 2009, 11:36 pm
Posts: 1173
Location: Indianapolis IN, USA
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.
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 11:37 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
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.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 11:48 pm 
Offline

Joined: June 12th, 2009, 11:36 pm
Posts: 1173
Location: Indianapolis IN, USA
I tried that, it didn't work either.

_________________
www.AutoHotkey.net/~Eedis
I love my wife and daughter so much.
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Bing [Bot], rbrtryn, Yahoo [Bot] and 67 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group