Search code examples
windowsprocesswindows-10autohotkeybackground-process

How to activate a background process using AutoHotkey?


mailmaster.exe is running as a background process (not shown on the taskbar), I tried activating it (bring it to the foreground) using Alt+M with the following script but didn't succeed:

!m::WinActivate ahk_exe mailmaster.exe

However, if mailmaster.exe is only minimized (still shown on the taskbar), I could bring it up with Alt+M.

How to activate it if it's running as a background process (not shown on the taskbar) as well?


Solution

  • Since mailmaster.exe is a singleton app, the following code will do the job:

    #IfWinNotActive ahk_exe mailmaster.exe
      !m::Run mailmaster
    #IfWinNotActive
    

    If the background app is not a singleton app, we could use the awesome TrayIcon library to simulate a left click on the app's tray icon to show it up:

    #IfWinNotActive ahk_exe mailmaster.exe
      !m::TrayIcon_Button("mailmaster.exe")
    #IfWinNotActive