Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

right click sub menu


  • Please log in to reply
4 replies to this topic
triley77
  • Guests
  • Last active:
  • Joined: --
Is it possible to:

Step #1. Force AHK to right click the mouse.
Step #2. Drive mouse to a given right click menu item to activate sub menu
Step #3. Select item in sub menu?


As shown here:


Posted Image

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Click Right
For the rest, it is generally easier to use keyboard accelerators. For instance, your example could be coded as:
Click Right
Send u
Send g
Notice the underlined characters in the menu.

triley77
  • Guests
  • Last active:
  • Joined: --
Hmmmmmm

The problem is that the sub menu I am looking to access does not have any set shortcuts. So doing a "send G" would not work.

In an ideal work I would love some type of code that looks for the TEXT of a given sub menu and selects that item.

Any other thoughts?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
It is possible, but I don't think it will work with Office. See Get info from context menu.

If an item doesn't have an underlined character, try the first character of its text instead.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
You may try using this, which probably won't work with Office or other programs with custom menus:
MenuSelectItem(ItemText, UseMouse=False) ; May changes CoordMode if UseMouse=true.
{
    ifWinNotExist, ahk_class #32768
        return false
    SendMessage, MN_GETHMENU:=0x01E1
    hMenu := ErrorLevel
    if !hMenu
        return false
    N := 0
    Loop % DllCall("GetMenuItemCount", "uint", hMenu)
    {
        ThisState := DllCall("GetMenuState", "uint", hMenu, "uint", A_Index-1, "uint", 0x400)
        if (ThisState & 0x860) ; MF_SEPARATOR | MF_MENUBREAK | MF_MENUBARBREAK
            continue
        N += 1
        VarSetCapacity(ThisText, DllCall("GetMenuString", "uint", hMenu, "uint", A_Index-1, "uint", 0, "int", 0, "uint", 0x400))
        DllCall("GetMenuString", "uint", hMenu, "uint", A_Index-1, "str", ThisText, "int", VarSetCapacity(ThisText)+1, "uint", 0x400)
        if (RegExReplace(ThisText, "(?<!&)&") = ItemText)
        {
            if UseMouse
            {
                VarSetCapacity(rect, 16)
                DllCall("GetMenuItemRect", "uint", WinExist(), "uint", hMenu, "uint", A_Index-1, "uint", &rect)
                WinGetPos, wx, wy
                x := NumGet(rect,0) + (NumGet(rect,8)-NumGet(rect,0))//2
                y := NumGet(rect,4) + (NumGet(rect,12)-NumGet(rect,4))//2
                CoordMode, Mouse, Screen
                Click %x%, %y%
            }
            else
                ControlSend,, {Down %N%}{Enter}
            return true
        }
    }
    return false
}
It should use whichever menu is top-most.