public object Execute(IUIAutomationRunner runner) { AutomationElement element = UIAutomationHelper.FindWindowControl(this, ControlType.Button, this.TimeOut); if (element == null) { throw new NullReferenceException(string.Format("Button element with AutomationId '{0}' and Name '{1}' can not be find.", element.Current.AutomationId, element.Current.Name)); } ThreadStart start2 = null; IntPtr nativeWindowHandle = (IntPtr)element.Current.NativeWindowHandle; if (nativeWindowHandle != IntPtr.Zero) { HandleRef hWnd = new HandleRef(nativeWindowHandle, nativeWindowHandle); PostMessage(hWnd, 0xf5, IntPtr.Zero, IntPtr.Zero); } else { if (start2 == null) { start2 = delegate { PatternOperator.Invoke(element); }; } ThreadStart start = start2; new Thread(start).Start(); Thread.Sleep(0xbb8); } return(null); }
public object Execute(IUIAutomationRunner action) { AutomationElement element = UIAutomationHelper.FindWindowControl(this, ControlType.MenuItem, this.TimeOut); if (element == null) { throw new NullReferenceException(string.Format("Menu element with AutomationId '{0}' and Name '{1}' can not be find.", element.Current.AutomationId, element.Current.Name)); } ThreadStart threadStart = delegate { PatternOperator.Invoke(element); }; new Thread(threadStart).Start(); Thread.Sleep(0xbb8); return(null); }