AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to retrieve menu item status WITHOUT mouse?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
n00b7
Guest





PostPosted: Wed Oct 28, 2009 2:58 pm    Post subject: How to retrieve menu item status WITHOUT mouse? Reply with quote

I am able to get to the menu item that I want (as seen in the attached image) without mouse commands:



However, before executing it, I would like verify that it is checked.

How do I do that?

Thx!
Back to top
gargoyle888



Joined: 10 Jan 2009
Posts: 16

PostPosted: Wed Oct 28, 2009 3:43 pm    Post subject: Reply with quote

I don't know what software you are using and the behavior may be software dependent. But, after highlighting the entry, the enter key usually forces it to be checked. Whether it was originally or not.
Back to top
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 1002
Location: Germany - Deutschland

PostPosted: Wed Oct 28, 2009 4:26 pm    Post subject: Reply with quote

Try sending the {Appskey}, then e.g. Send i, n for arraging by name (the underlined character within the menu).
Back to top
View user's profile Send private message
svi



Joined: 09 Oct 2006
Posts: 236
Location: Finland

PostPosted: Wed Oct 28, 2009 4:31 pm    Post subject: Reply with quote

Get Info from Context Menu
_________________
Pekka Vartto
Back to top
View user's profile Send private message
n00b7
Guest





PostPosted: Wed Oct 28, 2009 6:43 pm    Post subject: Reply with quote

svi wrote:
Get Info from Context Menu

Thank you all. Unfortunately it seems that I didn't explain my question well enough.

I just want to retrieve the status (that checkmark next to the menu item text). That's all. How do I do that?

The answer provided by svi is the closest to what I am looking but it relies on the mouse being the one selecting that menu.

I need a method that doesn't use the mouse at all. Is there such a thing?

Thx.
Back to top
svi



Joined: 09 Oct 2006
Posts: 236
Location: Finland

PostPosted: Wed Oct 28, 2009 9:21 pm    Post subject: Reply with quote

n00b7 wrote:
I need a method that doesn't use the mouse at all. Is there such a thing?

Sure there is. Replace these lines:
Code:
;Get mouse position and handle to wnd under the mouse cursor
  MouseGetPos, MouseScreenX, MouseScreenY, MouseWindowUID, MouseControlID
  WinGet,ControlHwnd, ID,ahk_id %MouseWindowUID%
with these:
Code:
IfWinNotExist ahk_class #32768
{
   ToolTip
   Return
}
 WinGet,ControlHwnd, ID,ahk_class #32768
(in Get Info from Context Menu),
so you'll get the info whenever the menu is shown.

But probably you want to retrieve the status without showing the menu...
Perhaps also that's been done (I'm too busy to try/search it now).
_________________
Pekka Vartto
Back to top
View user's profile Send private message
n00b7
Guest





PostPosted: Thu Oct 29, 2009 3:48 am    Post subject: Reply with quote

svi, you are a genius. What you suggested works perfectly:

svi wrote:
WinGet,ControlHwnd, ID,ahk_class #32768

But now I am puzzled: Winspector Spy says that both the main context menu and its submenu have the same class name #32768.

So, how does WinGet know to get the hWnd of the submenu instead of the main menu?

To further explain my question: If I follow WinGet by the following statement:
Code:
ContextMenCnt := GetContextMenuCount(hWnd)

Then I get the correct number of menu items in the submenu - if the submenu is open. And I get the correct number of menu items in the main menu - if the submenu is not open.

Obviously, I don't understand how this works. Can you (or anyone) explain?

Thx!
Back to top
svi



Joined: 09 Oct 2006
Posts: 236
Location: Finland

PostPosted: Thu Oct 29, 2009 6:54 pm    Post subject: Reply with quote

n00b7 wrote:
So, how does WinGet know to get the hWnd of the submenu instead of the main menu?

It just gets the handle of the topmost (in this case most recent) window that matches the specifications.
_________________
Pekka Vartto
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group