H
HASS.Agent4w ago
like-gold

Trouble with OBS recognising "Key" and "multipleKeys" commands as hotkeys

OBS doesn't seem to recognise hotkeys sent through homeassistant using the "Key" and "multipleKeys" commands. This issue can be replicated and also bypassed using the python library pyautogui. The following code exibits the same symptoms as HASS.Agent.
pyautogui.press("KEY")
pyautogui.press("KEY")
These two code snippets fix the issue
with pyautogui.hold("KEY"):
time.sleep(0.01)
with pyautogui.hold("KEY"):
time.sleep(0.01)
and
pyautogui.keyDown("KEY")
time.sleep(0.01)
pyautogui.keyUp("KEY")
pyautogui.keyDown("KEY")
time.sleep(0.01)
pyautogui.keyUp("KEY")
It seems like OBS doesn't recognise instantaneous keypresses, so hotkeys needs to be held down for a while for them to be executed. HASS.Agent doesn't hold the keys down. What would the best way of using these hotkeys in homeassistant be then? Just one of these python scripts modified to take an argument of the keypress? Then set it as a custom command? As a long term solution, it would be great if HASS.Agent supported a duration attribute for both keypress commands directly so we don't have to rely on workarounds.
7 Replies
DrR0x
DrR0x4w ago
We have had this before, though I think the conclusion was that the library we use to do keypresses doesn't work this certain apps. @Amadeo
Amadeo
Amadeo4w ago
As of now if the software is "too slow" to detect the keypress it won't work I have on my todolist to check if we can specify for how long it can be pressed (because if we do it the kiss way - just sleep for the amout of time user wants to keep the key pressed - whole command thread will be blocked) Alternative is to allow user to specify if they key is supposed to be pressed or held, with the catch that "lifting up" the button would be on user's side @brozorb I just did a POC of the above, want to be a beta tester? it's not perfect since keys need to be configured as separate commands and you need to "switch them on and off" but at least it's something
like-gold
like-goldOP4w ago
sure
Amadeo
Amadeo4w ago
do you have gihub account?
Amadeo
Amadeo4w ago
GitHub
Feature: ability to hold down button with KeyCommand · Issue #323 ...
Some software has issues detecting key presses made with KeyCommand and MultipleKeysCommand. Is your feature request related to a problem? Please describe. 3rd party software not detecting key pres...
like-gold
like-goldOP4w ago
GitHub
f-hicks - Overview
f-hicks has 32 repositories available. Follow their code on GitHub.
Amadeo
Amadeo4w ago
I'll build it and ping you on gh

Did you find this page helpful?