Question / Help Is it possible to show and hide the OBS UI Window with hotkeys?

AreYouChasingMe

New Member
I would like to assign a keyboard hotkey to show and hide the OBS window. I would like the same functionality that OBS provides in the Windows Tray when you press "show" or "hide". I tried using a Windows Shortcut Key, but when I use it to maximize OBS, I get the following message "OBS is already running! [...]". I then tried to google a solution using AutoHotkey, but the problem is that when the OBS window is minimized to the tray, it seems to disable the window into a white box, so when I try maximizing it with AutoHotkey, what gets maximized is just a white non-functional window until I press the maximize button at the top right corner.

Is there any way to assign the show and hide buttons found in the system tray to a keyboard shortcut? If not, are there any other tricks that could be used?
 

koala

Active Member
Currently, there is no OBS hotkey to restore OBS from the system tray.

Since you already tinkered with Autohotkey, you might try this macro. The trick is to "WinMinimize" OBS after restoring to make the white window contain the contents, but only if the window was restored from the taskbar. At this point in the marcro, It does not actually minimize OBS again, it makes the window contain its content.
Directly accessing the system tray icon with Autohotkey seems extremely difficult according to some articles about it. The macro below is quick and dirty and does not do the right thing from a programming point of view, but it works.

Code:
#Warn
#SingleInstance Force
#NoEnv

; CTRL-ALT-O: restore OBS
^!O::
RestoreOBS() {
  if WinExist("OBS ahk_exe obs64.exe")
    WinActivate, OBS ahk_exe obs64.exe
  else {
    DetectHiddenWindows, On
    WinRestore, OBS ahk_exe obs64.exe
    WinMinimize, OBS ahk_exe obs64.exe
  }
}
 

AreYouChasingMe

New Member
koala, thank you for the information and your workaround solution. Your script did not seem to work because there needed to be some sort of delay between WinRestore, OBS ahk_exe obs64.exe and WinMinimize, OBS ahk_exe obs64.exe. I used Google briefly to try and find a way to insert a pause in the script, but I wasn't able to find one in my searches. However, I found that it worked if I simply put another if statement in there. I had to make a couple slight changes, but I got it working! This hotkey will toggle the OBS window (I have always minimize to tray enabled) and work almost just like the hide and show buttons found in the tray. I appreciate your help!

Here is the code I am using in my AutoHotkey script. I am an extreme novice at this stuff, so feel free to optimize it.

Code:
#Warn
#SingleInstance Force
#NoEnv

; Shift-F4: minimize or restore OBS
+F4::
ToggleOBS() {
 
  DetectHiddenWindows, On
  if WinActive("OBS ahk_exe obs64.exe")
    {
    WinMinimize, OBS ahk_exe obs64.exe
    }
  else {
    WinActivate, OBS ahk_exe obs64.exe
    if WinActive("OBS ahk_exe obs64.exe")
    {
        WinMinimize, OBS ahk_exe obs64.exe
    }
  }
}
 
Top