autoHotkey进阶 --- 用于访问窗口对象-acc库的简单配置

autoHotkey进阶 — 用于访问窗口对象-acc库的简单配置

引言

accessible( acc) 库,是ahk的一个第三方的代码库.这个库通过访问微软库的底层api函数(Microsoft Active Accessibility (MSAA))实现一些窗口的基础操作函数.从名字也可以看出来,主要是让我们访问窗口的一些对象. 例如用于监测窗口\控件\gui元素的信息. 根据这些信息做一些特殊操作,或者操作这些对象的状态. 例如检测按钮的位置,并设置自动单击.

Microsoft Active Accessibility (MSAA) 是用于用户界面可访问性的应用程序编程接口 (API)。MSAA于1997年作为Microsoft Windows 95的平台附加组件引入。MSAA 旨在帮助辅助技术 (AT) 产品与应用程序(或操作系统)的标准和自定义用户界面 (UI) 元素进行交互,以及访问、识别和操作应用程序的 UI 元素。AT 产品与支持 MSAA 的应用程序配合使用,以便为有身体或认知困难、障碍或残疾的个人提供更好的访问。AT 产品的一些示例包括:用于视力受限用户的屏幕阅读器、适用于物理访问受限用户的屏幕键盘或用于听力受限用户的讲述人。MSAA还可用于自动化测试工具和基于计算机的培训应用程序。—引自维基百科

参考博客列表

  1. AutoHotkey MACC/acc.ahk简要使用引导

配置过程

  1. 下载github的代码 accV2下载地址
    在这里插入图片描述
  2. 解压缩得到下面的
    在这里插入图片描述
  3. 将AccV2.ahk 复制到和自己的脚本同个文件夹下.

也有介绍说把这个库直接放在ahk软件的库里面的. 我暂时没有采用这种方法.

在这里插入图片描述
5. 在自己脚本的开头引入上面的脚本,这样就可以用acc的函数了. 函数介绍看下面,或者打开 accV2.ahk脚本,在开头有英文介绍.
在这里插入图片描述

资源

函数列表

;----------------------------------------------------------------------------------------------------------------------
; Acc.ahk
;----------------------------------------------------------------------------------------------------------------------
; Authors   (dd/mm/yyyy):
;   Sean    ()
;   jethrow (19/02/2012)
;   Sancarn (26/11/2017,18/01/2019,10/05/2019)
;----------------------------------------------------------------------------------------------------------------------
; CHANGE LOG:
;----------------------------------------------------------------------------------------------------------------------
;19/02/2012:
;     Modified ComObjEnwrap params from (9,pacc) --> (9,pacc,1)
;     Changed ComObjUnwrap to ComObjValue in order to avoid AddRef (thanks fincs)
;     Added Acc_GetRoleText & Acc_GetStateText
;     Added additional functions - commented below
;     Removed original Acc_Children function
;26/11/2017:
;     Added Enumerations as Objects
;     Added IAccessible walking functionality e.g.
;         acc_childrenFilter(oAcc, ACC_FILTERS.byDescription, "Amazing button")
;         
;         acc_childrenFilter(oAcc, Func("myAwesomeFunction"), true)
;         myAwesomeFunction(oAcc,val){
;             return val
;         }
;     Added Acc_ChildProxy to Acc_Children
;18/01/2019:
;     Documentation Update
;10/05/2019:
;     Error Checking to ACC_ChildProxy
;----------------------------------------------------------------------------------------------------------------------
;ACC INTELLISENSE PACK:
;----------------------------------------------------------------------------------------------------------------------
;IAcc Member Properties: [accChild,accChildCount,accDefaultAction,accDescription,accFocus,accHelp,accHelpTopic,accKeyboardShortcut,accName,accParent,accRole,accSelection,accState,accValue]
;Member Methods:         [accDoDefaultAction,accHitTest,accLocation,accNavigate,accSelect]
;Global Constants:       [ACC_NAVDIR,ACC_SELECTIONFLAG,ACC_EVENT,VT_CONSTANTS,ACC_FILTERS,ACC_OBJID,ACC_STATE,ACC_ROLE]
;Global Methods:         [Acc_ObjectFromEvent,Acc_ObjectFromPoint,Acc_ObjectFromWindow,Acc_WindowFromObject,Acc_SetWinEventHook,Acc_UnhookWinEvent,Acc_Location,Acc_Parent,Acc_Child,Acc_Children,Acc_Get,acc_childrenFilter,acc_getRootElement]
;
;----------------------------------------------------------------------------------------------------------------------
; DOCUMENTATION:
;----------------------------------------------------------------------------------------------------------------------
;IAcc Member Properties:
;  accChild                Read-only        An IDispatch interface for the specified child, if one exists. All objects must support this property. See get_accChild.
;  accChildCount           Read-only        The number of children that belong to this object. All objects must support this property. See get_accChildCount.
;  accDefaultAction        Read-only        A string that describes the object's default action. Not all objects have a default action. See get_accDefaultAction.
;  accDescription          Read-only        Note  The accDescription property is not supported in the transition to UI Automation. Microsoft Active Accessibility servers and applications should not use it. A string that describes the visual appearance of the specified object. Not all objects have a description.
;  accFocus                Read-only        The object that has the keyboard focus. All objects that receive the keyboard focus must support this property. See get_accFocus.
;  accHelp                 Read-only        A help string. Not all objects support this property. See get_accHelp.
;  accHelpTopic            Read-only        Note  The accHelpTopic property is deprecated and should not be used.The full path of the help file associated with the specified object and the identifier of the appropriate topic within that file. Not all objects support this property.
;  accKeyboardShortcut     Read-only        The object's shortcut key or access key, also known as the mnemonic. All objects that have a shortcut key or an access key support this property. See get_accKeyboardShortcut.
;  accName                 Read-only        The name of the object. All objects support this property. See get_accName.
;  accParent               Read-only        The IDispatch interface of the object's parent. All objects support this property. See get_accParent.
;  accRole                 Read-only        Information that describes the role of the specified object. All objects support this property. See get_accRole.
;  accSelection            Read-only        The selected children of this object. All objects that support selection must support this property. See get_accSelection.
;  accState                Read-only        The current state of the object. All objects support this property. See get_accState.
;  accValue                Read/write       The value of the object. Not all objects have a value. See get_accValue, put_accValue.
;Member Methods:
;  accDoDefaultAction                       Performs the specified object's default action. Not all objects have a default action.
;  accHitTest                               Retrieves the child element or child object at a given point on the screen. All visual objects support this method.
;  accLocation                              Retrieves the specified object's current screen location. All visual objects support this method. 
;  accNavigate                              Note  The accNavigate method is deprecated and should not be used. Clients should use other methods and properties such as AccessibleChildren, get_accChild, get_accParent, and IEnumVARIANT. Traverses to another user interface element within a container and retrieves the object. All visual objects support this method.
;  accSelect                                Modifies the selection or moves the keyboard focus of the specified object. All objects that support selection or receive the keyboard focus must support this method.
;Global Constants:
;  ACC_NAVDIR                               Object containing different navigation direction flags.
;  ACC_SELECTIONFLAG                        Object containing different accSelect() Flags.
;  ACC_EVENT                                Object containing different windows events which can be used with Acc_ObjectFromEvent.
;  VT_CONSTANTS                             Object containing different COM VTable constants.
;  ACC_FILTERS                              Object containing filter functions to be used with acc_childrenFilter.
;  ACC_OBJID                                Object containing different object names and ids.
;  ACC_STATE                                Object containing different state names and ids.
;  ACC_ROLE                                 Object containing different role names and ids.
;Global Methods:
;  Acc_ObjectFromEvent(ByRef _idChild_, hWnd, idObject, idChild)                                    - Used to get Acc object from Event
;  Acc_ObjectFromPoint(ByRef _idChild_ = "", x = "", y = "")                                        - Used to get Acc object from X,Y Point
;  Acc_ObjectFromWindow(hWnd, idObject = -4)                                                        - Used to get Acc object from hWND
;  Acc_WindowFromObject(pacc)                                                                       - Used to get hWND from ACC object
;  Acc_SetWinEventHook(eventMin, eventMax, pCallback)                                               - Listen for Windows events. Call callback with Acc object param.
;  Acc_UnhookWinEvent(hHook)                                                                        - Stop listening to existing event hook.
;  Acc_Location(Acc, ChildId=0)                                                                     - Get the location of an IAccessible object
;  Acc_Parent(Acc)                                                                                  - Get the parent object of an element
;  Acc_Child(Acc, ChildId=0)                                                                        - Get a child of the object with a specified id.
;  Acc_Children(Acc)                                                                                - Get the children of an IAccessible object (as an array)
;  Acc_Get(Cmd, ChildPath="", ChildID=0, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="")  - Get an accessible object
;  acc_childrenFilter(oAcc, fCondition, value=0, returnOne=false, obj=0)                            - Filter children by some defined condition
;  acc_getRootElement()                                                                             - Returns the Acc Object for the Desktop (Root of all Acc tree elements)
;DEPRECATED AND INTERNAL METHODS:
;  Acc_Init()                                                                                       - DO NOT CALL!
;  Acc_Query(Acc)                                                                                   - DO NOT CALL! Query IAccessible interface from object
;  Acc_Error(p="")                                                                                  - DO NOT CALL! Error information
;  Acc_GetRoleText(nRole)                                                                           - [DEPRECATED. USE ACC_ROLE OBJECT   ] Get's ACC Role as Text.
;  Acc_GetStateText(nState)                                                                         - [DEPRECATED. USE ACC_STATE OBJECT  ] Get's ACC State as Text.
;  Acc_Role(Acc, ChildId=0)                                                                         - [DEPRECATED. USE ACC_ROLE OBJECT   ]
;  Acc_State(Acc, ChildId=0)                                                                        - [DEPRECATED. USE ACC_STATE OBJECT  ]
;  Acc_ChildrenByRole(Acc, Role)                                                                    - [DEPRECATED. USE acc_childrenFilter] Get all children of the specified role.
;  acc_childrenByName(oAccessible, name,returnOne=false)                                            - [DEPRECATED. USE acc_childrenFilter]Filter children by name, if returnOne then only 1 child is returned
;
;----------------------------------------------------------------------------------------------------------------------
;Further descriptions:
;----------------------------------------------------------------------------------------------------------------------
;acc_childrenFilter
;  Filters the children in an acc object and calls the function defined by the 2nd parameter with Acc object and the 3rd param.
;  If the function returns true, the child is included in the filter.
;Example:
;	The following function will include children based on the 3rd parameter:
;       acc_childrenFilter(oAcc, Func("myAwesomeFunction"), true) ;Returns all children
;		acc_childrenFilter(oAcc, Func("myAwesomeFunction"), true) ;Returns no  children
;       myAwesomeFunction(oAcc,val){
;           return val
;       }
;
;ACC_FILTERS
;  These are commonly used in conjunction with `acc_childrenFilter`:
;Example:
;  acc_childrenFilter(oAcc, ACC_FILTERS.byDescription, "Amazing button")
;List of helper methods:
;  ACC_FILTERS.byDefaultAction(oAcc,action) - Filter children by a specific default action
;  ACC_FILTERS.byDescription(oAcc,desc)     - Filter children by a specific description
;  ACC_FILTERS.byValue(oAcc, value)         - Filter children by a specific value
;  ACC_FILTERS.byHelp(oAcc, hlpTxt)         - Filter children by a specific help text
;  ACC_FILTERS.byState(oAcc, state)         - Filter children by a specific state
;  ACC_FILTERS.byRole(oAcc, role)           - Filter children by a specific role
;  ACC_FILTERS.byName(oAcc, name)           - Filter children by a specific name
;  ACC_FILTERS.byRegex(oAcc, regex)         - Filter children by regex matching against string: %accName%;%accHelp%;%accValue%;%accDescription%;%accDefaultAction%
;----------------------------------------------------------------------------------------------------------------------
Spy4Win v0.20b =================================== Spy for Window(探测更多的窗口信息) ● 软件简介:   Spy4Win(Spy for Window)是一个类似MS Spy++的辅助工具,主要功能是探测和获取窗口的更多信息(窗口基本信息,窗口的样式描述以及动态改变窗口样式,识别控件来源, 窗口类的相关信息,关系窗口的获取(父窗口/子窗口等),窗口内容的读取,窗口消息截获,可视窗口截图等)。提供了多种方法查找窗口(拖拽鼠标/枚举窗口(EnumWindow)/查找窗口(FindWindow)/直接指定窗口句柄/用热键获取当前鼠标下窗口等);可以从可执行文件中提取窗体可重用单元并生成Delphi和C++Builder支持的单元文件;克隆其他程序中的窗体菜单或系统菜单并应用到Delphi和C++Builder中;IE页面分析功能包括读取IE页面元素,缩放页面,高亮页面中的关键字,提取所有链接/图片链接/Flash链接,运行JavaScript和VBScript脚本等;程序代码生成可直接生成查找窗口和读取/设置窗口样式的代码以及窗口样式描述的参考,目前支持C++/Delphi/VB;屏幕颜色拾取获取屏幕任何一点的颜色并可将其储存起来,一组支持6个颜色,还兼有放大镜功能;进程管理包括当前进程/模块/线程查看;软件界面可根据用户的爱好自定义主题色彩,新版本中提供了对插件的支持,可以通过编写Dll来扩充软件功能。 ● 程序制作:   by ccrun(老妖),用C++Builder 6.0编写,未使用第三方控件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值