protected override void Execute(CodeActivityContext context) { Int32 _delayAfter = Common.GetValueOrDefault(context, this.DelayAfter, 300); Int32 _delayBefore = Common.GetValueOrDefault(context, this.DelayBefore, 300); Thread.Sleep(_delayBefore); try { // Prioritize to use the AutomationId or Name property to get faster. var nativeElement = UIAutomationCommon.GetNativeElement(context, WindowTitle, AutomationId, Name); if (nativeElement != null) { UIAutomationCommon.MoveOnNativeElement(nativeElement); Thread.Sleep(_delayAfter); return; } var selStr = Selector.Get(context); UiElement element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } //Int32 pointX = 0; //Int32 pointY = 0; //if (usePoint) //{ // pointX = offsetX.Get(context); // pointY = offsetY.Get(context); //} //else //{ // if (element != null) // { // pointX = element.GetClickablePoint().X; // pointY = element.GetClickablePoint().Y; // element.SetForeground(); // } // else // { // UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, "查找不到元素"); // return; // } //} var point = UIAutomationCommon.GetPoint(context, usePoint, offsetX, offsetY, element); if (point.X == -1 && point.Y == -1) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, Localize.LocalizedResources.GetString("msgNoElementFound")); return; } UiElement.MouseMoveTo(point); Thread.Sleep(_delayAfter); } catch (Exception e) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, e.Message); } }
protected override void Execute(CodeActivityContext context) { Int32 _delayAfter = Common.GetValueOrDefault(context, this.DelayAfter, 300); Int32 _delayBefore = Common.GetValueOrDefault(context, this.DelayBefore, 300); try { Thread.Sleep(_delayBefore); var selStr = Selector.Get(context); UiElement element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } //Int32 pointX = 0; //Int32 pointY = 0; //if (usePoint) //{ // pointX = offsetX.Get(context); // pointY = offsetY.Get(context); //} //else //{ // if (element != null) // { // pointX = element.GetClickablePoint().X; // pointY = element.GetClickablePoint().Y; // element.SetForeground(); // } //} var point = UIAutomationCommon.GetPoint(context, usePoint, offsetX, offsetY, element); if (point.X == -1 && point.Y == -1) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, Localize.LocalizedResources.GetString("msgNoElementFound")); return; } if (isRunClick) { UiElement.MouseMoveTo(point); UiElement.MouseAction((Plugins.Shared.Library.UiAutomation.ClickType)ClickType, (Plugins.Shared.Library.UiAutomation.MouseButton)MouseButton); } DealBaseKeyBordPress(); if (Common.DealVirtualKeyPress(SelectedKey.ToUpper())) { Common.DealVirtualKeyRelease(SelectedKey.ToUpper()); } DealBaseKeyBordRelease(); Thread.Sleep(_delayAfter); } catch (Exception e) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, e.Message); } }
protected override void Execute(CodeActivityContext context) { Int32 _delayAfter = Common.GetValueOrDefault(context, this.DelayAfter, 300); Int32 _delayBefore = Common.GetValueOrDefault(context, this.DelayBefore, 300); try { Thread.Sleep(_delayBefore); SecureString secureText = SecureText.Get(context); IntPtr inP = Marshal.SecureStringToBSTR(secureText);//inP为secureStr的句柄 string text = Marshal.PtrToStringBSTR(inP); var selStr = Selector.Get(context); UiElement element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } //Int32 pointX = 0; //Int32 pointY = 0; //if (usePoint) //{ // pointX = offsetX.Get(context); // pointY = offsetY.Get(context); //} //else //{ // if (element != null) // { // pointX = element.GetClickablePoint().X; // pointY = element.GetClickablePoint().Y; // element.SetForeground(); // } // else // { // UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, "查找不到元素"); // return; // } //} var point = UIAutomationCommon.GetPoint(context, usePoint, offsetX, offsetY, element); if (point.X == -1 && point.Y == -1) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, Localize.LocalizedResources.GetString("msgNoElementFound")); return; } /*执行鼠标点击事件*/ if (isRunClick) { UiElement.MouseMoveTo(point); UiElement.MouseAction((Plugins.Shared.Library.UiAutomation.ClickType)ClickType, (Plugins.Shared.Library.UiAutomation.MouseButton)MouseButton); } else if (true) { } else { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, "找不到键值"); } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "发送安全文本执行过程出错", e.Message); } }
protected override void Execute(CodeActivityContext context) { Int32 _delayAfter = Common.GetValueOrDefault(context, this.DelayAfter, 300); Int32 _delayBefore = Common.GetValueOrDefault(context, this.DelayBefore, 300); Thread.Sleep(_delayBefore); try { // Prioritize to use the AutomationId or Name property to get faster. var nativeElement = UIAutomationCommon.GetNativeElement(context, WindowTitle, AutomationId, Name); if (nativeElement != null) { int moveX = 0, moveY = 0; if (clickOffsetPoint) { moveX = moveOffsetX.Get(context); moveY = moveOffsetY.Get(context); } UIAutomationCommon.ClickNativeElement(nativeElement, moveX, moveY); Thread.Sleep(_delayAfter); return; } var selStr = Selector.Get(context); var element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } var point = UIAutomationCommon.GetPoint(context, usePoint, offsetX, offsetY, element); if (point.X == -1 && point.Y == -1) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, Localize.LocalizedResources.GetString("msgNoElementFound")); return; } if (KeyModifiers != null) { string[] sArray = KeyModifiers.Split(','); foreach (string i in sArray) { Common.DealKeyBordPress(i); } } UiElement.MouseMoveTo(point); UiElement.MouseAction((Plugins.Shared.Library.UiAutomation.ClickType)ClickType, (Plugins.Shared.Library.UiAutomation.MouseButton)MouseButton); if (KeyModifiers != null) { string[] sArray = KeyModifiers.Split(','); foreach (string i in sArray) { Common.DealKeyBordRelease(i); } } Thread.Sleep(_delayAfter); } catch (Exception e) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, e.Message); } }
protected override void Execute(CodeActivityContext context) { Int32 _delayAfter = Common.GetValueOrDefault(context, this.DelayAfter, 300); Int32 _delayBefore = Common.GetValueOrDefault(context, this.DelayBefore, 300); Thread.Sleep(_delayBefore); try { string expValue = Text.Get(context); List <string> strList = new List <string>(); ParseStringToList(ref expValue, ref strList); // Prioritize to use the AutomationId or Name property to get faster. var nativeElement = UIAutomationCommon.GetNativeElement(context, WindowTitle, AutomationId, Name); if (nativeElement != null) { if (moveOffsetClick) { int moveX = moveOffsetX.Get(context); int moveY = moveOffsetY.Get(context); UIAutomationCommon.MoveOnNativeElement(nativeElement, moveX, moveY); FlaUI.Core.Input.Mouse.Click(); } DoSendKeys(context, strList); Thread.Sleep(_delayAfter); return; } var selStr = Selector.Get(context); UiElement element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } //Int32 pointX = 0; //Int32 pointY = 0; //if (usePoint) //{ // pointX = offsetX.Get(context); // pointY = offsetY.Get(context); //} //else //{ // if (element != null) // { // pointX = element.GetClickablePoint().X; // pointY = element.GetClickablePoint().Y; // //element.SetForeground();//输入框置前窗口会导致焦点跳出,去除 // } //} var point = UIAutomationCommon.GetPoint(context, usePoint, offsetX, offsetY, element, false); if (point.X == -1 && point.Y == -1) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, Localize.LocalizedResources.GetString("msgNoElementFound")); return; } if (isRunClick) { UiElement.MouseMoveTo(point); UiElement.MouseAction((Plugins.Shared.Library.UiAutomation.ClickType)ClickType, (Plugins.Shared.Library.UiAutomation.MouseButton)MouseButton); } DoSendKeys(context, strList); Thread.Sleep(_delayAfter); } catch (Exception e) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, e.Message); } }