 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
alexisfch
Joined: 09 Nov 2009 Posts: 92
|
Posted: Tue Dec 15, 2009 1:58 am Post subject: making a conditional loop with keywait |
|
|
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!!  |
|
| Back to top |
|
 |
jethrow
Joined: 24 May 2009 Posts: 1907 Location: Iowa, USA
|
Posted: Tue Dec 15, 2009 5:19 am Post subject: |
|
|
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
} |
_________________
- in case I forgot to smile
Basic Webpage Controls
COM Object Reference |
|
| Back to top |
|
 |
George32 Guest
|
Posted: Tue Dec 15, 2009 10:31 am Post subject: |
|
|
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
|
Posted: Tue Dec 15, 2009 10:33 am Post subject: |
|
|
| 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
} |
|
|
| Back to top |
|
 |
Guest
|
Posted: Tue Dec 15, 2009 2:14 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|