void eventGrabber_Grabbed(object sender, EventGrabber.GrabbedEventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.Invoke(new EventHandler <EventGrabber.GrabbedEventArgs>(eventGrabber_Grabbed), new object[] { sender, e }); } else { if ((e.EventType == SetWinEventHookEventType.EVENT_OBJECT_LOCATIONCHANGE) && (e.ObjectId == -8)) { IAccessible acc = null; FromEvent(e.Window, e.ObjectId, 0, out acc); if (acc != null) { int left = 0; int top = 0; int width = 0; int height = 0; acc.accLocation(out left, out top, out width, out height); if (left != 0 && top != 0) { ShowCaretTrackWindow(left, top); } else { _caretTrackWindow.Hide(); } } } } }
public void Click() { int x, y, width, height; IAcc.accLocation(out x, out y, out width, out height, 0); SUIMouse.MouseClick(x, y); }
private static void LogAccessibleObject(int depth, IntPtr hWnd, IAccessible child) { sFile.Write(new String(' ', depth)); string value; try { value = child.accValue[0]; } catch (Exception) { value = ""; } string roleString; try { roleString = child.accRole[0] as string; if (child.accRole[0] is int) { roleString = Enum.GetName(typeof(AccessibleRole), (int)child.accRole[0]); } } catch (NullReferenceException) { roleString = "<undefined role>"; } int left, width, top, height; try { child.accLocation(out left, out top, out width, out height); } catch (Exception) { left = width = top = height = -1; } string name; try { name = child.accName[0]; } catch (NullReferenceException) { name = "<no name>"; } sFile.WriteLine("{0}[{1}]:{2}={3}, Role:{4}, State:{5}, Pos:{6},{7}", hWnd.ToString("X"), GetClassName(hWnd), name, value, roleString, child.accState[0], left, top); }
private void SetLocation(IAccessible accObject) { if (accObject != null) { int x1, y1; int width; int hieght; accObject.accLocation(out x1, out y1, out width, out hieght, 0); _location = new Rectangle(x1, y1, x1 + width, y1 + hieght); } }
public static Rectangle GetIHTMLDocumentPosition(IHTMLDocument doc) { if (doc != null) { IAccessible pAcc = IHTMLDocumentToMSAA(doc); if (pAcc != null) { int left, top, width, height; pAcc.accLocation(out left, out top, out width, out height, 0); return(new Rectangle(left, top, width, height)); } } return(new Rectangle(0, 0, 0, 0)); }
public static Rectangle GetIHTMLPosition(IHTMLElement element) { while (element != null) { IAccessible pAcc = IHTMLElementToMSAA(element); if (pAcc != null) { int left, top, width, height; pAcc.accLocation(out left, out top, out width, out height, 0); return(new Rectangle(left, top, width, height)); } else { element = element.parentElement; } } return(new Rectangle(0, 0, 0, 0)); }
internal static Rectangle GetAccLocation(IAccessible accObj, int childId) { int pxLeft = 0; int pyTop = 0; int pcxWidth = 0; int pcyHeight = 0; try { accObj.accLocation(out pxLeft, out pyTop, out pcxWidth, out pcyHeight, childId); } catch (Exception exception) { if (!IsOleAccException(exception) || !IsOleAccExceptionMaskable(exception)) { throw; } } return(new Rectangle(pxLeft, pyTop, pcxWidth, pcyHeight)); }
void IAccessibleInternal.accLocation(out int l, out int t, out int w, out int h, object childID) => publicIAccessible.accLocation(out l, out t, out w, out h, childID);
public AccessibleInformation GetInformation() { AccessibleInformation infor = new AccessibleInformation(); int x, y, width, height; int index = 0; //有些接口方法并未实现,有些属性无效,或者其他原因, 总之IAccessible的接口方法不安全,需要自行处理异常 getValue : try { switch (index) { case 0 : infor.AccDescription = _self.accDescription[_id]; break; case 1: infor.AccHelp = _self.accHelp[_id]; break; case 2: infor.AccDefaultAction = _self.accDefaultAction[_id]; break; case 3: infor.AccName = _self.accName[_id]; break; case 4: infor.AccRole = _self.accRole[_id]; break; case 5: infor.AccState = _self.accState[_id]; break; case 6: infor.AccValue = _self.accValue[_id]; break; case 7: infor.AccKeyboardShortcut = _self.accKeyboardShortcut[_id]; break; case 8: _self.accLocation(out x, out y, out width, out height, _id); infor.AccLocation = new Rectangle(x, y, width, height); break; case 9: infor.AccChildId = _id; break; case 10: if (_id == 0) { infor.AccChildCount = _self.accChildCount; } else { infor.AccChildCount = (_self.accChild[_id] as IAccessible).accChildCount; } break; } } catch { //catch (System.NotImplementedException) //catch (System.ArgumentException) //catch (System.Runtime.InteropServices.COMException) } if (++index != 11) { goto getValue; } infor.HandleWindow = _hwnd; StringBuilder stringBuilder = new StringBuilder(200); if (NativeMethods.GetClassName(_hwnd, stringBuilder, 200) != 0) { infor.ClassNameWindow = stringBuilder.ToString(); } int buffer = NativeMethods.GetWindowTextLength(_hwnd) + 1; stringBuilder = new StringBuilder(buffer); if (NativeMethods.GetWindowText(_hwnd, stringBuilder, buffer) != 0) { infor.TitleWindow = stringBuilder.ToString(); } return(infor); }
internal static NativeMethods.Win32Rect GetLocation(IAccessible acc, int idChild) { // NativeMethods.Win32Rect rect = NativeMethods.Win32Rect.Empty; try { acc.accLocation(out rect.left, out rect.top, out rect.right/*width*/, out rect.bottom/*height*/, idChild ); } catch (Exception e) { // Some impls (eg Media Center) return odd error codes; // so treat all but critical ones as a 'soft' failure (return empty rect) // Some impls (MediaPlayer) return E_POINTER, which translates // to NullReferenceException; ignore that also. if (Misc.IsCriticalException(e) && ! (e is NullReferenceException)) { throw; } return NativeMethods.Win32Rect.Empty; } rect.right += rect.left; // convert width to right rect.bottom += rect.top; // convert height to bottom return rect; }
void UnsafeNativeMethods.IAccessibleInternal.accLocation(out int l, out int t, out int w, out int h, object childID) { IntSecurity.UnmanagedCode.Assert(); publicIAccessible.accLocation(out l, out t, out w, out h, childID); }