public Marker() { InitializeComponent(); SetWindowLong(this.Handle, -20, GetWindowLong(this.Handle, -20) | 0x20 | 0x80000 | 0x08000000); //TRANSPARENT,LAYERED,NOACTIVATE Rectangle ScrBnd = Screen.PrimaryScreen.Bounds; Location = new Point(ScrBnd.Right, ScrBnd.Bottom); Size = ScrBnd.Size; ClearMarks(); Location = new Point(0, 0); Nav = new CountedNavi( AutoElem.FromHandle(GetDesktopWindow()) ); Nav.Walker = TreeWalker.ControlViewWalker; Nav.CurElemChanged += MarkElemInfo; RegHotkey(0, MK.Alt | MK.Control, Keys.Up); RegHotkey(1, MK.Alt | MK.Control, Keys.Down); RegHotkey(2, MK.Alt | MK.Control, Keys.Left); RegHotkey(3, MK.Alt | MK.Control, Keys.Right); RegHotkey(6, MK.Alt | MK.Control, Keys.D1); RegHotkey(7, MK.Alt | MK.Control, Keys.D2); RegHotkey(5, MK.Alt | MK.Control, Keys.Enter); }
protected override void WndProc(ref Message m) { if (m.Msg == 0x0312) //WM_HOTKEY { switch (m.WParam.ToInt32()) { case 0: case 1: case 2: case 3: var t = Nav.NavElem((NavCode)m.WParam); if (t != null) { Console.WriteLine(t); } break; case 5: if (Nav.CondMode) { MarkedOp(Nav.CurElem); } else { Nav.Walker = new TreeWalker(Oper.PropCond); int v = Nav.CondSibLst.Count; Console.WriteLine("Set Walker " + (v > 0 ? "Succeed" : "Failed")); if (v > 0) { if (v == 1 || (Oper.Mode == OpMode.Focus && v < 5)) { MarkedOp(Nav.CurElem); Nav.NavElem(NavCode.Parent); } else { ShowInput(); } } } break; case 6: Nav.CurElem = AutoElem.FromHandle(GetForegroundWindow()); Nav.NavElem(NavCode.Child); break; case 7: ShowInput(); break; } } base.WndProc(ref m); }
protected void VerifyCurElem() { if (!_curElem.Available()) { _curElem = AutoElem.FromHandle(GetDesktopWindow()); Console.WriteLine("Desktop Fallback"); if (CondMode) { Walker = UncondWalker; } } }
static void Main(string[] args) { foreach (var proc in Process.GetProcessesByName("chrome")) { if (proc.MainWindowHandle == IntPtr.Zero) { continue; } var element = AE.FromHandle(proc.MainWindowHandle); //var cond = new PC(AE.NameProperty, "アドレス検索バー")); var cond = new PC(AE.ControlTypeProperty, CT.Edit); var edit = element.FindFirst(TS.Descendants, cond); if (edit == null) { continue; } var pat = edit.GetCurrentPattern(VP.Pattern) as VP; var url = pat.Current.Value as string; // the url value is just surface of edit control, e.g. "http://" is hidden Console.WriteLine(url); } }