1
votes

I'm trying to do the following: Send to MusicBee the combination Ctrl+N (Next Track) whatever the application is currently active, by using AltGr+N key.

I've tried the following:

<^>!N::
if WinExist("ahk_exe MusicBee.exe")
    ControlSend, ahk_parent, ^n ; Send the keys to the last found window (found by WinExist)

which is supposed to work. The idea is to be able to circle through next tracks by keeping AltGr pressed, and pressing N multiple times. Means that I don't want to have to release AltGr key for the instruction to be sent to MusicBee.

Issue is the following: When keeping AltGr pressed, the first time I press N, nothing will happen (I go through the shortcut (if I add a MfgBox, I see that I go through the code, but nothing happens. When I press N a second time, it will work. When I say nothing happens at the first time, this is not exact : this will lock my Left Control key to down state. So if I'm for example in Notepad, I press AltGr+N (nothing happens in MusicBee), but then if I press just "O", the panel to open a file is displayed (as if Ctrl+O was pressed).

Then I've also tried:

ControlSend, ahk_parent, ^n{LCtrl up}

or

ControlSend, ahk_parent, {LCtrl down}n{LCtrl up}

but without success.

I've also played a bit with:

KeyWait N        ; wait the N key to be released

and

SetKeyDelay 10,10

but with no more success.

Do you have an idea how to avoid that the first combination to get AltGr will result in blocking LCtrl down ?

1

1 Answers

0
votes

Which version of AutoHotkey are you using? According to the developer - see last post in this thread on the AutoHotkey forum here https://www.autohotkey.com/boards/viewtopic.php?f=14&t=6006 - "Several bugs relating to AltGr have been fixed ..."[1]

So if you are not using v1.1.33.02 try updating to the latest one - which is currently v1.1.33.02 - https://www.autohotkey.com/download/ - or you can use the "installer" script in your AutoHotkey folder to update as well - it might solve your problem.

[1] Look for AltGr on this https://www.autohotkey.com/docs/AHKL_ChangeLog.htm page for an overview.