Jump to content
Sign in to follow this  

Minimize To Tray

Recommended Posts

firstly, dont use #NoTrayIcon in your script but use AutoItSetOption ( "TrayIconHide",1) to not show icon in systray when gui is displayed as it will be on your taskbar anyway, then do a check for when minimised hide the gui (to take it away from the taskbar), and set AutoItSetOption ( "TrayIconHide",0) to reshow the icon in the systray , and then create a menu choice(if preferred) on the sytray icon to restore it.

heres an example, its not perfect but i'll leave you to play with it

#include <GUIConstants.au3>

$Title="My GUI"


GUISetState (@SW_SHOW)



While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

if TrayGetMsg() = -7 then ; if icon clicked ($TRAY_EVENT_PRIMARYDOWN)

GUISetState(@SW_SHOW,$GUI) ; put back onto taskbar

GUISetState(@SW_RESTORE,$GUI) ;restore what was minimised

opt("TrayIconHide",1) ; hide systray icon


if NOT WinActive("My GUI") then

GUISetState(@SW_HIDE,$GUI) ; hide from taskbar

opt("TrayIconHide",0) ; display systray icon

TraySetToolTip($Title) ; icon title



Edited by Rick

Who needs puzzles when we have AutoIt!!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...