dumbeau / AutoHotPie

Radial menus in Windows, aka PIE MENYOOS!
MIT License
340 stars 18 forks source link

Send Key doesn't get detected by my other apps (like OBS) #8

Closed rexelbartolome closed 2 years ago

rexelbartolome commented 2 years ago

For some reason, it only accepts the simulated keypresses when OBS is the active window. But it disregards it if it's not active.

I've found that OBS can still listen for keypresses but it needs a key delay bigger than 5ms. I'm not sure how that will work for modifier keys. But maybe you'll get it more than me. Here's what I found:

obs does not accept ControlSend, however it listens for key presses when it is not active. To send hotkeys to an inactive obs you should use setkeydelay. You should try to avoid using sendinput / sendmode input, and instead simply use send "event" here is an example

;sendmode input  <--- this has been commented out deliberatley.
setkeydelay, 50,50
w::send ^j

if you need to use sendinput for other parts of your script, it may be possible to do the following

w::
sendinput, {ctrl down}{j down}
sleep, 50
sendinput, {ctrl up}{j up}
return
dumbeau commented 2 years ago

Good find! I was just having this issue in Illustrator, I'll be sure to test OBS too.

dumbeau commented 2 years ago

This should be fixed now, the second approach you listed ended up being faster and most reliable. The 'Send Key' function now has a 'Delay key release' checkbox that puts in the delay for how long a key is held down, this is on by default and the key delay time default is now set to 50ms as this seems to work in all the programs that are finnicky with simulated keystrokes. The only reason I'm making it an option (may take it out, we'll see) is because this delay pattern may be slow for some apps where people might want the speed, but either way it's still pretty fast especially for a single key shortcut. Thanks for bearing with me through these early stages here.

rexelbartolome commented 2 years ago

Awesome! Just had some time to tinker with it, pretty much works for everything now, probably wont even touch it since the slight speed difference doesn't bother me. I think it's alright to keep it there, maybe just a tooltip that says it's more reliable for most apps at the cost of some speed. And I'm honestly more than happy to help!

Been using this for teaching programs like Photoshop, Blender, etc. and having a screen annotation program as well as OBS on top of that kind of forced me to use really obscure shortcuts (which I couldn't even remember!) and this just felt like the right solution. So I'm just glad I'm able to help with the development 😊

dumbeau commented 2 years ago

This is really cool to hear! One of the things I've been working on is some application specific functions for photoshop, like toggling layer visibility by name or cycling through brushes by name (not a priority over the issues that come up). Ideally I can try and open up AHK as an extension language inside the app so people can write their own custom functions and have access to some of the pie menu related variables. Plus, AHK is easy enough to use.

rexelbartolome commented 2 years ago

Interesting! Maybe you should talk to Sergey Kritskiy about this since he's already done lots of extensions for Photoshop :) especially the layer visibility thing. Sadly the reason why I'm not as inclined to use Photoshop anymore is because of what you're trying to add, more functional keyboard shortcuts. Photoshop actions can only go so far, and it's too bad you can't map anything to the number row (unless you use a script ofc) so I've moved over to Krita which has better options in terms of keybinds to the point that I don't necessarily need pie menus to be efficient (unlike Photoshop or Blender)