Select a line from a menu with the text...?

Get help with using AutoHotkey and its commands and hotkeys
Elaphe666
Posts: 123
Joined: 28 Nov 2015, 11:39

Select a line from a menu with the text...?

27 Dec 2018, 05:26

How can I make my script select a specific line from a right-click menu (Chrome) based on the text on that line? Thank you.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Select a line from a menu with the text...?

27 Dec 2018, 09:15

- Here are two variants. Both using old-school approaches, the second also using Acc.
- When I tested, accDoDefaultAction did not appear to work on the right-click menu, hence I had to use MouseClick.

Code: Select all

q:: ;chrome - get url under cursor
SendInput, {Click right}
Clipboard := ""
Sleep, 30
SendInput, e ;Copy link address
ClipWait, 3
MsgBox, % Clipboard
return

;[Acc functions]
;Acc library (MSAA) and AccViewer download links - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

w:: ;chrome - get url under cursor
SendInput, {Click right}
WinWait, ahk_class Chrome_WidgetWin_2
hWnd := WinExist()
oAcc := Acc_Get("Object", "4.1.3.1", 0, "ahk_id " hWnd)
Clipboard := ""
;Sleep, 30
for _, oChild in Acc_Children(oAcc)
	if (oChild.accName(0) = "Copy link address")
	{
		oChild.accDoDefaultAction(0)
		oRect := Acc_Location(oChild)
		CoordMode, Mouse, Screen
		MouseGetPos, vCurX, vCurY
		MouseClick,, % oRect.x+oRect.w/2, % oRect.y+oRect.h/2
		MouseMove, % vCurX, % vCurY
	}
oAcc := oChild := ""
ClipWait, 3
MsgBox, % Clipboard
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], boiler, Google [Bot], Odlanir, pn4265 and 253 guests