I'm trying to create a hotkey to combine multiple selected pdf files into a single pdf file through the AppsKey context menu.
My only problem is that sometimes the position in the context menu for this option ("Combine supported files in Acrobat...") is the 3rd item down, sometimes it's the 6th item down, sometimes it's the 8th item down, etc. I can't find any rhyme or reason for why this position keeps changing.
Is there any way for AutoHotKey to select a context item by the text value rather than the position? I have seen Misha's script but my programming skills aren't nearly strong enough and I don't have enough time to read through all the other programming to parse out what I need to do. Are there any scripts or any directions that just do this one thing?
Thanks for any help
Selecting a context menu item by text value
-
- Posts: 5
- Joined: 09 Dec 2017, 19:24
Re: Selecting a context menu item by text value
try typing the letters of the text. If it works you can simulate the keystrokes with autohotkey.
Re: Selecting a context menu item by text value
Does the item appear somewhere as a menu item on a context menu descended from the menu bar? Does WinMenuSelectItem work?
Do you mean this script by Micha (that someone updated):
Get Info from Context Menu (x64/x32 compatible) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=31971
The principle of invoking menu items is to create a one-liner like this.
SendMessage, 0x111, 3,,, % "ahk_id " hWnd ;WM_COMMAND := 0x111
The menu item ID might not be 3, Micha's script shows a ToolTip with menu item IDs; usually, but not always that number is the number you need.
To literally do what you requested, this script should work:
Do you mean this script by Micha (that someone updated):
Get Info from Context Menu (x64/x32 compatible) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=31971
The principle of invoking menu items is to create a one-liner like this.
SendMessage, 0x111, 3,,, % "ahk_id " hWnd ;WM_COMMAND := 0x111
The menu item ID might not be 3, Micha's script shows a ToolTip with menu item IDs; usually, but not always that number is the number you need.
To literally do what you requested, this script should work:
Code: Select all
;based on:
;GUIs via DllCall: get/set internal/external control text - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=40514
;context menu window messages: focus/invoke item - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=5&t=39209
q:: ;invoke menu item in context menu that matches string
;e.g. Notepad right-click menu, 'Paste' menu item
SendMessage, 0x1E1,,,, ahk_class #32768 ;MN_GETHMENU := 0x1E1
hMenu := ErrorLevel
vNeedle := "Paste"
vNeedle := StrReplace(vNeedle, "&")
Loop, % DllCall("user32\GetMenuItemCount", Ptr,hMenu)
{
vIndex := A_Index-1
vID := DllCall("user32\GetMenuItemID", Ptr,hMenu, Int,vIndex, UInt)
if (vID = 0) || (vID = 0xFFFFFFFF) ;-1
continue
vChars := DllCall("user32\GetMenuString", Ptr,hMenu, UInt,vIndex, Ptr,0, Int,0, UInt,0x400) + 1
VarSetCapacity(vText, vChars << !!A_IsUnicode)
DllCall("user32\GetMenuString", Ptr,hMenu, UInt,vIndex, Str,vText, Int,vChars, UInt,0x400) ;MF_BYPOSITION := 0x400
if (StrReplace(vText, "&") = vNeedle)
{
PostMessage, 0x1F1, % vIndex, 0,, ahk_class #32768 ;MN_DBLCLK := 0x1F1
break
}
}
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Selecting a context menu item by text value
Tested (W7 Pro 64, Notepad) worked (for me)!jeeswg wrote:Does the item appear somewhere as a menu item on a context menu descended from the menu bar? Does WinMenuSelectItem work?
Do you mean this script by Micha (that someone updated):
Get Info from Context Menu (x64/x32 compatible) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=31971
The principle of invoking menu items is to create a one-liner like this.
SendMessage, 0x111, 3,,, % "ahk_id " hWnd ;WM_COMMAND := 0x111
The menu item ID might not be 3, Micha's script shows a ToolTip with menu item IDs; usually, but not always that number is the number you need.
To literally do what you requested, this script should work: [...]
