public void StartMousePointer() { Technologies.Technology tech = new Technologies.Technology(); Dictionary <string, string> allProccessSteps = getAllProcessSteps(); System.Windows.Point point = new System.Windows.Point(); while (true) { //Thread.Sleep(100); //Statt Mausklick + Strg nur Strg ist besser //Wenn Mausklick + Strg wird das jeweilige Dropdown geöffnet //Maus muss über einem "Prozessschritt" sein, dann Strg drücken -> Ausgabe Konsole Start(point, tech, allProccessSteps); if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { Dictionary[STRG] = "true"; //children(saoRef,parent); } if (_event != null) { _event(Dictionary, new EventArgs()); } } }
public void StartMousePointer() { Technologies.Technology tech = new Technologies.Technology(); System.Windows.Point point = new System.Windows.Point(); while (true) { Thread.Sleep(30); //Statt Mausklick + Strg nur Strg ist besser //Wenn Mausklick + Strg wird das jeweilige Dropdown geöffnet //Maus muss über einem "Prozessschritt" sein, dann Strg drücken -> Ausgabe Konsole if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { String s = Start(point, tech); Console.WriteLine(s); } } }
private String Start(System.Windows.Point point, Technologies.Technology tech) { //Technologies.Jab jab = new Technologies.Jab(); // Console.Write(tech.GetNameByPosition(point)); GetCursorPos(ref MousePoint); XKoordinate = MousePoint.X; YKoordinate = MousePoint.Y; //Text = "X = " + XKoordinate + " " + "Y = " + YKoordinate; point.X = XKoordinate; point.Y = YKoordinate; SystemAccessibleObject accessibleObject = null; accessibleObject = SystemAccessibleObject.FromPoint((int)point.X, (int)point.Y); var bounds = accessibleObject.Location; String name = "Name: " + tech.GetNameByPosition(point); if (name.Equals("Name: no name")) { point = new System.Windows.Point(accessibleObject.Location.X, accessibleObject.Location.Y - 0.5); name = "Name: " + tech.GetNameByPosition(point); } //String id = "ID: " + tech.GetIdByPosition(point); String type = "Typ: " + tech.GetTypeByPosition(point); String process = "Process: " + tech.GetProcessNameByPosition(point); String windowName = "Window: " + tech.GetWindowNameByPosition(point); String ausgabe = name + " " + type + " " + process + " " + windowName; return(ausgabe); }
private void Start(System.Windows.Point point, Technologies.Technology tech, Dictionary <string, string> allProcessSteps) { GetCursorPos(ref MousePoint); XKoordinate = MousePoint.X; YKoordinate = MousePoint.Y; point.X = XKoordinate; point.Y = YKoordinate; SystemAccessibleObject accessibleObject = null; try { accessibleObject = SystemAccessibleObject.FromPoint((int)point.X, (int)point.Y); } catch (Exception) { Console.WriteLine("Fehler"); } try { // Console.WriteLine("##########" + accessibleObject.Window.Process); //Console.WriteLine("##########" + accessibleObject.Parent.Name); SystemWindow window = new SystemWindow(accessibleObject.Window.HWnd); IntPtr pointer = GetActiveWindow(); SystemWindow window2 = new SystemWindow(pointer); //IntPtr comboboxex = FindWindowEx(HWnD, 0, "comboboxex32", null); //IntPtr combo = FindWindowEx(comboboxex, 0, "ComboBox", null); //IntPtr edit = FindWindowEx(combo, 0, "Edit", null); //// note: 3rd child of "Edit" may work, too //IntPtr intptrEdit = FindWindowEx(intptrAddressBand, IntPtr.Zero, "Edit", null); //var sao = SystemAccessibleObject.FromWindow(new ManagedWinapi.Windows.SystemWindow(intptrEdit), ManagedWinapi.Accessibility.AccessibleObjectID.OBJID_WINDOW); //var url = sao.Children[3].Value; if (window != null) { Console.WriteLine(window + " " + window.ClassName + " " + window.Title); } } catch (Exception) { Console.WriteLine("Fehler"); } saoRef = accessibleObject; //Console.WriteLine(accessibleObject.Location.X + " - " + accessibleObject.Location.Y + " ID: " + accessibleObject); //TODO //Try catch um if string Name = tech.GetNameByPosition(point); if (Name.Equals("no name")) { point = new System.Windows.Point(accessibleObject.Location.X, accessibleObject.Location.Y - 0.5); Name = tech.GetNameByPosition(point); } string parentName = ""; try { parentName = saoRef.Parent.Name; } catch (Exception e) { Console.WriteLine(e.StackTrace); } string Type = tech.GetTypeByPosition(point).ToString(); //string processName = tech.GetProcessNameByPosition(point); //string Program = Technologies.Technology.getApplicationNameByProcessName(tech.GetProcessNameByPosition(point)); string Program = tech.GetProcessNameByPosition(point); string Window = tech.GetWindowNameByPosition(point); if (Window != null && Window.Equals("")) { SystemWindow window = saoRef.Window; Console.WriteLine("window name: " + window.Title); //höchstes parentwindow holen while (window.Title.Equals("")) { window = window.Parent; Console.WriteLine("Fenstername : " + window.Title); } Window = window.Title; } string Parent = ""; int c = 0; try { if (saoRef.Parent.Name != null) { while (Parent != null && Parent.Equals("") && c < 10) { try { Parent = saoRef.Parent.Name; } catch (COMException e) { } c++; } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } string Info = String.Format("Info: Name = {0} Program = {1}", Name + " parent: " + parentName, Program); // var tecIdsAcc = tech.GetIdsByPosition(point, null); //SystemAccessibleObject[] allChildren = saoRef.Children; //Rekursive Methode findet Objekte oft doppelt, wie Date zum Beispiel. Einmal beim "normalen" //durchlaufen und ein //zweites mal, wenn es diesen Reiter öffnent //dbCompareWithSelectedObj(saoRef, allProcessSteps); /*foreach (SystemAccessibleObject childs in allChildren) * { * try * { * Console.WriteLine("-----------------------ChildName : " + childs.Name + " Parent: " + childs.Parent); * * } * catch (COMException e) * { * Console.WriteLine(e.Message); * } * } * String wtitle = saoRef.Window.Title; * * SystemWindow ww = new SystemWindow(new Control(wtitle)); * SystemAccessibleObject aa = SystemAccessibleObject.FromWindow(ww, AccessibleObjectID.OBJID_WINDOW); * */ //Console.WriteLine("!!!!!!!!!!!!!!!!!!!! " + ww.Title + " " + aa.Name + " loc" + aa.Location); counter = 0; /* * int count = 0; * foreach (var id in tecIdsAcc) * { * Dictionary[count + ""] = id; * count++; * Console.WriteLine("++++++++++++++" + id); * // SystemAccessibleObject test = new SystemAccessibleObject(id, 0); * } * // content.Add(CreateTextElement("ACC [" + (count++) + "]: " + id, GetColor(id))); */ Dictionary[INFO] = Info; Dictionary[NAME] = Name; Dictionary[PROGRAMM] = Program; Dictionary[TYPE] = Type; Dictionary[WINDOW] = Window; Dictionary[PARENT] = Parent; }