How to use hotkeys when focused program disables them?



  • I'm a power user, a game dev student, and and a twitch streamer, so multitasking is important to me. That having been said, programs like OBS and Voice Warrior require hotkeys to be used effectively. However, when certain programs (games mainly) are "focused" in Windows it's impossible to use them outside of that program save a few exceptions like peekthrough and Borderless Gaming. I know it's possible to disable focus altogether via regedit, but from my understanding this dramatically increases cpu usage, which I don't have much to spare. I've also heard autohotkey can fix this, but I haven't found a proper script to do so, nor am I proficient in the software's language to write a script to do so, does anyone have an editable script on hand or some other method to neutralize this hotkey disabling?



  • I found two workable methods that use AutoIt instead of AutoHotkey.

    1. By using the "ControlSend" command, I can send any input to any running programs regardless of focus status or even min/max status (but for some reason this does not work with many programs when the same command is used in AutoHotkey, hence me having to use AutoIt). I then converted the .aue file to an exe using AutoIt's built-in and bound it to a macro key on my Apex keyboard (I imagine there are some software online that can rebind any keys or add shortcuts if you lack these), and voila! I can now launch the script as an exe by pressing M1 on my keyboard, send a keystroke or key-hold via the ControlSend Windows API to OBS and many other hotkey-dependent program whether it's minimized, maximized, focused, or unfocused, bypassing the Windows limitations. However, it doesn't work with older programs (at least that's my theory as it doesn't work with VoiceWarrior, which was made for Windows 8).

    Here's an example of what that looks like:

        Opt("WinTitleMatchMode", 2)
    ControlSend ( "OBS" , "" , "" , "{F8}")
    
    1. To get other software such as VoiceWarrior I have a patchy and inelegant workaround. Simply put: focus it for five seconds while I speak my command, then auto return it to the background and refocus my previously focused program using the "WinPrevious" fuction made by Klexen on the AutoItScript forums.

    And here's an example of what that looks like:

    Opt("WinTitleMatchMode", 2)
    Func _WinPrevious($z = 1)
        If $z < 1 Then Return SetError(1, 0, 0) ; Bad parameter
        Local $avList = WinList()
        For $n = 1 to $avList[0][0]
            ; Test for non-blank title, and is visible
            If $avList[$n][0] <> "" And BitAND(WinGetState($avList[$n][1]), 2) Then
                If $z Then 
                    $z -= 1
                Else
                    WinActivate($avList[$n][1])
                    Return 1
                EndIf
            EndIf
        Next
        Return SetError(2, 0, 0) ; z-depth exceeded
    EndFunc
    WinActivate ( "VoiceWarrior" )
    Sleep (5000)
    _WinPrevious()
    

    Though I have to make sure I issue my commands with the hotkey pressed in those five seconds. Again, I convert it to an exe and add it to a macro.

    Hope this helps someone. I know a lot of people were searching for solutions like these.

    EDIT: If you have macros, you can set the software to a global autorun hotkey and assign THAT to a macro instead, then just add the holding down of the hotkey to the macro sequence so now you have the entire system automized.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2