TheDcoder Posted March 9, 2022 Share Posted March 9, 2022 Hi, my code is not able to create sub-menu items in the tray: #include <TrayConstants.au3> Opt("TrayMenuMode", 1 + 2) ; No default menu and automatic checkmarks Opt("TrayOnEventMode", 1) ; OnEvent mode Opt("TrayAutoPause", 0) ; No Auto-Pause Global $g_idTrayOption_Main, $g_idTrayOption_Sub, $g_idTrayOption_Exit Tray_Initialize() Func Tray_Initialize() TraySetClick(16) $g_idTrayOption_Main = TrayCreateItem("Open sub-menu") ConsoleWrite("Main ID: " & $g_idTrayOption_Main & @CRLF) $g_idTrayOption_Sub = TrayCreateItem("Sub-menu item", $g_idTrayOption_Main) ConsoleWrite("Sub ID: " & $g_idTrayOption_Sub & @CRLF) $g_idTrayOption_Exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, Tray_Exit) EndFunc Func Tray_Exit() Exit EndFunc While True Sleep(1000) WEnd The Sub ID for me is always 0, which according to the help file means TrayCreateItem has failed, what gives? I tried to find if there is any obvious error in my code but I cannot find any... so I need an extra pair of eyes to look at the code! Thanks for the help in advance EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Solution Subz Posted March 9, 2022 Solution Share Posted March 9, 2022 Shouldn't $g_idTrayOption_Main = TrayCreateItem("Open sub-menu") be $g_idTrayOption_Main = TrayCreateMenu("Open sub-menu") TheDcoder 1 Link to comment Share on other sites More sharing options...
TheDcoder Posted March 9, 2022 Author Share Posted March 9, 2022 I knew it would be something so obvious 😭 Thanks Subz for pointing out the error TheSaint 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now