Function Reference


TrayItemSetOnEvent

Defines a user-defined function to be called when a tray item is clicked.

TrayItemSetOnEvent ( itemID, "function" )

Parameters

itemID The item identifier (itemID) as returned by a TrayCreateItem function.
function The name of the user function to call.

Return Value

Success: Returns 1.
Failure: Returns 0.
@error: 1 if the "function" is not defined.

Remarks

OnEvent functions are only called when the option TrayOnEventMode is set to 1 - when in this mode TrayGetMsg is NOT used at all.

Within the called user function the item identifier can be retrieved with @TRAY_ID.

If the function is an empty string "" the previous user-defined is disabled.

Related

TrayCreateItem, TrayGetMsg, TrayOnEventMode (Option), TraySetOnEvent

Example


#NoTrayIcon

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.

TraySetClick(16) ; Only secondary mouse button will show the tray menu.

TrayCreateItem("Info")
TrayItemSetOnEvent(-1, "ShowInfo")

TrayCreateItem("")

TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "ExitScript")

TraySetState()

While 1
    Sleep(10) ; Idle loop
WEnd

Exit


; Functions
Func ShowInfo()
    MsgBox(0, "Info", "Tray OnEvent Demo")
EndFunc   ;==>ShowInfo


Func ExitScript()
    Exit
EndFunc   ;==>ExitScript