private void GetControlThreadProc(object param) { object[] actualParams = (object[])param; string controlId = (string)actualParams[0]; Type controlType = (Type)actualParams[1]; if (m_ClientChannel == null) { return; } try { IWinForm form = m_ClientChannel.GetWindow(m_WindowHandle); IWinControl controlproxy = form.GetControl(controlId, controlType); if (controlproxy == null) { return; } m_SurrogateControl = new SurrogateControl(controlproxy); m_Success = true; } catch (Exception e) { m_Success = false; } finally { m_ControlFound.Set(); } }
public IWinControl GetControl(string controlId, Type controltype) { IWinControl control = null; try { if (m_ControlList.Contains(controltype)) { control = (IWinControl)m_ControlList[controltype]; } else { IChildControlFinder selector = new ControlIdentifierByName(m_WindowHandle, controlId); ChildControlCrawler childlearner = new ChildControlCrawler(); childlearner.FindChildWindowAsync(m_WindowHandle, selector.FindChild, ENUM_TIMEOUT); if (!selector.ControlFound) { return(null); } control = (IWinControl)selector.ChildControl; m_ControlList.Add(controlId, control); } return(control); } catch (Exception e) { return(null); } }
static void Main(string[] args) { Engine e = new Engine(); Window w = e.GetWindow("SomeForm"); if (w == null) { Console.WriteLine("Window not found"); } else { bool dddd = false; IWinControl ctrl = w.GetControl("OK", typeof(Button)); string ssss; if (ctrl != null) { ssss = (string)ctrl.GetPropertyValue("Name", out dddd); ctrl.Invoke("OnClick", new object[] { new EventArgs() }); } IWinControl ctrl2 = w.GetControl("this", typeof(Form)); string ssss2; if (ctrl != null) { ssss2 = (string)ctrl2.GetPropertyValue("Text", out dddd); } List <IWinControl> ctrls = w.GetControls(typeof(Button)); if (ctrls != null) { foreach (IWinControl item in ctrls) { bool bsuccess = false; string str = (string)item.GetPropertyValue("Text", out bsuccess); Console.WriteLine(str); item.SetPropertyValue("Text", "Changed"); } } } while (true) { Console.WriteLine("Inside while"); Thread.Sleep(1000); } //IHookInterfaces.IWinForm win = engine.FindWindow("Form1", 20); /// IWinControl ctrl = win.GetControl("OK", typeof(Button)); /// SizeF s = new SizeF(3, 3); /// ctrl.Invoke("Scale", new object[] { s }); }
private void CreateControl(IntPtr handle, Control control) { m_ControlFound = true; m_Childhandle = handle; m_Control = control; m_ControlType = m_Control.GetType(); string controlId; if (control.AccessibleName != null && control.AccessibleName != "") { controlId = control.AccessibleName; } else { controlId = control.Text; } m_ZControl = new ZControl(controlId, handle, control, m_ControlType); }
public IWinControl GetControl(string controlId, Type controltype) { try { IWinForm form = m_ClientChannel.GetWindow(m_WindowHandle); IWinControl controlProxy = form.GetControl(controlId, controltype); if (controlProxy == null) { return(null); } IWinControl surrogateControl = new SurrogateControl(controlProxy); return(surrogateControl); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
public SurrogateControl(IWinControl control) { m_WinControl = control; }