Ignore or cancel KeyWait if a specific key is pressed?

Get help with using AutoHotkey and its commands and hotkeys
Hawky
Posts: 2
Joined: 20 May 2018, 18:56

Ignore or cancel KeyWait if a specific key is pressed?

20 May 2018, 19:26

Hi,
Noob, but working my way around. Here is what I would like to do. When I press down F1, F1 will still be sent, and when I release F1, Click will be sent. I was able to figure this out as simply:

However, I do not want the release of F1 to send Click if, before I release F1, I press a specific key, such as Q. Basically if I am holding down F1, then press Q, I no longer want the release of F1 to send Click. I would like to set this up with multiple keys though, those being Q, F, C, V, B, X. If I press any of those before releasing F1, Click will no longer be sent on release of F1.

This doesn't sound to me like it is asking for much, but I can't figure it out, so I'm thinking I need to be using something other than KeyWait.
Rohwedder
Posts: 1030
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Ignore or cancel KeyWait if a specific key is pressed?

21 May 2018, 00:29

Hallo,
try this:or that shorter version without KeyWait:or with Ternary Operator:

Code: [Select all] [Download] GeSHi © Codebox Plus

~*F1 Up::SendInput, % !InStr("qfcvbx", A_PriorKey)?"{Click}":
Hawky
Posts: 2
Joined: 20 May 2018, 18:56

Re: Ignore or cancel KeyWait if a specific key is pressed?

21 May 2018, 11:31

Rohwedder wrote:Hallo,
try this:or that shorter version without KeyWait:or with Ternary Operator:

Code: [Select all] [Download] GeSHi © Codebox Plus

~*F1 Up::SendInput, % !InStr("qfcvbx", A_PriorKey)?"{Click}":

These all seem to cancel Click if I do the action in a split second (Hold F1, press Q, release F1). However, if I am holding down F1 for more than a second before pressing Q, it's like it doesn't see I ever pressed Q and Click is still being sent on release of F1. I would like to hold down F1 for as long as I like before pressing Q (or any of the other keys) to effectively "cancel" the Click on release of F1, this way it doesn't click if I don't want it to.
Rohwedder
Posts: 1030
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Ignore or cancel KeyWait if a specific key is pressed?

21 May 2018, 16:00

Hallo,
then:

Code: [Select all] [Download] GeSHi © Codebox Plus

~F1::
Input, Keys, V, qfcvbx
SendInput, % (ErrorLevel = "NewInput")?"{Click}":
Return
~*F1 Up::Input

Return to “Ask For Help”

Who is online

Users browsing this forum: Archandrion, Qysh and 11 guests