Page 1 of 1

Firefox blocks Win-key macros from compile AHK scripts

Posted: 08 Oct 2019, 06:45
by Synetech
I just posted a bug-report at the Firefox bug-tracker.

The problem is that if you create an AHK script that has a hotkey that uses the Windows key to Send text, it works everywhere as expected, unless you compile the script, in which case, it works everywhere except Firefox. It's a strange, very specific scenario. :wtf:

There's a a thread here that seems like it's probably related, but that seems to be fixed, so unless it's a regression, the two issues might be caused by a common, underlying issue. :think:

Re: Firefox blocks Win-key macros from compile AHK scripts

Posted: 08 Oct 2019, 07:14
by joedf
Hmm interesting... :think:
I'll give this a try later today.

Re: Firefox blocks Win-key macros from compile AHK scripts

Posted: 08 Oct 2019, 09:34
by joedf
I have reproduced your case... :think:
So it seems the hotkey is still detected, but firefox doesnt get the "memo". If we use a msgbox, it shows the hotkey is still being detected...
If we use a sendinput instead, the desired behaviour is achieved. :+1:

Code: Select all

; ⊞Win+C should paste "foobar"
#c::sendInput foobar

Re: Firefox blocks Win-key macros from compile AHK scripts

Posted: 09 Oct 2019, 01:59
by lexikos
It works just fine on this Windows 7 computer.

Re: Firefox blocks Win-key macros from compile AHK scripts

Posted: 09 Oct 2019, 02:05
by jNizM
It works for me also.

Tested on:
Windows 10 - 1903 (Build 18362.418)
Firefox 69.0.2 (64-Bit)
AutoHotkey 1.1.30.03 (compiled as 64-Bit Unicode)

Re: Firefox blocks Win-key macros from compile AHK scripts

Posted: 09 Oct 2019, 02:49
by malcev
For me works compiled script in firefox 69.0.2 (64-bit), Win10 LTSC, ahk 64 bit 1.1.31.

Code: Select all

#c::send foobar

Re: Firefox blocks Win-key macros from compile AHK scripts

Posted: 09 Oct 2019, 08:25
by joedf
I just tried again today.... and it worked either way... hmmm

Test System Info:
Spoiler

Re: Firefox blocks Win-key macros from compile AHK scripts

Posted: 17 Oct 2019, 10:55
by Synetech
joedf wrote:
09 Oct 2019, 08:25
If we use a sendinput instead, the desired behaviour is achieved. … I just tried again today.... and it worked either way... hmmm
Hmm, indeed. I tried it with sendinput, but it didn't work. Then I reverted it to send and added a msgbox call to see the hotkey just before the send command, and now it. :think: Now I'm wondering if it's a race-condition, some sort of timing issue. I'm not sure why this only affects Firefox though. :eh:

I just tried it in a fresh VM and got the same results on my main system:
  • All versions work in Windows Explorer, Notepad, Chrome, everywhere
  • All version of raw script work in Firefox
  • Compiled script with msgbox before send works in Firefox
  • Compiled script without msgbox (with send or sendinput) does NOT work in Firefox
  • Replacing msgbox with tooltip makes it stop working in Firefox again
  • Adding a sleep delay doesn't make it work, only msgbox seems to work
I just downloaded the latest version of AHK and compiled it with the .bin files from that and it seems to work. I'm not sure what's different (maybe the compiler was defaulting to ANSI instead of Unicode—which still wouldn't explain why it was only failing in Firefox). Regardless, it seems to work properly now.

Also, I don't use the compiler that comes with AutoHotkey, I use the old compiler-wrapper (with the joystick icon) which provides a lot more control over the resulting executable. Passing the new (Unicode) .bin file to the old compiler also works. 👍 (I don't know why Unicode emojis are so huge on this message board. 🤔)