| View previous topic :: View next topic |
| Author |
Message |
n00b7 Guest
|
Posted: Wed Oct 28, 2009 2:58 pm Post subject: How to retrieve menu item status WITHOUT mouse? |
|
|
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
|
Posted: Wed Oct 28, 2009 3:43 pm Post subject: |
|
|
| 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 |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Oct 28, 2009 4:26 pm Post subject: |
|
|
| Try sending the {Appskey}, then e.g. Send i, n for arraging by name (the underlined character within the menu). |
|
| Back to top |
|
 |
svi
Joined: 09 Oct 2006 Posts: 236 Location: Finland
|
|
| Back to top |
|
 |
n00b7 Guest
|
Posted: Wed Oct 28, 2009 6:43 pm Post subject: |
|
|
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
|
Posted: Wed Oct 28, 2009 9:21 pm Post subject: |
|
|
| 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 |
|
 |
n00b7 Guest
|
Posted: Thu Oct 29, 2009 3:48 am Post subject: |
|
|
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
|
Posted: Thu Oct 29, 2009 6:54 pm Post subject: |
|
|
| 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 |
|
 |
|