【问题标题】:Right controlClick on ToolbarWindow321 autohotkey右键控制点击ToolbarWindow321 autohotkey
【发布时间】:2014-11-26 14:55:54
【问题描述】:

我是 autohotkey 的新手,目前对 ControlClick 存在误解。

我的目标是用 ControlClick 右键单击​​工具栏Window321 上的图标以显示上下文菜单。我不想使用 Click 或 Send,因为在会话锁定时可能会执行此操作。

我在网上搜索了一段时间并尝试了几件事。

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

如果我想要工具栏的下拉菜单,这个东西就很好用。事实并非如此。

我试过这样的:

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

但是什么也没显示。我尝试了几个坐标,并使用 AutoIt3 spy 来确定我的图标的位置。

我确定我做错了什么(当然,否则它会正常工作:)) 有人知道我必须做什么才能让它发挥作用吗?

【问题讨论】:

  • 这很难重建。您要点击什么图标,toolbarWindow321 是什么?谁能帮助你?

标签: autohotkey right-click trayicon


【解决方案1】:

我编写了一些代码来单击记事本“另存为”窗口中的“桌面”按钮。 在 Windows XP 版本的记事本上,这是一个 ToolbarWindow32 控件。 该代码使用 Acc 库中的函数,您可以将其放入脚本的 Lib 文件夹中。

Acc 库 [AHK_L] (更新于 09/27/2012) - 脚本和函数 - AutoHotkey 社区 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

编辑:在您的特定情况下,accDoDefaultAction 可能与右键单击不对应。

作为参考,我的脚本适用于 Windows XP 和 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

【讨论】:

    【解决方案2】:

    这个问题可能看起来是一个相对微不足道的事情,一个“阅读手册”的问题,但我记得我自己也遇到过问题。 可以说底部的方法应该像上面的那样工作,但不是。

    ;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
    

    代码注释:

    这也是对我不起作用的形式:

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

    我相信这一点:

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

    应该是这样的:

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

    去掉“1”

    补充说明:

    您可以使用 Acc 来识别按钮的坐标,然后使用 ControlClick 右键单击​​它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-26
      • 2018-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多