Right Control Click on ToolbarWindow321 autohotkey

I am completely new to autohotkey and right now I am facing a misunderstanding in ControlClick.

My goal is to right click on the icon in the Window321 toolbar with ControlClick to display the context menu. I don't want to use Click or Submit as the action can be performed when the session is locked.

I have searched the internet for a while and tried a few things.

ControlClick,,ahk_class Shell_TrayWnd,,R,NA x1500 y22

      

This thing works great if I want to have a dropdown menu in the toolbar. This is not the case.

I've tried something like this:

ControlClick,ToolbarWindow321,ahk_class Shell_TrayWnd,,Right,1,NA x1500 y22

      

But nothing is shown. I tried several coordinates and used AutoIt3 spy to determine the position of my icon.

I'm sure I did something wrong (of course, or this will work fine :)) Does anyone have any idea what I should do to make it work?

+3


source to share


2 answers


I wrote code to click on the Desktop button in the Save As Notepad. In the Windows XP version of Notepad, this was the ToolbarWindow32 control. The code uses functions from the Acc library, which you can put in your script Lib folder.

Acc Library [AHK_L] (updated 09/27/2012) - Scripts and Features - AutoHotkey Community https://autohotkey.com/board/topic/77303-acc-library-ahk-l-updated-09272012/

^q::
ControlGet, hCtl, Hwnd, , ToolbarWindow322, A
if !hCtl
Return

oAcc := Acc_Get("Object", "tool_bar", 0, "ahk_id " hCtl)
Loop, % oAcc.accChildCount
if (oAcc.accName(A_Index) = "Desktop")
if (1, oAcc.accDoDefaultAction(A_Index))
break
Return

      



EDIT: In your specific case, the accDoDefaultAction may not correspond to a right click.

For reference, my script, which works on both Windows XP and 7:

^q:: ;notepad (save as) - click Desktop button
^d:: ;notepad (save as) - click Desktop button
WinGet, hWnd, ID, A
hCtl := ""

if !hCtl ;check for treeview e.g. Win 7
{
ControlGet, hCtl, Hwnd, , SysTreeView321, ahk_id %hWnd%
if hCtl
oAcc := Acc_Get("Object", "outline", 0, "ahk_id " hCtl)
}

if !hCtl ;check for toolbar e.g. Win XP
{
ControlGet, hCtl, Hwnd, , ToolbarWindow322, ahk_id %hWnd%
if hCtl
oAcc := Acc_Get("Object", "tool_bar", 0, "ahk_id " hCtl)
}

Loop, % oAcc.accChildCount
if (oAcc.accName(A_Index) = "Desktop")
if (1, oAcc.accDoDefaultAction(A_Index))
break

Return

      

0


source


This problem may seem relatively trivial, "read the instructions", but I remember that I had problems with it. The method at the bottom should probably work like above, but doesn't.

;notepad save as (windows xp version) left-click Desktop button)
ControlClick, ToolbarWindow322, A, , , , NA x40 y100

;taskbar (windows 7) right-click taskbar button
ControlClick, x260 y20, ahk_class Shell_TrayWnd, , R
ControlClick, x260 y20, ahk_class Shell_TrayWnd, , R, NA

;taskbar (windows 7) right-click taskbar button (DIDN'T WORK)
;(clicked the wrong part of the taskbar, at the far right I believe)
ControlClick, , ahk_class Shell_TrayWnd, , R, x260 y20
ControlClick, , ahk_class Shell_TrayWnd, , R, NA x260 y20

      

Notes on your code:

this doesn't work for me either:

ControlClick,,ahk_class Shell_TrayWnd,,R,NA x1500 y22

      

I believe in it:



ControlClick,ToolbarWindow321,ahk_class Shell_TrayWnd,,Right,1,NA x1500 y22

      

should be as follows:

ControlClick,ToolbarWindow321,ahk_class Shell_TrayWnd,,Right,NA x1500 y22

      

with remote "1"

Note:

You can use Acc to determine the coordinates of the button and then use ControlClick to right-click it.

0


source







All Articles