How to send Esc hotkey Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
zxyzgt
Posts: 58
Joined: 04 Feb 2017, 22:54

How to send Esc hotkey

Post by zxyzgt » 01 Mar 2024, 14:11

I don't know why it doesn't work if I want to send Esc as a hotkey. It simply sends Esc and then the letter d in v2. There is no problem in v1 though.

Code: Select all

F2::
{
	; sendinput("{Esc}d")
	send("{Escape down}d{Escape up}")
}

Esc & d::msgbox("hi")

User avatar
WarlordAkamu67
Posts: 232
Joined: 21 Mar 2023, 06:52

Re: How to send Esc hotkey

Post by WarlordAkamu67 » 01 Mar 2024, 14:37

Do you see an error message of some sort? Is there any other information you can provide? Downloading the posted code gives me no problems. Esc + D shows a message box, and F2 hits Escape D. (tested by closing the move window in Adobe Illustrator).

zxyzgt
Posts: 58
Joined: 04 Feb 2017, 22:54

Re: How to send Esc hotkey

Post by zxyzgt » 01 Mar 2024, 14:59

No error message, just like sending Esc and the letter d. F2 can't hit Esc d for my case. See below.
If I change the Esc key to ctrl or alt, there is no problem at all.
I am running v2.0.11 on win10 by the way.
ahk.gif
ahk.gif (69.23 KiB) Viewed 439 times

niCode
Posts: 319
Joined: 17 Oct 2022, 22:09

Re: How to send Esc hotkey

Post by niCode » 01 Mar 2024, 15:46

Looks like it works just fine in the gif. I suspect the problem is you believe that hitting F2 should also send the message box? You weren't clear on what is supposed to happen. If so, then I have a hard time believing (though I can't test) it worked like that in v1 since both versions use the keyboard hook which would prevent the combo from being triggered by another hotkey without additional code. If you're expecting the message box to show up with F2, I would look into SendLevel and/or InputLevel.

zxyzgt
Posts: 58
Joined: 04 Feb 2017, 22:54

Re: How to send Esc hotkey

Post by zxyzgt » 01 Mar 2024, 16:07

@niCode , thanks for your reply and sorry for the confusion. That is right I am expecting F2 to fire the hotkey Esc+d and send the same message box. Below is what I changed from Esc to ctrl. There is no problem.
change to ctrl.gif
change to ctrl.gif (151.93 KiB) Viewed 433 times

niCode
Posts: 319
Joined: 17 Oct 2022, 22:09

Re: How to send Esc hotkey  Topic is solved

Post by niCode » 01 Mar 2024, 16:35

Using $, *, or ~ prefixes use the keyboard hook, as do custom combinations like in the original post. The keyboard hook prevents other hotkeys from triggering it. The new code doesn't use the keyboard hook so it can be triggered by other hotkeys. Have a look at the links I posted before on how to get hotkeys that have been "hooked" to be triggered by other hotkeys.

zxyzgt
Posts: 58
Joined: 04 Feb 2017, 22:54

Re: How to send Esc hotkey

Post by zxyzgt » 01 Mar 2024, 16:38

Thank you for your help @niCode

Post Reply

Return to “Ask for Help (v2)”