Jump to content
Sign in to follow this  


Recommended Posts


Using Version

I'm new to AutoIt (but not new to programming) and I'm getting an odd result using the TrayItemGetState function. I have written some code to take action when the user clicks an item in my tray menu, depending on its state. The code also toggles the checked state of the item. No matter which state the menu item is in, the call to TrayItemGetState always returns 68. Am I doing something wrong? Here's some example code which always returns 68 on my machine...

#include <Constants.au3>

; Set up Tray Menu...

AutoItSetOption("TrayAutoPause", 0)

AutoItSetOption("TrayMenuMode", 1)

AutoItSetOption("TrayOnEventMode", 1)

$optionsMenu = TrayCreateMenu("Quick Options")

$startOnBoot = TrayCreateItem("Start with Windows", $optionsMenu)

$exitItem = TrayCreateItem("Exit")

TrayItemSetOnEvent($startOnBoot, "SetOptions")

TrayItemSetOnEvent($exitItem, "AppExit")

TrayItemSetState($startOnBoot, $TRAY_UNCHECKED)



Func SetOptions()

ConsoleWrite("TrayItemGetState = " & TrayItemGetState($startOnBoot) & @LF)

If BitAND(TrayItemGetState($startOnBoot), $TRAY_UNCHECKED) = $TRAY_UNCHECKED Then

TrayItemSetState($startOnBoot, $TRAY_CHECKED)


TrayItemSetState($startOnBoot, $TRAY_UNCHECKED)


EndFunc ;==>SetOptions

Func AppExit()


EndFunc ;==>AppExit

Share this post

Link to post
Share on other sites

Hmphf... I get the same with Prod and Beta. Looks broke. :)

I suggest you post it to the Bug Reports.

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post

Link to post
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
Sign in to follow this