autoHotkey advanced --- simple configuration for accessing window object acc Library

autoHotkey advanced - simple configuration for accessing window object acc Library

introduction

Accessible (ACC) library is a third-party code library of ahk This library realizes the basic operation functions of some windows by accessing the underlying api function of Microsoft Library (Microsoft Active Accessibility (MSAA)) It can also be seen from the name that it mainly allows us to access some objects of the window For example, information used to monitor window \ control \ gui elements According to this information, do some special operations, or operate the state of these objects For example, detect the position of the button and set the automatic click

Microsoft Active Accessibility (MSAA) is an application programming interface (API) for user interface accessibility. MSAA was introduced in 1997 as a platform add-on to Microsoft Windows 95. MSAA is designed to help assistive technology (AT) products interact with standard and custom user interface (UI) elements of applications (or operating systems), as well as access, identify and operate UI elements of applications. AT products are used in conjunction with MSAA enabled applications to provide better access for individuals with physical or cognitive difficulties, disabilities or disabilities. Some examples of AT products include screen readers for vision restricted users, screen keyboards for physical access restricted users, or narrators for hearing restricted users. MSAA can also be used in automated testing tools and computer-based training applications From Wikipedia

Reference blog list

  1. AutoHotkey MACC/acc.ahk brief usage guide

Configuration process

  1. Download the code of github accV2 download address
  2. Decompress to get the following
  3. Connect accv2 Copy AHK to the same folder as your script
  4. Introduce the above script at the beginning of your script, so you can use acc functions See the function introduction below, or open accv2 AHK script is introduced in English at the beginning

resources

Function list

;----------------------------------------------------------------------------------------------------------------------
; 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%
;----------------------------------------------------------------------------------------------------------------------

Keywords: autohotkey

Added by raimis100 on Tue, 22 Feb 2022 18:14:28 +0200