AutoHotkey Community

It is currently May 26th, 2012, 9:35 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: August 12th, 2009, 4:07 am 
Offline

Joined: June 24th, 2008, 8:30 am
Posts: 126
I have a subroutine that runs, and in the subroutine it has a function call that is called from an external library. That function loops until I hit a specific key, then it returns to my original subroutine to contine. I would like to make a second subroutine that would exit or kill the loop in the external function without pressing the designated key to make it contine.

Here is some code so you can understand what I mean:
Code:
sub:
{

loop,
{
wait("Ctrl")   ; this calls the external function and waits until the Ctrl button is pressed

some code to do something
}


}


Here is my function that i'm using:
Code:
wait(passbutton)
{
clipboard=
while state<>"D"
{
GetKeyState, state, %passbutton%,P

mousegetpos,lx,ly
lx := lx+20
ly := ly-20
ToolTip, Press %passbutton%, %lx%, %ly%,
}
ToolTip
}


I would like a second subroutine to kill the previous function and/or subroutine. Something like this:

Code:
sub2:
{
Exit
}


This of course only kills the current thread, but the external function continues to loop/wait until the Ctrl button is pressed.


Anyone know how I can accomplish this?

_________________
“Whenever I'm about to do something, I think, 'Would an idiot do that?' And if they would, I do not do that thing.”

-Dwight


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2009, 10:23 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
why not make another version of the function that doesn't need the keypress?

send it a time or something.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2009, 8:33 pm 
Offline

Joined: June 24th, 2008, 8:30 am
Posts: 126
This is for a sort of html editor. What it does is I click a button on a gui to start the subroutine, and it waits until I click a key to continue. The reason I need this is because the subroutine will wait until I highlight the text that I am trying to format, and click the Ctrl button. At that point, it will copy the text, and add the correct html tags at the beginning and end of the text, then paste it. So a timer wouldn't work. I would either have to wait for it, or rush to highlight the correct text before it screws things up.

Here is the entire subroutine if it helps:
Code:
bullet:
{

guicontrol, Hide, • Bullets
guicontrol, Show, • Bullets Off

loop,
{
wait("Ctrl")      
sleep, 200
send, {ctrl down}c{ctrl up}
clipwait

text=%clipboard%

clipboard=<li>%text%</li>
send, {ctrl down}v{ctrl up}
sleep, 400
}

return
}

_________________
“Whenever I'm about to do something, I think, 'Would an idiot do that?' And if they would, I do not do that thing.”

-Dwight


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2009, 8:41 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
so the request is for some kind of cancel command?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, JSLover, virpara and 64 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