Jump to content

Cannot create sub-menu items in tray menu


Go to solution Solved by Subz,

Recommended Posts

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

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...