public static string GetRoleText(AccessibilityRole role) { var sb = new StringBuilder(1024); var length = Oleacc.GetRoleText(role, sb, 1024); return(sb.ToString()); }
public static string GetStateBitText(AccessibilityState state) { var sb = new StringBuilder(1024); var length = Oleacc.GetStateText(state, sb, 1024); return(sb.ToString()); }
/// <summary> /// 指定ウィンドウのウェブブラウザ情報を取得する /// </summary> /// <param name="hWnd">ウィンドウハンドル</param> /// <returns>ウェブブラウザ情報</returns> private IWebBrowser2 GetWebBrowser(IntPtr hWnd) { UIntPtr sendMessageResult = UIntPtr.Zero; // WM_HTML_GETOBJECTメッセージの送信 User32.SendMessageTimeout(hWnd, HtmlGetObject, 0, 0, (uint)SMTO.ABORTIFHUNG, 1000, ref sendMessageResult); if (sendMessageResult == UIntPtr.Zero) { return(null); } // HTML文書情報の取得 IHTMLDocument2 doc = null; var IID_IHTMLDocument3 = typeof(IHTMLDocument3).GUID; if (Oleacc.ObjectFromLresult(sendMessageResult, ref IID_IHTMLDocument3, 0, ref doc) != 0) { return(null); } using (Disposable.Create(() => ReleaseComObject(doc))) { // ウェブブラウザの取得 var serviceProvider = (Interop.Win32.IServiceProvider)doc.parentWindow; using (Disposable.Create(() => ReleaseComObject(serviceProvider))) { object result; serviceProvider.QueryService(typeof(IWebBrowserApp).GUID, typeof(IWebBrowser2).GUID, out result); return((IWebBrowser2)result); } } }
private void WmGetObject(ref Message m) { if (m.LParamInternal == NativeMethods.UiaRootObjectId) { // If the requested object identifier is UiaRootObjectId, // we should return an UI Automation provider using the UiaReturnRawElementProvider function. m.ResultInternal = UiaCore.UiaReturnRawElementProvider( this, m.WParamInternal, m.LParamInternal, GetChildAccessibleObject(_childWindowType)); return; } // See "How to Handle WM_GETOBJECT" in MSDN if ((int)m.LParamInternal == OBJID.CLIENT) { // Get the IAccessible GUID Guid IID_IAccessible = new Guid(NativeMethods.uuid_IAccessible); // Get an Lresult for the accessibility Object for this control try { // Obtain the Lresult IntPtr pUnknown = Marshal.GetIUnknownForObject(GetChildAccessibleObject(_childWindowType)); try { m.ResultInternal = Oleacc.LresultFromObject(ref IID_IAccessible, m.WParamInternal, new HandleRef(this, pUnknown)); } finally { Marshal.Release(pUnknown); } } catch (Exception e) { throw new InvalidOperationException(SR.RichControlLresult, e); } } else { // m.lparam != OBJID_CLIENT, so do default message processing DefWndProc(ref m); } }
private void WmGetObject(ref Message m) { if (m.LParam == (IntPtr)NativeMethods.UiaRootObjectId) { AccessibleObject uiaProvider = GetChildAccessibleObject(_childWindowType); // If the requested object identifier is UiaRootObjectId, // we should return an UI Automation provider using the UiaReturnRawElementProvider function. InternalAccessibleObject internalAccessibleObject = new InternalAccessibleObject(uiaProvider); m.Result = UiaCore.UiaReturnRawElementProvider( new HandleRef(this, Handle), m.WParam, m.LParam, internalAccessibleObject); return; } // See "How to Handle WM_GETOBJECT" in MSDN // if (unchecked ((int)(long)m.LParam) == OBJID.CLIENT) { // Get the IAccessible GUID // Guid IID_IAccessible = new Guid(NativeMethods.uuid_IAccessible); // Get an Lresult for the accessibility Object for this control // IntPtr punkAcc; try { AccessibleObject wfAccessibleObject = null; UiaCore.IAccessibleInternal iacc = null; if (_accessibilityObject is null) { wfAccessibleObject = GetChildAccessibleObject(_childWindowType); _accessibilityObject = new InternalAccessibleObject(wfAccessibleObject); } iacc = (UiaCore.IAccessibleInternal)_accessibilityObject; // Obtain the Lresult // punkAcc = Marshal.GetIUnknownForObject(iacc); try { m.Result = Oleacc.LresultFromObject(ref IID_IAccessible, m.WParam, new HandleRef(this, punkAcc)); } finally { Marshal.Release(punkAcc); } } catch (Exception e) { throw new InvalidOperationException(SR.RichControlLresult, e); } } else { // m.lparam != OBJID_CLIENT, so do default message processing DefWndProc(ref m); } }
private void WmGetObject(ref Message m) { if (m.LParam == (IntPtr)NativeMethods.UiaRootObjectId && // Managed UIAutomation providers are supplied for child list windows but not for the child edit window. // Child list accessibility object provides all necessary patterns and UIAutomation notifications, // so there is no need to native provider supplement. // Child edit accessibility object has only partial support of edit box accessibility, most of the patterns // and notifications for child edit window are supplied by native providers, so here is no need to // override root UIA object for child edit window. (_childWindowType == ChildWindowType.ListBox || _childWindowType == ChildWindowType.DropDownList)) { AccessibleObject uiaProvider = GetChildAccessibleObject(_childWindowType); // If the requested object identifier is UiaRootObjectId, // we should return an UI Automation provider using the UiaReturnRawElementProvider function. InternalAccessibleObject internalAccessibleObject = new InternalAccessibleObject(uiaProvider); m.Result = UiaCore.UiaReturnRawElementProvider( new HandleRef(this, Handle), m.WParam, m.LParam, internalAccessibleObject); return; } // See "How to Handle WM_GETOBJECT" in MSDN // if (unchecked ((int)(long)m.LParam) == OBJID.CLIENT) { // Get the IAccessible GUID // Guid IID_IAccessible = new Guid(NativeMethods.uuid_IAccessible); // Get an Lresult for the accessibility Object for this control // IntPtr punkAcc; try { AccessibleObject wfAccessibleObject = null; UiaCore.IAccessibleInternal iacc = null; if (_accessibilityObject is null) { wfAccessibleObject = GetChildAccessibleObject(_childWindowType); _accessibilityObject = new InternalAccessibleObject(wfAccessibleObject); } iacc = (UiaCore.IAccessibleInternal)_accessibilityObject; // Obtain the Lresult // punkAcc = Marshal.GetIUnknownForObject(iacc); try { m.Result = Oleacc.LresultFromObject(ref IID_IAccessible, m.WParam, new HandleRef(this, punkAcc)); } finally { Marshal.Release(punkAcc); } } catch (Exception e) { throw new InvalidOperationException(SR.RichControlLresult, e); } } else { // m.lparam != OBJID_CLIENT, so do default message processing DefWndProc(ref m); } }