AutoHotkey Community

It is currently May 27th, 2012, 12:34 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: December 15th, 2009, 2:58 am 
Offline

Joined: November 9th, 2009, 4:24 pm
Posts: 94
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!! :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 6:19 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
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 ;) , 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
}

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 11:31 am 
[quote="jethrow"][/quote]

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
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 11:33 am 
Offline

Joined: November 9th, 2009, 4:24 pm
Posts: 94
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 ;) , 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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 15th, 2009, 3:14 pm 
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
}


Report this post
Top
  
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: Bing [Bot], iDrug, Leef_me, Ohnitiel, rjgatito, Yahoo [Bot] and 22 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