Remapped keys don't work

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
KilliK
Posts: 255
Joined: 10 Mar 2016, 21:19

Remapped keys don't work

08 Nov 2018, 05:55

Hello.
I am trying to remap two keys with the Hotkey command while Chrome is active, so that one key will trigger the other which will trigger an event.
But I encountered a peculiar problem.

This works:

Code: Select all

Hotkey, F1, test1, on
Hotkey, F3, test2, on
Return

test1:
Send {F3}
Return

test2:
msgbox Hello
Return
But this doesn't work:

Code: Select all

SetTitleMatchMode, 2
#if WinActive("ahk_exe chrome.exe") 

Hotkey, F1, test1, on
Hotkey, F3, test2, on
Return

test1:
Send {F3}
Return

test2:
msgbox Hello
Return
F1 will be remapped to F3, but F3 wont trigger the msgbox. But it will work as an F3 key since Chrome's search bar appears when I press F1.
I doubled checked and Chrome is active and its wintitle is correct. if I remove the entire #if condition, the remap will work and the msgbox will appear. But with it, it wont.

What exactly causes this and how I can fix it?
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: Remapped keys don't work

09 Nov 2018, 05:43

Try adding an #if just before the first Return.
Part of my AHK work can be found here.
just me
Posts: 9482
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Remapped keys don't work

09 Nov 2018, 05:59

Code: Select all

#if WinActive("ahk_exe chrome.exe")
doesn't affect the Hotkey command.

Code: Select all

SetTitleMatchMode, 2
; #if WinActive("ahk_exe chrome.exe")
Hotkey, IfWinActive, ahk_exe chrome.exe
Hotkey, F1, test1, on
Hotkey, F3, test2, on
Hotkey, IfWinActive
Return
test1:
Send {F3}
Return
test2:
msgbox Hello
Return
?
User avatar
KilliK
Posts: 255
Joined: 10 Mar 2016, 21:19

Re: Remapped keys don't work

13 Nov 2018, 09:41

Hello.
I tried your suggestions but they didnt work.
F3 is still sent normally instead of triggering the event, if winactive is set. Without it, F3 triggers the msgbox as it is supposed to do.
is this intended behavior, a bug, or the code is missing something?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 476 guests