TrayMinimizer - Enable Minimize to tray with two lines and minimal impact

Post your working scripts, libraries and tools
User avatar
evilC
Posts: 4181
Joined: 27 Feb 2014, 12:30

TrayMinimizer - Enable Minimize to tray with two lines and minimal impact

01 Mar 2018, 16:02

For a while now, I have been using Skan's MinimizeToTray, but I find it a bit of a pain to add to a script - I wanted a quick and easy solution.
So I ripped his code apart, and here is a version which should be much simpler to use.

For easiest use, place the library in your "My Documents" folder, in AutoHotkey\Lib
Then just include it in any script in any folder by adding this line to the start: #include <TrayMinimizer>

Once you have done building your gui, call TrayMinimizer.Init() - for example:

Code: [Select all] [Download] GeSHi © Codebox Plus

#Include <TrayMinimizer>	; <-- Pulls in the code from another file

; Build your GUI
Gui, Add, Text,, THIS IS A TEST
Gui, Show, w200

TrayMinimizer.Init(false) ; <-- Initializes and optionally minimizes
return


If you call TrayMinimizer.Init(false), the window will stay open, if you just call TrayMinimizer.Init(), it will minimize on startup

Code: [Select all] [Expand] [Download] (TrayMinimizer.ahk)GeSHi © Codebox Plus


As a side note, Skan's original code used DrawAnimatedRects API calls to make the window minimize towards the tray, but this does not seem to work for me. In the original code, it seemed to use the global variable R to store two RECT structs, so it could pass those to the WinAPI call. I guess this could be done with ObjSetCapacity and stored as a class property, but I cannot even seem to get the original code to work. If anyone could help out, that would be great, but I am not hugely fussed as it is largely cosmetic.
burque505
Posts: 446
Joined: 22 Jan 2017, 19:37

Re: TrayMinimizer - Enable Minimize to tray with two lines and minimal impact

01 Mar 2018, 17:29

Thanks, works great, add to my LIB folder.
Regards,
burque505
guest3456
Posts: 2313
Joined: 09 Oct 2013, 10:31

Re: TrayMinimizer - Enable Minimize to tray with two lines and minimal impact

13 Mar 2018, 10:24

evilC wrote:As a side note, Skan's original code used DrawAnimatedRects API calls to make the window minimize towards the tray, but this does not seem to work for me. In the original code, it seemed to use the global variable R to store two RECT structs, so it could pass those to the WinAPI call. I guess this could be done with ObjSetCapacity and stored as a class property, but I cannot even seem to get the original code to work. If anyone could help out, that would be great, but I am not hugely fussed as it is largely cosmetic.



this claims that that API is dependent upon Aero (which cannot be turned off in Win8+):
https://stackoverflow.com/questions/401 ... 5_40116051
https://social.msdn.microsoft.com/Forum ... aero-theme

i tested on my win7 VM with basic theme and AHK basic, and SKAN's original script did work. with Aero theme it failed.

workaround is to just loop yourself and move the window. the built-in API wasn't very smooth anyway
https://stackoverflow.com/questions/989 ... 287#989287


Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 6 guests