TrayMenu(_Action = "") { global Icon, AppName static Menus If (_Action = "init") { Menu, Tray, Icon, %Icons%,, 1 Menu, Tray, NoStandard Menu, Tray, DeleteAll Menu, Tray, Tip, %AppName% OnMessage(0x404, "TrayMenu_NotifyIcon") } Else If (_Action = "menus") { Return Menus } Else If (_Action = "create") { TrayMenu("destroy") ; Create main menu and submenus and get handles in an array MenuNames := "Main,Games,Tools,Update,Actions,Manage,Run,Install,Enable" Loop, Parse, MenuNames, `, { %A_LoopField%Menu := TrayMenu_Create() Menus := SA_Set(Menus, %A_LoopField%Menu, A_LoopField) } ; Add all Tools to the Tools menu Loop,% SA_Len(Tools := ToolXML_Find()) { ID := SA_Get(Tools, A_Index) Enabled := ToolXML_Get(ID, "@enabled") Installed := ToolXML_Get(ID, "@installed") Title := ToolXML_Get(ID, "title") If Enabled and Installed MMenu_Add(RunMenu, Title, "", "", "i" . ID) Else If tmp_Enabled MMenu_Add(EnableMenu, Title, "", "", "i" . ID) Else MMenu_Add(InstallMenu, Title, "", "", "i" . ID) } ; Tools menu ToolsItems := "Run,Enable,Install" Loop, Parse, ToolsItems, `, MMenu_Add(ToolsMenu, A_LoopField, "", 0, "m" %A_LoopField%Menu) ; Update menu UpdateItems := "Everything,Tools,Games,Mods" Loop, Parse, UpdateItems, `, MMenu_Add(UpdateMenu, A_LoopField) ; Actions menu MMenu_Add(Actions, "Lock Steam", "", "", "itrLockSteam") MMenu_Add(Actions, "Enable Steam Dock", "", "", "itrDockSteam") MMenu_Add(Actions, "Disable Screensaver", "", "", "itrDisableSS") ; Tools menu ManageItems := "Update Manager,CD Key Manager,Hotkey Manager,Backup Manager" Loop, Parse, ManageItems, `, MMenu_Add(Manage, A_LoopField) ; The actual Tray menu ;MMenu_Add(TrayMenu, AppName, "", 0, "d") - Program name in menu. SubMenus := "Games,Tools,Update,Actions,Manage,Settings" Loop, Parse, SubMenus, `, MMenu_Add(MainMenu, A_LoopField, "", 0, "m" . %A_LoopField%Menu) MMenu_Add(MainMenu, "Settings") MMenu_Add(MainMenu, "Exit") } Else If (_Action = "destroy") or (_Action = "exit") { MMenu_Destroy(SA_Get(Menus, "TrayMenu")) } Return true } TrayMenu_NotifyIcon(wParam, lParam) { static IgnoreClick If Not IgnoreClick { If (lParam = 0x205) ;Right click menu SetTimer, RightClickTray, -1 Else If (lParam = 0x202) { ; Left click menu IgnoreClick := true KeyWait, LButton, D T0.2 If ErrorLevel SetTimer, LeftClickTray, -1 Else SetTimer, OpenSteam, 50 } } Else ignoreClick := false Return 0 } TrayMenu_Create() { Return MMenu_Create("s16 c2F312D tFFFFFF") }