0

I have a very simple AutoHotkey script that listens for certain key presses to run Windows Shortcut files (lnk):

F21::
    Run "C:\Users\djcim\Google Drive\Powershell Scripts\Admin Shortcuts\djcim\StartOBS.lnk"
    Return

F22::
    Run "C:\Users\djcim\Google Drive\Powershell Scripts\Admin Shortcuts\djcim\StopOBS.lnk"
    Return

It seems to capture the key presses in most situations, however when I have certain programs focused like OBS or VSCode nothing happens.

Are these programs somehow blocking AutoHotkey from capturing these key presses? I have verified that neither of these programs are using F21 or F22 for shortcuts in program.

2

I am sure you meant F11 and F12.

If you are running an application with admin privileges, and at the same time, if AHK is running with lower privileges, then AHK won't intercept the key presses, and that could very well be the reason behind the problem you have described.

And if that is the case, the solution is to run the AHK script with the same privileges as other applications that you have mentioned.

More here:

https://stackoverflow.com/questions/1890351/why-is-visual-studio-catching-key-events-before-autohotkey

  • 1
    Actually I am using F21 and F22 via an Elgato Stream Deck, though it does seem you're right on the money with the issue being admin rights in the problematic programs. However, even when I run the script with admin rights the problem persists, still if I compile and run the exe as admin it seems programs running with admin rights are blocking the keystrokes. Restarts, rewrites, recompiles with every option I see available doesn't seem to fix the issue. I've assigned the keyboard shortcut to simply type "q" instead of start a program, comes through in VSCode without admin rights but not with. – Nimble Jun 19 at 7:50
  • 1
    The final issue was that the Elgato Stream Deck software wasn't elevated, thank you for pointing me in the right direction. It may be worth noting in the answer that every program involved must elevated, though that may be a given to many. – Nimble Jun 19 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.