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 

Why does KeyWait not Wait?

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



Joined: 08 Oct 2006
Posts: 91
Location: denmark

PostPosted: Mon Jun 09, 2008 12:23 pm    Post subject: Why does KeyWait not Wait? Reply with quote

Hey,

I have

Code:

SetTitleMatchMode,2
IfWinNotExist,%gbstitle%
{
GoSub,gogb
KeyWait, x
MsgBox, worked
WinMaximize,%gbstitle%
}


and the gogb sub is




Code:
gogb:
Run IEXPLORE.EXE %gbssite%
Return



The problem when I run it the msgbox pops up immediately with worked, which strikes me weird, I want to basically pause until the key I'm waiting for is hit.
Back to top
View user's profile Send private message
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Mon Jun 09, 2008 12:37 pm    Post subject: Reply with quote

Running this simple code
Code:
KeyWait, X
MsgBox OK
shows me it only works when I have already pressed X before I run the script. So unless you have X pressed down before the code is executed it will simply continue. Why not use WinWaitActive or IfWinExist to "wait". or lookin to the D option of Keywait
Back to top
View user's profile Send private message
Klaus



Joined: 12 May 2005
Posts: 205
Location: Münster, Germany

PostPosted: Mon Jun 09, 2008 12:53 pm    Post subject: Reply with quote

Hi, pantagruel,
You should use the D-option for KeyWait (like HugoV proposed),
Code:
KeyWait, x, D

because "KeyWait,x" (means: wait until the x-key is released) is always true except x is hold down when function is launched.
Regards,
Klaus
Back to top
View user's profile Send private message Send e-mail
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