jacky998877 Posted December 15, 2022 Share Posted December 15, 2022 (edited) after i checked the tray item "exit_the_program-" , it should return 65 , but it always gives me 68 #include <TrayConstants.au3> #include <AutoItConstants.au3> Opt("TrayMenuMode", 5) ; Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. $exit_tray_item= TrayCreateItem("exit_the_program--") TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. pause_the_program() Func pause_the_program() $exit_state = TrayItemGetState($exit_tray_item) While 1 ToolTip($exit_state) WEnd EndFunc Edited December 15, 2022 by jacky998877 Link to comment Share on other sites More sharing options...
Solution spudw2k Posted December 15, 2022 Solution Share Posted December 15, 2022 (edited) Two things; First, you are "capturing" the state of the tray item before your while loop, so the tooltip will never update if the state changes. Second, you should consider adding a sleep in the loop in order to reduce CPU usage. Try this Func pause_the_program() While 1 ToolTip(TrayItemGetState($exit_tray_item)) sleep(10) WEnd EndFunc edit: three things Any particular reason you marked your own post as the one that solved the topic? Edited December 15, 2022 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
jacky998877 Posted December 16, 2022 Author Share Posted December 16, 2022 18 hours ago, spudw2k said: Two things; First, you are "capturing" the state of the tray item before your while loop, so the tooltip will never update if the state changes. Second, you should consider adding a sleep in the loop in order to reduce CPU usage. Try this Func pause_the_program() While 1 ToolTip(TrayItemGetState($exit_tray_item)) sleep(10) WEnd EndFunc edit: three things Any particular reason you marked your own post as the one that solved the topic? thx. for i figured it out that the problem lies in the while loop. but i should have added "solved" in the title instead Link to comment Share on other sites More sharing options...
spudw2k Posted December 16, 2022 Share Posted December 16, 2022 Cool. Glad you managed to short it out for yourself. It's a moot point now since there is an explanation and fix for the issue, but in the future if you resolve your own issue it would be beneficial to future readers to know how it was solved; so if you would consider, go ahead and add to your post how you fixed it. jacky998877 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
jacky998877 Posted December 16, 2022 Author Share Posted December 16, 2022 4 hours ago, spudw2k said: Cool. Glad you managed to short it out for yourself. It's a moot point now since there is an explanation and fix for the issue, but in the future if you resolve your own issue it would be beneficial to future readers to know how it was solved; so if you would consider, go ahead and add to your post how you fixed it. accutually i just solved it just as the same as the solution u v provided 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