using Accessibility;
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Vanara.PInvoke
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static partial class Oleacc
{
// Input to DISPID_ACC_NAVIGATE
private const int NAVDIR_DOWN = 0x00000002;
private const int NAVDIR_FIRSTCHILD = 0x00000007;
private const int NAVDIR_LASTCHILD = 0x00000008;
private const int NAVDIR_LEFT = 0x00000003;
private const int NAVDIR_MAX = 0x00000009;
private const int NAVDIR_MIN = 0x00000000;
private const int NAVDIR_NEXT = 0x00000005;
private const int NAVDIR_PREVIOUS = 0x00000006;
private const int NAVDIR_RIGHT = 0x00000004;
private const int NAVDIR_UP = 0x00000001;
// Input to DISPID_ACC_SELECT
private const int SELFLAG_ADDSELECTION = 0x00000008;
private const int SELFLAG_EXTENDSELECTION = 0x00000004;
private const int SELFLAG_NONE = 0x00000000;
private const int SELFLAG_REMOVESELECTION = 0x00000010;
private const int SELFLAG_TAKEFOCUS = 0x00000001;
private const int SELFLAG_TAKESELECTION = 0x00000002;
private const int SELFLAG_VALID = 0x0000001F;
public enum AccessibilityRole : uint
{
ROLE_SYSTEM_TITLEBAR = 0x00000001,
ROLE_SYSTEM_MENUBAR = 0x00000002,
ROLE_SYSTEM_SCROLLBAR = 0x00000003,
ROLE_SYSTEM_GRIP = 0x00000004,
ROLE_SYSTEM_SOUND = 0x00000005,
ROLE_SYSTEM_CURSOR = 0x00000006,
ROLE_SYSTEM_CARET = 0x00000007,
ROLE_SYSTEM_ALERT = 0x00000008,
ROLE_SYSTEM_WINDOW = 0x00000009,
ROLE_SYSTEM_CLIENT = 0x0000000A,
ROLE_SYSTEM_MENUPOPUP = 0x0000000B,
ROLE_SYSTEM_MENUITEM = 0x0000000C,
ROLE_SYSTEM_TOOLTIP = 0x0000000D,
ROLE_SYSTEM_APPLICATION = 0x0000000E,
ROLE_SYSTEM_DOCUMENT = 0x0000000F,
ROLE_SYSTEM_PANE = 0x00000010,
ROLE_SYSTEM_CHART = 0x00000011,
ROLE_SYSTEM_DIALOG = 0x00000012,
ROLE_SYSTEM_BORDER = 0x00000013,
ROLE_SYSTEM_GROUPING = 0x00000014,
ROLE_SYSTEM_SEPARATOR = 0x00000015,
ROLE_SYSTEM_TOOLBAR = 0x00000016,
ROLE_SYSTEM_STATUSBAR = 0x00000017,
ROLE_SYSTEM_TABLE = 0x00000018,
ROLE_SYSTEM_COLUMNHEADER = 0x00000019,
ROLE_SYSTEM_ROWHEADER = 0x0000001A,
ROLE_SYSTEM_COLUMN = 0x0000001B,
ROLE_SYSTEM_ROW = 0x0000001C,
ROLE_SYSTEM_CELL = 0x0000001D,
ROLE_SYSTEM_LINK = 0x0000001E,
ROLE_SYSTEM_HELPBALLOON = 0x0000001F,
ROLE_SYSTEM_CHARACTER = 0x00000020,
ROLE_SYSTEM_LIST = 0x00000021,
ROLE_SYSTEM_LISTITEM = 0x00000022,
ROLE_SYSTEM_OUTLINE = 0x00000023,
ROLE_SYSTEM_OUTLINEITEM = 0x00000024,
ROLE_SYSTEM_PAGETAB = 0x00000025,
ROLE_SYSTEM_PROPERTYPAGE = 0x00000026,
ROLE_SYSTEM_INDICATOR = 0x00000027,
ROLE_SYSTEM_GRAPHIC = 0x00000028,
ROLE_SYSTEM_STATICTEXT = 0x00000029,
ROLE_SYSTEM_TEXT = 0x0000002A, // Editable, selectable, etc.
ROLE_SYSTEM_PUSHBUTTON = 0x0000002B,
ROLE_SYSTEM_CHECKBUTTON = 0x0000002C,
ROLE_SYSTEM_RADIOBUTTON = 0x0000002D,
ROLE_SYSTEM_COMBOBOX = 0x0000002E,
ROLE_SYSTEM_DROPLIST = 0x0000002F,
ROLE_SYSTEM_PROGRESSBAR = 0x00000030,
ROLE_SYSTEM_DIAL = 0x00000031,
ROLE_SYSTEM_HOTKEYFIELD = 0x00000032,
ROLE_SYSTEM_SLIDER = 0x00000033,
ROLE_SYSTEM_SPINBUTTON = 0x00000034,
ROLE_SYSTEM_DIAGRAM = 0x00000035,
ROLE_SYSTEM_ANIMATION = 0x00000036,
ROLE_SYSTEM_EQUATION = 0x00000037,
ROLE_SYSTEM_BUTTONDROPDOWN = 0x00000038,
ROLE_SYSTEM_BUTTONMENU = 0x00000039,
ROLE_SYSTEM_BUTTONDROPDOWNGRID = 0x0000003A,
ROLE_SYSTEM_WHITESPACE = 0x0000003B,
ROLE_SYSTEM_PAGETABLIST = 0x0000003C,
ROLE_SYSTEM_CLOCK = 0x0000003D,
ROLE_SYSTEM_SPLITBUTTON = 0x0000003E,
ROLE_SYSTEM_IPADDRESS = 0x0000003F,
ROLE_SYSTEM_OUTLINEBUTTON = 0x00000040,
}
[Flags]
public enum AccessibilityState : uint
{
STATE_SYSTEM_NORMAL = 0x00000000,
STATE_SYSTEM_UNAVAILABLE = 0x00000001, // Disabled
STATE_SYSTEM_SELECTED = 0x00000002,
STATE_SYSTEM_FOCUSED = 0x00000004,
STATE_SYSTEM_PRESSED = 0x00000008,
STATE_SYSTEM_CHECKED = 0x00000010,
STATE_SYSTEM_MIXED = 0x00000020, // 3-state checkbox or toolbar button
STATE_SYSTEM_INDETERMINATE = STATE_SYSTEM_MIXED,
STATE_SYSTEM_READONLY = 0x00000040,
STATE_SYSTEM_HOTTRACKED = 0x00000080,
STATE_SYSTEM_DEFAULT = 0x00000100,
STATE_SYSTEM_EXPANDED = 0x00000200,
STATE_SYSTEM_COLLAPSED = 0x00000400,
STATE_SYSTEM_BUSY = 0x00000800,
STATE_SYSTEM_FLOATING = 0x00001000, // Children "owned" not "contained" by parent
STATE_SYSTEM_MARQUEED = 0x00002000,
STATE_SYSTEM_ANIMATED = 0x00004000,
STATE_SYSTEM_INVISIBLE = 0x00008000,
STATE_SYSTEM_OFFSCREEN = 0x00010000,
STATE_SYSTEM_SIZEABLE = 0x00020000,
STATE_SYSTEM_MOVEABLE = 0x00040000,
STATE_SYSTEM_SELFVOICING = 0x00080000,
STATE_SYSTEM_FOCUSABLE = 0x00100000,
STATE_SYSTEM_SELECTABLE = 0x00200000,
STATE_SYSTEM_LINKED = 0x00400000,
STATE_SYSTEM_TRAVERSED = 0x00800000,
STATE_SYSTEM_MULTISELECTABLE = 0x01000000, // Supports multiple selection
STATE_SYSTEM_EXTSELECTABLE = 0x02000000, // Supports extended selection
STATE_SYSTEM_ALERT_LOW = 0x04000000, // This information is of low priority
STATE_SYSTEM_ALERT_MEDIUM = 0x08000000, // This information is of medium priority
STATE_SYSTEM_ALERT_HIGH = 0x10000000, // This information is of high priority
STATE_SYSTEM_PROTECTED = 0x20000000,
STATE_SYSTEM_VALID = 0x7FFFFFFF,
STATE_SYSTEM_HASPOPUP = 0x40000000,
}
/// Accessibility running utility states.
[PInvokeData("oleacc.h", MSDNShortId = "0AEDDE0D-D8E2-4C9E-AB2B-2FF0ACC3695D")]
[Flags]
public enum ANRUS
{
/// The AT application is providing an on-screen keyboard.
ANRUS_ON_SCREEN_KEYBOARD_ACTIVE = 0x0000001,
/// The AT application is consuming redirected touch input.
ANRUS_TOUCH_MODIFICATION_ACTIVE = 0x0000002,
///
/// The AT application is relying on audio (such as text-to-speech) to convey essential information to the user and should remain
/// audible over other system sounds.
///
ANRUS_PRIORITY_AUDIO_ACTIVE = 0x0000004,
///
/// The AT application is relying on audio (such as text-to-speech) to convey essential information to the user but should not
/// change relative to other system sounds.
///
ANRUS_PRIORITY_AUDIO_ACTIVE_NODUCK = 0x0000008,
/// Undocumented.
ANRUS_PRIORITY_AUDIO_DYNAMIC_DUCK = 0x0000010,
}
/// Retrieves the child ID or IDispatch of each child within an accessible container object.
///
/// Type: IAccessible*
/// Pointer to the container object's IAccessible interface.
///
///
/// Type: LONG
///
/// Specifies the zero-based index of the first child that is retrieved. This parameter is an index, not a child ID, and it is
/// usually is set to zero (0).
///
///
///
/// Type: LONG
/// Specifies the number of children to retrieve. To retrieve the current number of children, an application calls IAccessible::get_accChildCount.
///
///
/// Type: VARIANT*
///
/// Pointer to an array of VARIANT structures that receives information about the container's children. If the vt member of an
/// array element is VT_I4, then the lVal member for that element is the child ID. If the vt member of an array element
/// is VT_DISPATCH, then the pdispVal member for that element is the address of the child object's IDispatch interface.
///
///
///
/// Type: LONG*
///
/// Address of a variable that receives the number of elements in the rgvarChildren array that is populated by the
/// AccessibleChildren function. This value is the same as that of the cChildren parameter; however, if you request more
/// children than exist, this value will be less than that of cChildren.
///
///
///
/// Type: STDAPI
/// If successful, returns S_OK.
/// If not successful, returns one of the following or another standard COM error code.
///
///
/// Return code
/// Description
///
/// -
/// E_INVALIDARG
/// An argument is not valid.
///
/// -
/// S_FALSE
/// The function succeeded, but there are fewer elements in the rgvarChildren array than there are children requested in cChildren.
///
///
///
///
///
/// To retrieve information about all of the children in a container, the iChildStart parameter must be zero (0), and cChildren must
/// be the value returned by IAccessible::get_accChildCount.
///
///
/// When calling this function to obtain information about the children of a user interface element, it is recommended that clients
/// obtain information about all of the children. For example, iChildStart must be zero (0), and cChildren must be the value returned
/// by IAccessible::get_accChildCount.
///
///
/// If a child ID is returned for an element, then the container must provide information about the child element. To obtain
/// information about the element, clients use the container's IAccessible interface pointer and specify the obtained child ID in
/// calls to the IAccessible properties.
///
///
/// Clients must call the IUnknown::Release method for any IDispatch interfaces retrieved by this function, and free the array when
/// it is no longer required.
///
/// Examples
///
/// The following example function displays a view of the element tree below the element that is passed in. The name and role of each
/// element are printed by user-defined functions that are not shown here.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-accessiblechildren HRESULT AccessibleChildren( IAccessible
// *paccContainer, LONG iChildStart, LONG cChildren, VARIANT *rgvarChildren, LONG *pcObtained );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "dc9262d8-f57f-41f8-8945-d95f38d197e9")]
public static extern HRESULT AccessibleChildren(IAccessible paccContainer, int iChildStart, int cChildren, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 2)] object[] rgvarChildren, out int pcObtained);
///
/// Retrieves the address of the IAccessible interface for the object that generated the event that is currently being processed by
/// the client's event hook function.
///
///
/// Type: HWND
///
/// Specifies the window handle of the window that generated the event. This value must be the window handle that is sent to the
/// event hook function.
///
///
///
/// Type: DWORD
///
/// Specifies the object ID of the object that generated the event. This value must be the object ID that is sent to the event hook function.
///
///
///
/// Type: DWORD
///
/// Specifies whether the event was triggered by an object or one of its child elements. If the object triggered the event, dwChildID
/// is CHILDID_SELF. If a child element triggered the event, dwChildID is the element's child ID. This value must be the child ID
/// that is sent to the event hook function.
///
///
///
/// Type: IAccessible**
///
/// Address of a pointer variable that receives the address of an IAccessible interface. The interface is either for the object that
/// generated the event, or for the parent of the element that generated the event.
///
///
///
/// Type: VARIANT*
/// Address of a VARIANT structure that specifies the child ID that can be used to access information about the UI element.
///
///
/// Type: STDAPI
/// If successful, returns S_OK.
/// If not successful, returns one of the following or another standard COM error code.
///
///
/// Return code
/// Description
///
/// -
/// E_INVALIDARG
/// An argument is not valid.
///
///
///
///
///
/// Clients call this function within an event hook function to obtain an IAccessible interface pointer to either the object that
/// generated the event or to the parent of the element that generated the event. The parameters sent to the WinEventProc callback
/// function must be used for this function's hwnd, dwObjectID, and dwChildID parameters.
///
///
/// This function retrieves the lowest-level accessible object in the object hierarchy that is associated with an event. If the
/// element that generated the event is not an accessible object (that is, does not support IAccessible), then the function retrieves
/// the IAccessible interface of the parent object. The parent object must provide information about the child element through
/// the IAccessible interface.
///
///
/// As with other IAccessible methods and functions, clients might receive errors for IAccessible interface pointers because
/// of a user action. For more information, see Receiving Errors for IAccessible Interface Pointers.
///
///
/// This function fails if called in response to EVENT_OBJECT_CREATE because the object is not fully initialized. Similarly, clients
/// should not call this in response to EVENT_OBJECT_DESTROY because the object is no longer available and cannot respond. Clients
/// watch for EVENT_OBJECT_SHOW and EVENT_OBJECT_HIDE events rather than for EVENT_OBJECT_CREATE and EVENT_OBJECT_DESTROY.
///
/// Examples
/// The following example code shows this method being called in a WinEventProc event handler.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-accessibleobjectfromevent HRESULT AccessibleObjectFromEvent(
// HWND hwnd, DWORD dwId, DWORD dwChildId, IAccessible **ppacc, VARIANT *pvarChild );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "d453c163-3918-4a1c-9636-16816227a295")]
public static extern HRESULT AccessibleObjectFromEvent(HWND hwnd, uint dwId, uint dwChildId, out IAccessible ppacc, [MarshalAs(UnmanagedType.Struct)] out object pvarChild);
///
/// Retrieves the address of the IAccessible interface pointer for the object displayed at a specified point on the screen.
///
/// Specifies, in physical screen coordinates, the point that is examined.
/// Address of a pointer variable that receives the address of the object's IAccessible interface.
///
/// Address of a VARIANT structure that specifies whether the IAccessible interface pointer that is returned in ppacc belongs to the
/// object displayed at the specified point, or to the parent of the element at the specified point. The vt member of the
/// VARIANT is always VT_I4. If the lVal member is CHILDID_SELF, then the IAccessible interface pointer at ppacc
/// belongs to the object at the point. If the lVal member is not CHILDID_SELF, ppacc is the address of the IAccessible
/// interface of the child element's parent object. Clients must call VariantClear on the retrieved VARIANT parameter when
/// finished using it.
///
///
/// If successful, returns S_OK.
/// If not successful, returns one of the following or another standard COM error code.
///
///
/// Return code
/// Description
///
/// -
/// E_INVALIDARG
/// An argument is not valid.
///
///
///
///
///
/// This function retrieves the lowest-level accessible object in the object hierarchy at a given point. If the element at the point
/// is not an accessible object (that is, does not support IAccessible), then the function retrieves the IAccessible interface
/// of the parent object. The parent object must provide information about the child element through the IAccessible
/// interface. Call IAccessible::accHitTest to identify the child element at the specified screen coordinates.
///
///
/// As with other IAccessible methods and functions, clients might receive errors for IAccessible interface pointers because
/// of a user action. For more information, see Receiving Errors for IAccessible Interface Pointers.
///
/// Client Example
///
/// The following example function selects the item at a specified point on the screen. It is assumed that a single selection is wanted.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-accessibleobjectfrompoint HRESULT AccessibleObjectFromPoint(
// POINT ptScreen, IAccessible **ppacc, VARIANT *pvarChild );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "b781b74f-5c36-4a65-a9b1-ecf7f8e5b531")]
public static extern HRESULT AccessibleObjectFromPoint(POINT ptScreen, out IAccessible ppacc, [MarshalAs(UnmanagedType.Struct)] out object pvarChild);
/// Retrieves the address of the specified interface for the object associated with the specified window.
///
/// Type: HWND
///
/// Specifies the handle of a window for which an object is to be retrieved. To retrieve an interface pointer to the cursor or caret
/// object, specify NULL and use the appropriate object ID in dwObjectID.
///
///
///
/// Type: DWORD
///
/// Specifies the object ID. This value is one of the standard object identifier constants or a custom object ID such as
/// OBJID_NATIVEOM, which is the object ID for the Office native object model. For more information about OBJID_NATIVEOM, see
/// the Remarks section in this topic.
///
///
///
/// Type: REFIID
///
/// Specifies the reference identifier of the requested interface. This value is either IID_IAccessible or IID_IDispatch, but it can
/// also be IID_IUnknown, or the IID of any interface that the object is expected to support.
///
///
///
/// Type: void**
/// Address of a pointer variable that receives the address of the specified interface.
///
///
/// Type: STDAPI
/// If successful, returns S_OK.
/// If not successful, returns one of the following or another standard COM error code.
///
///
/// Return code
/// Description
///
/// -
/// E_INVALIDARG
/// An argument is not valid.
///
/// -
/// E_NOINTERFACE
/// The requested interface is not supported.
///
///
///
///
///
/// Clients call this function to retrieve the address of an object's IAccessible, IDispatch, IEnumVARIANT, IUnknown, or other
/// supported interface pointer.
///
///
/// As with other IAccessible methods and functions, clients might receive errors for IAccessible interface pointers because
/// of a user action. For more information, see Receiving Errors for IAccessible Interface Pointers.
///
///
/// Clients use this function to obtain access to the Microsoft Office 2000 native object model. The native object model provides
/// clients with accessibility information about an Office application's document or client area that is not exposed by Microsoft
/// Active Accessibility.
///
///
/// To obtain an IDispatch interface pointer to a class supported by the native object model, specify OBJID_NATIVEOM in dwObjectID.
/// When using this object identifier, the hwnd parameter must match the following window class types.
///
///
///
/// Office application
/// Window class
/// IDispatch pointer to
///
/// -
/// Word
/// _WwG
/// Window
///
/// -
/// Excel
/// EXCEL7
/// Window
///
/// -
/// PowerPoint
/// paneClassDC
/// DocumentWindow
///
/// -
/// Command Bars
/// MsoCommandBar
/// CommandBar
///
///
///
/// Note that the above window classes correspond to the innermost document window or pane window. For more information about the
/// Office object model, see the Microsoft Office 2000/Visual Basic Programmer's Guide.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-accessibleobjectfromwindow HRESULT
// AccessibleObjectFromWindow( HWND hwnd, DWORD dwId, REFIID riid, void **ppvObject );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "297ac50f-2a58-477b-ba57-5d1416c191b3")]
public static extern HRESULT AccessibleObjectFromWindow(HWND hwnd, uint dwId, in Guid riid, [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 2)] out object ppvObject);
///
/// Allows an assistive technology (AT) application to notify the system that it is interacting with UI through a Windows Automation
/// API (such as Microsoft UI Automation) as a result of a touch gesture from the user. This allows the assistive technology to
/// notify the target application and the system that the user is interacting with touch.
///
/// A window that belongs to the AT process that is calling AccNotifyTouchInteraction.
/// The nearest window of the automation element that the AT is targeting.
/// The center point of the automation element (or a point in the bounding rectangle of the element).
///
/// If successful, returns S_OK.
/// If not successful, returns a standard COM error code.
///
///
///
/// This function requires the calling process to have UIAccess or higher privileges. If the caller does not have the required
/// privileges, the call to AccNotifyTouchInteraction fails and returns E_ACCESSDENIED. For more information, see
/// Security Considerations for Assistive Technologies and /MANIFESTUAC (Embeds UAC information in manifest).
///
///
/// When an AT is consuming touch data (such as when using the RegisterPointerInputTarget function), the shell and applications that
/// the AT interacts with through the Windows Automation API are not aware that the user is interacting through touch. For the system
/// to expose touch-related functionality to the user, the AT must use AccNotifyTouchInteraction to notify the system that it
/// is performing the interaction in response to user touch input.
///
/// Examples
/// This code example shows how to call the AccNotifyTouchInteraction function.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-accnotifytouchinteraction HRESULT AccNotifyTouchInteraction(
// HWND hwndApp, HWND hwndTarget, POINT ptTarget );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "CB533913-95A7-45D5-B0D3-E931E4F73B2E")]
public static extern HRESULT AccNotifyTouchInteraction(HWND hwndApp, HWND hwndTarget, POINT ptTarget);
///
/// Sets system values that indicate whether an assistive technology (AT) application's current state affects functionality that is
/// typically provided by the system.
///
///
/// Type: HWND
/// The handle of the AT application window. This parameter must not be NULL.
///
///
/// Type: DWORD
/// A mask that indicates the system values being set. It can be a combination of the following values:
/// ANRUS_ON_SCREEN_KEYBOARD_ACTIVE
/// ANRUS_TOUCH_MODIFICATION_ACTIVE
/// ANRUS_PRIORITY_AUDIO_ACTIVE
/// ANRUS_PRIORITY_AUDIO_ACTIVE_NODUCK
///
///
/// Type: DWORD
///
/// The new settings for the system values indicated by dwUtilityStateMask. This parameter can be zero to reset the system values, or
/// a combination of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// ANRUS_ON_SCREEN_KEYBOARD_ACTIVE 0x0000001
/// The AT application is providing an on-screen keyboard.
///
/// -
/// ANRUS_TOUCH_MODIFICATION_ACTIVE 0x0000002
/// The AT application is consuming redirected touch input.
///
/// -
/// ANRUS_PRIORITY_AUDIO_ACTIVE 0x0000004
///
/// The AT application is relying on audio (such as text-to-speech) to convey essential information to the user and should remain
/// audible over other system sounds.
///
///
/// -
/// ANRUS_PRIORITY_AUDIO_ACTIVE_NODUCK 0x0000008
///
/// The AT application is relying on audio (such as text-to-speech) to convey essential information to the user but should not change
/// relative to other system sounds.
///
///
///
///
///
/// Type: STDAPI
/// If successful, returns S_OK.
/// If not successful, returns a standard COM error code.
///
///
/// Before it exits, an AT application should reset any system values that it previously set.
///
/// This function requires the calling process to have UIAccess or higher privileges. If the caller does not have the required
/// privileges, the call to AccSetRunningUtilityState fails and returns E_ACCESSDENIED. For more information, see
/// Security Considerations for Assistive Technologies and /MANIFESTUAC (Embeds UAC information in manifest).
///
/// Examples
/// This code example shows how to call the AccSetRunningUtilityState function.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-accsetrunningutilitystate HRESULT AccSetRunningUtilityState(
// HWND hwndApp, DWORD dwUtilityStateMask, DWORD dwUtilityState );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "0AEDDE0D-D8E2-4C9E-AB2B-2FF0ACC3695D")]
public static extern HRESULT AccSetRunningUtilityState(HWND hwndApp, ANRUS dwUtilityStateMask, ANRUS dwUtilityState);
///
/// Creates an accessible object with the methods and properties of the specified type of system-provided user interface element.
///
///
/// Type: HWND
/// Window handle of the system-provided user interface element (a control) for which an accessible object is created.
///
///
/// Type: LONG
/// Object ID. This value is usually OBJID_CLIENT, but it may be another object identifier.
///
///
/// Type: REFIID
///
/// Reference identifier of the requested interface. This value is one of the following: IID_IAccessible, IID_IDispatch,
/// IID_IEnumVARIANT, or IID_IUnknown.
///
///
///
/// Type: void**
/// Address of a pointer variable that receives the address of the specified interface.
///
///
/// Type: STDAPI
/// If successful, returns S_OK.
/// If not successful, returns a standard COM error code.
///
///
///
/// Server applications call this function when they contain a custom UI object that is similar to a system-provided object. Server
/// developers can call CreateStdAccessibleObject to override the IAccessible methods and properties as required to match
/// their custom objects. Alternatively, server developers can use Dynamic Annotation to override specific properties without having
/// to use difficult subclassing techniques that CreateStdAccessibleObject requires. Server developers should still use
/// CreateStdAccessibleObject for structural changes, such as hiding a child element or creating a placeholder child element.
/// This approach saves server developers the work of fully implementing all of the IAccessible properties and methods.
///
///
/// This function is similar to CreateStdAccessibleProxy, except that CreateStdAccessibleProxy allows you to specify the class
/// name as a parameter whereas CreateStdAccessibleObject uses the class name associated with the hwnd parameter.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-createstdaccessibleobject HRESULT CreateStdAccessibleObject(
// HWND hwnd, LONG idObject, REFIID riid, void **ppvObject );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "50b6f391-98a4-4276-840f-028cc18e99ef")]
public static extern HRESULT CreateStdAccessibleObject(HWND hwnd, int idObject, in Guid riid, [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 2)] out object ppvObject);
///
/// Creates an accessible object that has the properties and methods of the specified class of system-provided user interface element.
///
///
/// Type: HWND
/// Window handle of the system-provided user interface element (a control) for which an accessible object is created.
///
///
/// Type: LPCTSTR
///
/// Pointer to a null-terminated string of the class name of a system-provided user interface element for which an accessible object
/// is created. The window class name is one of the common controls (defined in Comctl32.dll), predefined controls (defined in
/// User32.dll), or window elements.
///
///
///
/// Type: LONG
///
/// Object ID. This value is usually OBJID_CLIENT, which is one of the object identifier constants, but it may be another object identifier.
///
///
///
/// Type: REFIID
///
/// Reference identifier of the interface requested. This value is one of the following: IID_IAccessible, IID_IDispatch,
/// IID_IEnumVARIANT, or IID_IUnknown.
///
///
///
/// Type: void**
/// Address of a pointer variable that receives the address of the specified interface.
///
///
/// Type: STDAPI
/// If successful, returns S_OK.
/// If not successful, returns a standard COM error code.
///
///
///
/// Server applications call this function when they contain a custom control that is similar to a system-provided control. Server
/// applications can call CreateStdAccessibleProxy to override the IAccessible methods and properties as required to match
/// their custom controls. Alternatively, server developers can use Dynamic Annotation to override specific properties without having
/// to use difficult subclassing techniques that were required with CreateStdAccessibleProxy. Server developers should still
/// use CreateStdAccessibleProxy for structural changes, such as hiding a child element or creating a placeholder child
/// element. This approach saves server developers the work of fully implementing all of the IAccessible properties and methods.
///
///
/// This function is similar to CreateStdAccessibleObject, except that CreateStdAccessibleObject always uses the class name
/// associated with the hwnd whereas CreateStdAccessibleProxy allows you to specify the class name as a parameter.
///
///
/// Use CreateStdAccessibleProxy to create an accessible object for a user interface element that is superclassed. When a user
/// interface element is superclassed, an application creates a custom control with a window class name different from the predefined
/// control on which it is based. Because the class name associated with the hwnd parameter is the superclass window class name,
/// specify the base class name (the system class name on which the superclassed control is based) in pszClassName.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-createstdaccessibleproxya HRESULT CreateStdAccessibleProxyA(
// HWND hwnd, LPCSTR pClassName, LONG idObject, REFIID riid, void **ppvObject );
[DllImport(Lib.Oleacc, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("oleacc.h", MSDNShortId = "724b2a38-f7ca-4423-acd4-0871623d1201")]
public static extern HRESULT CreateStdAccessibleProxy(HWND hwnd, [MarshalAs(UnmanagedType.LPTStr)] string pClassName, int idObject, in Guid riid, [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 3)] out object ppvObject);
/// Retrieves the version number and build number of the Microsoft Active Accessibility file Oleacc.dll.
///
/// Type: DWORD*
///
/// Address of a DWORD that receives the version number. The major version number is placed in the high word, and the minor
/// version number is placed in the low word.
///
///
///
/// Type: DWORD*
///
/// Address of a DWORD that receives the build number. The major build number is placed in the high word, and the minor build
/// number is placed in the low word.
///
///
/// This function does not return a value.
///
/// This function provides an easy way to get the version and build numbers for Oleacc.dll. The GetFileVersionInfoSize,
/// GetFileVersionInfo, and VerQueryValue functions can be used to retrieve the same information.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-getoleaccversioninfo void GetOleaccVersionInfo( DWORD *pVer,
// DWORD *pBuild );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "96dcdb85-4f35-4274-ba57-2f565c3ebb5f")]
public static extern void GetOleaccVersionInfo(out uint pVer, out uint pBuild);
/// Retrieves a process handle from a window handle.
///
/// Type: HANDLE
/// If successful, returns the handle of the process that owns the window.
/// If not successful, returns NULL.
///
///
///
/// In previous versions of the operating system, a process could open another process (to access its memory, for example) using
/// OpenProcess. This function succeeds if the caller has appropriate privileges; usually the caller and target process must
/// be the same user.
///
///
/// On Windows Vista, however, OpenProcess fails in the scenario where the caller has UIAccess, and the target process is
/// elevated. In this case, the owner of the target process is in the Administrators group, but the calling process is running with
/// the restricted token, so does not have membership in this group, and is denied access to the elevated process. If the caller has
/// UIAccess, however, they can use a windows hook to inject code into the target process, and from within the target process, send a
/// handle back to the caller.
///
///
/// GetProcessHandleFromHwnd is a convenience function that uses this technique to obtain the handle of the process that owns
/// the specified HWND. Note that it only succeeds in cases where the caller and target process are running as the same user. The
/// returned handle has the following privileges: PROCESS_DUP_HANDLE | PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE |
/// SYNCHRONIZE. If other privileges are required, it may be necessary to implement the hooking technique explicitly instead of using
/// this function.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/WinAuto/getprocesshandlefromhwnd HANDLE WINAPI GetProcessHandleFromHwnd( _In_
// HWND hwnd );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("", MSDNShortId = "173579d2-c930-402c-81c7-761b063b5b51")]
public static extern HPROCESS GetProcessHandleFromHwnd(HWND hwnd);
/// Retrieves the localized string that describes the object's role for the specified role value.
///
/// Type: DWORD
/// One of the object role constants.
///
///
/// Type: LPTSTR
///
/// Address of a buffer that receives the role text string. If this parameter is NULL, the function returns the role string's
/// length, not including the null character.
///
///
///
/// Type: UINT
///
/// The size of the buffer that is pointed to by the lpszRole parameter. For ANSI strings, this value is measured in bytes; for
/// Unicode strings, it is measured in characters.
///
///
///
/// Type: UINT
///
/// If successful, and if lpszRole is non- NULL, the return value is the number of bytes (ANSI strings) or characters (Unicode
/// strings) copied into the buffer, not including the terminating null character. If lpszRole is NULL, the return value
/// represents the string's length, not including the null character.
///
///
/// If the string resource does not exist, or if the lpszRole parameter is not a valid pointer, the return value is zero (0). To get
/// extended error information, call GetLastError.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-getroletexta UINT GetRoleTextA( DWORD lRole, LPSTR lpszRole,
// UINT cchRoleMax );
[DllImport(Lib.Oleacc, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("oleacc.h", MSDNShortId = "58436001-92d7-4afa-af07-169c8bbda9ba")]
public static extern uint GetRoleText(AccessibilityRole lRole, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszRole, uint cchRoleMax);
///
/// Retrieves a localized string that describes an object's state for a single predefined state bit flag. Because state values are a
/// combination of one or more bit flags, clients call this function more than once to retrieve all state strings.
///
///
/// Type: DWORD
/// One of the object state constants.
///
///
/// Type: LPTSTR
///
/// Address of a buffer that receives the state text string. If this parameter is NULL, the function returns the state
/// string's length, not including the null character.
///
///
///
/// Type: UINT
///
/// The size of the buffer that is pointed to by the lpszStateBit parameter. For ANSI strings, this value is measured in bytes; for
/// Unicode strings, it is measured in characters.
///
///
///
/// Type: UINT
///
/// If successful, and if lpszStateBit is non- NULL, the return value is the number of bytes (ANSI strings) or characters
/// (Unicode strings) that are copied into the buffer, not including the null-terminated character. If lpszStateBit is NULL,
/// the return value represents the string's length, not including the null character.
///
///
/// If the string resource does not exist, or if the lpszStateBit parameter is not a valid pointer, the return value is zero (0). To
/// get extended error information, call GetLastError.
///
///
/// This function accepts only one state bit at a time, not a bitmask.
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-getstatetexta UINT GetStateTextA( DWORD lStateBit, LPSTR
// lpszState, UINT cchState );
[DllImport(Lib.Oleacc, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("oleacc.h", MSDNShortId = "2a136883-870e-48c3-b182-1cdc64768894")]
public static extern uint GetStateText(AccessibilityState lStateBit, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszState, uint cchState);
/// Returns a reference, similar to a handle, to the specified object. Servers return this reference when handling WM_GETOBJECT.
///
/// Type: REFIID
/// Reference identifier of the interface provided to the client. This parameter is IID_IAccessible.
///
///
/// Type: WPARAM
/// Value sent by the associated WM_GETOBJECT message in its wParam parameter.
///
///
/// Type: LPUNKNOWN
/// Address of the IAccessible interface to the object that corresponds to the WM_GETOBJECT message.
///
///
/// Type: LRESULT
/// If successful, returns a positive value that is a reference to the object.
/// If not successful, returns one of the values in the table that follows, or another standard COM error code.
///
///
/// Return code
/// Description
///
/// -
/// E_INVALIDARG
/// One or more arguments are not valid.
///
/// -
/// E_NOINTERFACE
/// The object specified in the pAcc parameter does not support the interface specified in the riid parameter.
///
/// -
/// E_OUTOFMEMORY
/// Insufficient memory to store the object reference.
///
/// -
/// E_UNEXPECTED
/// An unexpected error occurred.
///
///
///
///
///
/// Servers call this function only when handling the WM_GETOBJECT message. For an overview of how LresultFromObject is
/// related to WM_GETOBJECT, see How WM_GETOBJECT Works.
///
///
/// LresultFromObject increments the object's reference count. If you are not storing the interface pointer passed to the
/// function (that is, you create a new interface pointer for the object each time WM_GETOBJECT is received), call the object's
/// Release method to decrement the reference count back to one. Then the client calls Release and the object is destroyed.
/// For more information, see How to Handle WM_GETOBJECT.
///
///
/// Each time a server processes WM_GETOBJECT for a specific object, it calls LresultFromObject to obtain a new reference to
/// the object. Servers do not save the reference returned from LresultFromObject from one instance of processing
/// WM_GETOBJECT to use as the message's return value when processing subsequent WM_GETOBJECT messages for the same
/// object. This causes the client to receive an error.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-lresultfromobject LRESULT LresultFromObject( REFIID riid,
// WPARAM wParam, LPUNKNOWN punk );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "c219a4cd-7a8f-4942-8975-b3d823b6497f")]
public static extern IntPtr LresultFromObject(in Guid riid, IntPtr wParam, [In, MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 0)] object punk);
///
/// Retrieves a requested interface pointer for an accessible object based on a previously generated object reference.
///
/// This function is designed for internal use by Microsoft Active Accessibility and is documented for informational purposes only.
/// Neither clients nor servers should call this function.
///
///
///
/// Type: LRESULT
/// A 32-bit value returned by a previous successful call to the LresultFromObject function.
///
///
/// Type: REFIID
/// Reference identifier of the interface to be retrieved. This is IID_IAccessible.
///
///
/// Type: WPARAM
/// Value sent by the associated WM_GETOBJECT message in its wParam parameter.
///
///
/// Type: void**
/// Receives the address of the IAccessible interface on the object that corresponds to the WM_GETOBJECT message.
///
///
/// Type: STDAPI
/// If successful, returns S_OK.
/// If not successful, returns one of the following standard COM error codes.
///
///
/// Return code
/// Description
///
/// -
/// E_INVALIDARG
///
/// One or more arguments are not valid. This occurs when the lResult parameter specified is not a value obtained by a call to
/// LresultFromObject, or when lResult is a value used on a previous call to ObjectFromLresult.
///
///
/// -
/// E_NOINTERFACE
/// The object specified in the ppvObject parameter does not support the interface specified by the riid parameter.
///
/// -
/// E_OUTOFMEMORY
/// Insufficient memory to store the object reference.
///
/// -
/// E_UNEXPECTED
/// An unexpected error occurred.
///
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-objectfromlresult HRESULT ObjectFromLresult( LRESULT
// lResult, REFIID riid, WPARAM wParam, void **ppvObject );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "97e766fd-e142-40d1-aba7-408b45d33426")]
public static extern HRESULT ObjectFromLresult(IntPtr lResult, in Guid riid, IntPtr wParam, [MarshalAs(UnmanagedType.IUnknown, IidParameterIndex = 1)] out object ppvObject);
/// Retrieves the window handle that corresponds to a particular instance of an IAccessible interface.
///
/// Type: IAccessible*
/// Pointer to the IAccessible interface whose corresponding window handle will be retrieved. This parameter must not be NULL.
///
///
/// Type: HWND*
///
/// Address of a variable that receives a handle to the window containing the object specified in pacc. If this value is NULL
/// after the call, the object is not contained within a window; for example, the mouse pointer is not contained within a window.
///
///
///
/// Type: STDAPI
/// If successful, returns S_OK.
/// If not successful, returns the following or another standard COM error code.
///
///
/// Return code
/// Description
///
/// -
/// E_INVALIDARG
/// An argument is not valid.
///
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/oleacc/nf-oleacc-windowfromaccessibleobject HRESULT
// WindowFromAccessibleObject( IAccessible *, HWND *phwnd );
[DllImport(Lib.Oleacc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("oleacc.h", MSDNShortId = "b3a3d3dd-ef84-4323-ab6d-6331d8389f11")]
public static extern HRESULT WindowFromAccessibleObject([In] IAccessible arg1, out HWND phwnd);
}
}