AutoHotkey Community

It is currently May 27th, 2012, 12:38 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: September 16th, 2005, 9:33 am 
Offline

Joined: November 3rd, 2004, 11:24 am
Posts: 51
Code:
#Persistent
Menu, Menu1, Add, Item 1, Label
SetTimer, Watch, 500
Return

Watch:
   Menu, Menu1, Delete, Item 1 ; or Menu, Menu1, DeleteAll
   Menu, Menu1, Add, Item 1, Label
Return

Label:
   MsgBox, 0, , OK!
Return

F1::Menu, Menu1, Show


Note:
It works fine (the user get the "OK" message) in version 1.0.33.0
It don't works in actual version (1.0.35.x and later)
But at SetTimer >= 5000 it sometimes works
And without Delete -- no problems...

:?

And big thanks for the GREAT program! :D

_________________
My AHK project: http://landvermesser.tripod.com/


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 16th, 2005, 12:55 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Short answer: This can be fixed by lowering the priority of the timer so that it doesn't run while the menu thread is running:

SetTimer, Watch, 500, -1 ; Alternatively, you could raise the priority of each menu item.

Longer answer:
Landvermesser wrote:
It works fine (the user get the "OK" message) in version 1.0.33.0
It don't works in actual version (1.0.35.x and later)
I tested it on 1.0.33.0 and the MsgBox never appears (same behavior as later versions).

This is caused by the fact that the timer comes due while you're selecting the menu item. The sequence goes like this:
1) You select the item in the menu.
2) Your selection goes into the queue to await processing.
3) The program notices that your timer is overdue so runs it before the queued event. Note: Timers don't run while a menu is displayed, which is why it's almost always overdue at this point.
4) When the timer finishes, the queued event's menu item ID is now invalid because the timer deleted the old menu item and put one of the same name in its place. Therefore, the event is discarded.

Although I'm not sure if this behavior can be fixed, I'll look into it. Thanks for reporting it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2005, 7:13 pm 
Offline

Joined: November 3rd, 2004, 11:24 am
Posts: 51
Thanks, Chris!
The short answer is short but works very good. Now I can use the last AHK version! Hurrra!!! :D

_________________
My AHK project: http://landvermesser.tripod.com/


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: No registered users and 2 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