Unable to use Send to send a windows key combination Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Meroveus
Posts: 35
Joined: 23 May 2016, 17:38

Unable to use Send to send a windows key combination

13 May 2020, 15:38

An application (OBS_Studio) has user-defined hotkeys
I defined #{Numpad9} to activate a certain scene
It works, regardless of the current active window, when typed at the keyboard
#{Numpad9} is not an existing hotkey in any other application or AHK script.

Code: Select all

;attempt 1
SendInput, #{Numpad9}
;attempt 2
SendInput, {#}{Numpad9}
The above does nothing.
I have tried all variants of Send except for Raw for both attempts.
When sending using non-winkey combinations, attempt 1 works quite reliably
eg
SendInput, ^K
works fine.

I have tried activating OBS first, but again the keystroke seems to get absorbed.

Any ideas?
GEV
Posts: 844
Joined: 25 Feb 2014, 00:50

Re: Unable to use Send to send a windows key combination

13 May 2020, 16:50

If OBS_Studio is running with admin privileges, then AHK won't intercept the key presses.
Try to run the script as administrator.
Meroveus
Posts: 35
Joined: 23 May 2016, 17:38

Re: Unable to use Send to send a windows key combination

13 May 2020, 20:57

Whether OBS_Studio is running as admin or not,
Hotkeys sent from an AHK script will not be recognized unless OBS_Studio is the active window at the time the keys are sent.

In my case AHK must always run as admin since I move windows around.
To ensure this, I have this at the top of every script where admin privs are absolutely necessary:

Code: Select all

If % ! A_IsAdmin {
	MsgBox, Not running as admin.  To move windows, we need to run as admin
	ExitApp
}

I tried using
ControlSend,ahk_parent,%key%,ahk_id %id%
But this did not work, nor did it work with a blank control field.

Windows Spy does not identify a focused control.

I can probably live with this restriction
gregster
Posts: 4621
Joined: 30 Sep 2013, 06:48

Re: Unable to use Send to send a windows key combination

13 May 2020, 21:28

If I remember correctly, you need to use a certain key delay to make OBS reliably register sent keys or certain key combos (and activate global hotkeys in the OBS setiings).
Not sure about the win key combos, though. It's possible that they don't work.
Meroveus
Posts: 35
Joined: 23 May 2016, 17:38

Re: Unable to use Send to send a windows key combination  Topic is solved

20 May 2020, 17:05

I have managed to reliably send OBS hotkeys to OBS using AHK
@gregster suggested using SetKeyDelay which turned out to be part of the solution.
The other part was using ControlSend

See this thread for code that works
https://www.autohotkey.com/boards/viewtopic.php?p=329921#p329921

Also note that in that thread the SetKeyDelay values are 50,80
I'm currently using -1,80 successfully.

Also note that I can send win-key combos using this method also.

Return to “Ask For Help”

Who is online

Users browsing this forum: masato, songdg and 47 guests