Get MENUITEM Number of an External Application

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Lennon
Posts: 2
Joined: 16 Jun 2018, 12:35

Get MENUITEM Number of an External Application

16 Jun 2018, 13:06

Greetings All,

For few days now I have been looking around on Threads and Posts for a solution for this one but rather have got bewildered and posting this hoping for a resolution.
RH shows the below for a 128 MENU LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US:

Code: Select all

MENUITEM SEPARATOR
    POPUP "Intraday"
    {
      MENUITEM "Day/Night",  5003
      MENUITEM SEPARATOR
      MENUITEM "&Hourly",  5004
      MENUITEM "15-mi&nute",  5005
      MENUITEM "&5-minute",  5006
      MENUITEM "&1-minute",  5007
      MENUITEM "15-&second",  5008
      MENUITEM "5-secon&d",  5009
      MENUITEM "1-second",  5010
      MENUITEM "Tic&k",  5011
      MENUITEM SEPARATOR
      MENUITEM "Custom 1",  5012
      MENUITEM "Custom 2",  5013
      MENUITEM "Custom 3",  5014
      MENUITEM "Custom 4",  5015
      MENUITEM "Custom 5",  5016
      MENUITEM SEPARATOR
      MENUITEM "Custom tick 1",  5017
      MENUITEM "Custom tick 2",  5018
      MENUITEM "Custom tick 3",  5019
      MENUITEM "Custom tick 4",  5020
      MENUITEM "Custom tick 5",  5021
      MENUITEM SEPARATOR
    }
    MENUITEM "&Daily",  5002
    MENUITEM "&Weekly",  5001
    MENUITEM "&Monthly",  5000
    MENUITEM "Quarterly",  4999
    MENUITEM "Yearly",  4998
    MENUITEM SEPARATOR
The user on the external application has clicked and selected anyone of these MENUITEM. How do I get the currently selected MENUITEM number and manipulate the selection from AHK? Is it even possible? Scite's SPY says that the parent menu is a part of a XTPToolBar13. So we are not dealing with a conventional ComboBox or a ListBox. I am out of luck on this one....

Appreciate your kind help!
Many thanks!


P.S. This is my first post, because all of my previous queries were asked before by others and resolved in this forum. I just had to search as a guest. Have been using AHK for past 2 years (still a Rookie BTW :) ). Extremely grateful to this helping community. Thank you! :clap:
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Get MENUITEM Number of an External Application

18 Jun 2018, 19:19

That appears to be the resource definition for Win32 menu, but since you mention XTPToolBar13, maybe it is not directly attached to the window. In that case, it would be a popup menu, shown only when you click on the toolbar. You cannot access some other program's popup menu until it pops up.

If you can do something to popup the menu (i.e. send the appropriate keys), you can probably use MN_GETHMENU via SendMessage to get the menu handle. Once you have the handle, you can use GetMenuState to determine whether an item is checked. You may find examples of using MN_GETHMENU or GetMenuState if you search the forums. For a list of mutually exclusive items, you would need to use GetMenuState sequentially, on each item, to find the one that is checked.

However, some programs do not update their menus until they are being displayed (i.e. the checked state may be incorrect prior to displaying the menu).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Giresharu, Google [Bot] and 251 guests