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 

Simple Question Re: GUI Buttons Interrupting Functions...

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



Joined: 21 May 2008
Posts: 85

PostPosted: Fri Aug 22, 2008 1:23 am    Post subject: Simple Question Re: GUI Buttons Interrupting Functions... Reply with quote

I think this is simple but I can find some code and post it if necessary.

I'll often trigger a function call when a gui button is pressed. Once the function is launched, the gui stops responding [i.e., you can press buttons but they won't launch their subroutines] until the function is terminated/returns, and any additional button presses aren't cached-- they're simply lost forever.

I'm sure that this comes up often but I'm not sure what to search for.

What if I wanted to launch a function with a gui button press, and have a different button-- a pause button (or reload), or whatever other button call a function and interrupt the currently executing function? Since I'm using functions instead of subroutines (does it make a difference?), I'm not sure I can use a timer to send a routine if a button has been pressed while a function is running.

Sorry if this is confusing, I'm wrapping up a long day. I'll try to clean this up later.
Back to top
View user's profile Send private message
Sivvy



Joined: 21 Jul 2008
Posts: 711
Location: Calgary, AB, Canada

PostPosted: Fri Aug 22, 2008 1:07 pm    Post subject: Reply with quote

This one wasn't answered, but maybe something in here might work for you.

http://www.autohotkey.com/forum/viewtopic.php?t=34891
Back to top
View user's profile Send private message MSN Messenger
jaco0646



Joined: 07 Oct 2006
Posts: 666
Location: MN, USA

PostPosted: Fri Aug 22, 2008 3:24 pm    Post subject: Reply with quote

This works for me.
Code:
#SingleInstance force
#NoEnv

Gui, Add, Button, gFunct, Function
Gui, Add, Button, gPause, Pause

Gui, Show
return
GuiClose:
ExitApp

Funct:
Function()
MsgBox,Function finished.
return

Pause:
Pause,,1
return

Function()
{
 Sleep, 5000
}

_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Tue Aug 26, 2008 4:36 pm    Post subject: Reply with quote

Sorry for the slow response, but I’ve been out of town the last few days. I’ve created some sample scripts and they seem to work fine, so I’m wondering if my problems stem from the fact that the functions that I am calling have high cpu utilization as they are Imagesearch functions (and setbatchlines is set to -1 within those functions). Its almost as if the gui buttons are buffered when clicked but never executed (well, sometimes they work, sometimes they don’t, but you may have to hit the buttons quite a few times). I can’t post the entire code, but I will try to recreate the issue with imagesearch on some non-proprietary software and post it. Appreciate the feedback, and the other thread seems like it may be relevant as well.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   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