Keywait, adding "if errorlevel"

Share your ideas as to how the documentation can be improved.
coldcart845
Posts: 3
Joined: 24 Jun 2020, 03:32

Keywait, adding "if errorlevel"

Post by coldcart845 » 24 Jun 2020, 03:59

For keywait, https://www.autohotkey.com/docs/commands/KeyWait.htm
Add to the examples or.. sugested functionality, "If Errorlevel=0".

With "If Errorlevel=0" you'd do:
~F8::
keywait, f8, T1 D
If ErrorLevel = 0
{
/ / / run cmd
}
return

Meaning, if you press f8 two times, do something, else return.
If you don't do it like that, and you do:

~F8::
keywait, f8, T1 D
run cmd
return

When it gets to keywait, if errorlevel is 1, it doesn't "fail and automatically return" or wtv, it goes on with the next line.

With that mechanism you can do things like this, which are basically hotstrings, but... I think they are worth mentioning in the keywait page (also, the correct implementation uses sleep as follows):

~c::
keywait, m, T1 D
If ErrorLevel = 0
{
/ / / sleep 200
/ / / keywait, d, T1 D
/ / / If ErrorLevel = 0
/ / / {
/ / / / / / sleep 200
/ / / / / / keywait, ENTER, T1 D
/ / / / / / If ErrorLevel = 0
/ / / / / / {
/ / / / / / / / / run cmd
/ / / / / / }
/ / / / / / return
/ / / }
/ / / return
}
return

Type cmdENTER, open cmd.
coldcart845
Posts: 3
Joined: 24 Jun 2020, 03:32

Re: Keywait, adding "if errorlevel"

Post by coldcart845 » 24 Jun 2020, 04:11

Reading other replies in this board, apparently "if !Errorlevel" is common, ok, this may be unnecesary then.

pd:
And, there's a link to Errorlevel there, ok... I still would add an "if errorlevel" example, to induce the less advanced to that knowledge, but idk.
Post Reply

Return to “Suggestions on Documentation Improvements”