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 

making a conditional loop with keywait

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



Joined: 09 Nov 2009
Posts: 92

PostPosted: Tue Dec 15, 2009 1:58 am    Post subject: making a conditional loop with keywait Reply with quote

how can I do a conditional loop with keywait

I have this (for two diferent keys "a" and "s") but doesn't work.

Code:
goto, difkey
return

difkey:
Loop
{
if (KeyWait(a, "D10")) {
run notepad.exe
 Break
    }
{
if (KeyWait(s, "D20")) {
run explorer.exe
 Break
    }
}


Thanks!! Razz
Back to top
View user's profile Send private message
jethrow



Joined: 24 May 2009
Posts: 1907
Location: Iowa, USA

PostPosted: Tue Dec 15, 2009 5:19 am    Post subject: Reply with quote

First things first, KeyWait is a command, not a function. Your example uses it as a function. After that, I'm still not entirely sure what your wanting to accomplish Wink , but here's my best shot:
Code:
goto, difkey
return

difkey:
Loop
{
if (KeyWait("a", "DT10")) {
run notepad.exe
 Break
    }
; {
if (KeyWait("s", "DT20")) {
run explorer.exe
 Break
    }
}

KeyWait( key, options ) {
   KeyWait, %key%, %options%
   Return, Not ErrorLevel
}

_________________
Very Happy - in case I forgot to smile
Basic Webpage Controls
COM Object Reference
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
George32
Guest





PostPosted: Tue Dec 15, 2009 10:31 am    Post subject: Reply with quote

jethrow wrote:


I did it with this, directed if ErrorLevel = 0, but doesn't work
Code:
goto, difkey
return

difkey:
Loop
{
if (KeyWait("a", "DT20"))
If(ErrorLevel) {
run notepad.exe
 Break
    }
; {
if (KeyWait("s", "DT10"))
If(ErrorLevel) {
run explorer.exe
 Break
    }
}

KeyWait( key, options ) {
   KeyWait, %key%, %options%
   Return, Not ErrorLevel
}
Back to top
alexisfch



Joined: 09 Nov 2009
Posts: 92

PostPosted: Tue Dec 15, 2009 10:33 am    Post subject: Reply with quote

jethrow wrote:
First things first, KeyWait is a command, not a function. Your example uses it as a function. After that, I'm still not entirely sure what your wanting to accomplish Wink , but here's my best shot:
Code:
goto, difkey
return

difkey:
Loop
{
if (KeyWait("a", "DT10")) {
run notepad.exe
 Break
    }
; {
if (KeyWait("s", "DT20")) {
run explorer.exe
 Break
    }
}

KeyWait( key, options ) {
   KeyWait, %key%, %options%
   Return, Not ErrorLevel
}


What do you want to say with this????:

Code:
KeyWait( key, options ) {
   KeyWait, %key%, %options%
   Return, Not ErrorLevel
}
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Dec 15, 2009 2:14 pm    Post subject: Reply with quote

do u even understand his suggestions?

if u dont put "" on a, it will think of as variable name
thus, in the example code u provide:
Code:
if (KeyWait(a, "D10")) {

a <-- will be blank

u might understand better if u test the following script
Code:
function(a,b)
function("a","b")
a=123
b=456
function(a,b)
return

function( key, options ) {
   msgbox, %key% %options%
   Return
}
Back to top
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