minimise to system tray

By ChrisL in AutoIt Example Scripts,
minimise a gui to the system tray Edit~: Updated to support newer versions of Autoit, thanks to Zedna too I've used some of your suggestions #NoTrayIcon #include <GuiConstants.au3> #include <Constants.au3> Opt("GUIEventOptions",1) Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"SpecialEvent") $gui = GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_MINIMIZE GuiSetState(@SW_MINIMIZE) GuiSetState(@SW_HIDE) TraySetState(1) ; show If @OSVersion = "WIN_NT4" or @OSVersion = "WIN_ME" or @OSVersion = "WIN_98" or @OSVersion = "WIN_95" then TraySetToolTip ("My app - click here to restore") Else Traytip ("My App", "click here to restore", 5) EndIf Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func SpecialEvent() GuiSetState(@SW_RESTORE) GuiSetState(@SW_Show) TraySetState(2) ; hide EndFunc
  • 13 replies