Search code examples
windowsautohotkeyvisible

ahk how to keep visible a window though not active


The below script works but minimizes a screen inactive, but I would like to keep the inactive window visible. what should I do?

F9::
      IfWinExist ahk_class Forge10MDIClass
      WinMove ahk_class Forge10MDIClass
      WinActivate ahk_class Forge10MDIClass
Send {space} ;; pauses audio file (toggles)
Send !{Esc} ;; Alt + Esc in Windows 8; but it is minimizing and I dont want that
return

Solution

  • You could do this in 2 different ways:

    First: Store the active window and switch back after toggling the audio file

    F9::
        WinGet, active_id, ID, A
        IfWinExist ahk_class Forge10MDIClass
        {
            WinActivate ahk_class Forge10MDIClass
            Send {space} ;; pauses audio file (toggles)
            WinActivate, ahk_id %active_id%
        }
        Return
    

    Second: Use ControlSend to send Space directly to the window without having to activate it.

    F9::ControlSend, ahk_parent, {Space}, ahk_class Forge10MDIClass
    

    Note: I do not have this software, so I cannot confirm that ControlSend works properly with it.

    Hope this helps.