If win exists activate but when active minimize it with the same shortcut. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
entropy
Posts: 93
Joined: 17 Oct 2014, 01:45

If win exists activate but when active minimize it with the same shortcut.

Post by entropy » 17 May 2022, 11:33

I’m having this shortcut and works perfectly.

Code: Select all

CapsLock & f1::
IfWinExist Firefox
	WinActivate
else
	Run "Firefox"
return
However, I’d like to achieve the same behaviour as the win keys combined with any number 0 to 9.
For example, in position 1 on my taskbar I have Chrome and when I press #1 Chrome is being activated, however, when I press again #1 when Chrome is active, the window minimises.
Is there a way to achieve the same when I press my key CapsLock & f1::
Thanks!

User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: If win exists activate but when active minimize it with the same shortcut.  Topic is solved

Post by mikeyww » 17 May 2022, 11:39

Code: Select all

CapsLock & F1::
If WinExist("ahk_exe firefox.exe")
 If WinActive()
      WinMinimize
 Else WinActivate
Else Run, firefox
Return


Post Reply

Return to “Ask for Help (v1)”