Jump to content

why it doesnt give me the value 65


Go to solution Solved by spudw2k,

Recommended Posts

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_itemTrayCreateItem("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 by jacky998877
Link to comment
Share on other sites

  • Solution

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 by spudw2k
Link to comment
Share on other sites

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

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.

Link to comment
Share on other sites

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

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