AutoHotkey Community

It is currently May 27th, 2012, 4:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: February 28th, 2010, 7:37 am 
Offline

Joined: November 26th, 2009, 3:00 am
Posts: 13
Is there any way to setup an event that will be run after the user right-clicks the tray icon but before the menu appears?

I'm looking for a way to be able to update the menu items before the user sees them (e.g. check/uncheck items), but I don't know exactly when item's should be checked or unchecked. If I was able to always update the menu before the user sees it, it would always show the menu items correctly to the user.

Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2010, 9:01 pm 
You would use one of these in your script:
Code:
Check, MenuItemName: Adds a visible checkmark in the menu next to MenuItemName (if there isn't one already).

Uncheck, MenuItemName: Removes the checkmark (if there is one) from MenuItemName.

ToggleCheck, MenuItemName: Adds a checkmark if there wasn't one; otherwise, removes it.



Say you have:
Code:
Menu, Tray, Add, Item1, label1
Menu, Tray, Add, Item2, label2
Menu, Tray, Add, Item3, label3
Menu, Tray, Add, Item4, label4


So if USER clicks on Item1 it will take him/her to "label1:"
And in "label1:" you would have:
Code:
label1:
Menu, Tray, ToggleCheck, Item1
;more code here to do whatever


You can even base the toggle/& code on which item is clicked and have all of them going to the same Label:
Code:
Menu, Tray, ToggleCheck, %A_ThisMenuItem%
; more code, using either %A_ThisMenuItem% OR %A_ThisMenuItemPos%


Check out the DOCS for all the stuff you can do with the tray menu!

DBM


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 12:35 am 
Offline

Joined: November 26th, 2009, 3:00 am
Posts: 13
Thanks for the help, however the problem is that I don't know if the item should be checked or not. It launches some program and if the program fails (i.e. it quit) I don't want a checkmark next to the item, which represents that the program isn't running. However, if a program didn't fail, then the checkmark should stay there.

Thus, it's not always correct to toggle the checkmark, especially if the program is quit/launched not through this script. The ultimate solution would be to always refresh the menu before the user sees it, this way it's guaranteed to be correct.

Sorry I wasn't clearer in my first post.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Mickers, rbrtryn and 66 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group