Minimize program to task tray toggle Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
LeFunk
Posts: 86
Joined: 29 Aug 2016, 03:12

Minimize program to task tray toggle

Post by LeFunk » 09 Jun 2023, 10:11

Hello!

I'm trying to create a toggle that minimizes a program to task tray if its window is open, but opens its window if it's currently on task tray:

Code: Select all

#o::
{
DetectHiddenWindows(true)
   if WinActive("VueMinder Pro")
   {
     WinMinimize("VueMinder Pro")
	 Return
   }
   Else
   {
      if WinExist("VueMinder Pro")
      {
         winid := WinGetID("VueMinder Pro")
         DllCall("SwitchToThisWindow", "UInt", winid, "UInt", 1)
		Return
      }
		if !WinExist("VueMinder Pro")
		{
		Run("`"C:\Program Files (x86)\VueSoft\VueMinder\VueMinder.exe`"")
		ErrorLevel := WinWait("VueMinder Pro", , 4) , ErrorLevel := ErrorLevel = 0 ? 1 : 0
		WinActivate("VueMinder Pro")
		Return
		}
   }
   Return
}
For some reason, it works only once. Have I missed something?
Thanks in advance!

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

Re: Minimize program to task tray toggle

Post by mikeyww » 09 Jun 2023, 12:35

In VueMinder settings, configure the hotkey for show/hide to Ctrl+Shift+F1.

Options -> Hotkeys -> Show/hide main VueMinder window

Code: Select all

#Requires AutoHotkey v2.0
#HotIf WinExist('ahk_exe VueMinder.exe')
#o::Send '^+{F1}'
#HotIf

LeFunk
Posts: 86
Joined: 29 Aug 2016, 03:12

Re: Minimize program to task tray toggle

Post by LeFunk » 10 Jun 2023, 10:41

The problem with Options -> Hotkeys -> Show/hide main VueMinder window shortcut is that although it opens the Vueminder window, it doesn't close/minimize it (at least on my PC).
I also noticed now that my code works perfectly IF there's another program's window on my desktop (activated or not).
It works only once if the desktop is empty (shortcut opens Vueminders, closes Vueminder, then nothing). Odd.

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

Re: Minimize program to task tray toggle

Post by mikeyww » 10 Jun 2023, 11:32

You could try one of the other keyboard shortcuts in the program, and then adjust the script accordingly. It worked here.

LeFunk
Posts: 86
Joined: 29 Aug 2016, 03:12

Re: Minimize program to task tray toggle

Post by LeFunk » 11 Jun 2023, 09:15

I'm just completely puzzled by this. For some reason, the Vueminder shortcut opens the window, but doesn't close it.

When I assign a script to close it:

Code: Select all

#Requires AutoHotkey v2.0
#HotIf WinActive('ahk_exe VueMinder.exe')
#o::
{
WinMinimize("VueMinder Pro")
}
#HotIf
It does close the Vueminder window. But if it was the only window, then after that none of my hotkeys work. I have to manually click somewhere on the screen so they could start working again. I have tried sending a click after 500 ms sleep, etc as a workaround, but none of it has any effect.

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

Re: Minimize program to task tray toggle  Topic is solved

Post by mikeyww » 11 Jun 2023, 09:39

Have you tried changing the shortcut as I mentioned?
None of my hotkeys work.
Use only the short script, with no other hotkeys. That will enable you to troubleshoot more quickly and get your script working.

My script does not use the WinActive function.

Code: Select all

#Requires AutoHotkey v2.0
#HotIf WinExist('ahk_exe VueMinder.exe')
#o Up::Send '^+{F9}'
#HotIf
image230611-1045-001_cr.png
Program hotkeys
image230611-1045-001_cr.png (15.6 KiB) Viewed 301 times

LeFunk
Posts: 86
Joined: 29 Aug 2016, 03:12

Re: Minimize program to task tray toggle

Post by LeFunk » 11 Jun 2023, 10:23

I closed all the other apps/scripts and ran just this code, and it works!
Turns out that a screen dimmer program was interfering with it.

Thank you very much for your help, @mikeyww !

Post Reply

Return to “Ask for Help (v2)”