Jump to content

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"

$GUI=GUICreate($Title)

GUISetState (@SW_SHOW)

opt("TrayIconHide",1)

Opt("TrayMenuMode",1)

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

endif

if NOT WinActive("My GUI") then

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

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

TraySetToolTip($Title) ; icon title

endif

Wend

Edited by Rick

Who needs puzzles when we have AutoIt!!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...