diff --git a/.gitattributes b/.gitattributes index 1ff0c4230..70770eb38 100644 --- a/.gitattributes +++ b/.gitattributes @@ -61,3 +61,9 @@ #*.PDF diff=astextplain #*.rtf diff=astextplain #*.RTF diff=astextplain + + +# skip merge +taskt/latest.json merge=ours +taskt/Properties/AssemblyInfo.cs merge=ours +taskt/Core/MyURLs.UserOriginal.cs merge=ours diff --git a/.gitignore b/.gitignore index f8c0983c9..7c2078e80 100644 --- a/.gitignore +++ b/.gitignore @@ -261,6 +261,3 @@ __pycache__/ *.pyc /sharpRPA/sharpRPA2.licenseheader -#Custom Files -taskt/latest.json -taskt/Properties/AssemblyInfo.cs diff --git a/README.md b/README.md index e24b684eb..715aa4d2c 100644 --- a/README.md +++ b/README.md @@ -57,17 +57,15 @@ Please note whatever software that taskt is automating can affect the minimum so * .NET Framework 4.8 * (We think it will probably work in Windows Server 2022/2025 :-) -**Attension**: Windows 7, Windows 8.1, Windows Server 2012, Windows Server 2016 are no longer supported. +**Attension**: Windows 7/8.1/10, Windows Server 2012 are no longer supported. ## Recommended - * Windows 10/11/Server 2019 (32bit and 64bit) + * Windows 11/Server 2019 (32bit and 64bit) * 4GB ram * 1GB disk space * 2 CPU * .NET Framework 4.8 - * (We think it will probably work in Windows Server 2022 :-) - -**Attention**: After windows 10 support ends, windows 10 will be removed from the recommended environment. + * (We think it will probably work in Windows Server 2022/2025 :-) [![Open New Issue](https://img.shields.io/badge/Open-New Issue-blue.svg)](https://github.com/saucepleez/taskt/issues/new) [![Chat on Gitter](https://img.shields.io/badge/Chat-On Gitter-green.svg)](https://gitter.im/taskt-rpa/Lobby) diff --git a/taskt/App.config b/taskt/App.config index cac1c6eec..9b9ac787c 100644 --- a/taskt/App.config +++ b/taskt/App.config @@ -42,23 +42,23 @@ limitations under the License. - + - + - + - + - + @@ -78,7 +78,7 @@ limitations under the License. - + @@ -86,7 +86,7 @@ limitations under the License. - + diff --git a/taskt/App.cs b/taskt/App.cs index f350521a0..fa5a0b78e 100644 --- a/taskt/App.cs +++ b/taskt/App.cs @@ -1,6 +1,8 @@ -using System.Diagnostics; +using System.Collections.Generic; +using System.Diagnostics; using System.Windows.Forms; using taskt.Core; +using taskt.Core.Automation.Commands; namespace taskt { @@ -34,6 +36,16 @@ public static class App /// public static SafeApplicationSettings Taskt_Settings { get; private set; } + /// + /// all commands info, etc + /// + public static List AllCommandsInfo { get; private set; } + + static App() + { + AllCommandsInfo = ScriptCommandInformation.CreateScriptCommandInformations(); + } + /// /// update location, version info /// diff --git a/taskt/Core/ApplicationSettings/ClientSettings.cs b/taskt/Core/ApplicationSettings/ClientSettings.cs index c5524e791..4982314e8 100644 --- a/taskt/Core/ApplicationSettings/ClientSettings.cs +++ b/taskt/Core/ApplicationSettings/ClientSettings.cs @@ -163,6 +163,74 @@ public int RemoveBeforeConvertedFileDays public bool DisplayNumberBeforeParameterDescription { get; set; } + public bool DisplayParameterOrderInDescription { get; set; } + + private int _GUIInspectMaxSiblings; + + public int GUIInspectMaxSiblings + { + get + { + return _GUIInspectMaxSiblings; + } + set + { + if (value >= 0) + { + _GUIInspectMaxSiblings = value; + } + } + } + + private int _GUIInspectMaxDepth; + + public int GUIInspectMaxDepth + { + get + { + return _GUIInspectMaxDepth; + } + set + { + if (value >= 0) + { + _GUIInspectMaxDepth = value; + } + } + } + + private int _GUIInspectSearchTime; + public int GUIInspectSearchTime + { + get + { + return _GUIInspectSearchTime; + } + set + { + if (value >= 0) + { + _GUIInspectSearchTime = value; + } + } + } + + private int _GUIInspectMouseInterval; + public int GUIInspectMouseInterval + { + get + { + return _GUIInspectMouseInterval; + } + set + { + if (value >= 500) + { + _GUIInspectMouseInterval = value; + } + } + } + //private static readonly string InterDefaultBrowserInstanceNameKeyword = "%kwd_default_browser_instance%"; //private static readonly string InterDefaultStopWatchInstanceNameKeyword = "%kwd_default_stopwatch_instance%"; //private static readonly string InterDefaultExcelInstanceNameKeyword = "%kwd_default_excel_instance%"; @@ -224,6 +292,12 @@ public ClientSettings() ChangeItemsWithWheelWhenNotForcused = false; DisplayNumberBeforeParameterDescription = true; + DisplayParameterOrderInDescription = false; + + GUIInspectMaxSiblings = 64; + GUIInspectMaxDepth = 32; + GUIInspectSearchTime = 5; + GUIInspectMouseInterval = 1500; } /// diff --git a/taskt/Core/ApplicationSettings/EngineSettings.cs b/taskt/Core/ApplicationSettings/EngineSettings.cs index 773ea5558..b1c85277c 100644 --- a/taskt/Core/ApplicationSettings/EngineSettings.cs +++ b/taskt/Core/ApplicationSettings/EngineSettings.cs @@ -49,8 +49,8 @@ public int DelayBetweenCommands public bool UseNewParser { get; set; } public bool IgnoreFirstVariableMarkerInOutputParameter { get; set; } public int MaxFileCounter { get; set; } - public int MaxUIElementInpectDepth { get; set; } - public int MaxUIElementInspectSiblingNodes { get; set; } + //public int MaxUIElementInpectDepth { get; set; } + //public int MaxUIElementInspectSiblingNodes { get; set; } public EngineSettings() { @@ -81,8 +81,8 @@ public EngineSettings() UseNewParser = true; IgnoreFirstVariableMarkerInOutputParameter = true; MaxFileCounter = 999; - MaxUIElementInpectDepth = 256; - MaxUIElementInspectSiblingNodes = int.MaxValue; + //MaxUIElementInpectDepth = 256; + //MaxUIElementInspectSiblingNodes = int.MaxValue; } /// diff --git a/taskt/Core/ApplicationSettings/IClientSettings.cs b/taskt/Core/ApplicationSettings/IClientSettings.cs index 43006c949..f3437e135 100644 --- a/taskt/Core/ApplicationSettings/IClientSettings.cs +++ b/taskt/Core/ApplicationSettings/IClientSettings.cs @@ -231,5 +231,30 @@ public interface IClientSettings /// display number before parameter description /// bool DisplayNumberBeforeParameterDescription { get; } + + /// + /// display parameter order in description (instead of number) + /// + bool DisplayParameterOrderInDescription { get; } + + /// + /// UIElement Max Siblings in GUI Inspect Tool + /// + int GUIInspectMaxSiblings { get; } + + /// + /// UIElement Max Depth in GUI Inspect Tool + /// + int GUIInspectMaxDepth { get; } + + /// + /// UIElement Max Search Time in GUI Inspect Tool + /// + int GUIInspectSearchTime { get; } + + /// + /// UIElement Mouse search interval (ms) in GUI Inspect Tool + /// + int GUIInspectMouseInterval { get; } } } diff --git a/taskt/Core/ApplicationSettings/IEngineSettings.cs b/taskt/Core/ApplicationSettings/IEngineSettings.cs index 3de339b60..f533faec7 100644 --- a/taskt/Core/ApplicationSettings/IEngineSettings.cs +++ b/taskt/Core/ApplicationSettings/IEngineSettings.cs @@ -137,14 +137,14 @@ public interface IEngineSettings /// int MaxFileCounter { get; } - /// - /// max UIElement inspect depth - /// - int MaxUIElementInpectDepth { get; } - - /// - /// max UIElement inspect sibling nodes - /// - int MaxUIElementInspectSiblingNodes { get; } + ///// + ///// max UIElement inspect depth + ///// + //int MaxUIElementInpectDepth { get; } + + ///// + ///// max UIElement inspect sibling nodes + ///// + //int MaxUIElementInspectSiblingNodes { get; } } } diff --git a/taskt/Core/ApplicationSettings/SafeClientSettings.cs b/taskt/Core/ApplicationSettings/SafeClientSettings.cs index a902d0254..e5c5e20bd 100644 --- a/taskt/Core/ApplicationSettings/SafeClientSettings.cs +++ b/taskt/Core/ApplicationSettings/SafeClientSettings.cs @@ -337,5 +337,45 @@ public bool DisplayNumberBeforeParameterDescription return clientSettings.DisplayNumberBeforeParameterDescription; } } + + public bool DisplayParameterOrderInDescription + { + get + { + return clientSettings.DisplayParameterOrderInDescription; + } + } + + public int GUIInspectMaxSiblings + { + get + { + return clientSettings.GUIInspectMaxSiblings; + } + } + + public int GUIInspectMaxDepth + { + get + { + return clientSettings.GUIInspectMaxDepth; + } + } + + public int GUIInspectSearchTime + { + get + { + return clientSettings.GUIInspectSearchTime; + } + } + + public int GUIInspectMouseInterval + { + get + { + return clientSettings.GUIInspectMouseInterval; + } + } } } diff --git a/taskt/Core/ApplicationSettings/SafeEngineSettings.cs b/taskt/Core/ApplicationSettings/SafeEngineSettings.cs index 642f73755..da79789e3 100644 --- a/taskt/Core/ApplicationSettings/SafeEngineSettings.cs +++ b/taskt/Core/ApplicationSettings/SafeEngineSettings.cs @@ -235,19 +235,19 @@ public int MaxFileCounter return engineSettings.MaxFileCounter; } } - public int MaxUIElementInpectDepth - { - get - { - return engineSettings.MaxUIElementInpectDepth; - } - } - public int MaxUIElementInspectSiblingNodes - { - get - { - return engineSettings.MaxUIElementInspectSiblingNodes; - } - } + //public int MaxUIElementInpectDepth + //{ + // get + // { + // return engineSettings.MaxUIElementInpectDepth; + // } + //} + //public int MaxUIElementInspectSiblingNodes + //{ + // get + // { + // return engineSettings.MaxUIElementInspectSiblingNodes; + // } + //} } } diff --git a/taskt/Core/Automation/Commands/API/ExecuteDLLCommand.cs b/taskt/Core/Automation/Commands/APIGroup/ExecuteDLLCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/API/ExecuteDLLCommand.cs rename to taskt/Core/Automation/Commands/APIGroup/ExecuteDLLCommand.cs diff --git a/taskt/Core/Automation/Commands/API/HTTPExecuteRESTAPICommand.cs b/taskt/Core/Automation/Commands/APIGroup/HTTPExecuteRESTAPICommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/API/HTTPExecuteRESTAPICommand.cs rename to taskt/Core/Automation/Commands/APIGroup/HTTPExecuteRESTAPICommand.cs diff --git a/taskt/Core/Automation/Commands/API/HTTPSendHTTPRequestCommand.cs b/taskt/Core/Automation/Commands/APIGroup/HTTPSendHTTPRequestCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/API/HTTPSendHTTPRequestCommand.cs rename to taskt/Core/Automation/Commands/APIGroup/HTTPSendHTTPRequestCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/ACompileCSharpSomethingCommands.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ACompileCSharpSomethingCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/ACompileCSharpSomethingCommands.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ACompileCSharpSomethingCommands.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/ARunCSharpSomethingCommands.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ARunCSharpSomethingCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/ARunCSharpSomethingCommands.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ARunCSharpSomethingCommands.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/ARunScriptByCodeCommands.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ARunScriptByCodeCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/ARunScriptByCodeCommands.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ARunScriptByCodeCommands.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/ARunScriptFileCommands.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ARunScriptFileCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/ARunScriptFileCommands.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ARunScriptFileCommands.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/AScriptFileCommands.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/AScriptFileCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/AScriptFileCommands.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/AScriptFileCommands.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/CSharpCodeFileControls.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/CSharpCodeFileControls.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/CSharpCodeFileControls.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/CSharpCodeFileControls.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/CompileCSharpCodeCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/CompileCSharpCodeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/CompileCSharpCodeCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/CompileCSharpCodeCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/CompileCSharpFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/CompileCSharpFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/CompileCSharpFileCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/CompileCSharpFileCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/ICSharpCompileProperties.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ICSharpCompileProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/ICSharpCompileProperties.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/ICSharpCompileProperties.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/LoadScriptFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/LoadScriptFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/LoadScriptFileCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/LoadScriptFileCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/OpenFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/OpenFileCommand.cs new file mode 100644 index 000000000..3f01df950 --- /dev/null +++ b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/OpenFileCommand.cs @@ -0,0 +1,103 @@ +using System; +using System.Diagnostics; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Application/Script")] + [Attributes.ClassAttributes.SubGruop("File/Folder")] + [Attributes.ClassAttributes.CommandSettings("Open File")] + [Attributes.ClassAttributes.Description("This command opens the specified file")] + [Attributes.ClassAttributes.UsesDescription("Use this command to open the specified file")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_files))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class OpenFileCommand : AFileExistsFilePathPathResultCommands + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time until Folder Opens")] + [PropertyIsOptional(true, "2")] + [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyFirstValue("2")] + [PropertyDisplayText(true, "Wait Time for Open")] + [PropertyParameterOrder(7000)] + public string v_WaitTimeForOpen { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + [PropertyParameterOrder(20100)] + public string v_WindowNameResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + [PropertyParameterOrder(20200)] + public string v_WindowHandleResult { get; set; } + + [XmlAttribute] + [PropertyDisplayText(true, "Wait Time for File")] + public override string v_WaitTimeForFile { get; set; } + + public OpenFileCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.FileAction(engine, + new Func(path => + { + using (var p = new Process()) + { + p.StartInfo = new ProcessStartInfo() + { + UseShellExecute = true, + FileName= path, + }; + p.Start(); + + // wait time to open + var wait = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeForOpen), engine); + System.Threading.Thread.Sleep(wait * 1000); + + string newWindowName; + IntPtr newWindowHandle; + if (p.MainWindowHandle == IntPtr.Zero) + { + newWindowHandle = EM_CanHandleWindowHandleExtentionMethods.GetActiveWindowHandle(); + using (var n = new InnerScriptVariable(engine)) + { + var getName = new GetWindowNameFromWindowHandleCommand() + { + v_WindowHandle = newWindowHandle.ToString(), + v_WindowNameResult = n.VariableName, + }; + getName.RunCommand(engine); + newWindowName = n.VariableValue.ToString(); + } + } + else + { + newWindowName = p.MainWindowTitle; + newWindowHandle = p.MainWindowHandle; + } + + if (!string.IsNullOrEmpty(v_WindowNameResult)) + { + newWindowName.StoreInUserVariable(engine, v_WindowNameResult); + } + if (!string.IsNullOrEmpty(v_WindowHandleResult)) + { + newWindowHandle.StoreInUserVariable(engine, v_WindowHandleResult); + } + } + return path; + }) + ); + } + } +} diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/OpenFolderCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/OpenFolderCommand.cs new file mode 100644 index 000000000..0d802f223 --- /dev/null +++ b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/OpenFolderCommand.cs @@ -0,0 +1,96 @@ +using System; +using System.Diagnostics; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Application/Script")] + [Attributes.ClassAttributes.SubGruop("File/Folder")] + [Attributes.ClassAttributes.CommandSettings("Open Folder")] + [Attributes.ClassAttributes.Description("This command opens the specified folder")] + [Attributes.ClassAttributes.UsesDescription("Use this command to open the specified folder")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_files))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class OpenFolderCommand : AFolderExistsFolderPathPathResultCommands + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time until Folder Opens")] + [PropertyIsOptional(true, "1")] + [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyFirstValue("1")] + [PropertyDisplayText(true, "Wait Time for Open")] + [PropertyParameterOrder(7000)] + public string v_WaitTimeForOpen { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + [PropertyParameterOrder(20100)] + public string v_WindowNameResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + [PropertyParameterOrder(20200)] + public string v_WindowHandleResult { get; set; } + + [XmlAttribute] + [PropertyDisplayText(true, "Wait Time for Folder")] + public override string v_WaitTimeForFolder { get; set; } + + /// + /// explorer process name + /// + private const string ExplorerProcessName = "explorer"; + + public OpenFolderCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.FolderAction(engine, + new Func(path => + { + var procInfo = new ProcessStartInfo() + { + UseShellExecute = true, + Verb = "Open", + FileName = path, + }; + Process.Start(procInfo); + + // wait time to open + var wait = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeForOpen), engine); + System.Threading.Thread.Sleep(wait * 1000); + + var currentHandle = EM_CanHandleWindowHandleExtentionMethods.GetActiveWindowHandle(); + + if (!string.IsNullOrEmpty(v_WindowNameResult)) + { + using (var name = new InnerScriptVariable(engine)) + { + var getName = new GetWindowNameFromWindowHandleCommand() + { + v_WindowHandle = currentHandle.ToString(), + v_WindowNameResult = name.VariableName, + }; + getName.RunCommand(engine); + name.VariableValue.ToString().StoreInUserVariable(engine, v_WindowNameResult); + } + } + if (!string.IsNullOrEmpty(v_WindowHandleResult)) + { + currentHandle.StoreInUserVariable(engine, v_WindowHandleResult); + } + + return path; + }) + ); + } + } +} diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunBatchScriptByCodeCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunBatchScriptByCodeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/RunBatchScriptByCodeCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunBatchScriptByCodeCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunBatchScriptFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunBatchScriptFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/RunBatchScriptFileCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunBatchScriptFileCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunCSharpCodeCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunCSharpCodeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/RunCSharpCodeCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunCSharpCodeCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunCSharpFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunCSharpFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/RunCSharpFileCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunCSharpFileCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunJavaScriptByCodeCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunJavaScriptByCodeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/RunJavaScriptByCodeCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunJavaScriptByCodeCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunJavaScriptFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunJavaScriptFileCommand.cs similarity index 92% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/RunJavaScriptFileCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunJavaScriptFileCommand.cs index 1b96d277b..7610536ad 100644 --- a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunJavaScriptFileCommand.cs +++ b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunJavaScriptFileCommand.cs @@ -63,18 +63,17 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) var webInstance = new SeleniumBrowserCreateWebBrowserInstanceCommand() { v_InstanceName = instanceVar, - v_EngineType = "Edge", + v_BrowserType = "Edge", v_HeadlessMode = "Yes", }; webInstance.RunCommand(engine); - var executeJS = new SeleniumBrowserExecuteScriptCommand() + var executeJS = new SeleniumBrowserExecuteJavaScriptFromFileCommand() { v_InstanceName = instanceVar, - v_CodeType = "File", - v_ScriptCode = filePath, - v_Args = this.v_Arguments, - v_userVariableName = this.v_Result, + v_FilePath = filePath, + v_Arguments = this.v_Arguments, + v_Result = this.v_Result, }; executeJS.RunCommand(engine); diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunPowerShellScriptByCodeCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunPowerShellScriptByCodeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/RunPowerShellScriptByCodeCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunPowerShellScriptByCodeCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunPowerShellScriptFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunPowerShellScriptFileCommand.cs similarity index 99% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/RunPowerShellScriptFileCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunPowerShellScriptFileCommand.cs index 567e90aa2..bb4e38907 100644 --- a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunPowerShellScriptFileCommand.cs +++ b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunPowerShellScriptFileCommand.cs @@ -165,7 +165,7 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) UseShellExecute = false, RedirectStandardOutput = true }; - var proc = Process.Start(startInfo); + var proc = System.Diagnostics.Process.Start(startInfo); // url: https://stackoverflow.com/questions/2285288/calling-a-ruby-script-in-c-sharp/12848337#12848337 var reader = proc.StandardOutput; diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/RunScriptFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunScriptFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/RunScriptFileCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/RunScriptFileCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/StartApplicationCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/StartApplicationCommand.cs similarity index 74% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/StartApplicationCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/StartApplicationCommand.cs index 39725022d..5bbc03f36 100644 --- a/taskt/Core/Automation/Commands/ApplicationScriptFile/StartApplicationCommand.cs +++ b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/StartApplicationCommand.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; using taskt.Core.Script; @@ -103,35 +104,29 @@ public StartApplicationCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { // local start process func - System.Diagnostics.Process StartProcess(string name, string arguments) + Process StartProcess(string name, string arguments, bool shell) { - if (string.IsNullOrEmpty(arguments)) + var proc = new Process(); + proc.StartInfo.FileName = name; + if (!string.IsNullOrEmpty(arguments)) { - return System.Diagnostics.Process.Start(name); - } - else - { - return System.Diagnostics.Process.Start(name, arguments); + proc.StartInfo.Arguments = arguments; } + proc.StartInfo.UseShellExecute = shell; + proc.Start(); + + return proc; } var args = v_Arguments.ExpandValueOrUserVariable(engine); - System.Diagnostics.Process p; + Process p; try { // consider the application name is specified var appName = v_ApplicationPath.ExpandValueOrUserVariable(engine); - //if (string.IsNullOrEmpty(args)) - //{ - // p = System.Diagnostics.Process.Start(appName); - //} - //else - //{ - // p = System.Diagnostics.Process.Start(appName, args); - //} - p = StartProcess(appName, args); + p = StartProcess(appName, args, false); } catch { @@ -148,40 +143,65 @@ System.Diagnostics.Process StartProcess(string name, string arguments) }; fileExists.RunCommand(engine); } - p = StartProcess(filePath, args); + p = StartProcess(filePath, args, false); } var waitTimeUntil = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeForExecute), engine); System.Threading.Thread.Sleep(waitTimeUntil); - // process name - if (!string.IsNullOrEmpty(v_StartedProcessName)) - { - p.ProcessName.StoreInUserVariable(engine, v_StartedProcessName); - } - // window name - if (!string.IsNullOrEmpty(v_WindowName)) + // current window handle + if (!string.IsNullOrEmpty(v_StartedProcessName) || !string.IsNullOrEmpty(v_WindowName) || + !string.IsNullOrEmpty(v_WindowHandle)) { - p.MainWindowTitle.StoreInUserVariable(engine, v_WindowName); - } - // window handle - if (!string.IsNullOrEmpty(v_WindowHandle)) - { - p.MainWindowHandle.StoreInUserVariable(engine, v_WindowHandle); - } - - //var waitForExit = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WaitForExit), engine); - //if (waitForExit == "yes") - //{ - // p.WaitForExit(); - //} + var currentHandle = (p.MainWindowHandle != IntPtr.Zero) ? p.MainWindowHandle : EM_CanHandleWindowHandleExtentionMethods.GetActiveWindowHandle(); + // process name + if (!string.IsNullOrEmpty(v_StartedProcessName)) + { + using (var proc = new InnerScriptVariable(engine)) + { + var getProc = new GetProcessNameFromWindowHandleCommand() + { + v_WindowHandle = currentHandle.ToString(), + v_Result = proc.VariableName, + }; + getProc.RunCommand(engine); + proc.VariableValue.ToString().StoreInUserVariable(engine, v_StartedProcessName); + } + } + // window name + if (!string.IsNullOrEmpty(v_WindowName)) + { + if (p.MainWindowHandle != IntPtr.Zero) + { + p.MainWindowTitle.StoreInUserVariable(engine, v_WindowName); + } + else + { + using (var name = new InnerScriptVariable(engine)) + { + var getName = new GetWindowNameFromWindowHandleCommand() + { + v_WindowHandle = currentHandle.ToString(), + v_WindowNameResult = name.VariableName, + }; + getName.RunCommand(engine); + name.VariableValue.ToString().StoreInUserVariable(engine, v_WindowName); + } + } + } + // window handle + if (!string.IsNullOrEmpty(v_WindowHandle)) + { + currentHandle.StoreInUserVariable(engine, v_WindowHandle); + } + } + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_WaitForExit), engine)) { p.WaitForExit(); } - //System.Threading.Thread.Sleep(2000); var waitTimeBeforeNext = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeBeforeNext), engine); System.Threading.Thread.Sleep(waitTimeBeforeNext); } diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/StopApplicationCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/StopApplicationCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/StopApplicationCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/StopApplicationCommand.cs index ca6afde6d..2d2276903 100644 --- a/taskt/Core/Automation/Commands/ApplicationScriptFile/StopApplicationCommand.cs +++ b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/StopApplicationCommand.cs @@ -61,7 +61,7 @@ private void lnkProcessSelector_Click(object sender, EventArgs e) { if (fm.ShowDialog() == DialogResult.OK) { - txt.Text = fm.selectedItem.ToString(); + txt.Text = fm.SelectedItem.ToString(); } } } diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/StopCurrentScriptFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/StopCurrentScriptFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/StopCurrentScriptFileCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/StopCurrentScriptFileCommand.cs diff --git a/taskt/Core/Automation/Commands/ApplicationScriptFile/UnloadScriptFileCommand.cs b/taskt/Core/Automation/Commands/ApplicationScriptFileGroup/UnloadScriptFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/ApplicationScriptFile/UnloadScriptFileCommand.cs rename to taskt/Core/Automation/Commands/ApplicationScriptFileGroup/UnloadScriptFileCommand.cs diff --git a/taskt/Core/Automation/Commands/Color/AColorCreateCommands.cs b/taskt/Core/Automation/Commands/ColorGroup/AColorCreateCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Color/AColorCreateCommands.cs rename to taskt/Core/Automation/Commands/ColorGroup/AColorCreateCommands.cs diff --git a/taskt/Core/Automation/Commands/Color/ConvertColorCommand.cs b/taskt/Core/Automation/Commands/ColorGroup/ConvertColorCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Color/ConvertColorCommand.cs rename to taskt/Core/Automation/Commands/ColorGroup/ConvertColorCommand.cs diff --git a/taskt/Core/Automation/Commands/Color/CreateColorCommand.cs b/taskt/Core/Automation/Commands/ColorGroup/CreateColorCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Color/CreateColorCommand.cs rename to taskt/Core/Automation/Commands/ColorGroup/CreateColorCommand.cs diff --git a/taskt/Core/Automation/Commands/Color/CreateColorFormARGBNumberCommand.cs b/taskt/Core/Automation/Commands/ColorGroup/CreateColorFormARGBNumberCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Color/CreateColorFormARGBNumberCommand.cs rename to taskt/Core/Automation/Commands/ColorGroup/CreateColorFormARGBNumberCommand.cs diff --git a/taskt/Core/Automation/Commands/Color/CreateColorFormExcelColorCommand.cs b/taskt/Core/Automation/Commands/ColorGroup/CreateColorFormExcelColorCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Color/CreateColorFormExcelColorCommand.cs rename to taskt/Core/Automation/Commands/ColorGroup/CreateColorFormExcelColorCommand.cs diff --git a/taskt/Core/Automation/Commands/Color/CreateColorFormHexCommand.cs b/taskt/Core/Automation/Commands/ColorGroup/CreateColorFormHexCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Color/CreateColorFormHexCommand.cs rename to taskt/Core/Automation/Commands/ColorGroup/CreateColorFormHexCommand.cs diff --git a/taskt/Core/Automation/Commands/Color/EM_CanHandleColorExtensionMethods.cs b/taskt/Core/Automation/Commands/ColorGroup/EM_CanHandleColorExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Color/EM_CanHandleColorExtensionMethods.cs rename to taskt/Core/Automation/Commands/ColorGroup/EM_CanHandleColorExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Color/ICanHandleColor.cs b/taskt/Core/Automation/Commands/ColorGroup/ICanHandleColor.cs similarity index 67% rename from taskt/Core/Automation/Commands/Color/ICanHandleColor.cs rename to taskt/Core/Automation/Commands/ColorGroup/ICanHandleColor.cs index e97b62c41..ac5634324 100644 --- a/taskt/Core/Automation/Commands/Color/ICanHandleColor.cs +++ b/taskt/Core/Automation/Commands/ColorGroup/ICanHandleColor.cs @@ -3,7 +3,7 @@ /// /// for Color Variable type /// - public interface ICanHandleColor : ILExpandableProperties + public interface ICanHandleColor : IExpandableProperties { } } diff --git a/taskt/Core/Automation/Commands/Color/IColorCreateProperties.cs b/taskt/Core/Automation/Commands/ColorGroup/IColorCreateProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Color/IColorCreateProperties.cs rename to taskt/Core/Automation/Commands/ColorGroup/IColorCreateProperties.cs diff --git a/taskt/Core/Automation/Commands/Color/IColorProperties.cs b/taskt/Core/Automation/Commands/ColorGroup/IColorProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Color/IColorProperties.cs rename to taskt/Core/Automation/Commands/ColorGroup/IColorProperties.cs diff --git a/taskt/Core/Automation/Commands/CommandClassesControl.cs b/taskt/Core/Automation/Commands/CommandClassesControl.cs new file mode 100644 index 000000000..5d16316ba --- /dev/null +++ b/taskt/Core/Automation/Commands/CommandClassesControl.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace taskt.Core.Automation.Commands +{ + /// + /// management commands class name and full name + /// + public static class CommandClassesControl + { + /// + /// classname & fullname dictionary + /// + private static Dictionary commandClassDic = null; + + /// + /// search base namespace + /// + private const string NSBase = "taskt.Core.Automation.Commands"; + + static CommandClassesControl() + { + CreateCommandClassDic(); + } + + /// + /// create classname and namespace dictionary + /// + private static void CreateCommandClassDic() + { + commandClassDic = new Dictionary(); + + string getClassName(Type x) + { + var fn = x.FullName; + return fn.Substring(fn.LastIndexOf('.') + 1); ; + } + + var asm = Assembly.GetExecutingAssembly(); + var types = asm.GetTypes().Where(p => + { + if (p.IsClass) + { + //// check abstract class + //if (p.IsAbstract && !p.IsSealed) + //{ + // return false; + //} + + // class, sealed class, static class + var ns = p.Namespace ?? ""; + var name = getClassName(p); + return ( + ((ns == NSBase) || (ns.StartsWith($"{NSBase}."))) && + (!name.StartsWith("EM_")) && + (!name.Contains("+<>")) + ); + } + else + { + return false; + } + }); + foreach (var t in types) + { + var full = t.FullName; + var name = getClassName(t); + if (!commandClassDic.ContainsKey(name)) + { + commandClassDic.Add(name, full); + } + else + { + throw new Exception($"Duplicate classname. class: '{name}', fullname: '{full}'"); + } + } + } + + /// + /// return class full name (commands class) + /// + /// + /// + /// + public static string GetClassFullName(string className) + { + if (commandClassDic.ContainsKey(className)) + { + return commandClassDic[className]; + } + else + { + throw new Exception($"Class Name does not exists. class: '{className}'"); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/ConditionControls.cs b/taskt/Core/Automation/Commands/ConditionControls.cs index 3f01b5c6c..148e6b797 100644 --- a/taskt/Core/Automation/Commands/ConditionControls.cs +++ b/taskt/Core/Automation/Commands/ConditionControls.cs @@ -1,8 +1,8 @@ using System; -using System.Data; -using System.Windows.Forms; using System.Collections.Generic; +using System.Data; using System.Linq; +using System.Windows.Forms; using taskt.Core.Automation.Attributes.PropertyAttributes; using taskt.Core.Script; @@ -305,20 +305,62 @@ private static bool DetermineStatementTruth_WindowNameExists(DataTable actionPar var param = DataTableControls.GetFieldValues(actionParameterTable, "Parameter Name", "Parameter Value", engine); try { - IntPtr wHnd = WindowControls.FindWindowHandle(param["Window Name"], param["Search Method"], engine); - return true; + //IntPtr wHnd = WindowControls.FindWindowHandle(param["Window Name"], param["Search Method"], engine); + using (var res = new InnerScriptVariable(engine)) + { + var checkWin = new CheckWindowNameExistsCommand() + { + v_WindowName = param["Window Name"], + v_CheckMethod = param["Search Method"], + v_Result = res.VariableName, + }; + checkWin.RunCommand(engine); + + if (bool.TryParse(res.VariableValue.ToString(), out bool r)) + { + return r; + } + else + { + return false; + } + } + + //return true; } catch { return false; } } + private static bool DetermineStatementTruth_ActiveWindow(DataTable actionParameterTable, Engine.AutomationEngineInstance engine) { var param = DataTableControls.GetFieldValues(actionParameterTable, "Parameter Name", "Parameter Value", engine); - var searchFunc = WindowControls.GetWindowNameCompareMethod(param["Search Method"]); - return (searchFunc(WindowControls.GetCurrentWindowName(), param["Window Name"])); + + //var searchFunc = WindowControls.GetWindowNameCompareMethod(param["Search Method"]); + Func searchFunc; + switch (param["Search Method"].ToLower()) + { + case "starts with": + searchFunc = (a, b) => a.StartsWith(b); + break; + case "ends with": + searchFunc = (a, b) => a.EndsWith(b); + break; + case "exact match": + searchFunc = (a, b) => (a == b); + break; + case "contains": + searchFunc = (a, b) => a.Contains(b); + break; + default: + throw new Exception($"Search method '{param["Search Method"]}' is not support."); + } + + return searchFunc(EM_CanHandleWindowNameExtensionMethods.GetActiveWindowName(), param["Window Name"]); } + private static bool DetermineStatementTruth_File(DataTable actionParameterTable, Engine.AutomationEngineInstance engine) { var param = DataTableControls.GetFieldValues(actionParameterTable, "Parameter Name", "Parameter Value", engine); @@ -368,8 +410,8 @@ private static bool DetermineStatementTruth_WebElement(DataTable actionParameter var checkWebElement = new SeleniumBrowserCheckWebElementExistsCommand() { v_InstanceName = param["WebBrowser Instance Name"], - v_SeleniumSearchType = param["Element Search Method"], - v_SeleniumSearchParameter = param["Element Search Parameter"], + v_SearchMethod = param["Element Search Method"], + v_SearchParameter = param["Element Search Parameter"], //v_Result = VariableNameControls.GetInnerVariableName(0, engine), v_Result = res.VariableName, }; @@ -389,7 +431,7 @@ private static bool DetermineStatementTruth_GUIElement(DataTable actionParameter if (windowName == VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowName.VariableName, engine)) { //windowName = User32.User32Functions.GetActiveWindowTitle(); - windowName = WindowControls.GetActiveWindowTitle(); + windowName = EM_CanHandleWindowNameExtensionMethods.GetActiveWindowName(); } var searchTb = new DataTable(); @@ -421,10 +463,10 @@ private static bool DetermineStatementTruth_GUIElement(DataTable actionParameter actionTb.Columns.Add("Parameter Value"); actionTb.Rows.Add("Apply To Variable", myName.VariableName); - var checkUI = new UIAutomationUIElementActionCommand + var checkUI = new UIAutomationUIElementActionAfterSearchUIElementFromWindowNameCommand { v_WindowName = windowName, - v_UIASearchParameters = searchTb, + v_SearchParameters = searchTb, v_AutomationType = "Check UIElement Exists", v_UIAActionParameters = actionTb, }; diff --git a/taskt/Core/Automation/Commands/Data/HTMLGetHTMLTextByXPath.cs b/taskt/Core/Automation/Commands/DataGroup/HTMLGetHTMLTextByXPath.cs similarity index 100% rename from taskt/Core/Automation/Commands/Data/HTMLGetHTMLTextByXPath.cs rename to taskt/Core/Automation/Commands/DataGroup/HTMLGetHTMLTextByXPath.cs diff --git a/taskt/Core/Automation/Commands/Data/LogDataCommand.cs b/taskt/Core/Automation/Commands/DataGroup/LogDataCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Data/LogDataCommand.cs rename to taskt/Core/Automation/Commands/DataGroup/LogDataCommand.cs diff --git a/taskt/Core/Automation/Commands/Data/PDFTextExtractionCommand.cs b/taskt/Core/Automation/Commands/DataGroup/PDFTextExtractionCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Data/PDFTextExtractionCommand.cs rename to taskt/Core/Automation/Commands/DataGroup/PDFTextExtractionCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/IDataTableColumnProperties.cs b/taskt/Core/Automation/Commands/DataTable/IDataTableColumnProperties.cs deleted file mode 100644 index 3114c86bb..000000000 --- a/taskt/Core/Automation/Commands/DataTable/IDataTableColumnProperties.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace taskt.Core.Automation.Commands -{ - public interface IDataTableColumnProperties : ILDataTableProperties, ILDataTableColumnPositionProperties - { - // only imple - } -} diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableBothColumnCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableBothColumnCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ADataTableBothColumnCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableBothColumnCommands.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableBothDataTableCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableBothDataTableCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ADataTableBothDataTableCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableBothDataTableCommands.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableBothRowCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableBothRowCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ADataTableBothRowCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableBothRowCommands.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableColumnCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableColumnCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ADataTableColumnCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableColumnCommands.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableColumnRowCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableColumnRowCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ADataTableColumnRowCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableColumnRowCommands.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableCreateFromDataTableCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableCreateFromDataTableCommands.cs similarity index 92% rename from taskt/Core/Automation/Commands/DataTable/ADataTableCreateFromDataTableCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableCreateFromDataTableCommands.cs index be0971088..a38447d81 100644 --- a/taskt/Core/Automation/Commands/DataTable/ADataTableCreateFromDataTableCommands.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableCreateFromDataTableCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for Create From DataTable commands /// - public abstract class ADataTableCreateFromDataTableCommands : ScriptCommand, ILDataTableCreateFromDataTableProperties + public abstract class ADataTableCreateFromDataTableCommands : ScriptCommand, IDataTableCreateFromDataTableProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_InputDataTableName))] diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableGetFromDataTableColumnCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableGetFromDataTableColumnCommands.cs similarity index 89% rename from taskt/Core/Automation/Commands/DataTable/ADataTableGetFromDataTableColumnCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableGetFromDataTableColumnCommands.cs index a03c579fd..dbad1ca19 100644 --- a/taskt/Core/Automation/Commands/DataTable/ADataTableGetFromDataTableColumnCommands.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableGetFromDataTableColumnCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for Get Something From DataTable Column commands /// - public abstract class ADataTableGetFromDataTableColumnCommands : ADataTableColumnCommands, ILResultProperties + public abstract class ADataTableGetFromDataTableColumnCommands : ADataTableColumnCommands, IResultProperties { [XmlAttribute] [PropertyParameterOrder(10000)] diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableGetFromDataTableCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableGetFromDataTableCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ADataTableGetFromDataTableCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableGetFromDataTableCommands.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableGetFromDataTableRowCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableGetFromDataTableRowCommands.cs similarity index 90% rename from taskt/Core/Automation/Commands/DataTable/ADataTableGetFromDataTableRowCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableGetFromDataTableRowCommands.cs index 3248e27c2..b9aedecc0 100644 --- a/taskt/Core/Automation/Commands/DataTable/ADataTableGetFromDataTableRowCommands.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableGetFromDataTableRowCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for Get From DataTable Row commands /// - public abstract class ADataTableGetFromDataTableRowCommands : ADataTableRowCommands, ILResultProperties + public abstract class ADataTableGetFromDataTableRowCommands : ADataTableRowCommands, IResultProperties { [XmlAttribute] [PropertyParameterOrder(10000)] diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableInputDataTableCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableInputDataTableCommands.cs similarity index 93% rename from taskt/Core/Automation/Commands/DataTable/ADataTableInputDataTableCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableInputDataTableCommands.cs index 8692b040b..079e0ae8f 100644 --- a/taskt/Core/Automation/Commands/DataTable/ADataTableInputDataTableCommands.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableInputDataTableCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for Input DataTable commands /// - public abstract class ADataTableInputDataTableCommands : ScriptCommand, ILDataTableProperties + public abstract class ADataTableInputDataTableCommands : ScriptCommand, IDataTableProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_InputDataTableName))] diff --git a/taskt/Core/Automation/Commands/DataTable/ADataTableRowCommands.cs b/taskt/Core/Automation/Commands/DataTableGroup/ADataTableRowCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ADataTableRowCommands.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ADataTableRowCommands.cs diff --git a/taskt/Core/Automation/Commands/DataTable/AddDataTableColumnCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/AddDataTableColumnCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/AddDataTableColumnCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/AddDataTableColumnCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/AddDataTableRowByDictionaryCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/AddDataTableRowByDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/AddDataTableRowByDictionaryCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/AddDataTableRowByDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/AddDataTableRowCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/AddDataTableRowCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/AddDataTableRowCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/AddDataTableRowCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/AddDataTableRowsByDataTableCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/AddDataTableRowsByDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/AddDataTableRowsByDataTableCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/AddDataTableRowsByDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/CheckDataTableColumnExistsCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/CheckDataTableColumnExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/CheckDataTableColumnExistsCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/CheckDataTableColumnExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToDataTableCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToDataTableCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToDictionaryCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToDictionaryCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToJSONCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToJSONCommand.cs similarity index 99% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToJSONCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToJSONCommand.cs index e5015a064..c8cf0e66e 100644 --- a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToJSONCommand.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToJSONCommand.cs @@ -75,8 +75,6 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) var json = Newtonsoft.Json.JsonConvert.SerializeObject(EM_CanHandleListExtensionMethods.ExpandUserVariableAsList(myList)); json.StoreInUserVariable(engine, v_Result); } - - int v = 3; } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToListCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToListCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToListCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToTextCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableColumnToTextCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableColumnToTextCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToDataTableCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToDataTableCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToDictionaryCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToDictionaryCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToJSONCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToJSONCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToJSONCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToJSONCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToListCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToListCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToListCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToTextCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableRowToTextCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableRowToTextCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableToJSONCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableToJSONCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableToJSONCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableToJSONCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableToTextCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableToTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableToTextCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableToTextCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ConvertDataTableToVisualizedTextCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableToVisualizedTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ConvertDataTableToVisualizedTextCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ConvertDataTableToVisualizedTextCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/CopyDataTableCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/CopyDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/CopyDataTableCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/CopyDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/CreateDataTableCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/CreateDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/CreateDataTableCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/CreateDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/DeleteDataTableColumnCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/DeleteDataTableColumnCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/DeleteDataTableColumnCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/DeleteDataTableColumnCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/DeleteDataTableRowCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/DeleteDataTableRowCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/DeleteDataTableRowCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/DeleteDataTableRowCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/EM_CanHandleDataTable.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_CanHandleDataTable.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/EM_CanHandleDataTable.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_CanHandleDataTable.cs diff --git a/taskt/Core/Automation/Commands/DataTable/EM_DataTableColumnPositionPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableColumnPositionPropertiesExtensionMethods.cs similarity index 94% rename from taskt/Core/Automation/Commands/DataTable/EM_DataTableColumnPositionPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableColumnPositionPropertiesExtensionMethods.cs index 915841af5..7cea98c8f 100644 --- a/taskt/Core/Automation/Commands/DataTable/EM_DataTableColumnPositionPropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableColumnPositionPropertiesExtensionMethods.cs @@ -13,7 +13,7 @@ public static class EM_DataTableColumnPositionPropertiesExtensionMethods /// /// /// - public static (int, string) ExpandValueOrUserVariableAsDataTableColumn(this ILDataTableColumnPositionProperties command, DataTable table, Engine.AutomationEngineInstance engine) + public static (int, string) ExpandValueOrUserVariableAsDataTableColumn(this IDataTableColumnPositionProperties command, DataTable table, Engine.AutomationEngineInstance engine) { var sc = command.ToScriptCommand(); diff --git a/taskt/Core/Automation/Commands/DataTable/EM_DataTableColumnPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableColumnPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/EM_DataTableColumnPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableColumnPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/DataTable/EM_DataTableColumnRowPositionPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableColumnRowPositionPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/EM_DataTableColumnRowPositionPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableColumnRowPositionPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/DataTable/EM_DataTableCreateFromDataTableExtensionMethods.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableCreateFromDataTableExtensionMethods.cs similarity index 77% rename from taskt/Core/Automation/Commands/DataTable/EM_DataTableCreateFromDataTableExtensionMethods.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableCreateFromDataTableExtensionMethods.cs index 5e82a4774..8b5c1cfa8 100644 --- a/taskt/Core/Automation/Commands/DataTable/EM_DataTableCreateFromDataTableExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableCreateFromDataTableExtensionMethods.cs @@ -10,7 +10,7 @@ public static class EM_DataTableCreateFromDataTableExtensionMethods /// /// /// - public static DataTable ExpandUserVariableAsDataTable(this ILDataTableCreateFromDataTableProperties command, Engine.AutomationEngineInstance engine) + public static DataTable ExpandUserVariableAsDataTable(this IDataTableCreateFromDataTableProperties command, Engine.AutomationEngineInstance engine) { return command.ExpandUserVariableAsDataTable(nameof(command.v_TargetDataTable), engine); } @@ -21,7 +21,7 @@ public static DataTable ExpandUserVariableAsDataTable(this ILDataTableCreateFrom /// /// /// - public static void StoreDataTableInUserVariable(this ILDataTableCreateFromDataTableProperties command, DataTable table, Engine.AutomationEngineInstance engine) + public static void StoreDataTableInUserVariable(this IDataTableCreateFromDataTableProperties command, DataTable table, Engine.AutomationEngineInstance engine) { command.StoreDataTableInUserVariable(table, nameof(command.v_NewDataTable), engine); } diff --git a/taskt/Core/Automation/Commands/DataTable/EM_DataTableExtensionMethods.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/EM_DataTableExtensionMethods.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/DataTable/EM_DataTablePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTablePropertiesExtensionMethods.cs similarity index 87% rename from taskt/Core/Automation/Commands/DataTable/EM_DataTablePropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_DataTablePropertiesExtensionMethods.cs index 640e0f01c..3199e7b0b 100644 --- a/taskt/Core/Automation/Commands/DataTable/EM_DataTablePropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTablePropertiesExtensionMethods.cs @@ -10,7 +10,7 @@ public static class EM_DataTablePropertiesExtensionMethods /// /// /// - public static DataTable ExpandUserVariableAsDataTable(this ILDataTableProperties command, Engine.AutomationEngineInstance engine) + public static DataTable ExpandUserVariableAsDataTable(this IDataTableProperties command, Engine.AutomationEngineInstance engine) { return command.ExpandUserVariableAsDataTable(nameof(command.v_DataTable), engine); } diff --git a/taskt/Core/Automation/Commands/DataTable/EM_DataTableResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableResultPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/EM_DataTableResultPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableResultPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/DataTable/EM_DataTableRowPositionPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableRowPositionPropertiesExtensionMethods.cs similarity index 92% rename from taskt/Core/Automation/Commands/DataTable/EM_DataTableRowPositionPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableRowPositionPropertiesExtensionMethods.cs index 14f9f0dfd..ca6bb0502 100644 --- a/taskt/Core/Automation/Commands/DataTable/EM_DataTableRowPositionPropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableRowPositionPropertiesExtensionMethods.cs @@ -13,7 +13,7 @@ public static class EM_DataTableRowPositionPropertiesExtensionMethods /// /// /// - public static int ExpandValueOrUserVariableAsDataTableRow(this ILDataTableRowPositionProperties command, DataTable table, Engine.AutomationEngineInstance engine) + public static int ExpandValueOrUserVariableAsDataTableRow(this IDataTableRowPositionProperties command, DataTable table, Engine.AutomationEngineInstance engine) { // fix if row index empty if (string.IsNullOrEmpty(command.v_RowIndex)) diff --git a/taskt/Core/Automation/Commands/DataTable/EM_DataTableRowPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableRowPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/EM_DataTableRowPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DataTableGroup/EM_DataTableRowPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ExportDataTableAsTextFileCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ExportDataTableAsTextFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ExportDataTableAsTextFileCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ExportDataTableAsTextFileCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ExportDataTableColumnAsTextFileCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ExportDataTableColumnAsTextFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ExportDataTableColumnAsTextFileCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ExportDataTableColumnAsTextFileCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ExportDataTableRowAsTextFileCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ExportDataTableRowAsTextFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/ExportDataTableRowAsTextFileCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ExportDataTableRowAsTextFileCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/FilterDataTableColumnByRowValueCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/FilterDataTableColumnByRowValueCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/DataTable/FilterDataTableColumnByRowValueCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/FilterDataTableColumnByRowValueCommand.cs index f504e2ed6..952d21487 100644 --- a/taskt/Core/Automation/Commands/DataTable/FilterDataTableColumnByRowValueCommand.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/FilterDataTableColumnByRowValueCommand.cs @@ -16,7 +16,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class FilterDataTableColumnByRowValueCommand : ADataTableCreateFromDataTableCommands, ILDataTableRowPositionProperties, ILFilterValueProperties, IHaveDataTableElements + public sealed class FilterDataTableColumnByRowValueCommand : ADataTableCreateFromDataTableCommands, IDataTableRowPositionProperties, IFilterValueProperties, IHaveDataTableElements { [XmlAttribute] //[PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_InputDataTableName))] diff --git a/taskt/Core/Automation/Commands/DataTable/FilterDataTableCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/FilterDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/FilterDataTableCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/FilterDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/FilterDataTableRowByColumnValueCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/FilterDataTableRowByColumnValueCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/DataTable/FilterDataTableRowByColumnValueCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/FilterDataTableRowByColumnValueCommand.cs index 329141975..e22a4e2ef 100644 --- a/taskt/Core/Automation/Commands/DataTable/FilterDataTableRowByColumnValueCommand.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/FilterDataTableRowByColumnValueCommand.cs @@ -16,7 +16,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class FilterDataTableRowByColumnValueCommand : ADataTableCreateFromDataTableCommands, ILDataTableColumnPositionProperties, ILFilterValueProperties, IHaveDataTableElements + public sealed class FilterDataTableRowByColumnValueCommand : ADataTableCreateFromDataTableCommands, IDataTableColumnPositionProperties, IFilterValueProperties, IHaveDataTableElements { [XmlAttribute] //[PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_InputDataTableName))] diff --git a/taskt/Core/Automation/Commands/DataTable/GetDataTableColumnCountCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/GetDataTableColumnCountCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/GetDataTableColumnCountCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/GetDataTableColumnCountCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/GetDataTableColumnListCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/GetDataTableColumnListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/GetDataTableColumnListCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/GetDataTableColumnListCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/GetDataTableRowCountCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/GetDataTableRowCountCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/GetDataTableRowCountCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/GetDataTableRowCountCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/GetDataTableValueCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/GetDataTableValueCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/DataTable/GetDataTableValueCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/GetDataTableValueCommand.cs index 90d66760e..997c9f7f6 100644 --- a/taskt/Core/Automation/Commands/DataTable/GetDataTableValueCommand.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/GetDataTableValueCommand.cs @@ -14,7 +14,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetDataTableValueCommand : ADataTableColumnRowCommands, ILResultProperties + public sealed class GetDataTableValueCommand : ADataTableColumnRowCommands, IResultProperties { //[XmlAttribute] //[PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_InputDataTableName))] diff --git a/taskt/Core/Automation/Commands/DataTable/ICanHandleDataTable.cs b/taskt/Core/Automation/Commands/DataTableGroup/ICanHandleDataTable.cs similarity index 54% rename from taskt/Core/Automation/Commands/DataTable/ICanHandleDataTable.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ICanHandleDataTable.cs index 11108a4fa..fa6d94350 100644 --- a/taskt/Core/Automation/Commands/DataTable/ICanHandleDataTable.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/ICanHandleDataTable.cs @@ -1,6 +1,6 @@ namespace taskt.Core.Automation.Commands { - public interface ICanHandleDataTable : ILExpandableProperties + public interface ICanHandleDataTable : IExpandableProperties { // nothing } diff --git a/taskt/Core/Automation/Commands/DataTable/ILDataTableColumnPositionProperties.cs b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableColumnPositionProperties.cs similarity index 82% rename from taskt/Core/Automation/Commands/DataTable/ILDataTableColumnPositionProperties.cs rename to taskt/Core/Automation/Commands/DataTableGroup/IDataTableColumnPositionProperties.cs index 5c943e50d..b24ae469f 100644 --- a/taskt/Core/Automation/Commands/DataTable/ILDataTableColumnPositionProperties.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableColumnPositionProperties.cs @@ -3,7 +3,7 @@ /// /// DataTable Column Position Properties /// - public interface ILDataTableColumnPositionProperties : ILExpandableProperties + public interface IDataTableColumnPositionProperties : IExpandableProperties { /// /// Column Type (Index or ColumnName) diff --git a/taskt/Core/Automation/Commands/DataTableGroup/IDataTableColumnProperties.cs b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableColumnProperties.cs new file mode 100644 index 000000000..06e11133b --- /dev/null +++ b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableColumnProperties.cs @@ -0,0 +1,7 @@ +namespace taskt.Core.Automation.Commands +{ + public interface IDataTableColumnProperties : IDataTableProperties, IDataTableColumnPositionProperties + { + // only imple + } +} diff --git a/taskt/Core/Automation/Commands/DataTable/IDataTableColumnRowPositionProperties.cs b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableColumnRowPositionProperties.cs similarity index 52% rename from taskt/Core/Automation/Commands/DataTable/IDataTableColumnRowPositionProperties.cs rename to taskt/Core/Automation/Commands/DataTableGroup/IDataTableColumnRowPositionProperties.cs index 119960492..ca0a4d52b 100644 --- a/taskt/Core/Automation/Commands/DataTable/IDataTableColumnRowPositionProperties.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableColumnRowPositionProperties.cs @@ -3,7 +3,7 @@ /// /// DataTable Column Row specified properties /// - public interface IDataTableColumnRowPositionProperties : ILDataTableProperties, ILDataTableColumnPositionProperties, ILDataTableRowPositionProperties + public interface IDataTableColumnRowPositionProperties : IDataTableProperties, IDataTableColumnPositionProperties, IDataTableRowPositionProperties { // only imple } diff --git a/taskt/Core/Automation/Commands/DataTable/ILDataTableCreateFromDataTableProperties.cs b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableCreateFromDataTableProperties.cs similarity index 80% rename from taskt/Core/Automation/Commands/DataTable/ILDataTableCreateFromDataTableProperties.cs rename to taskt/Core/Automation/Commands/DataTableGroup/IDataTableCreateFromDataTableProperties.cs index 488be4ffd..a80ab33ef 100644 --- a/taskt/Core/Automation/Commands/DataTable/ILDataTableCreateFromDataTableProperties.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableCreateFromDataTableProperties.cs @@ -3,7 +3,7 @@ /// /// Create From DataTable properties /// - public interface ILDataTableCreateFromDataTableProperties : ILExpandableProperties, ICanHandleDataTable + public interface IDataTableCreateFromDataTableProperties : IExpandableProperties, ICanHandleDataTable { /// /// DataTable Variable Name to Create DataTable diff --git a/taskt/Core/Automation/Commands/DataTable/IDataTableGetFromDataTable.cs b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableGetFromDataTable.cs similarity index 72% rename from taskt/Core/Automation/Commands/DataTable/IDataTableGetFromDataTable.cs rename to taskt/Core/Automation/Commands/DataTableGroup/IDataTableGetFromDataTable.cs index 709ffd6ac..0f491d27e 100644 --- a/taskt/Core/Automation/Commands/DataTable/IDataTableGetFromDataTable.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableGetFromDataTable.cs @@ -3,7 +3,7 @@ /// /// Get something from DataTable properties /// - public interface IDataTableGetFromDataTable : ILResultProperties + public interface IDataTableGetFromDataTable : IResultProperties { // string v_Result { get;set;} } diff --git a/taskt/Core/Automation/Commands/DataTable/ILDataTableProperties.cs b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableProperties.cs similarity index 73% rename from taskt/Core/Automation/Commands/DataTable/ILDataTableProperties.cs rename to taskt/Core/Automation/Commands/DataTableGroup/IDataTableProperties.cs index aa7bab118..7cdd717a4 100644 --- a/taskt/Core/Automation/Commands/DataTable/ILDataTableProperties.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableProperties.cs @@ -3,7 +3,7 @@ /// /// DataTable properties /// - public interface ILDataTableProperties : ICanHandleDataTable, ILExpandableProperties + public interface IDataTableProperties : ICanHandleDataTable, IExpandableProperties { /// /// DataTable variabe name diff --git a/taskt/Core/Automation/Commands/DataTable/IDataTableResultProperties.cs b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableResultProperties.cs similarity index 63% rename from taskt/Core/Automation/Commands/DataTable/IDataTableResultProperties.cs rename to taskt/Core/Automation/Commands/DataTableGroup/IDataTableResultProperties.cs index 0594d71a7..1564ed6ff 100644 --- a/taskt/Core/Automation/Commands/DataTable/IDataTableResultProperties.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableResultProperties.cs @@ -3,7 +3,7 @@ /// /// Result is DataTable properties /// - public interface IDataTableResultProperties : ILResultProperties, ICanHandleDataTable + public interface IDataTableResultProperties : IResultProperties, ICanHandleDataTable { // only imple } diff --git a/taskt/Core/Automation/Commands/DataTable/ILDataTableRowPositionProperties.cs b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableRowPositionProperties.cs similarity index 76% rename from taskt/Core/Automation/Commands/DataTable/ILDataTableRowPositionProperties.cs rename to taskt/Core/Automation/Commands/DataTableGroup/IDataTableRowPositionProperties.cs index 65ab210e7..e38417096 100644 --- a/taskt/Core/Automation/Commands/DataTable/ILDataTableRowPositionProperties.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableRowPositionProperties.cs @@ -3,7 +3,7 @@ /// /// DataTable Row Position Properties /// - public interface ILDataTableRowPositionProperties : ILExpandableProperties + public interface IDataTableRowPositionProperties : IExpandableProperties { /// /// DataTable Row Index diff --git a/taskt/Core/Automation/Commands/DataTable/IDataTableRowProperties.cs b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableRowProperties.cs similarity index 59% rename from taskt/Core/Automation/Commands/DataTable/IDataTableRowProperties.cs rename to taskt/Core/Automation/Commands/DataTableGroup/IDataTableRowProperties.cs index 53e3a9f05..3b5686630 100644 --- a/taskt/Core/Automation/Commands/DataTable/IDataTableRowProperties.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/IDataTableRowProperties.cs @@ -3,7 +3,7 @@ /// /// DataTable Row Properties /// - public interface IDataTableRowProperties : ILDataTableProperties, ILDataTableRowPositionProperties + public interface IDataTableRowProperties : IDataTableProperties, IDataTableRowPositionProperties { // no imple } diff --git a/taskt/Core/Automation/Commands/DataTable/JoinDataTableColumnAsTextCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/JoinDataTableColumnAsTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/JoinDataTableColumnAsTextCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/JoinDataTableColumnAsTextCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/JoinDataTableRowAsTextCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/JoinDataTableRowAsTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/JoinDataTableRowAsTextCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/JoinDataTableRowAsTextCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/ReplaceDataTableColumnValueCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ReplaceDataTableColumnValueCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/DataTable/ReplaceDataTableColumnValueCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ReplaceDataTableColumnValueCommand.cs index 2b74f7c40..c117f8bd2 100644 --- a/taskt/Core/Automation/Commands/DataTable/ReplaceDataTableColumnValueCommand.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/ReplaceDataTableColumnValueCommand.cs @@ -16,7 +16,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ReplaceDataTableColumnValueCommand : ADataTableColumnCommands, ILReplaceValueProperties, IHaveDataTableElements + public sealed class ReplaceDataTableColumnValueCommand : ADataTableColumnCommands, IReplaceValueProperties, IHaveDataTableElements { //[XmlAttribute] //[PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_BothDataTableName))] diff --git a/taskt/Core/Automation/Commands/DataTable/ReplaceDataTableRowValueCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ReplaceDataTableRowValueCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/DataTable/ReplaceDataTableRowValueCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ReplaceDataTableRowValueCommand.cs index d20ecaac5..406627217 100644 --- a/taskt/Core/Automation/Commands/DataTable/ReplaceDataTableRowValueCommand.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/ReplaceDataTableRowValueCommand.cs @@ -16,7 +16,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ReplaceDataTableRowValueCommand : ADataTableRowCommands, ILReplaceValueProperties, IHaveDataTableElements + public sealed class ReplaceDataTableRowValueCommand : ADataTableRowCommands, IReplaceValueProperties, IHaveDataTableElements { //[XmlAttribute] //[PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_BothDataTableName))] diff --git a/taskt/Core/Automation/Commands/DataTable/ReplaceDataTableValueCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/ReplaceDataTableValueCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/DataTable/ReplaceDataTableValueCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/ReplaceDataTableValueCommand.cs index 8a9a9ab67..20c285fc5 100644 --- a/taskt/Core/Automation/Commands/DataTable/ReplaceDataTableValueCommand.cs +++ b/taskt/Core/Automation/Commands/DataTableGroup/ReplaceDataTableValueCommand.cs @@ -16,7 +16,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ReplaceDataTableValueCommand : ADataTableBothDataTableCommands, ILReplaceValueProperties, IHaveDataTableElements + public sealed class ReplaceDataTableValueCommand : ADataTableBothDataTableCommands, IReplaceValueProperties, IHaveDataTableElements { //[XmlAttribute] //[PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_BothDataTableName))] diff --git a/taskt/Core/Automation/Commands/DataTable/SearchAndDeleteDataTableRowsCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/SearchAndDeleteDataTableRowsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/SearchAndDeleteDataTableRowsCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/SearchAndDeleteDataTableRowsCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/SetDataTableColumnValuesByDataTableCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/SetDataTableColumnValuesByDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/SetDataTableColumnValuesByDataTableCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/SetDataTableColumnValuesByDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/SetDataTableColumnValuesByListCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/SetDataTableColumnValuesByListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/SetDataTableColumnValuesByListCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/SetDataTableColumnValuesByListCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/SetDataTableRowValuesByDataTableCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/SetDataTableRowValuesByDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/SetDataTableRowValuesByDataTableCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/SetDataTableRowValuesByDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/SetDataTableRowValuesByDictionaryCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/SetDataTableRowValuesByDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/SetDataTableRowValuesByDictionaryCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/SetDataTableRowValuesByDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/DataTable/SetDataTableValueCommand.cs b/taskt/Core/Automation/Commands/DataTableGroup/SetDataTableValueCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DataTable/SetDataTableValueCommand.cs rename to taskt/Core/Automation/Commands/DataTableGroup/SetDataTableValueCommand.cs diff --git a/taskt/Core/Automation/Commands/Database/DatabaseDefineConnectionCommand.cs b/taskt/Core/Automation/Commands/DatabaseGroup/DatabaseDefineConnectionCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Database/DatabaseDefineConnectionCommand.cs rename to taskt/Core/Automation/Commands/DatabaseGroup/DatabaseDefineConnectionCommand.cs diff --git a/taskt/Core/Automation/Commands/Database/DatabaseExecuteQueryCommand.cs b/taskt/Core/Automation/Commands/DatabaseGroup/DatabaseExecuteQueryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Database/DatabaseExecuteQueryCommand.cs rename to taskt/Core/Automation/Commands/DatabaseGroup/DatabaseExecuteQueryCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/ACalculateDateTimeCommands.cs b/taskt/Core/Automation/Commands/DateTimeGroup/ACalculateDateTimeCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/ACalculateDateTimeCommands.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/ACalculateDateTimeCommands.cs diff --git a/taskt/Core/Automation/Commands/DateTime/ADateTimeConvertCommands.cs b/taskt/Core/Automation/Commands/DateTimeGroup/ADateTimeConvertCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/ADateTimeConvertCommands.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/ADateTimeConvertCommands.cs diff --git a/taskt/Core/Automation/Commands/DateTime/ADateTimeCreateCommands.cs b/taskt/Core/Automation/Commands/DateTimeGroup/ADateTimeCreateCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/ADateTimeCreateCommands.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/ADateTimeCreateCommands.cs diff --git a/taskt/Core/Automation/Commands/DateTime/AFormatDateTimeCommands.cs b/taskt/Core/Automation/Commands/DateTimeGroup/AFormatDateTimeCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/AFormatDateTimeCommands.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/AFormatDateTimeCommands.cs diff --git a/taskt/Core/Automation/Commands/DateTime/AGetFormattedDateTimeFromCalculatedDateTimeCommands.cs b/taskt/Core/Automation/Commands/DateTimeGroup/AGetFormattedDateTimeFromCalculatedDateTimeCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/AGetFormattedDateTimeFromCalculatedDateTimeCommands.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/AGetFormattedDateTimeFromCalculatedDateTimeCommands.cs diff --git a/taskt/Core/Automation/Commands/DateTime/CalculateDateTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/CalculateDateTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/CalculateDateTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/CalculateDateTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/CalculateDateTimeFromExcelSerialCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/CalculateDateTimeFromExcelSerialCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/CalculateDateTimeFromExcelSerialCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/CalculateDateTimeFromExcelSerialCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/CalculateDateTimeFromTextCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/CalculateDateTimeFromTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/CalculateDateTimeFromTextCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/CalculateDateTimeFromTextCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/CalculateDateTimeFromUnixTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/CalculateDateTimeFromUnixTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/CalculateDateTimeFromUnixTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/CalculateDateTimeFromUnixTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/ConvertDateTimeToExcelSerialCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/ConvertDateTimeToExcelSerialCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/ConvertDateTimeToExcelSerialCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/ConvertDateTimeToExcelSerialCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/ConvertDateTimeToUnixTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/ConvertDateTimeToUnixTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/ConvertDateTimeToUnixTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/ConvertDateTimeToUnixTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/CreateDateTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/CreateDateTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/CreateDateTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/CreateDateTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/CreateDateTimeFromExcelSerialCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/CreateDateTimeFromExcelSerialCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/CreateDateTimeFromExcelSerialCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/CreateDateTimeFromExcelSerialCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/CreateDateTimeFromTextCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/CreateDateTimeFromTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/CreateDateTimeFromTextCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/CreateDateTimeFromTextCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/CreateDateTimeFromUnixTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/CreateDateTimeFromUnixTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/CreateDateTimeFromUnixTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/CreateDateTimeFromUnixTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/EM_CanHandleDateTimExtensionMethods.cs b/taskt/Core/Automation/Commands/DateTimeGroup/EM_CanHandleDateTimExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/EM_CanHandleDateTimExtensionMethods.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/EM_CanHandleDateTimExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/DateTime/EM_DateTimeConvertPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DateTimeGroup/EM_DateTimeConvertPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/EM_DateTimeConvertPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/EM_DateTimeConvertPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/DateTime/EM_DateTimeResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DateTimeGroup/EM_DateTimeResultPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/EM_DateTimeResultPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/EM_DateTimeResultPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/DateTime/FormatDateTimeByExcelSerialCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/FormatDateTimeByExcelSerialCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/FormatDateTimeByExcelSerialCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/FormatDateTimeByExcelSerialCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/FormatDateTimeByTextCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/FormatDateTimeByTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/FormatDateTimeByTextCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/FormatDateTimeByTextCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/FormatDateTimeByUnixTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/FormatDateTimeByUnixTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/FormatDateTimeByUnixTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/FormatDateTimeByUnixTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/FormatDateTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/FormatDateTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/FormatDateTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/FormatDateTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/GetDateTimeDifferencesCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/GetDateTimeDifferencesCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/GetDateTimeDifferencesCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/GetDateTimeDifferencesCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/GetFormatedDateTimeFromCalculatedDateTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/GetFormatedDateTimeFromCalculatedDateTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/GetFormatedDateTimeFromCalculatedDateTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/GetFormatedDateTimeFromCalculatedDateTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/GetFormatedDateTimeFromCalculatedExcelSerialDateTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/GetFormatedDateTimeFromCalculatedExcelSerialDateTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/GetFormatedDateTimeFromCalculatedExcelSerialDateTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/GetFormatedDateTimeFromCalculatedExcelSerialDateTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/GetFormatedDateTimeFromCalculatedTextDateTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/GetFormatedDateTimeFromCalculatedTextDateTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/GetFormatedDateTimeFromCalculatedTextDateTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/GetFormatedDateTimeFromCalculatedTextDateTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/GetFormatedDateTimeFromCalculatedUnixDateTimeCommand.cs b/taskt/Core/Automation/Commands/DateTimeGroup/GetFormatedDateTimeFromCalculatedUnixDateTimeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/GetFormatedDateTimeFromCalculatedUnixDateTimeCommand.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/GetFormatedDateTimeFromCalculatedUnixDateTimeCommand.cs diff --git a/taskt/Core/Automation/Commands/DateTime/ICanHandleDateTime.cs b/taskt/Core/Automation/Commands/DateTimeGroup/ICanHandleDateTime.cs similarity index 66% rename from taskt/Core/Automation/Commands/DateTime/ICanHandleDateTime.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/ICanHandleDateTime.cs index 6ada700f5..b4e4afa46 100644 --- a/taskt/Core/Automation/Commands/DateTime/ICanHandleDateTime.cs +++ b/taskt/Core/Automation/Commands/DateTimeGroup/ICanHandleDateTime.cs @@ -3,7 +3,7 @@ /// /// for DateTime commands /// - public interface ICanHandleDateTime : ILExpandableProperties + public interface ICanHandleDateTime : IExpandableProperties { } } diff --git a/taskt/Core/Automation/Commands/DateTime/IDateTimeConvertProperties.cs b/taskt/Core/Automation/Commands/DateTimeGroup/IDateTimeConvertProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/IDateTimeConvertProperties.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/IDateTimeConvertProperties.cs diff --git a/taskt/Core/Automation/Commands/DateTime/IDateTimeCreateProperties.cs b/taskt/Core/Automation/Commands/DateTimeGroup/IDateTimeCreateProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/IDateTimeCreateProperties.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/IDateTimeCreateProperties.cs diff --git a/taskt/Core/Automation/Commands/DateTime/IDateTimeResultProperties.cs b/taskt/Core/Automation/Commands/DateTimeGroup/IDateTimeResultProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/DateTime/IDateTimeResultProperties.cs rename to taskt/Core/Automation/Commands/DateTimeGroup/IDateTimeResultProperties.cs diff --git a/taskt/Core/Automation/Commands/DialogMessage/ShowHTMLInputDialogCommand.cs b/taskt/Core/Automation/Commands/DialogMessage/ShowHTMLInputDialogCommand.cs deleted file mode 100644 index e23b31707..000000000 --- a/taskt/Core/Automation/Commands/DialogMessage/ShowHTMLInputDialogCommand.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; -using System.Linq; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using taskt.Core.Script; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Dialog/Message")] - [Attributes.ClassAttributes.CommandSettings("Show HTML Input Dialog")] - [Attributes.ClassAttributes.Description("Allows the entry of data into a web-enabled form")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want a fancy data collection.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements 'WebBrowser Control' to achieve automation.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ShowHTMLInputDialogCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_MultiLinesTextBox))] - [PropertyDescription("HTML for the Dialog")] - [InputSpecification("HTML", true)] - [PropertyCustomUIHelper("Launch HTML Builder", nameof(ShowHTMLBuilder))] - [PropertyValidationRule("HTML", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(false, "")] - [PropertyFirstValue( -@" - - - - Please Provide Information - - - -
-
-

Directions

-

This a sample data collection form that can be presented to a user. You can add and implement as many fields as you need or choose standard form inputs. Note, each field will require a data-variable or v_applyToVariable attribute specifying which variable should contain the respective value for the input field.
-DO NOT USE form tags to enclose the element. The variable information will not be retrieved correctly.

-

The OK button should call chrome.webview.hostObjects.fm.OK(); with onclick attribute, etc.
-Similarly, The Cancel button should call chrome.webview.hostObjects.fm.Cancel(); with onclick attribute, etc.

-
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
-
- - -
-
-

Free input area

- -
-


-

-
- -")] - public string v_InputHTML { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("When an Error should Occur on any Result other than 'OK'")] - [PropertyUISelectionOption("Error On Close")] - [PropertyUISelectionOption("Do Not Error On Close")] - [PropertyIsOptional(true, "Error On Close")] - public string v_ErrorOnClose { get; set; } - - public ShowHTMLInputDialogCommand() - { - //this.CommandName = "HTMLInputCommand"; - //this.SelectionName = "Prompt for HTML Input"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - if (engine.tasktEngineUI == null) - { - engine.ReportProgress("HTML UserInput Supported With UI Only"); - MessageBox.Show("HTML UserInput Supported With UI Only", "UserInput Command", MessageBoxButtons.OK, MessageBoxIcon.Information); - return; - } - - //invoke ui for data collection - var result = engine.tasktEngineUI.Invoke(new Action(() => - { - //sample for temp testing - var htmlInput = v_InputHTML.ExpandValueOrUserVariable(engine); - - var errorOnClose = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ErrorOnClose), engine); - - var variables = engine.tasktEngineUI.ShowHTMLInput(htmlInput); - - //if user selected Ok then process variables - //null result means user cancelled/closed - if (variables != null) - { - ////store each one into context - //foreach (var variable in variables) - //{ - // variable.VariableValue.ToString().StoreInUserVariable(engine, variable.VariableName); - //} - - Action newVariableAction; - if (engine.engineSettings.CreateMissingVariablesDuringExecution) - { - newVariableAction = new Action((v) => - { - engine.VariableList.Add(v); - }); - } - else - { - newVariableAction = new Action((v) => { - // nothing - }); - } - - foreach(var v in variables) - { - var existsVar = engine.VariableList.FirstOrDefault(t => v.VariableName == t.VariableName); - if (existsVar != null) - { - existsVar.VariableValue = v.VariableValue; - } - else - { - newVariableAction(v); - } - } - - // DBG - //var x = engine.VariableList; - } - else if (errorOnClose == "Error On Close") - { - throw new Exception("Input Form was closed by the user"); - } - })); - } - - private void ShowHTMLBuilder(object sender, EventArgs e) - { - using (var htmlForm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmHTMLBuilder()) - { - var htmlInput = (TextBox)ControlsList[nameof(v_InputHTML)]; - htmlForm.rtbHTML.Text = htmlInput.Text; - - if (htmlForm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) - { - htmlInput.Text = htmlForm.rtbHTML.Text; - } - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/DialogMessage/ShowUserInputDialogCommand.cs b/taskt/Core/Automation/Commands/DialogMessage/ShowUserInputDialogCommand.cs deleted file mode 100644 index dfef68110..000000000 --- a/taskt/Core/Automation/Commands/DialogMessage/ShowUserInputDialogCommand.cs +++ /dev/null @@ -1,166 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Data; -using taskt.UI.Forms; -using System.Windows.Forms; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Dialog/Message")] - [Attributes.ClassAttributes.CommandSettings("Show User Input Dialog")] - [Attributes.ClassAttributes.Description("Sends keystrokes to a targeted window")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send keystroke inputs to a window.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows.Forms.SendKeys' method to achieve automation.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ShowUserInputDialogCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Dialog Title")] - [InputSpecification("Title", true)] - [SampleUsage("**Please Provide Input**")] - [PropertyFirstValue("Please Provide Input")] - [PropertyValidationRule("Title", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyIsOptional(true)] - [PropertyDisplayText(true, "Title")] - public string v_InputHeader { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Input Directions")] - [InputSpecification("Input Directions", true)] - [SampleUsage("**Please fill in the following fields**")] - [PropertyFirstValue("Directions: Please fill in the following fields")] - [PropertyIsOptional(true)] - [PropertyValidationRule("Input Direction", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(true, "Input Directions")] - public string v_InputDirections { get; set; } - - [XmlElement] - [PropertyDescription("User Input Parameters")] - [InputSpecification("User Input", true)] - [SampleUsage("")] - [Remarks("")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] - [PropertyDataGridViewSetting(false, true, true, 400, 250, true, 2)] - [PropertyDataGridViewColumnSettings("Type", "Input Type", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.ComboBox, "TextBox\nComboBox\nCheckBox", "TextBox")] - [PropertyDataGridViewColumnSettings("Label", "Input Label", false)] - [PropertyDataGridViewColumnSettings("Size", "Input Size (X,Y)", false)] - [PropertyDataGridViewColumnSettings("DefaultValue", "Default Value", false)] - [PropertyDataGridViewColumnSettings("UserInput", "User Input", false)] - [PropertyDataGridViewColumnSettings("ApplyToVariable", "Apply To Variable", false)] - [PropertyCustomUIHelper("Add Input Parameter", nameof(lnkAddInputParameter_Click), "addrow")] - [PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.AllEditableDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] - public DataTable v_UserInputConfig { get; set; } - - public ShowUserInputDialogCommand() - { - //this.CommandName = "UserInputCommand"; - //this.SelectionName = "Prompt for Input"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - if (engine.tasktEngineUI == null) - { - engine.ReportProgress("UserInput Supported With UI Only"); - MessageBox.Show("UserInput Supported With UI Only", "UserInput Command", MessageBoxButtons.OK, MessageBoxIcon.Information); - return; - } - - //create clone of original - //var clonedCommand = Common.Clone(this); - var clonedCommand = (ShowUserInputDialogCommand)this.Clone(); - - //translate variable - clonedCommand.v_InputHeader = clonedCommand.v_InputHeader.ExpandValueOrUserVariable(engine); - clonedCommand.v_InputDirections = clonedCommand.v_InputDirections.ExpandValueOrUserVariable(engine); - - //translate variables for each label - foreach (DataRow rw in clonedCommand.v_UserInputConfig.Rows) - { - //rw["DefaultValue"] = rw["DefaultValue"].ToString().ConvertToUserVariable(engine); - rw["DefaultValue"] = (rw.Field("DefaultValue") ?? "").ExpandValueOrUserVariable(engine); - - var targetVariable = rw["ApplyToVariable"] as string; - - if (string.IsNullOrEmpty(targetVariable)) - { - var newMessage = new ShowMessageCommand - { - v_Message = "User Input question '" + rw["Label"] + "' is missing variables to apply results to! Results for the item will not be tracked. To fix this, assign a variable in the designer!", - v_AutoCloseAfter = "10" - }; - newMessage.RunCommand(engine); - } - } - - //invoke ui for data collection - var result = engine.tasktEngineUI.Invoke(new Action(() => - { - - //get input from user - var userInputs = engine.tasktEngineUI.ShowInput(clonedCommand); - - //check if user provided input - if (userInputs != null) - { - //loop through each input and assign - for (int i = 0; i < userInputs.Count; i++) - { - var targetVariable = VariableNameControls.GetVariableName(v_UserInputConfig.Rows[i].Field("ApplyToVariable") ?? "", engine); - - //store user data in variable - if (!string.IsNullOrEmpty(targetVariable)) - { - userInputs[i].StoreInUserVariable(engine, targetVariable); - } - } - } - } - )); - } - - private void lnkAddInputParameter_Click(object sender, EventArgs e) - { - var newRow = v_UserInputConfig.NewRow(); - newRow["Size"] = "500,100"; - v_UserInputConfig.Rows.Add(newRow); - } - - public override bool IsValidate(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - base.IsValidate(editor); - - for (int i = 0; i < v_UserInputConfig.Rows.Count; i++) - { - var row = v_UserInputConfig.Rows[i]; - - if (string.IsNullOrEmpty(row.Field("Type"))) - { - this.validationResult += "Input Type #" + (i + 1) + " is empty.\n"; - this.IsValid = false; - } - if (string.IsNullOrEmpty(row.Field("Size"))) - { - this.validationResult += "Input Size #" + (i + 1) + " is empty.\n"; - this.IsValid = false; - } - } - - return this.IsValid; - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - DataTableControls.BeforeValidate_NoRowAdding((DataGridView)ControlsList[nameof(v_UserInputConfig)], v_UserInputConfig); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/DialogMessage/AShowFileFolderDialogCommands.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/AShowFileFolderDialogCommands.cs similarity index 66% rename from taskt/Core/Automation/Commands/DialogMessage/AShowFileFolderDialogCommands.cs rename to taskt/Core/Automation/Commands/DialogMessageGroup/AShowFileFolderDialogCommands.cs index 8d79cbf8d..02975b189 100644 --- a/taskt/Core/Automation/Commands/DialogMessage/AShowFileFolderDialogCommands.cs +++ b/taskt/Core/Automation/Commands/DialogMessageGroup/AShowFileFolderDialogCommands.cs @@ -9,7 +9,7 @@ namespace taskt.Core.Automation.Commands /// /// for Show File/Folder Dialog commands /// - public abstract class AShowFileFolderDialogCommands : ScriptCommand, ICanHandleFolderPath + public abstract class AShowFileFolderDialogCommands : ScriptCommand, IWaitDialogResultProperties, ICanHandleFolderPath { [XmlAttribute] [PropertyVirtualProperty(nameof(FolderPathControls), nameof(FolderPathControls.v_FolderPath))] @@ -30,25 +30,27 @@ public abstract class AShowFileFolderDialogCommands : ScriptCommand, ICanHandleF public string v_Result { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnore))] - [PropertyDescription("When Dialog Result Is Cancel")] - [PropertyUISelectionOption("Set Empty")] - [PropertyUISelectionOption("Show Dialog Again")] - [PropertyDetailSampleUsage("**Ignore**", "Nothing to do. The Result Variable is not Changed.")] - [PropertyDetailSampleUsage("**Set Empty**", "Result Variable value is Empty")] - [PropertyDetailSampleUsage("**Show Dialog Again", "Show Dialog Again")] - [PropertyIsOptional(true, "Show Dialog Again")] - [PropertyValidationRule("When Dialog Result Is Cancel", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(false, "When Dialog Result Is Cancel")] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnore))] + //[PropertyDescription("When Dialog Result Is Cancel")] + //[PropertyUISelectionOption("Set Empty")] + //[PropertyUISelectionOption("Show Dialog Again")] + //[PropertyDetailSampleUsage("**Ignore**", "Nothing to do. The Result Variable is not Changed.")] + //[PropertyDetailSampleUsage("**Set Empty**", "Result Variable value is Empty")] + //[PropertyDetailSampleUsage("**Show Dialog Again", "Show Dialog Again")] + //[PropertyIsOptional(true, "Show Dialog Again")] + //[PropertyValidationRule("When Dialog Result Is Cancel", PropertyValidationRule.ValidationRuleFlags.None)] + //[PropertyDisplayText(false, "When Dialog Result Is Cancel")] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_WhenCancel))] [PropertyParameterOrder(12000)] public string v_WhenCancel { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name To Store Dislog Result")] - [Remarks("Value is **OK** or **Cancel**")] - [PropertyValidationRule("DialogResult", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(false, "DialogResult")] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyDescription("Variable Name To Store Dislog Result")] + //[Remarks("Value is **OK** or **Cancel**")] + //[PropertyValidationRule("DialogResult", PropertyValidationRule.ValidationRuleFlags.None)] + //[PropertyDisplayText(false, "DialogResult")] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_DialogResult))] [PropertyParameterOrder(13000)] public string v_DialogResult { get; set; } @@ -93,15 +95,16 @@ protected void ShowDialogProcess(dynamic dialog, Func GetPathFunc, strin throw new Exception($"Strange dialog object. Type; {dialog.GetType().Name}"); } - void StoreDialogResultValue(string v) - { - if (!string.IsNullOrEmpty(v_DialogResult)) - { - v.StoreInUserVariable(engine, v_DialogResult); - } - } + //void StoreDialogResultValue(string v) + //{ + // if (!string.IsNullOrEmpty(v_DialogResult)) + // { + // v.StoreInUserVariable(engine, v_DialogResult); + // } + //} - var whenCancel = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenCancel), engine); + //var whenCancel = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenCancel), engine); + var whenCancel = this.ExpandValueOrUserVariableAsWhenCancel(engine); switch (whenCancel) { case "show dialog again": @@ -114,17 +117,20 @@ void StoreDialogResultValue(string v) isAgain = false; } } - StoreDialogResultValue("OK"); + //StoreDialogResultValue("OK"); + this.StoreDialogResultInUserVariable("OK", engine); break; default: if ((int)dialog.ShowDialog() == okValue) { GetPathFunc().StoreInUserVariable(engine, v_Result); - StoreDialogResultValue("OK"); + //StoreDialogResultValue("OK"); + this.StoreDialogResultInUserVariable("OK", engine); } else { - StoreDialogResultValue("Cancel"); + //StoreDialogResultValue("Cancel"); + this.StoreDialogResultInUserVariable("Cancel", engine); switch (whenCancel) { case "error": diff --git a/taskt/Core/Automation/Commands/DialogMessageGroup/EM_DialogResultPropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/EM_DialogResultPropertiesExtentionMethods.cs new file mode 100644 index 000000000..3a924c2e8 --- /dev/null +++ b/taskt/Core/Automation/Commands/DialogMessageGroup/EM_DialogResultPropertiesExtentionMethods.cs @@ -0,0 +1,22 @@ +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_DialogResultPropertiesExtentionMethods + { + + /// + /// store dialog result in user variable + /// + /// + /// + /// + public static void StoreDialogResultInUserVariable(this IDialogResultProperties command, string result, AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(command.v_DialogResult)) + { + result.StoreInUserVariable(engine, command.v_DialogResult); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/DialogMessageGroup/EM_WaitDialogResultPropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/EM_WaitDialogResultPropertiesExtentionMethods.cs new file mode 100644 index 000000000..aa6446c87 --- /dev/null +++ b/taskt/Core/Automation/Commands/DialogMessageGroup/EM_WaitDialogResultPropertiesExtentionMethods.cs @@ -0,0 +1,17 @@ +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_WaitDialogResultPropertiesExtentionMethods + { + /// + /// expand value or variable as When Cancel + /// + /// + /// + public static string ExpandValueOrUserVariableAsWhenCancel(this IWaitDialogResultProperties command, AutomationEngineInstance engine) + { + return ((ScriptCommand)command).ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_WhenCancel), engine); + } + } +} diff --git a/taskt/Core/Automation/Commands/DialogMessageGroup/IDialogResultProperties.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/IDialogResultProperties.cs new file mode 100644 index 000000000..3de5ea066 --- /dev/null +++ b/taskt/Core/Automation/Commands/DialogMessageGroup/IDialogResultProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// for to get dialog result properties + /// + public interface IDialogResultProperties : IExpandableProperties + { + /// + /// variable name to store dialog result + /// + string v_DialogResult { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/DialogMessageGroup/IWaitDialogResultProperties.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/IWaitDialogResultProperties.cs new file mode 100644 index 000000000..4ca026efa --- /dev/null +++ b/taskt/Core/Automation/Commands/DialogMessageGroup/IWaitDialogResultProperties.cs @@ -0,0 +1,18 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// for to get/wait dialog result properties + /// + public interface IWaitDialogResultProperties : IDialogResultProperties + { + /// + /// behavior when user click cancel in Dialog + /// + string v_WhenCancel { get; set; } + + ///// + ///// variable name to store dialog result + ///// + //string v_DialogResult { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/DialogMessageGroup/ShowDialogControls.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowDialogControls.cs new file mode 100644 index 000000000..e755c2a69 --- /dev/null +++ b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowDialogControls.cs @@ -0,0 +1,47 @@ +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + public static class ShowDialogControls + { + /// + /// behavior when click cancel in dialog + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnore))] + [PropertyDescription("When Dialog Result Is Cancel")] + [PropertyUISelectionOption("Set Empty")] + [PropertyUISelectionOption("Show Dialog Again")] + [PropertyDetailSampleUsage("**Ignore**", "Nothing to do. The Result Variable is not Changed.")] + [PropertyDetailSampleUsage("**Set Empty**", "Result Variable value is Empty")] + [PropertyDetailSampleUsage("**Show Dialog Again", "Show Dialog Again")] + [PropertyIsOptional(true, "Show Dialog Again")] + [PropertyValidationRule("When Dialog Result Is Cancel", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "When Dialog Result Is Cancel")] + //[PropertyParameterOrder(12000)] + public static string v_WhenCancel { get; } + + /// + /// variable name to store dialog result + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name To Store Dislog Result")] + [Remarks("Value is **OK** or **Cancel**")] + [PropertyValidationRule("DialogResult", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "DialogResult")] + //[PropertyParameterOrder(13000)] + public static string v_DialogResult { get; } + + /// + /// dialog title + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Dialog Title")] + [InputSpecification("Title", true)] + [PropertyDetailSampleUsage("**Title**", PropertyDetailSampleUsage.ValueType.Value)] + [PropertyDetailSampleUsage("**{{{vTitle}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyValidationRule("Title", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyIsOptional(true)] + [PropertyDisplayText(true, "Title")] + public static string v_DialogTitle { get; } + } +} diff --git a/taskt/Core/Automation/Commands/DialogMessage/ShowFileDialogCommand.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowFileDialogCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DialogMessage/ShowFileDialogCommand.cs rename to taskt/Core/Automation/Commands/DialogMessageGroup/ShowFileDialogCommand.cs diff --git a/taskt/Core/Automation/Commands/DialogMessage/ShowFolderDialogCommand.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowFolderDialogCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/DialogMessage/ShowFolderDialogCommand.cs rename to taskt/Core/Automation/Commands/DialogMessageGroup/ShowFolderDialogCommand.cs diff --git a/taskt/Core/Automation/Commands/DialogMessageGroup/ShowHTMLInputDialogCommand.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowHTMLInputDialogCommand.cs new file mode 100644 index 000000000..7c0b674d7 --- /dev/null +++ b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowHTMLInputDialogCommand.cs @@ -0,0 +1,392 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Dialog/Message")] + [Attributes.ClassAttributes.CommandSettings("Show HTML Input Dialog")] + [Attributes.ClassAttributes.Description("Allows the entry of data into a web-enabled form")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want a fancy data collection.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements 'WebBrowser Control' to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class ShowHTMLInputDialogCommand : ScriptCommand, IWaitDialogResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_MultiLinesTextBox))] + [PropertyDescription("HTML for the Dialog")] + [InputSpecification("HTML", true)] + [PropertyCustomUIHelper("Launch HTML Builder", nameof(ShowHTMLBuilder))] + [PropertyValidationRule("HTML", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(false, "HTML")] + [PropertyFirstValue( +@" + + + + Please Provide Information + + + +
+
+

Directions

+

This a sample data collection form that can be presented to a user. You can add and implement as many fields as you need or choose standard form inputs. Note, each field will require a data-variable or v_applyToVariable attribute specifying which variable should contain the respective value for the input field.
+DO NOT USE form tags to enclose the element. The variable information will not be retrieved correctly.

+

The OK button should call chrome.webview.hostObjects.fm.OK(); with onclick attribute, etc.
+Similarly, The Cancel button should call chrome.webview.hostObjects.fm.Cancel(); with onclick attribute, etc.

+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+

Free input area

+ +
+


+

+
+ +")] + [PropertyParameterOrder(1000)] + public string v_InputHTML { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_DialogTitle))] + [PropertyFirstValue("ShowHTMLInputDialog Command")] + [PropertyIsOptional(true, "ShowHTMLInputDialog Command")] + [PropertyParameterOrder(2000)] + public string v_DialogTitle { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When an Error should Occur on any Result other than 'OK'")] + //[PropertyUISelectionOption("Error On Close")] + //[PropertyUISelectionOption("Do Not Error On Close")] + //[PropertyIsOptional(true, "Error On Close")] + //[PropertyDisplayText(false, "Error")] + //public string v_ErrorOnClose { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_WhenCancel))] + [PropertyParameterOrder(12000)] + public string v_WhenCancel { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_DialogResult))] + [PropertyParameterOrder(13000)] + public string v_DialogResult { get; set; } + + public ShowHTMLInputDialogCommand() + { + //this.CommandName = "HTMLInputCommand"; + //this.SelectionName = "Prompt for HTML Input"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + if (engine.tasktEngineUI == null) + { + engine.ReportProgress("HTML UserInput Supported With UI Only"); + MessageBox.Show("HTML UserInput Supported With UI Only", "UserInput Command", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + + //// invoke ui for data collection + //var result = engine.tasktEngineUI.Invoke(new Action(() => + //{ + // // sample for temp testing + // var htmlInput = v_InputHTML.ExpandValueOrUserVariable(engine); + + // var errorOnClose = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ErrorOnClose), engine); + + // var variables = engine.tasktEngineUI.ShowHTMLInput(htmlInput); + + // // if user selected Ok then process variables + // // null result means user cancelled/closed + // if (variables != null) + // { + // ////store each one into context + // //foreach (var variable in variables) + // //{ + // // variable.VariableValue.ToString().StoreInUserVariable(engine, variable.VariableName); + // //} + + // Action newVariableAction; + // if (engine.engineSettings.CreateMissingVariablesDuringExecution) + // { + // newVariableAction = new Action((v) => + // { + // engine.VariableList.Add(v); + // }); + // } + // else + // { + // newVariableAction = new Action((v) => { + // // nothing + // }); + // } + + // foreach(var v in variables) + // { + // var existsVar = engine.VariableList.FirstOrDefault(t => v.VariableName == t.VariableName); + // if (existsVar != null) + // { + // existsVar.VariableValue = v.VariableValue; + // } + // else + // { + // newVariableAction(v); + // } + // } + // } + // else if (errorOnClose == "Error On Close") + // { + // throw new Exception("Input Form was closed by the user"); + // } + //})); + + void SetOrAddVariableValueProcess(List vs) + { + if (vs != null) + { + Action newVariableAction; + if (engine.engineSettings.CreateMissingVariablesDuringExecution) + { + newVariableAction = new Action((v) => + { + engine.VariableList.Add(v); + }); + } + else + { + newVariableAction = new Action((v) => { + // nothing + }); + } + + foreach (var v in vs) + { + var existsVar = engine.VariableList.FirstOrDefault(t => v.VariableName == t.VariableName); + if (existsVar != null) + { + existsVar.VariableValue = v.VariableValue; + } + else + { + newVariableAction(v); + } + } + } + } + + engine.tasktEngineUI.Invoke(new Action(() => + { + // sample for temp testing + var htmlInput = v_InputHTML.ExpandValueOrUserVariable(engine); + + //var errorOnClose = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ErrorOnClose), engine); + //var errorOnClose = ""; + var whenCancel = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenCancel), engine); + + if (string.IsNullOrEmpty(v_DialogTitle)) + { + v_DialogTitle = "ShowHTMLInputDialog Command"; + } + var title = this.ExpandValueOrUserVariable(nameof(v_DialogTitle), "DialogTitle", engine); + + //List variables = null; + + if (whenCancel == "show dialog again") + { + bool isAgain = true; + do + { + using (var fm = new UI.Forms.ScriptEngine.Supplemental.frmHTMLDisplayForm(htmlInput, title)) + { + if (fm.ShowDialog() == DialogResult.OK) + { + //variables = fm.VariablesList; + SetOrAddVariableValueProcess(fm.VariablesList); + isAgain = false; + } + } + } while (isAgain); + this.StoreDialogResultInUserVariable("OK", engine); + } + else + { + using (var fm = new UI.Forms.ScriptEngine.Supplemental.frmHTMLDisplayForm(htmlInput, title)) + { + if (fm.ShowDialog() == DialogResult.OK) + { + SetOrAddVariableValueProcess(fm.VariablesList); + this.StoreDialogResultInUserVariable("OK", engine); + } + else + { + switch (whenCancel) + { + case "error": + throw new Exception("Error. HTML Input clicked Cancel."); + + case "ignore": + break; + + case "set empty": + var vars = fm.VariablesList; + if (vars != null) + { + Action newVariableAction; + if (engine.engineSettings.CreateMissingVariablesDuringExecution) + { + newVariableAction = new Action((v) => + { + engine.VariableList.Add(new ScriptVariable() + { + VariableName = v.VariableName, + VariableValue = "", + }); + }); + } + else + { + newVariableAction = new Action((v) => + { + // nothing + }); + } + + foreach (var v in vars) + { + var existsVar = engine.VariableList.FirstOrDefault(t => v.VariableName == t.VariableName); + if (existsVar != null) + { + existsVar.VariableValue = ""; + } + else + { + newVariableAction(v); + } + } + } + break; + } + this.StoreDialogResultInUserVariable("Cancel", engine); + } + } + } + + //// if user selected Ok then process variables + //// null result means user cancelled/closed + //if (variables != null) + //{ + // Action newVariableAction; + // if (engine.engineSettings.CreateMissingVariablesDuringExecution) + // { + // newVariableAction = new Action((v) => + // { + // engine.VariableList.Add(v); + // }); + // } + // else + // { + // newVariableAction = new Action((v) => { + // // nothing + // }); + // } + + // foreach (var v in variables) + // { + // var existsVar = engine.VariableList.FirstOrDefault(t => v.VariableName == t.VariableName); + // if (existsVar != null) + // { + // existsVar.VariableValue = v.VariableValue; + // } + // else + // { + // newVariableAction(v); + // } + // } + //} + //else if (errorOnClose == "Error On Close") + //{ + // throw new Exception("Input Form was closed by the user"); + //} + })); + } + + private void ShowHTMLBuilder(object sender, EventArgs e) + { + using (var htmlForm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmHTMLBuilder()) + { + var htmlInput = (TextBox)ControlsList[nameof(v_InputHTML)]; + htmlForm.rtbHTML.Text = htmlInput.Text; + + if (htmlForm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) + { + htmlInput.Text = htmlForm.rtbHTML.Text; + } + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/DialogMessage/ShowMessageCommand.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowMessageCommand.cs similarity index 86% rename from taskt/Core/Automation/Commands/DialogMessage/ShowMessageCommand.cs rename to taskt/Core/Automation/Commands/DialogMessageGroup/ShowMessageCommand.cs index 43ef5f0ff..7f9f47205 100644 --- a/taskt/Core/Automation/Commands/DialogMessage/ShowMessageCommand.cs +++ b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowMessageCommand.cs @@ -15,7 +15,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ShowMessageCommand : ScriptCommand + public sealed class ShowMessageCommand : ScriptCommand, IDialogResultProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_MultiLinesTextBox))] @@ -77,13 +77,16 @@ public sealed class ShowMessageCommand : ScriptCommand public string v_DialogType { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Dialog Title")] - [InputSpecification("Text")] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Dialog Title")] + //[InputSpecification("Text")] + //[PropertyIsOptional(true, "ShowMessage Command")] + //[PropertyValidationRule("DialogTitle", PropertyValidationRule.ValidationRuleFlags.None)] + //[PropertyFirstValue("ShowMessage Command")] + //[PropertyDisplayText(false, "Dialog Title")] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_DialogTitle))] + [PropertyFirstValue("ShowMessage Comamnd")] [PropertyIsOptional(true, "ShowMessage Command")] - [PropertyValidationRule("DialogTitle", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyFirstValue("ShowMessage Command")] - [PropertyDisplayText(false, "Dialog Title")] public string v_DialogTitle { get; set; } [XmlAttribute] @@ -97,11 +100,12 @@ public sealed class ShowMessageCommand : ScriptCommand public string v_WaitForAnswer { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Store Dialog Result")] - [PropertyIsOptional(true)] - [PropertyValidationRule("Dialog Result", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(false, "Dialog Result")] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyDescription("Variable Name to Store Dialog Result")] + //[PropertyIsOptional(true)] + //[PropertyValidationRule("Dialog Result", PropertyValidationRule.ValidationRuleFlags.None)] + //[PropertyDisplayText(false, "Dialog Result")] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_DialogResult))] public string v_DialogResult { get; set; } public ShowMessageCommand() @@ -168,10 +172,11 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) using (var confirmationForm = new frmDialog(variableMessage, dialogTitle, dialogType, closeAfter, true, fontName, fontSize)) { var res = confirmationForm.ShowDialog(); - if (!string.IsNullOrEmpty(v_DialogResult)) - { - res.ToString().StoreInUserVariable(engine, v_DialogResult); - } + //if (!string.IsNullOrEmpty(v_DialogResult)) + //{ + // //res.ToString().StoreInUserVariable(engine, v_DialogResult); + //} + this.StoreDialogResultInUserVariable(res.ToString(), engine); } })); } diff --git a/taskt/Core/Automation/Commands/DialogMessageGroup/ShowUserInputDialogCommand.cs b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowUserInputDialogCommand.cs new file mode 100644 index 000000000..a2a0a27b1 --- /dev/null +++ b/taskt/Core/Automation/Commands/DialogMessageGroup/ShowUserInputDialogCommand.cs @@ -0,0 +1,359 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Dialog/Message")] + [Attributes.ClassAttributes.CommandSettings("Show User Input Dialog")] + [Attributes.ClassAttributes.Description("Sends keystrokes to a targeted window")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send keystroke inputs to a window.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows.Forms.SendKeys' method to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class ShowUserInputDialogCommand : ScriptCommand, IWaitDialogResultProperties, IHaveDataTableElements + { + [XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Dialog Title")] + //[InputSpecification("Title", true)] + //[SampleUsage("**Please Provide Input**")] + //[PropertyFirstValue("Please Provide Input")] + //[PropertyValidationRule("Title", PropertyValidationRule.ValidationRuleFlags.None)] + //[PropertyIsOptional(true)] + //[PropertyDisplayText(true, "Title")] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_DialogTitle))] + [PropertyFirstValue("Please Provide Input")] + [PropertyIsOptional(true, "Please Provide Input")] + [PropertyParameterOrder(1000)] + public string v_DialogTitle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Message")] + [InputSpecification("Message", true)] + [SampleUsage("**Please fill in the following fields**")] + [PropertyFirstValue("Directions: Please fill in the following fields")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Message Direction", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Message")] + [PropertyParameterOrder(2000)] + public string v_Message { get; set; } + + [XmlElement] + [PropertyDescription("User Input Parameters")] + [InputSpecification("User Input", true)] + [SampleUsage("")] + [Remarks("")] + [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + [PropertyDataGridViewSetting(false, true, true, 400, 250, true, 2)] + [PropertyDataGridViewColumnSettings("Type", "Input Type", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.ComboBox, "TextBox\nComboBox\nCheckBox", "TextBox")] + [PropertyDataGridViewColumnSettings("Label", "Input Label", false)] + [PropertyDataGridViewColumnSettings("Size", "Input Size (X,Y)", false)] + [PropertyDataGridViewColumnSettings("DefaultValue", "Default Value", false)] + [PropertyDataGridViewColumnSettings("UserInput", "User Input", false)] + [PropertyDataGridViewColumnSettings("ApplyToVariable", "Apply To Variable", false)] + [PropertyCustomUIHelper("Add Input Parameter", nameof(lnkAddInputParameter_Click), "addrow")] + [PropertyCustomUIHelper("Delete Row", nameof(lnkDeleteInputParameter_Click), "deleterow")] + [PropertyCustomUIHelper("Move Up Row", nameof(lnkUpInputParameter_Click), "uprow")] + [PropertyCustomUIHelper("Move Down Row", nameof(lnkDownInputParameter_Click), "downrow")] + [PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.AllEditableDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] + [PropertyParameterOrder(3000)] + public DataTable v_UserInputConfig { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Dialog Buttons")] + [PropertyUISelectionOption("OKCancel")] + [PropertyUISelectionOption("OKOnly")] + [PropertyUISelectionOption("AcceptCancel")] + [PropertyUISelectionOption("AcceptOnly")] + [PropertyIsOptional(true, "OKCancel")] + [PropertyValidationRule("Dialog Buttons", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyParameterOrder(11000)] + public string v_DialogButtons { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_WhenCancel))] + [PropertyParameterOrder(12000)] + public string v_WhenCancel { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ShowDialogControls), nameof(ShowDialogControls.v_DialogResult))] + [PropertyParameterOrder(13000)] + public string v_DialogResult { get; set; } + + public ShowUserInputDialogCommand() + { + //this.CommandName = "UserInputCommand"; + //this.SelectionName = "Prompt for Input"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + if (engine.tasktEngineUI == null) + { + engine.ReportProgress("UserInput Supported With UI Only"); + MessageBox.Show("UserInput Supported With UI Only", "UserInput Command", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + + // create clone of original + var clonedCommand = (ShowUserInputDialogCommand)this.Clone(); + + // expand variables + clonedCommand.v_DialogTitle = clonedCommand.v_DialogTitle.ExpandValueOrUserVariable(engine); + clonedCommand.v_Message = clonedCommand.v_Message.ExpandValueOrUserVariable(engine); + + // expand variables for each label + foreach (DataRow rw in clonedCommand.v_UserInputConfig.Rows) + { + rw["DefaultValue"] = (rw.Field("DefaultValue") ?? "").ExpandValueOrUserVariable(engine); + + var targetVariable = rw["ApplyToVariable"] as string; + + if (string.IsNullOrEmpty(targetVariable)) + { + var newMessage = new ShowMessageCommand + { + v_Message = $"User Input question '{rw["Label"]}' is missing variables to apply results to! Results for the item will not be tracked. To fix this, assign a variable in the designer!", + v_AutoCloseAfter = "10" + }; + newMessage.RunCommand(engine); + } + } + + //// invoke ui for data collection + //var result = engine.tasktEngineUI.Invoke(new Action(() => + // { + + // //get input from user + // var userInputs = engine.tasktEngineUI.ShowInput(clonedCommand); + + // //check if user provided input + // if (userInputs != null) + // { + // //loop through each input and assign + // for (int i = 0; i < userInputs.Count; i++) + // { + // var targetVariable = VariableNameControls.GetVariableName(v_UserInputConfig.Rows[i].Field("ApplyToVariable") ?? "", engine); + + // //store user data in variable + // if (!string.IsNullOrEmpty(targetVariable)) + // { + // userInputs[i].StoreInUserVariable(engine, targetVariable); + // } + // } + // } + // } + //)); + + var dialogButtons = (UI.Forms.ScriptEngine.Supplemental.frmUserInput.ButtonState)Enum.Parse(typeof(UI.Forms.ScriptEngine.Supplemental.frmUserInput.ButtonState), this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_DialogButtons), engine), true); + + var whenCancel = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenCancel), engine); + + void SetVariableValues(List values) + { + for (int i = values.Count - 1; i >= 0; i--) + { + var targetVariable = VariableNameControls.GetVariableName(v_UserInputConfig.Rows[i].Field("ApplyToVariable") ?? "", engine); + + // store user data in variable + if (!string.IsNullOrEmpty(targetVariable)) + { + values[i].StoreInUserVariable(engine, targetVariable); + } + } + } + + engine.tasktEngineUI.Invoke(new Action(() => + { + //var responses = new List(); + using (var fm = new UI.Forms.ScriptEngine.Supplemental.frmUserInput(clonedCommand, dialogButtons)) + { + if (whenCancel == "show dialog again") + { + bool isAgain = true; + do + { + //if (fm.ShowDialog() == DialogResult.OK) + //{ + // isAgain = false; + // SetVariableValues(fm.GetSpecifiedValues()); + //} + var r = fm.ShowDialog(); + if (r == DialogResult.OK) + { + isAgain = false; + SetVariableValues(fm.GetSpecifiedValues()); + } + } while (isAgain); + this.StoreDialogResultInUserVariable(fm.DialogResultText, engine); + } + else + { + if (fm.ShowDialog() == DialogResult.OK) + { + SetVariableValues(fm.GetSpecifiedValues()); + this.StoreDialogResultInUserVariable(fm.DialogResultText, engine); + } + else + { + switch (whenCancel) + { + case "error": + throw new Exception("Error. UserInput Dialog is Clicked Cancel."); + + case "ignore": + break; + + case "set empty": + for (int i = v_UserInputConfig.Rows.Count - 1; i >= 0; i--) + { + var targetVariable = VariableNameControls.GetVariableName(v_UserInputConfig.Rows[i].Field("ApplyToVariable") ?? "", engine); + "".StoreInUserVariable(engine, targetVariable); + } + break; + } + this.StoreDialogResultInUserVariable("Cancel", engine); + } + } + } + })); + } + + private void lnkAddInputParameter_Click(object sender, EventArgs e) + { + var newRow = v_UserInputConfig.NewRow(); + newRow["Size"] = "500,100"; + v_UserInputConfig.Rows.Add(newRow); + } + + private void lnkUpInputParameter_Click(object sender, EventArgs e) + { + var dgv = this.ControlsList.GetPropertyControl(nameof(v_UserInputConfig)); + var row = dgv.CurrentCell.RowIndex; + if (row > 0) + { + SwapUserInputParameterRows(row, row - 1); + dgv.CurrentCell = dgv[dgv.CurrentCell.ColumnIndex, row - 1]; + } + } + + private void lnkDownInputParameter_Click(object sender, EventArgs e) + { + var dgv = this.ControlsList.GetPropertyControl(nameof(v_UserInputConfig)); + var row = dgv.CurrentCell.RowIndex; + if (row < dgv.Rows.Count - 1) + { + SwapUserInputParameterRows(row, row + 1); + dgv.CurrentCell = dgv[dgv.CurrentCell.ColumnIndex, row + 1]; + } + } + + private void lnkDeleteInputParameter_Click(object sender, EventArgs e) + { + var dgv = this.ControlsList.GetPropertyControl(nameof(v_UserInputConfig)); + var row = dgv.CurrentCell.RowIndex; + v_UserInputConfig.Rows[row].Delete(); + } + + /// + /// swap v_UserInputConfig parameters value + /// + /// + /// + private void SwapUserInputParameterRows(int a, int b) + { + //var dgv = this.ControlsList.GetPropertyControl(nameof(v_UserInputConfig)); + + for (int i = v_UserInputConfig.Columns.Count - 1; i > 0; i--) + { + var va = v_UserInputConfig.Rows[a][i]?.ToString() ?? ""; + var vb = v_UserInputConfig.Rows[b][i]?.ToString() ?? ""; + v_UserInputConfig.Rows[a][i] = vb; + v_UserInputConfig.Rows[b][i] = va; + } + } + + public override bool IsValidate(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + base.IsValidate(editor); + + + int dgvRows; + DataGridView dgv = null; + try + { + dgv = this.ControlsList.GetPropertyControl(nameof(v_UserInputConfig)); + dgvRows = dgv.Rows.Count; + } + catch + { + dgvRows = v_UserInputConfig.Rows.Count; + } + + //var rows = (dgvRows < v_UserInputConfig.Rows.Count) ? dgvRows : v_UserInputConfig.Rows.Count; + + DataTable targetDT; + int rows; + if (dgvRows < v_UserInputConfig.Rows.Count) + { + rows = dgvRows; + targetDT = new DataTable(); + targetDT.Columns.Add("Type"); + targetDT.Columns.Add("Label"); + targetDT.Columns.Add("Size"); + targetDT.Columns.Add("DefaultValue"); + targetDT.Columns.Add("UserInput"); + targetDT.Columns.Add("ApplyToVariable"); + int cols = dgv.Columns.Count; + for (int i = 0; i < rows; i++) + { + targetDT.Rows.Add(); + for (int j = 0; j < cols; j++) + { + targetDT.Rows[i][j] = dgv[j, i].Value?.ToString() ?? ""; + } + } + } + else + { + rows = v_UserInputConfig.Rows.Count; + targetDT = v_UserInputConfig; + } + + for (int i = 0; i < rows; i++) + { + var row = targetDT.Rows[i]; + var showIndex = i + 1; + + if (string.IsNullOrEmpty(row.Field("Type"))) + { + this.validationResult += $"Input Type #{showIndex} is empty.\n"; + this.IsValid = false; + } + if (string.IsNullOrEmpty(row.Field("Size"))) + { + this.validationResult += $"Input Size #{showIndex} is empty.\n"; + this.IsValid = false; + } + } + + return this.IsValid; + } + + public override void BeforeValidate() + { + base.BeforeValidate(); + DataTableControls.BeforeValidate_NoRowAdding((DataGridView)ControlsList[nameof(v_UserInputConfig)], v_UserInputConfig); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Dictionary/ADictionaryAddCreateCommands.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryAddCreateCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/ADictionaryAddCreateCommands.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryAddCreateCommands.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ADictionaryCreateFromDictionaryCommands.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryCreateFromDictionaryCommands.cs similarity index 93% rename from taskt/Core/Automation/Commands/Dictionary/ADictionaryCreateFromDictionaryCommands.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryCreateFromDictionaryCommands.cs index e9b6b4934..21d8c227f 100644 --- a/taskt/Core/Automation/Commands/Dictionary/ADictionaryCreateFromDictionaryCommands.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryCreateFromDictionaryCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for Create Dictionary From Dictionary commands /// - public abstract class ADictionaryCreateFromDictionaryCommands : ScriptCommand, ILDictionaryCreateFromDictionary + public abstract class ADictionaryCreateFromDictionaryCommands : ScriptCommand, IDictionaryCreateFromDictionary { [XmlAttribute] [PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_InputDictionaryName))] diff --git a/taskt/Core/Automation/Commands/Dictionary/ADictionaryGetFromDictionaryCommands.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryGetFromDictionaryCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/ADictionaryGetFromDictionaryCommands.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryGetFromDictionaryCommands.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ADictionaryInputDictionaryCommands.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryInputDictionaryCommands.cs similarity index 93% rename from taskt/Core/Automation/Commands/Dictionary/ADictionaryInputDictionaryCommands.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryInputDictionaryCommands.cs index 16bc2bf42..5a54f1a65 100644 --- a/taskt/Core/Automation/Commands/Dictionary/ADictionaryInputDictionaryCommands.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryInputDictionaryCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for Input Dictionary commands /// - public abstract class ADictionaryInputDictionaryCommands : ScriptCommand, ILDictionaryProperties + public abstract class ADictionaryInputDictionaryCommands : ScriptCommand, IDictionaryProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_InputDictionaryName))] diff --git a/taskt/Core/Automation/Commands/Dictionary/ADictionaryKeyActionCommands.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryKeyActionCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/ADictionaryKeyActionCommands.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryKeyActionCommands.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ADictionaryKeyCommands.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryKeyCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/ADictionaryKeyCommands.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ADictionaryKeyCommands.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/AddDictionaryItemCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/AddDictionaryItemCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/AddDictionaryItemCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/AddDictionaryItemCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/CheckDictionaryKeyExistsCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/CheckDictionaryKeyExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/CheckDictionaryKeyExistsCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/CheckDictionaryKeyExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ConcatenateDictionaryCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ConcatenateDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/ConcatenateDictionaryCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ConcatenateDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ConvertDictionaryToDataTableCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ConvertDictionaryToDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/ConvertDictionaryToDataTableCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ConvertDictionaryToDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ConvertDictionaryToJSONCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ConvertDictionaryToJSONCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/ConvertDictionaryToJSONCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ConvertDictionaryToJSONCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ConvertDictionaryToListCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ConvertDictionaryToListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/ConvertDictionaryToListCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ConvertDictionaryToListCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/CopyDictionaryCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/CopyDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/CopyDictionaryCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/CopyDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/CovnertDictionaryToTextCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/CovnertDictionaryToTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/CovnertDictionaryToTextCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/CovnertDictionaryToTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/CovnertDictionaryToVisualizedTextCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/CovnertDictionaryToVisualizedTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/CovnertDictionaryToVisualizedTextCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/CovnertDictionaryToVisualizedTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/CreateDictionaryCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/CreateDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/CreateDictionaryCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/CreateDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/EM_CanHandleDictionary.cs b/taskt/Core/Automation/Commands/DictionaryGroup/EM_CanHandleDictionary.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/EM_CanHandleDictionary.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/EM_CanHandleDictionary.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/EM_DicitionaryCreateFromDictionaryExtensionMethods.cs b/taskt/Core/Automation/Commands/DictionaryGroup/EM_DicitionaryCreateFromDictionaryExtensionMethods.cs similarity index 77% rename from taskt/Core/Automation/Commands/Dictionary/EM_DicitionaryCreateFromDictionaryExtensionMethods.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/EM_DicitionaryCreateFromDictionaryExtensionMethods.cs index 769418090..e8e425bf2 100644 --- a/taskt/Core/Automation/Commands/Dictionary/EM_DicitionaryCreateFromDictionaryExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/EM_DicitionaryCreateFromDictionaryExtensionMethods.cs @@ -10,7 +10,7 @@ public static class EM_DicitionaryCreateFromDictionaryExtensionMethods /// /// /// - public static Dictionary ExpandUserVariableAsDictionary(this ILDictionaryCreateFromDictionary command, Engine.AutomationEngineInstance engine) + public static Dictionary ExpandUserVariableAsDictionary(this IDictionaryCreateFromDictionary command, Engine.AutomationEngineInstance engine) { return command.ExpandUserVariableAsDictionary(nameof(command.v_TargetDictionary), engine); } @@ -22,7 +22,7 @@ public static Dictionary ExpandUserVariableAsDictionary(this ILD /// /// /// - public static void StoreDictionaryInUserVariable(this ILDictionaryCreateFromDictionary command, Dictionary dic, Engine.AutomationEngineInstance engine) + public static void StoreDictionaryInUserVariable(this IDictionaryCreateFromDictionary command, Dictionary dic, Engine.AutomationEngineInstance engine) { command.StoreDictionaryInUserVariable(dic, nameof(command.v_NewDictionary), engine); } diff --git a/taskt/Core/Automation/Commands/Dictionary/EM_DictionaryKeyPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DictionaryGroup/EM_DictionaryKeyPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/EM_DictionaryKeyPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/EM_DictionaryKeyPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/EM_DictionaryPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DictionaryGroup/EM_DictionaryPropertiesExtensionMethods.cs similarity index 85% rename from taskt/Core/Automation/Commands/Dictionary/EM_DictionaryPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/EM_DictionaryPropertiesExtensionMethods.cs index e0517b5a8..706990fde 100644 --- a/taskt/Core/Automation/Commands/Dictionary/EM_DictionaryPropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/EM_DictionaryPropertiesExtensionMethods.cs @@ -10,7 +10,7 @@ public static class EM_DictionaryPropertiesExtensionMethods /// /// /// - public static Dictionary ExpandUserVariableAsDictionary(this ILDictionaryProperties command, Engine.AutomationEngineInstance engine) + public static Dictionary ExpandUserVariableAsDictionary(this IDictionaryProperties command, Engine.AutomationEngineInstance engine) { return command.ExpandUserVariableAsDictionary(nameof(command.v_Dictionary), engine); } diff --git a/taskt/Core/Automation/Commands/Dictionary/EM_DictionaryResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/DictionaryGroup/EM_DictionaryResultPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/EM_DictionaryResultPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/EM_DictionaryResultPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ExportDictionaryAsTextFileCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ExportDictionaryAsTextFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/ExportDictionaryAsTextFileCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ExportDictionaryAsTextFileCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/FilterDictionaryCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/FilterDictionaryCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/Dictionary/FilterDictionaryCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/FilterDictionaryCommand.cs index d7f3e12e5..8784617a2 100644 --- a/taskt/Core/Automation/Commands/Dictionary/FilterDictionaryCommand.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/FilterDictionaryCommand.cs @@ -17,7 +17,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_dictionary))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class FilterDictionaryCommand : ADictionaryCreateFromDictionaryCommands, ILFilterValueProperties, IHaveDataTableElements + public sealed class FilterDictionaryCommand : ADictionaryCreateFromDictionaryCommands, IFilterValueProperties, IHaveDataTableElements { [XmlAttribute] //[PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_InputDictionaryName))] diff --git a/taskt/Core/Automation/Commands/Dictionary/GetDictionaryKeyFromValueCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/GetDictionaryKeyFromValueCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/GetDictionaryKeyFromValueCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/GetDictionaryKeyFromValueCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/GetDictionaryKeysListCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/GetDictionaryKeysListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/GetDictionaryKeysListCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/GetDictionaryKeysListCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/GetDictionaryValueCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/GetDictionaryValueCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/GetDictionaryValueCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/GetDictionaryValueCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ICanHandleDictionary.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ICanHandleDictionary.cs similarity index 68% rename from taskt/Core/Automation/Commands/Dictionary/ICanHandleDictionary.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ICanHandleDictionary.cs index 0d2c2ba88..302477133 100644 --- a/taskt/Core/Automation/Commands/Dictionary/ICanHandleDictionary.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/ICanHandleDictionary.cs @@ -3,7 +3,7 @@ /// /// for handle Dictionary /// - public interface ICanHandleDictionary : ILExpandableProperties + public interface ICanHandleDictionary : IExpandableProperties { // nothing } diff --git a/taskt/Core/Automation/Commands/Dictionary/IDictionaryAddCreateProperties.cs b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryAddCreateProperties.cs similarity index 80% rename from taskt/Core/Automation/Commands/Dictionary/IDictionaryAddCreateProperties.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryAddCreateProperties.cs index 24335dfc1..5c6fd3459 100644 --- a/taskt/Core/Automation/Commands/Dictionary/IDictionaryAddCreateProperties.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryAddCreateProperties.cs @@ -5,7 +5,7 @@ namespace taskt.Core.Automation.Commands /// /// Add Items to Dictionary or Create Dictionary properties /// - public interface IDictionaryAddCreateProperties : ILDictionaryProperties + public interface IDictionaryAddCreateProperties : IDictionaryProperties { /// /// Dictionary Keys & Values diff --git a/taskt/Core/Automation/Commands/Dictionary/ILDictionaryCreateFromDictionary.cs b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryCreateFromDictionary.cs similarity index 82% rename from taskt/Core/Automation/Commands/Dictionary/ILDictionaryCreateFromDictionary.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryCreateFromDictionary.cs index a49dfa31d..493357dc1 100644 --- a/taskt/Core/Automation/Commands/Dictionary/ILDictionaryCreateFromDictionary.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryCreateFromDictionary.cs @@ -3,7 +3,7 @@ /// /// Create Dictionary from Dictionary properties /// - public interface ILDictionaryCreateFromDictionary: ILExpandableProperties, ICanHandleDictionary + public interface IDictionaryCreateFromDictionary: IExpandableProperties, ICanHandleDictionary { /// /// Dictionary variable name to Create New Dictionary diff --git a/taskt/Core/Automation/Commands/Dictionary/IDictionaryGetFromDictionaryProperties.cs b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryGetFromDictionaryProperties.cs similarity index 69% rename from taskt/Core/Automation/Commands/Dictionary/IDictionaryGetFromDictionaryProperties.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryGetFromDictionaryProperties.cs index 48b505db2..8d62d1017 100644 --- a/taskt/Core/Automation/Commands/Dictionary/IDictionaryGetFromDictionaryProperties.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryGetFromDictionaryProperties.cs @@ -3,7 +3,7 @@ /// /// Get something from Dictionary properties /// - public interface IDictionaryGetFromDictionaryProperties : ILResultProperties + public interface IDictionaryGetFromDictionaryProperties : IResultProperties { //string v_Result { get; set; } } diff --git a/taskt/Core/Automation/Commands/Dictionary/IDictionaryKeyActionProperties.cs b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryKeyActionProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/IDictionaryKeyActionProperties.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryKeyActionProperties.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/IDictionaryKeyProperties.cs b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryKeyProperties.cs similarity index 77% rename from taskt/Core/Automation/Commands/Dictionary/IDictionaryKeyProperties.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryKeyProperties.cs index 734032c3c..65265effe 100644 --- a/taskt/Core/Automation/Commands/Dictionary/IDictionaryKeyProperties.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryKeyProperties.cs @@ -3,7 +3,7 @@ /// /// Dictionary & Key properties /// - public interface IDictionaryKeyProperties : ILDictionaryProperties + public interface IDictionaryKeyProperties : IDictionaryProperties { /// /// Dictionary key name diff --git a/taskt/Core/Automation/Commands/Dictionary/ILDictionaryProperties.cs b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryProperties.cs similarity index 73% rename from taskt/Core/Automation/Commands/Dictionary/ILDictionaryProperties.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryProperties.cs index 6b0545ee5..a876d5632 100644 --- a/taskt/Core/Automation/Commands/Dictionary/ILDictionaryProperties.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryProperties.cs @@ -3,7 +3,7 @@ /// /// Dictionary properties /// - public interface ILDictionaryProperties : ICanHandleDictionary, ILExpandableProperties + public interface IDictionaryProperties : ICanHandleDictionary, IExpandableProperties { /// /// Dictionary variable name diff --git a/taskt/Core/Automation/Commands/Dictionary/IDictionaryResultProperties.cs b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryResultProperties.cs similarity index 63% rename from taskt/Core/Automation/Commands/Dictionary/IDictionaryResultProperties.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryResultProperties.cs index a89ed0808..2a3215814 100644 --- a/taskt/Core/Automation/Commands/Dictionary/IDictionaryResultProperties.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/IDictionaryResultProperties.cs @@ -3,7 +3,7 @@ /// /// Result is Dictionary Properties /// - public interface IDictionaryResultProperties : ILResultProperties, ICanHandleDictionary + public interface IDictionaryResultProperties : IResultProperties, ICanHandleDictionary { // only imple } diff --git a/taskt/Core/Automation/Commands/Dictionary/JoinDictionaryValuesAsTextCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/JoinDictionaryValuesAsTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/JoinDictionaryValuesAsTextCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/JoinDictionaryValuesAsTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/RemoveDictionaryItemCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/RemoveDictionaryItemCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/RemoveDictionaryItemCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/RemoveDictionaryItemCommand.cs diff --git a/taskt/Core/Automation/Commands/Dictionary/ReplaceDictionaryCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/ReplaceDictionaryCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/Dictionary/ReplaceDictionaryCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/ReplaceDictionaryCommand.cs index 713665719..61a883906 100644 --- a/taskt/Core/Automation/Commands/Dictionary/ReplaceDictionaryCommand.cs +++ b/taskt/Core/Automation/Commands/DictionaryGroup/ReplaceDictionaryCommand.cs @@ -17,7 +17,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_dictionary))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ReplaceDictionaryCommand : ADictionaryInputDictionaryCommands, ILReplaceValueProperties, IHaveDataTableElements + public sealed class ReplaceDictionaryCommand : ADictionaryInputDictionaryCommands, IReplaceValueProperties, IHaveDataTableElements { [XmlAttribute] [PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_BothDictionaryName))] diff --git a/taskt/Core/Automation/Commands/Dictionary/SetDictionaryValueCommand.cs b/taskt/Core/Automation/Commands/DictionaryGroup/SetDictionaryValueCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Dictionary/SetDictionaryValueCommand.cs rename to taskt/Core/Automation/Commands/DictionaryGroup/SetDictionaryValueCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitGetAddressesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitGetAddressesAsDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitGetAddressesAsDataTableCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitGetAddressesAsDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitGetAddressesAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitGetAddressesAsDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitGetAddressesAsDictionaryCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitGetAddressesAsDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitGetAddressesAsListCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitGetAddressesAsListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitGetAddressesAsListCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitGetAddressesAsListCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitGetEMailFromEMailListCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitGetEMailFromEMailListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitGetEMailFromEMailListCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitGetEMailFromEMailListCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitGetEMailTextCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitGetEMailTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitGetEMailTextCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitGetEMailTextCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitGetEmailAttachmentsNameCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitGetEmailAttachmentsNameCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitGetEmailAttachmentsNameCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitGetEmailAttachmentsNameCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitLoadEmailCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitLoadEmailCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitLoadEmailCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitLoadEmailCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitRecieveEmailListUsingIMAPCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitRecieveEmailListUsingIMAPCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitRecieveEmailListUsingIMAPCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitRecieveEmailListUsingIMAPCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitRecieveEmailListUsingPOPCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitRecieveEmailListUsingPOPCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitRecieveEmailListUsingPOPCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitRecieveEmailListUsingPOPCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitSaveEmailAttachmentsCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitSaveEmailAttachmentsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitSaveEmailAttachmentsCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitSaveEmailAttachmentsCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitSaveEmailCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitSaveEmailCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitSaveEmailCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitSaveEmailCommand.cs diff --git a/taskt/Core/Automation/Commands/EMail/MailKitSendEmailCommand.cs b/taskt/Core/Automation/Commands/EMailGroup/MailKitSendEmailCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/EMail/MailKitSendEmailCommand.cs rename to taskt/Core/Automation/Commands/EMailGroup/MailKitSendEmailCommand.cs diff --git a/taskt/Core/Automation/Commands/Engine/ErrorHandlingCommand.cs b/taskt/Core/Automation/Commands/EngineGroup/ErrorHandlingCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Engine/ErrorHandlingCommand.cs rename to taskt/Core/Automation/Commands/EngineGroup/ErrorHandlingCommand.cs diff --git a/taskt/Core/Automation/Commands/Engine/GetBotStoreDataCommand.cs b/taskt/Core/Automation/Commands/EngineGroup/GetBotStoreDataCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Engine/GetBotStoreDataCommand.cs rename to taskt/Core/Automation/Commands/EngineGroup/GetBotStoreDataCommand.cs diff --git a/taskt/Core/Automation/Commands/Engine/PauseScriptCommand.cs b/taskt/Core/Automation/Commands/EngineGroup/PauseScriptCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Engine/PauseScriptCommand.cs rename to taskt/Core/Automation/Commands/EngineGroup/PauseScriptCommand.cs diff --git a/taskt/Core/Automation/Commands/Engine/SetEngineDelayCommand.cs b/taskt/Core/Automation/Commands/EngineGroup/SetEngineDelayCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Engine/SetEngineDelayCommand.cs rename to taskt/Core/Automation/Commands/EngineGroup/SetEngineDelayCommand.cs diff --git a/taskt/Core/Automation/Commands/Engine/SetEnginePreferenceCommand.cs b/taskt/Core/Automation/Commands/EngineGroup/SetEnginePreferenceCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Engine/SetEnginePreferenceCommand.cs rename to taskt/Core/Automation/Commands/EngineGroup/SetEnginePreferenceCommand.cs diff --git a/taskt/Core/Automation/Commands/Engine/ShowEngineContextCommand.cs b/taskt/Core/Automation/Commands/EngineGroup/ShowEngineContextCommand.cs similarity index 78% rename from taskt/Core/Automation/Commands/Engine/ShowEngineContextCommand.cs rename to taskt/Core/Automation/Commands/EngineGroup/ShowEngineContextCommand.cs index 388bde51b..f349753df 100644 --- a/taskt/Core/Automation/Commands/Engine/ShowEngineContextCommand.cs +++ b/taskt/Core/Automation/Commands/EngineGroup/ShowEngineContextCommand.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.Remoting.Contexts; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; @@ -41,15 +42,24 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) { var closeValue = this.ExpandValueOrUserVariableAsInteger(nameof(v_AutoCloseAfter), engine); - //automatically close messageboxes for server requests - if (engine.serverExecution && closeValue <= 0) + // automatically close messageboxes for server requests + if (engine.serverExecution && (closeValue <= 0)) { closeValue = 10; } - var result = engine.tasktEngineUI.Invoke(new Action(() => + //var result = engine.tasktEngineUI.Invoke(new Action(() => + // { + // engine.tasktEngineUI.ShowEngineContext(engine.GetEngineContext(), closeValue); + // } + //)); + + engine.tasktEngineUI.Invoke(new Action(() => { - engine.tasktEngineUI.ShowEngineContext(engine.GetEngineContext(), closeValue); + using (var fm = new UI.Forms.ScriptEngine.Supplemental.frmEngineContextViewer(engine.GetEngineContextAsJSON(), closeValue)) + { + fm.ShowDialog(); + } } )); } diff --git a/taskt/Core/Automation/Commands/Engine/UploadBotStoreDataCommand.cs b/taskt/Core/Automation/Commands/EngineGroup/UploadBotStoreDataCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Engine/UploadBotStoreDataCommand.cs rename to taskt/Core/Automation/Commands/EngineGroup/UploadBotStoreDataCommand.cs diff --git a/taskt/Core/Automation/Commands/Error/CatchExceptionCommand.cs b/taskt/Core/Automation/Commands/ErrorGroup/CatchExceptionCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Error/CatchExceptionCommand.cs rename to taskt/Core/Automation/Commands/ErrorGroup/CatchExceptionCommand.cs diff --git a/taskt/Core/Automation/Commands/Error/EndTryCommand.cs b/taskt/Core/Automation/Commands/ErrorGroup/EndTryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Error/EndTryCommand.cs rename to taskt/Core/Automation/Commands/ErrorGroup/EndTryCommand.cs diff --git a/taskt/Core/Automation/Commands/Error/FinallyCommand.cs b/taskt/Core/Automation/Commands/ErrorGroup/FinallyCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Error/FinallyCommand.cs rename to taskt/Core/Automation/Commands/ErrorGroup/FinallyCommand.cs diff --git a/taskt/Core/Automation/Commands/Error/IHaveTryAdditionalCommands.cs b/taskt/Core/Automation/Commands/ErrorGroup/IHaveTryAdditionalCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Error/IHaveTryAdditionalCommands.cs rename to taskt/Core/Automation/Commands/ErrorGroup/IHaveTryAdditionalCommands.cs diff --git a/taskt/Core/Automation/Commands/Error/ThrowExceptionCommand.cs b/taskt/Core/Automation/Commands/ErrorGroup/ThrowExceptionCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Error/ThrowExceptionCommand.cs rename to taskt/Core/Automation/Commands/ErrorGroup/ThrowExceptionCommand.cs diff --git a/taskt/Core/Automation/Commands/Error/TryCommand.cs b/taskt/Core/Automation/Commands/ErrorGroup/TryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Error/TryCommand.cs rename to taskt/Core/Automation/Commands/ErrorGroup/TryCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelCellActionCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelCellActionCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelCellActionCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelCellActionCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelCellCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelCellCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelCellCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelCellCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelColumnRangeCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRangeCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelColumnRangeCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRangeCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelColumnRangeGetCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRangeGetCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelColumnRangeGetCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRangeGetCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelColumnRangeSetCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRangeSetCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelColumnRangeSetCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRangeSetCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelColumnRowRangeCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRowRangeCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelColumnRowRangeCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRowRangeCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelColumnRowRangeGetCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRowRangeGetCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelColumnRowRangeGetCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnRowRangeGetCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelColumnSpecifiedCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnSpecifiedCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelColumnSpecifiedCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelColumnSpecifiedCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelInstanceCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelInstanceCommands.cs similarity index 94% rename from taskt/Core/Automation/Commands/Excel/AExcelInstanceCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelInstanceCommands.cs index fe5f1fa11..25ec028b2 100644 --- a/taskt/Core/Automation/Commands/Excel/AExcelInstanceCommands.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/AExcelInstanceCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for commands that using Excel instance /// - public abstract class AExcelInstanceCommands : ScriptCommand, ILExcelInstanceProperties + public abstract class AExcelInstanceCommands : ScriptCommand, IExcelInstanceProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(ExcelControls), nameof(ExcelControls.v_InputInstanceName))] diff --git a/taskt/Core/Automation/Commands/Excel/AExcelRCLocationActionCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelRCLocationActionCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelRCLocationActionCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelRCLocationActionCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelRCLocationCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelRCLocationCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelRCLocationCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelRCLocationCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelRowRangeCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelRowRangeCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelRowRangeCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelRowRangeCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelRowRangeGetCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelRowRangeGetCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelRowRangeGetCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelRowRangeGetCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelRowRangeSetCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelRowRangeSetCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelRowRangeSetCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelRowRangeSetCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/AExcelSheetCommands.cs b/taskt/Core/Automation/Commands/ExcelGroup/AExcelSheetCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/AExcelSheetCommands.cs rename to taskt/Core/Automation/Commands/ExcelGroup/AExcelSheetCommands.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelApplicationExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelApplicationExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelApplicationExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelApplicationExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelCellPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelCellPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelCellPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelCellPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelCellValueTypePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelCellValueTypePropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelCellValueTypePropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelCellValueTypePropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelColumnRangeGetPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnRangeGetPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelColumnRangeGetPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnRangeGetPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelColumnRangePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnRangePropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelColumnRangePropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnRangePropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelColumnRangeSetPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnRangeSetPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelColumnRangeSetPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnRangeSetPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelColumnRowRangePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnRowRangePropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelColumnRowRangePropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnRowRangePropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelColumnSpecifiedPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnSpecifiedPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelColumnSpecifiedPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelColumnSpecifiedPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelInstancePropertiesExtenstionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelInstancePropertiesExtenstionMethods.cs similarity index 94% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelInstancePropertiesExtenstionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelInstancePropertiesExtenstionMethods.cs index eaa1c9119..3e034f58e 100644 --- a/taskt/Core/Automation/Commands/Excel/EM_ExcelInstancePropertiesExtenstionMethods.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelInstancePropertiesExtenstionMethods.cs @@ -12,7 +12,7 @@ public static class EM_ExcelInstancePropertiesExtenstionMethods /// /// /// - public static Application ExpandValueOrVariableAsExcelInstance(this ILExcelInstanceProperties command, Engine.AutomationEngineInstance engine) + public static Application ExpandValueOrVariableAsExcelInstance(this IExcelInstanceProperties command, Engine.AutomationEngineInstance engine) { string ins = command.v_InstanceName.ExpandValueOrUserVariable(engine); var instanceObject = engine.GetAppInstance(ins); @@ -32,7 +32,7 @@ public static Application ExpandValueOrVariableAsExcelInstance(this ILExcelInsta /// /// /// - public static (Application, Worksheet) ExpandValueOrVariableAsExcelInstanceAndCurrentWorksheet(this ILExcelInstanceProperties command, Engine.AutomationEngineInstance engine) + public static (Application, Worksheet) ExpandValueOrVariableAsExcelInstanceAndCurrentWorksheet(this IExcelInstanceProperties command, Engine.AutomationEngineInstance engine) { var ins = command.ExpandValueOrVariableAsExcelInstance(engine); if (ins.Worksheets.Count > 0) @@ -109,7 +109,7 @@ private static Worksheet GetPreviousWorksheet(Application instance, Worksheet cu /// /// /// - public static Worksheet ExpandValueOrVariableAsExcelWorksheet(this ILExcelInstanceProperties command, string sheetName, Engine.AutomationEngineInstance engine) + public static Worksheet ExpandValueOrVariableAsExcelWorksheet(this IExcelInstanceProperties command, string sheetName, Engine.AutomationEngineInstance engine) { (var ins, var currentSheet) = command.ExpandValueOrVariableAsExcelInstanceAndCurrentWorksheet(engine); @@ -147,7 +147,7 @@ public static Worksheet ExpandValueOrVariableAsExcelWorksheet(this ILExcelInstan /// /// /// - public static string ExpandValueOrVariableAsExcelWorksheetName(this ILExcelInstanceProperties command, string sheet, Engine.AutomationEngineInstance engine) + public static string ExpandValueOrVariableAsExcelWorksheetName(this IExcelInstanceProperties command, string sheet, Engine.AutomationEngineInstance engine) { var newSheet = sheet.ExpandValueOrUserVariable(engine); diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelRCLocationPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRCLocationPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelRCLocationPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRCLocationPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelRCValueTypePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRCValueTypePropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelRCValueTypePropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRCValueTypePropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelRowRangeGetPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRowRangeGetPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelRowRangeGetPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRowRangeGetPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelRowRangePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRowRangePropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelRowRangePropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRowRangePropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelRowRangeSetPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRowRangeSetPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelRowRangeSetPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelRowRangeSetPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelWorksheetActionPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelWorksheetActionPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelWorksheetActionPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelWorksheetActionPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelWorksheetExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelWorksheetExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelWorksheetExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelWorksheetExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/EM_ExcelWorksheetPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelWorksheetPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/EM_ExcelWorksheetPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ExcelGroup/EM_ExcelWorksheetPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelActivateWorksheetCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelActivateWorksheetCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelActivateWorksheetCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelActivateWorksheetCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelAddWorkbookCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelAddWorkbookCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelAddWorkbookCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelAddWorkbookCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelAddWorksheetCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelAddWorksheetCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelAddWorksheetCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelAddWorksheetCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelAppendCellCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelAppendCellCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelAppendCellCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelAppendCellCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelAppendRowCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelAppendRowCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelAppendRowCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelAppendRowCommand.cs diff --git a/taskt/Core/Automation/Commands/ExcelGroup/ExcelAttachExcelInstanceCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelAttachExcelInstanceCommand.cs new file mode 100644 index 000000000..3de1aa67e --- /dev/null +++ b/taskt/Core/Automation/Commands/ExcelGroup/ExcelAttachExcelInstanceCommand.cs @@ -0,0 +1,98 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Excel")] + [Attributes.ClassAttributes.SubGruop("Instance")] + [Attributes.ClassAttributes.CommandSettings("Attach Excel Instance")] + [Attributes.ClassAttributes.Description("This command Attach the Excel Instance.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Attach an Existing Excelas Excel Instance.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Excel Interop to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class ExcelAttachExcelInstanceCommand : AExcelInstanceCommands + { + [XmlAttribute] + [PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] + [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.TextBox)] + [PropertyTextBoxSetting(1, false)] + public override string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + [PropertyParameterOrder(6000)] + public string v_WindowHandle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Reference Style")] + [PropertyUISelectionOption("A1")] + [PropertyUISelectionOption("R1C1")] + [PropertyIsOptional(true, "A1")] + [PropertyValidationRule("Reference Style", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Reference Style")] + [Remarks("Strongly recommend specifying **A1**")] + [PropertyParameterOrder(7000)] + public string v_ReferenceStyle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time for Excel")] + [PropertyIsOptional(true, "10")] + [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Wait Time")] + [PropertyParameterOrder(9000)] + public string v_WaitTimeForExcel { get; set; } + + public ExcelAttachExcelInstanceCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(v_WaitTimeForExcel)) + { + v_WaitTimeForExcel = "10"; + } + var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeForExcel), engine); + + var r = WaitControls.WaitProcess(waitTime, "Excel", new Func<(bool, object)>(() => + { + try + { + var excel = (Microsoft.Office.Interop.Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application"); + return (true, excel); + } + catch + { + return (false, null); + } + }), engine); + + if (r is Microsoft.Office.Interop.Excel.Application newExcelSession) + { + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ReferenceStyle), engine)) + { + case "a1": + newExcelSession.ReferenceStyle = Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1; + break; + case "r1c1": + newExcelSession.ReferenceStyle = Microsoft.Office.Interop.Excel.XlReferenceStyle.xlR1C1; + break; + } + + var vInstance = v_InstanceName.ExpandValueOrUserVariable(engine); + engine.AddAppInstance(vInstance, newExcelSession); + + if (!string.IsNullOrEmpty(v_WindowHandle)) + { + newExcelSession.Hwnd.StoreInUserVariable(engine, v_WindowHandle); + } + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Excel/ExcelCheckCellValueExistsCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCheckCellValueExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelCheckCellValueExistsCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelCheckCellValueExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelCheckCellValueExistsRCCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCheckCellValueExistsRCCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelCheckCellValueExistsRCCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelCheckCellValueExistsRCCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelCheckExcelInstanceExistsCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCheckExcelInstanceExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelCheckExcelInstanceExistsCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelCheckExcelInstanceExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelCheckWorksheetExistsCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCheckWorksheetExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelCheckWorksheetExistsCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelCheckWorksheetExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelCloseExcelInstanceCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCloseExcelInstanceCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelCloseExcelInstanceCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelCloseExcelInstanceCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelCopyWorksheetCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCopyWorksheetCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelCopyWorksheetCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelCopyWorksheetCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelCreateDataTableFromExcelFile.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCreateDataTableFromExcelFile.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelCreateDataTableFromExcelFile.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelCreateDataTableFromExcelFile.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelCreateDictionaryFromExcelFile.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCreateDictionaryFromExcelFile.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelCreateDictionaryFromExcelFile.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelCreateDictionaryFromExcelFile.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelCreateExcelInstanceCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCreateExcelInstanceCommand.cs similarity index 67% rename from taskt/Core/Automation/Commands/Excel/ExcelCreateExcelInstanceCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelCreateExcelInstanceCommand.cs index 921023af5..fc6f9380b 100644 --- a/taskt/Core/Automation/Commands/Excel/ExcelCreateExcelInstanceCommand.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/ExcelCreateExcelInstanceCommand.cs @@ -28,6 +28,18 @@ public sealed class ExcelCreateExcelInstanceCommand : AExcelInstanceCommands [PropertyParameterOrder(6000)] public string v_WindowHandle { get; set; } + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Reference Style")] + [PropertyUISelectionOption("A1")] + [PropertyUISelectionOption("R1C1")] + [PropertyIsOptional(true, "A1")] + [PropertyValidationRule("Reference Style", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Reference Style")] + [Remarks("Strongly recommend specifying **A1**")] + [PropertyParameterOrder(7000)] + public string v_ReferenceStyle { get; set; } + public ExcelCreateExcelInstanceCommand() { } @@ -41,6 +53,16 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) Visible = true }; + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ReferenceStyle), engine)) + { + case "a1": + newExcelSession.ReferenceStyle = Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1; + break; + case "r1c1": + newExcelSession.ReferenceStyle = Microsoft.Office.Interop.Excel.XlReferenceStyle.xlR1C1; + break; + } + engine.AddAppInstance(vInstance, newExcelSession); if (!string.IsNullOrEmpty(v_WindowHandle)) diff --git a/taskt/Core/Automation/Commands/Excel/ExcelDeleteCellCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelDeleteCellCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelDeleteCellCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelDeleteCellCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelDeleteRowCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelDeleteRowCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelDeleteRowCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelDeleteRowCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelDeleteWorksheetCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelDeleteWorksheetCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelDeleteWorksheetCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelDeleteWorksheetCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetCellCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetCellCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetCellCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetCellCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetCellRCCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetCellRCCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetCellRCCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetCellRCCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetColumnValuesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetColumnValuesAsDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetColumnValuesAsDataTableCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetColumnValuesAsDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetColumnValuesAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetColumnValuesAsDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetColumnValuesAsDictionaryCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetColumnValuesAsDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetColumnValuesAsListCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetColumnValuesAsListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetColumnValuesAsListCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetColumnValuesAsListCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetCurrentWorksheetCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetCurrentWorksheetCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetCurrentWorksheetCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetCurrentWorksheetCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetExcelInformationCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetExcelInformationCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetExcelInformationCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetExcelInformationCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetLastRowIndexCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetLastRowIndexCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetLastRowIndexCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetLastRowIndexCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetRangeCommand .cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRangeCommand .cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetRangeCommand .cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRangeCommand .cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetRangeCommandASDT.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRangeCommandASDT.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetRangeCommandASDT.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRangeCommandASDT.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetRangeValuesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRangeValuesAsDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetRangeValuesAsDataTableCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRangeValuesAsDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetRowValuesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRowValuesAsDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetRowValuesAsDataTableCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRowValuesAsDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetRowValuesAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRowValuesAsDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetRowValuesAsDictionaryCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRowValuesAsDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetRowValuesAsListCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRowValuesAsListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetRowValuesAsListCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetRowValuesAsListCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetWorksheetInformationCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetWorksheetInformationCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetWorksheetInformationCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetWorksheetInformationCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGetWorksheetsCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGetWorksheetsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGetWorksheetsCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGetWorksheetsCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGoToCellCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGoToCellCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGoToCellCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGoToCellCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelGoToCellRCCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelGoToCellRCCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelGoToCellRCCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelGoToCellRCCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelOpenWorkbookCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelOpenWorkbookCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelOpenWorkbookCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelOpenWorkbookCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelRenameWorksheetCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelRenameWorksheetCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelRenameWorksheetCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelRenameWorksheetCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelRunExcelMacroCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelRunExcelMacroCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelRunExcelMacroCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelRunExcelMacroCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSaveAsCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSaveAsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelSaveAsCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSaveAsCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSaveCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSaveCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelSaveCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSaveCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSetCellCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetCellCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/Excel/ExcelSetCellCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSetCellCommand.cs index 9a19b1994..16706c844 100644 --- a/taskt/Core/Automation/Commands/Excel/ExcelSetCellCommand.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetCellCommand.cs @@ -14,7 +14,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ExcelSetCellCommand : AExcelCellActionCommands, ILExcelValueSetProperties + public sealed class ExcelSetCellCommand : AExcelCellActionCommands, IExcelValueSetProperties { //[XmlAttribute] //[PropertyVirtualProperty(nameof(ExcelControls), nameof(ExcelControls.v_InputInstanceName))] diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSetCellRCCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetCellRCCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/Excel/ExcelSetCellRCCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSetCellRCCommand.cs index 525d1d929..33cf00a4f 100644 --- a/taskt/Core/Automation/Commands/Excel/ExcelSetCellRCCommand.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetCellRCCommand.cs @@ -14,7 +14,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ExcelSetCellRCCommand : AExcelRCLocationActionCommands, ILExcelValueSetProperties + public sealed class ExcelSetCellRCCommand : AExcelRCLocationActionCommands, IExcelValueSetProperties { //[XmlAttribute] //[PropertyVirtualProperty(nameof(ExcelControls), nameof(ExcelControls.v_InputInstanceName))] diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSetColumnValuesFromDataTableCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetColumnValuesFromDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelSetColumnValuesFromDataTableCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSetColumnValuesFromDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSetColumnValuesFromDictionaryCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetColumnValuesFromDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelSetColumnValuesFromDictionaryCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSetColumnValuesFromDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSetColumnValuesFromListCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetColumnValuesFromListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelSetColumnValuesFromListCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSetColumnValuesFromListCommand.cs diff --git a/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetColumnWidthCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetColumnWidthCommand.cs new file mode 100644 index 000000000..4b448026c --- /dev/null +++ b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetColumnWidthCommand.cs @@ -0,0 +1,44 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Excel")] + [Attributes.ClassAttributes.SubGruop("Column")] + [Attributes.ClassAttributes.CommandSettings("Set Column Width")] + [Attributes.ClassAttributes.Description("This command set Column Width")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to set Column Width")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_spreadsheet))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class ExcelSetColumnWidthCommand : AExcelColumnSpecifiedCommands + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Column Width")] + [InputSpecification("Number")] + [PropertyShowSampleUsageInDescription(true)] + [PropertyDetailSampleUsage("**10**", PropertyDetailSampleUsage.ValueType.Value)] + [PropertyDetailSampleUsage("**{{{vWdith}}}**", PropertyDetailSampleUsage.ValueType.VariableName)] + [PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + [PropertyDisplayText(true, "Width")] + [PropertyParameterOrder(8500)] + public string v_Width { get; set; } + + public ExcelSetColumnWidthCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + (var sheet, var column) = this.ExpandValueOrVariableAsExcelCurrentWorksheetAndColumnIndex(engine); + + var width = this.ExpandValueOrUserVariableAsInteger(nameof(v_Width), engine); + + sheet.Columns[column].ColumnWidth = width; + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSetRowValuesFormDataTableCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetRowValuesFormDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelSetRowValuesFormDataTableCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSetRowValuesFormDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSetRowValuesFormDictionaryCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetRowValuesFormDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelSetRowValuesFormDictionaryCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSetRowValuesFormDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSetRowValuesFormListCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSetRowValuesFormListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelSetRowValuesFormListCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSetRowValuesFormListCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelSplitRangeByColumnCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelSplitRangeByColumnCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelSplitRangeByColumnCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelSplitRangeByColumnCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/ExcelWriteRangeCommand.cs b/taskt/Core/Automation/Commands/ExcelGroup/ExcelWriteRangeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/ExcelWriteRangeCommand.cs rename to taskt/Core/Automation/Commands/ExcelGroup/ExcelWriteRangeCommand.cs diff --git a/taskt/Core/Automation/Commands/Excel/IExcelCellActionProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelCellActionProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/IExcelCellActionProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelCellActionProperties.cs diff --git a/taskt/Core/Automation/Commands/Excel/IExcelCellProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelCellProperties.cs similarity index 78% rename from taskt/Core/Automation/Commands/Excel/IExcelCellProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelCellProperties.cs index cf0311bc4..731934623 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelCellProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelCellProperties.cs @@ -3,7 +3,7 @@ /// /// Excel **Single** Cell properties /// - public interface IExcelCellProperties : ILExcelInstanceProperties + public interface IExcelCellProperties : IExcelInstanceProperties { /// /// cell location diff --git a/taskt/Core/Automation/Commands/Excel/IExcelCellValueTypeProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelCellValueTypeProperties.cs similarity index 67% rename from taskt/Core/Automation/Commands/Excel/IExcelCellValueTypeProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelCellValueTypeProperties.cs index 4b6e21a14..5dda2d383 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelCellValueTypeProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelCellValueTypeProperties.cs @@ -3,7 +3,7 @@ /// /// for Cell value type properties /// - public interface IExcelCellValueTypeProperties : ILExcelValueTypeProperties + public interface IExcelCellValueTypeProperties : IExcelValueTypeProperties { // only implements } diff --git a/taskt/Core/Automation/Commands/Excel/IExcelColumnRangeGetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRangeGetProperties.cs similarity index 83% rename from taskt/Core/Automation/Commands/Excel/IExcelColumnRangeGetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRangeGetProperties.cs index 675365981..bfa28664d 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelColumnRangeGetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRangeGetProperties.cs @@ -3,7 +3,7 @@ /// /// excel column range get properties /// - public interface IExcelColumnRangeGetProperties : IExcelColumnRangeProperties, ILExcelRangeGetProperties + public interface IExcelColumnRangeGetProperties : IExcelColumnRangeProperties, IExcelRangeGetProperties { // only implements } diff --git a/taskt/Core/Automation/Commands/Excel/IExcelColumnRangeProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRangeProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/IExcelColumnRangeProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRangeProperties.cs diff --git a/taskt/Core/Automation/Commands/Excel/IExcelColumnRangeSetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRangeSetProperties.cs similarity index 83% rename from taskt/Core/Automation/Commands/Excel/IExcelColumnRangeSetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRangeSetProperties.cs index f0bf53a11..ffffa8bba 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelColumnRangeSetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRangeSetProperties.cs @@ -3,7 +3,7 @@ /// /// excel column range set properties /// - public interface IExcelColumnRangeSetProperties : IExcelColumnRangeProperties, ILExcelRangeSetProperties + public interface IExcelColumnRangeSetProperties : IExcelColumnRangeProperties, IExcelRangeSetProperties { // only implements } diff --git a/taskt/Core/Automation/Commands/Excel/IExcelColumnRowRangeGetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRowRangeGetProperties.cs similarity index 83% rename from taskt/Core/Automation/Commands/Excel/IExcelColumnRowRangeGetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRowRangeGetProperties.cs index 3eb5dc3fb..58191f7f6 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelColumnRowRangeGetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRowRangeGetProperties.cs @@ -3,7 +3,7 @@ /// /// for excel column-row range (2D-range) get properties /// - public interface IExcelColumnRowRangeGetProperties : IExcelColumnRowRangeProperties, ILExcelRangeGetProperties + public interface IExcelColumnRowRangeGetProperties : IExcelColumnRowRangeProperties, IExcelRangeGetProperties { // only implements } diff --git a/taskt/Core/Automation/Commands/Excel/IExcelColumnRowRangeProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRowRangeProperties.cs similarity index 85% rename from taskt/Core/Automation/Commands/Excel/IExcelColumnRowRangeProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRowRangeProperties.cs index 1d1e85a2a..bf79df363 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelColumnRowRangeProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRowRangeProperties.cs @@ -3,7 +3,7 @@ /// /// for Excel Column-Row Range (2D-Range) Properties /// - public interface IExcelColumnRowRangeProperties : ILExcelInstanceProperties, IExcelRCRangeProperties + public interface IExcelColumnRowRangeProperties : IExcelInstanceProperties, IExcelRCRangeProperties { /// /// column start index diff --git a/taskt/Core/Automation/Commands/Excel/IExcelColumnRowRangeSetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRowRangeSetProperties.cs similarity index 83% rename from taskt/Core/Automation/Commands/Excel/IExcelColumnRowRangeSetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRowRangeSetProperties.cs index 7172514b6..167bfb28b 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelColumnRowRangeSetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnRowRangeSetProperties.cs @@ -3,7 +3,7 @@ /// /// for Excel column-row range (2D-Range) set properties /// - public interface IExcelColumnRowRangeSetProperties : IExcelColumnRowRangeProperties, ILExcelRangeSetProperties + public interface IExcelColumnRowRangeSetProperties : IExcelColumnRowRangeProperties, IExcelRangeSetProperties { // only implements } diff --git a/taskt/Core/Automation/Commands/Excel/IExcelColumnSpecifiedProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnSpecifiedProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/IExcelColumnSpecifiedProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelColumnSpecifiedProperties.cs diff --git a/taskt/Core/Automation/Commands/Excel/ILExcelInstanceProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelInstanceProperties.cs similarity index 77% rename from taskt/Core/Automation/Commands/Excel/ILExcelInstanceProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelInstanceProperties.cs index 7456a5bc9..3af339101 100644 --- a/taskt/Core/Automation/Commands/Excel/ILExcelInstanceProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelInstanceProperties.cs @@ -3,7 +3,7 @@ /// /// excel instance properties /// - public interface ILExcelInstanceProperties : ILExpandableProperties + public interface IExcelInstanceProperties : IExpandableProperties { /// /// excel instance name diff --git a/taskt/Core/Automation/Commands/Excel/IExcelRCLocationActionProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRCLocationActionProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/IExcelRCLocationActionProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelRCLocationActionProperties.cs diff --git a/taskt/Core/Automation/Commands/Excel/IExcelRCLocationProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRCLocationProperties.cs similarity index 82% rename from taskt/Core/Automation/Commands/Excel/IExcelRCLocationProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelRCLocationProperties.cs index 2e6a954cf..98b67c086 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelRCLocationProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRCLocationProperties.cs @@ -3,7 +3,7 @@ /// /// cell RC row, column properties /// - public interface IExcelRCLocationProperties : ILExcelInstanceProperties + public interface IExcelRCLocationProperties : IExcelInstanceProperties { /// /// cell row index diff --git a/taskt/Core/Automation/Commands/Excel/IExcelRCRangeProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRCRangeProperties.cs similarity index 73% rename from taskt/Core/Automation/Commands/Excel/IExcelRCRangeProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelRCRangeProperties.cs index 5599bc473..d8c047f7b 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelRCRangeProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRCRangeProperties.cs @@ -3,7 +3,7 @@ /// /// Range properties specified Row, Column /// - public interface IExcelRCRangeProperties : ILExcelInstanceProperties, IExcelRCValueTypeProperties + public interface IExcelRCRangeProperties : IExcelInstanceProperties, IExcelRCValueTypeProperties { /// /// column type Name(Range) or Index diff --git a/taskt/Core/Automation/Commands/Excel/IExcelRCValueTypeProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRCValueTypeProperties.cs similarity index 68% rename from taskt/Core/Automation/Commands/Excel/IExcelRCValueTypeProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelRCValueTypeProperties.cs index f61bb9c75..4aa87c298 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelRCValueTypeProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRCValueTypeProperties.cs @@ -3,7 +3,7 @@ /// /// for Excel RC Value Type properties /// - public interface IExcelRCValueTypeProperties : ILExcelValueTypeProperties + public interface IExcelRCValueTypeProperties : IExcelValueTypeProperties { // only implements } diff --git a/taskt/Core/Automation/Commands/Excel/ILExcelRangeGetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRangeGetProperties.cs similarity index 78% rename from taskt/Core/Automation/Commands/Excel/ILExcelRangeGetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelRangeGetProperties.cs index 88e1b0284..d65ec68d0 100644 --- a/taskt/Core/Automation/Commands/Excel/ILExcelRangeGetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRangeGetProperties.cs @@ -3,7 +3,7 @@ /// /// excel Range get properties /// - public interface ILExcelRangeGetProperties : ILExpandableProperties + public interface IExcelRangeGetProperties : IExpandableProperties { /// /// variable name to store result diff --git a/taskt/Core/Automation/Commands/Excel/ILExcelRangeSetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRangeSetProperties.cs similarity index 81% rename from taskt/Core/Automation/Commands/Excel/ILExcelRangeSetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelRangeSetProperties.cs index 03f367ef6..7744fefc8 100644 --- a/taskt/Core/Automation/Commands/Excel/ILExcelRangeSetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRangeSetProperties.cs @@ -3,7 +3,7 @@ /// /// excel range Set properties /// - public interface ILExcelRangeSetProperties : ILExpandableProperties + public interface IExcelRangeSetProperties : IExpandableProperties { /// /// behavior when specified Item(List/Dictionary/DataTable) items not enough diff --git a/taskt/Core/Automation/Commands/Excel/IExcelRowRangeGetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRowRangeGetProperties.cs similarity index 85% rename from taskt/Core/Automation/Commands/Excel/IExcelRowRangeGetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelRowRangeGetProperties.cs index 39a01deb7..d4ad565b1 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelRowRangeGetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRowRangeGetProperties.cs @@ -3,7 +3,7 @@ /// /// row Range Get commands properties /// - public interface IExcelRowRangeGetProperties : IExcelRowRangeProperties, ILExcelRangeGetProperties + public interface IExcelRowRangeGetProperties : IExcelRowRangeProperties, IExcelRangeGetProperties { // only implements } diff --git a/taskt/Core/Automation/Commands/Excel/IExcelRowRangeProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRowRangeProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/IExcelRowRangeProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelRowRangeProperties.cs diff --git a/taskt/Core/Automation/Commands/Excel/IExcelRowRangeSetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRowRangeSetProperties.cs similarity index 85% rename from taskt/Core/Automation/Commands/Excel/IExcelRowRangeSetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelRowRangeSetProperties.cs index e3ba5e4be..8bd22f234 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelRowRangeSetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelRowRangeSetProperties.cs @@ -3,7 +3,7 @@ /// /// for Excel Row Range Set properties /// - public interface IExcelRowRangeSetProperties : IExcelRowRangeProperties, ILExcelRangeSetProperties + public interface IExcelRowRangeSetProperties : IExcelRowRangeProperties, IExcelRangeSetProperties { // only implements } diff --git a/taskt/Core/Automation/Commands/Excel/ILExcelValueSetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelValueSetProperties.cs similarity index 70% rename from taskt/Core/Automation/Commands/Excel/ILExcelValueSetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelValueSetProperties.cs index b4ba3a7af..041305684 100644 --- a/taskt/Core/Automation/Commands/Excel/ILExcelValueSetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelValueSetProperties.cs @@ -1,6 +1,6 @@ namespace taskt.Core.Automation.Commands { - public interface ILExcelValueSetProperties : ILExpandableProperties + public interface IExcelValueSetProperties : IExpandableProperties { /// /// text to set diff --git a/taskt/Core/Automation/Commands/Excel/ILExcelValueTypeProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelValueTypeProperties.cs similarity index 76% rename from taskt/Core/Automation/Commands/Excel/ILExcelValueTypeProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelValueTypeProperties.cs index 960a15463..e4b760ac3 100644 --- a/taskt/Core/Automation/Commands/Excel/ILExcelValueTypeProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelValueTypeProperties.cs @@ -3,7 +3,7 @@ /// /// excel value type properties /// - public interface ILExcelValueTypeProperties : ILExpandableProperties + public interface IExcelValueTypeProperties : IExpandableProperties { /// /// value type diff --git a/taskt/Core/Automation/Commands/Excel/IExcelWorksheetActionProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelWorksheetActionProperties.cs similarity index 70% rename from taskt/Core/Automation/Commands/Excel/IExcelWorksheetActionProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelWorksheetActionProperties.cs index 565989391..4eb522973 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelWorksheetActionProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelWorksheetActionProperties.cs @@ -1,6 +1,6 @@ namespace taskt.Core.Automation.Commands { - public interface IExcelWorksheetActionProperties : ILExcelInstanceProperties + public interface IExcelWorksheetActionProperties : IExcelInstanceProperties { /// /// worksheet name for action diff --git a/taskt/Core/Automation/Commands/Excel/IExcelWorksheetCopyRenameProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelWorksheetCopyRenameProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Excel/IExcelWorksheetCopyRenameProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelWorksheetCopyRenameProperties.cs diff --git a/taskt/Core/Automation/Commands/Excel/IExcelWorksheetProperties.cs b/taskt/Core/Automation/Commands/ExcelGroup/IExcelWorksheetProperties.cs similarity index 76% rename from taskt/Core/Automation/Commands/Excel/IExcelWorksheetProperties.cs rename to taskt/Core/Automation/Commands/ExcelGroup/IExcelWorksheetProperties.cs index 5b5db4e76..c969f2ed8 100644 --- a/taskt/Core/Automation/Commands/Excel/IExcelWorksheetProperties.cs +++ b/taskt/Core/Automation/Commands/ExcelGroup/IExcelWorksheetProperties.cs @@ -3,7 +3,7 @@ /// /// excel worksheet properties /// - public interface IExcelWorksheetProperties : ILExcelInstanceProperties + public interface IExcelWorksheetProperties : IExcelInstanceProperties { /// /// excel worksheet name diff --git a/taskt/Core/Automation/Commands/File/AFileCopyMoveFileCommands.cs b/taskt/Core/Automation/Commands/FileGroup/AFileCopyMoveFileCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/AFileCopyMoveFileCommands.cs rename to taskt/Core/Automation/Commands/FileGroup/AFileCopyMoveFileCommands.cs diff --git a/taskt/Core/Automation/Commands/File/AFileCopySameRenameFileCommands.cs b/taskt/Core/Automation/Commands/FileGroup/AFileCopySameRenameFileCommands.cs similarity index 99% rename from taskt/Core/Automation/Commands/File/AFileCopySameRenameFileCommands.cs rename to taskt/Core/Automation/Commands/FileGroup/AFileCopySameRenameFileCommands.cs index 1de51d5dc..4dbfc9245 100644 --- a/taskt/Core/Automation/Commands/File/AFileCopySameRenameFileCommands.cs +++ b/taskt/Core/Automation/Commands/FileGroup/AFileCopySameRenameFileCommands.cs @@ -108,7 +108,7 @@ protected Func CreateActionFunc(Action processFu var newExtension = v_NewExtension.ExpandValueOrUserVariable(engine); if (!newExtension.StartsWith(".")) { - newExtension = "." + newExtension; + newExtension = $".{newExtension}"; } var newFileOption = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ExtensionOption), engine); diff --git a/taskt/Core/Automation/Commands/File/AFileExistsFilePathBeforeAfterResultCommands.cs b/taskt/Core/Automation/Commands/FileGroup/AFileExistsFilePathBeforeAfterResultCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/AFileExistsFilePathBeforeAfterResultCommands.cs rename to taskt/Core/Automation/Commands/FileGroup/AFileExistsFilePathBeforeAfterResultCommands.cs diff --git a/taskt/Core/Automation/Commands/File/AFileExistsFilePathCommands.cs b/taskt/Core/Automation/Commands/FileGroup/AFileExistsFilePathCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/AFileExistsFilePathCommands.cs rename to taskt/Core/Automation/Commands/FileGroup/AFileExistsFilePathCommands.cs diff --git a/taskt/Core/Automation/Commands/File/AFileExistsFilePathPathResultCommands.cs b/taskt/Core/Automation/Commands/FileGroup/AFileExistsFilePathPathResultCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/AFileExistsFilePathPathResultCommands.cs rename to taskt/Core/Automation/Commands/FileGroup/AFileExistsFilePathPathResultCommands.cs diff --git a/taskt/Core/Automation/Commands/File/AFileFilePathCommands.cs b/taskt/Core/Automation/Commands/FileGroup/AFileFilePathCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/AFileFilePathCommands.cs rename to taskt/Core/Automation/Commands/FileGroup/AFileFilePathCommands.cs diff --git a/taskt/Core/Automation/Commands/File/AFileNumberedFileCommands.cs b/taskt/Core/Automation/Commands/FileGroup/AFileNumberedFileCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/AFileNumberedFileCommands.cs rename to taskt/Core/Automation/Commands/FileGroup/AFileNumberedFileCommands.cs diff --git a/taskt/Core/Automation/Commands/File/CheckFileExistsCommand.cs b/taskt/Core/Automation/Commands/FileGroup/CheckFileExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/CheckFileExistsCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/CheckFileExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/File/CopyFileCommand.cs b/taskt/Core/Automation/Commands/FileGroup/CopyFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/CopyFileCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/CopyFileCommand.cs diff --git a/taskt/Core/Automation/Commands/File/CopyFileToSameFolderCommand.cs b/taskt/Core/Automation/Commands/FileGroup/CopyFileToSameFolderCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/CopyFileToSameFolderCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/CopyFileToSameFolderCommand.cs diff --git a/taskt/Core/Automation/Commands/File/DeleteFileCommand.cs b/taskt/Core/Automation/Commands/FileGroup/DeleteFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/DeleteFileCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/DeleteFileCommand.cs diff --git a/taskt/Core/Automation/Commands/File/EM_CanHandleFileNameExtensionMethods.cs b/taskt/Core/Automation/Commands/FileGroup/EM_CanHandleFileNameExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/EM_CanHandleFileNameExtensionMethods.cs rename to taskt/Core/Automation/Commands/FileGroup/EM_CanHandleFileNameExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/File/EM_CanHandleFilePathExtentionMethods.cs b/taskt/Core/Automation/Commands/FileGroup/EM_CanHandleFilePathExtentionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/EM_CanHandleFilePathExtentionMethods.cs rename to taskt/Core/Automation/Commands/FileGroup/EM_CanHandleFilePathExtentionMethods.cs diff --git a/taskt/Core/Automation/Commands/File/EM_FileExistsFilePathBeforeAfterPathResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/FileGroup/EM_FileExistsFilePathBeforeAfterPathResultPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/EM_FileExistsFilePathBeforeAfterPathResultPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/FileGroup/EM_FileExistsFilePathBeforeAfterPathResultPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/File/EM_FileExistsFilePathPathResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/FileGroup/EM_FileExistsFilePathPathResultPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/EM_FileExistsFilePathPathResultPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/FileGroup/EM_FileExistsFilePathPathResultPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/File/EM_FileExistsFilePathPropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/FileGroup/EM_FileExistsFilePathPropertiesExtentionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/EM_FileExistsFilePathPropertiesExtentionMethods.cs rename to taskt/Core/Automation/Commands/FileGroup/EM_FileExistsFilePathPropertiesExtentionMethods.cs diff --git a/taskt/Core/Automation/Commands/File/EM_FilePathPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/FileGroup/EM_FilePathPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/EM_FilePathPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/FileGroup/EM_FilePathPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/File/ExtractZipFileCommand.cs b/taskt/Core/Automation/Commands/FileGroup/ExtractZipFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/ExtractZipFileCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/ExtractZipFileCommand.cs diff --git a/taskt/Core/Automation/Commands/File/ExtractionFilePathCommand.cs b/taskt/Core/Automation/Commands/FileGroup/ExtractionFilePathCommand.cs similarity index 97% rename from taskt/Core/Automation/Commands/File/ExtractionFilePathCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/ExtractionFilePathCommand.cs index 4dbdb4a93..cb2ca9dc3 100644 --- a/taskt/Core/Automation/Commands/File/ExtractionFilePathCommand.cs +++ b/taskt/Core/Automation/Commands/FileGroup/ExtractionFilePathCommand.cs @@ -56,7 +56,7 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) var filePath = this.ExpandValueOrUserVariableAsFilePath(engine); string format = v_Format.ExpandValueOrUserVariable(engine); - string result = FilePathControls.FormatFileFolderPath(filePath, format); + string result = FilePathControls.ExtractionFilePath(filePath, format); result.StoreInUserVariable(engine, v_Result); } diff --git a/taskt/Core/Automation/Commands/File/GetFileInformationCommand.cs b/taskt/Core/Automation/Commands/FileGroup/GetFileInformationCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/GetFileInformationCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/GetFileInformationCommand.cs diff --git a/taskt/Core/Automation/Commands/File/GetFilesPathAsListCommand.cs b/taskt/Core/Automation/Commands/FileGroup/GetFilesPathAsListCommand.cs similarity index 89% rename from taskt/Core/Automation/Commands/File/GetFilesPathAsListCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/GetFilesPathAsListCommand.cs index b6e438f04..3b6d37cc3 100644 --- a/taskt/Core/Automation/Commands/File/GetFilesPathAsListCommand.cs +++ b/taskt/Core/Automation/Commands/FileGroup/GetFilesPathAsListCommand.cs @@ -4,6 +4,7 @@ using System.Linq; using System.IO; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; namespace taskt.Core.Automation.Commands { @@ -16,7 +17,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_files))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetFilesPathAsListCommand : AFolderExistsFolderPathCommands, ITextCompareProperties, IListResultProperties + public sealed class GetFilesPathAsListCommand : AFolderExistsFolderPathCommands, ITextCheckProperties, IListResultProperties { //[XmlAttribute] //[PropertyDescription("Path to the Source Folder")] @@ -53,20 +54,20 @@ public sealed class GetFilesPathAsListCommand : AFolderExistsFolderPathCommands, //[PropertyUISelectionOption("Exact match")] //[PropertyIsOptional(true, "Contains")] //[PropertyDisplayText(true, "Search Method")] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CompareMethod))] - [PropertyDescription("File Name Compare Method")] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CheckMethod))] + [PropertyDescription("File Name Check Method")] [PropertyParameterOrder(6100)] - public string v_CompareMethod { get; set; } + public string v_CheckMethod { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveNo))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveNo))] [PropertyParameterOrder(6200)] public string v_CaseSensitive { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_TrimBeforeCompare))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_TrimBeforeCheck))] [PropertyParameterOrder(6300)] - public string v_TrimBeforeCompare { get; set; } + public string v_TrimBeforeCheck { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] @@ -105,7 +106,7 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) // get all files var fullFilesList = Directory.GetFiles(sourceFolder).ToList(); - var compareFunc = this.GetCompareFunction(engine); + var compareFunc = this.GetTextCheckFunction(engine); var comparedFilesList = new List(); foreach (var f in fullFilesList) { diff --git a/taskt/Core/Automation/Commands/File/GetLastExistentNumberdFilePathCommand.cs b/taskt/Core/Automation/Commands/FileGroup/GetLastExistentNumberdFilePathCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/GetLastExistentNumberdFilePathCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/GetLastExistentNumberdFilePathCommand.cs diff --git a/taskt/Core/Automation/Commands/File/GetNonExistentFilePathCommand.cs b/taskt/Core/Automation/Commands/FileGroup/GetNonExistentFilePathCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/GetNonExistentFilePathCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/GetNonExistentFilePathCommand.cs diff --git a/taskt/Core/Automation/Commands/File/GetRandomFilePathCommand.cs b/taskt/Core/Automation/Commands/FileGroup/GetRandomFilePathCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/GetRandomFilePathCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/GetRandomFilePathCommand.cs diff --git a/taskt/Core/Automation/Commands/File/ICanHandleFileName.cs b/taskt/Core/Automation/Commands/FileGroup/ICanHandleFileName.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/ICanHandleFileName.cs rename to taskt/Core/Automation/Commands/FileGroup/ICanHandleFileName.cs diff --git a/taskt/Core/Automation/Commands/File/ICanHandleFilePath.cs b/taskt/Core/Automation/Commands/FileGroup/ICanHandleFilePath.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/ICanHandleFilePath.cs rename to taskt/Core/Automation/Commands/FileGroup/ICanHandleFilePath.cs diff --git a/taskt/Core/Automation/Commands/File/IFileExistsFilePathBeforeAfterPathResultProperties.cs b/taskt/Core/Automation/Commands/FileGroup/IFileExistsFilePathBeforeAfterPathResultProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/IFileExistsFilePathBeforeAfterPathResultProperties.cs rename to taskt/Core/Automation/Commands/FileGroup/IFileExistsFilePathBeforeAfterPathResultProperties.cs diff --git a/taskt/Core/Automation/Commands/File/IFileExistsFilePathPathResultProperties.cs b/taskt/Core/Automation/Commands/FileGroup/IFileExistsFilePathPathResultProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/IFileExistsFilePathPathResultProperties.cs rename to taskt/Core/Automation/Commands/FileGroup/IFileExistsFilePathPathResultProperties.cs diff --git a/taskt/Core/Automation/Commands/File/IFileExistsFilePathProperties.cs b/taskt/Core/Automation/Commands/FileGroup/IFileExistsFilePathProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/IFileExistsFilePathProperties.cs rename to taskt/Core/Automation/Commands/FileGroup/IFileExistsFilePathProperties.cs diff --git a/taskt/Core/Automation/Commands/File/IFilePathProperties.cs b/taskt/Core/Automation/Commands/FileGroup/IFilePathProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/IFilePathProperties.cs rename to taskt/Core/Automation/Commands/FileGroup/IFilePathProperties.cs diff --git a/taskt/Core/Automation/Commands/File/MoveFileCommand.cs b/taskt/Core/Automation/Commands/FileGroup/MoveFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/MoveFileCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/MoveFileCommand.cs diff --git a/taskt/Core/Automation/Commands/File/RenameFileCommand.cs b/taskt/Core/Automation/Commands/FileGroup/RenameFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/RenameFileCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/RenameFileCommand.cs diff --git a/taskt/Core/Automation/Commands/File/WaitForFileToExistCommand.cs b/taskt/Core/Automation/Commands/FileGroup/WaitForFileToExistCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/File/WaitForFileToExistCommand.cs rename to taskt/Core/Automation/Commands/FileGroup/WaitForFileToExistCommand.cs diff --git a/taskt/Core/Automation/Commands/FilePathControls.cs b/taskt/Core/Automation/Commands/FilePathControls.cs index d4d0c43f3..b04613378 100644 --- a/taskt/Core/Automation/Commands/FilePathControls.cs +++ b/taskt/Core/Automation/Commands/FilePathControls.cs @@ -527,12 +527,12 @@ internal static class FilePathControls //} /// - /// format file/folder path to specified format + /// extraction file/folder path to specified format /// /// /// /// - public static string FormatFileFolderPath(string path, string format) + public static string ExtractionFilePath(string path, string format) { // todo: separate when path is folder or file switch (format.ToLower()) diff --git a/taskt/Core/Automation/Commands/Folder/AFileFilePathCommands.cs b/taskt/Core/Automation/Commands/FolderGroup/AFileFilePathCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/AFileFilePathCommands.cs rename to taskt/Core/Automation/Commands/FolderGroup/AFileFilePathCommands.cs diff --git a/taskt/Core/Automation/Commands/Folder/AFolderCopyMoveCommands.cs b/taskt/Core/Automation/Commands/FolderGroup/AFolderCopyMoveCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/AFolderCopyMoveCommands.cs rename to taskt/Core/Automation/Commands/FolderGroup/AFolderCopyMoveCommands.cs diff --git a/taskt/Core/Automation/Commands/Folder/AFolderCopySameRenameFolderCommands.cs b/taskt/Core/Automation/Commands/FolderGroup/AFolderCopySameRenameFolderCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/AFolderCopySameRenameFolderCommands.cs rename to taskt/Core/Automation/Commands/FolderGroup/AFolderCopySameRenameFolderCommands.cs diff --git a/taskt/Core/Automation/Commands/Folder/AFolderExistsFolderBeforeAfterResultCommands.cs b/taskt/Core/Automation/Commands/FolderGroup/AFolderExistsFolderBeforeAfterResultCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/AFolderExistsFolderBeforeAfterResultCommands.cs rename to taskt/Core/Automation/Commands/FolderGroup/AFolderExistsFolderBeforeAfterResultCommands.cs diff --git a/taskt/Core/Automation/Commands/Folder/AFolderExistsFolderPathCommands.cs b/taskt/Core/Automation/Commands/FolderGroup/AFolderExistsFolderPathCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/AFolderExistsFolderPathCommands.cs rename to taskt/Core/Automation/Commands/FolderGroup/AFolderExistsFolderPathCommands.cs diff --git a/taskt/Core/Automation/Commands/Folder/AFolderExistsFolderPathPathResultCommands.cs b/taskt/Core/Automation/Commands/FolderGroup/AFolderExistsFolderPathPathResultCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/AFolderExistsFolderPathPathResultCommands.cs rename to taskt/Core/Automation/Commands/FolderGroup/AFolderExistsFolderPathPathResultCommands.cs diff --git a/taskt/Core/Automation/Commands/Folder/CheckFolderExistsCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/CheckFolderExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/CheckFolderExistsCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/CheckFolderExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/CopyFolderCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/CopyFolderCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/CopyFolderCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/CopyFolderCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/CopyFolderInSameLocationCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/CopyFolderInSameLocationCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/CopyFolderInSameLocationCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/CopyFolderInSameLocationCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/CreateFolderByPathCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/CreateFolderByPathCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/CreateFolderByPathCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/CreateFolderByPathCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/CreateFolderCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/CreateFolderCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/CreateFolderCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/CreateFolderCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/DeleteFolderCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/DeleteFolderCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/DeleteFolderCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/DeleteFolderCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/EM_CanHandleFolderNameExtensionMethods.cs b/taskt/Core/Automation/Commands/FolderGroup/EM_CanHandleFolderNameExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/EM_CanHandleFolderNameExtensionMethods.cs rename to taskt/Core/Automation/Commands/FolderGroup/EM_CanHandleFolderNameExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Folder/EM_CanHandleFolderPathExtensionMethods.cs b/taskt/Core/Automation/Commands/FolderGroup/EM_CanHandleFolderPathExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/EM_CanHandleFolderPathExtensionMethods.cs rename to taskt/Core/Automation/Commands/FolderGroup/EM_CanHandleFolderPathExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Folder/EM_FolderCopyFolderPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/FolderGroup/EM_FolderCopyFolderPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/EM_FolderCopyFolderPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/FolderGroup/EM_FolderCopyFolderPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Folder/EM_FolderExistsFolderPathBeforeAfterPathResultPropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/FolderGroup/EM_FolderExistsFolderPathBeforeAfterPathResultPropertiesExtentionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/EM_FolderExistsFolderPathBeforeAfterPathResultPropertiesExtentionMethods.cs rename to taskt/Core/Automation/Commands/FolderGroup/EM_FolderExistsFolderPathBeforeAfterPathResultPropertiesExtentionMethods.cs diff --git a/taskt/Core/Automation/Commands/Folder/EM_FolderExistsFolderPathPathResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/FolderGroup/EM_FolderExistsFolderPathPathResultPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/EM_FolderExistsFolderPathPathResultPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/FolderGroup/EM_FolderExistsFolderPathPathResultPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Folder/EM_FolderExistsFolderPathPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/FolderGroup/EM_FolderExistsFolderPathPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/EM_FolderExistsFolderPathPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/FolderGroup/EM_FolderExistsFolderPathPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Folder/EM_FolderPathPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/FolderGroup/EM_FolderPathPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/EM_FolderPathPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/FolderGroup/EM_FolderPathPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Folder/ExtractionFolderPathCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/ExtractionFolderPathCommand.cs similarity index 77% rename from taskt/Core/Automation/Commands/Folder/ExtractionFolderPathCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/ExtractionFolderPathCommand.cs index 61ecdac77..78c90b649 100644 --- a/taskt/Core/Automation/Commands/Folder/ExtractionFolderPathCommand.cs +++ b/taskt/Core/Automation/Commands/FolderGroup/ExtractionFolderPathCommand.cs @@ -24,8 +24,9 @@ public sealed class ExtractionFolderPathCommand : AFolderFolderPathCommands [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] [PropertyDescription("Folder Path Format")] - [PropertyUISelectionOption("Folder")] - [PropertyUISelectionOption("DriveName")] + [PropertyUISelectionOption("Folder Name")] + [PropertyUISelectionOption("Parent Folder")] + [PropertyUISelectionOption("Drive Name")] [PropertyCustomUIHelper("Format Checker", nameof(lnkFormatChecker_Click))] [PropertyValidationRule("Format", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "Format")] @@ -50,9 +51,22 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) //string folderPath = v_TargetFolderPath.ExpandValueOrUserVariableAsFolderPath(engine); var folderPath = this.ExpandValueOrUserVariableAsFolderPath(engine); - var format = v_Format.ExpandValueOrUserVariable(engine); + //var format = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_Format), engine); + string cFormat = ""; + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_Format), engine)) + { + case "folder name": + cFormat = "FileName"; + break; + case "parent folder": + cFormat = "Folder"; + break; + case "drive name": + cFormat = "DriveName"; + break; + } - var result = FilePathControls.FormatFileFolderPath(folderPath, format); + var result = FilePathControls.ExtractionFilePath(folderPath, cFormat); result.StoreInUserVariable(engine, v_Result); } diff --git a/taskt/Core/Automation/Commands/Folder/GetFoldersPathAsListCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/GetFoldersPathAsListCommand.cs similarity index 86% rename from taskt/Core/Automation/Commands/Folder/GetFoldersPathAsListCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/GetFoldersPathAsListCommand.cs index 765c47ac3..fb46f759e 100644 --- a/taskt/Core/Automation/Commands/Folder/GetFoldersPathAsListCommand.cs +++ b/taskt/Core/Automation/Commands/FolderGroup/GetFoldersPathAsListCommand.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; namespace taskt.Core.Automation.Commands { @@ -16,7 +17,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_files))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetFoldersPathAsListCommand : AFolderExistsFolderPathCommands, ITextCompareProperties, IListResultProperties + public sealed class GetFoldersPathAsListCommand : AFolderExistsFolderPathCommands, ITextCheckProperties, IListResultProperties { //[XmlAttribute] //[PropertyVirtualProperty(nameof(FolderPathControls), nameof(FolderPathControls.v_FolderPath))] @@ -43,20 +44,20 @@ public sealed class GetFoldersPathAsListCommand : AFolderExistsFolderPathCommand //[PropertyUISelectionOption("Ends with")] //[PropertyUISelectionOption("Exact match")] //[PropertyIsOptional(true, "Contains")] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CompareMethod))] - [PropertyDescription("Folder Name Compare Method")] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CheckMethod))] + [PropertyDescription("Folder Name Check Method")] [PropertyParameterOrder(6100)] - public string v_CompareMethod { get; set; } + public string v_CheckMethod { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveNo))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveNo))] [PropertyParameterOrder(6200)] public string v_CaseSensitive { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_TrimBeforeCompare))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_TrimBeforeCheck))] [PropertyParameterOrder(6300)] - public string v_TrimBeforeCompare { get; set; } + public string v_TrimBeforeCheck { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] @@ -88,7 +89,7 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) //var searchFolder = v_SearchFolderName.ExpandValueOrUserVariableAsFolderName(engine); var searchFolder = this.ExpandValueOrUserVariable(nameof(v_SearchFolderName), "Folder Name", engine); - var compareFunc = this.GetCompareFunction(engine); + var compareFunc = this.GetTextCheckFunction(engine); var filteredDirectory = new List(); foreach (var f in directoriesList) diff --git a/taskt/Core/Automation/Commands/Folder/GetRandomFolderPathCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/GetRandomFolderPathCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/GetRandomFolderPathCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/GetRandomFolderPathCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/GetSpecialFolderPathCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/GetSpecialFolderPathCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/GetSpecialFolderPathCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/GetSpecialFolderPathCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/ICanHandleFolderName.cs b/taskt/Core/Automation/Commands/FolderGroup/ICanHandleFolderName.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/ICanHandleFolderName.cs rename to taskt/Core/Automation/Commands/FolderGroup/ICanHandleFolderName.cs diff --git a/taskt/Core/Automation/Commands/Folder/ICanHandleFolderPath.cs b/taskt/Core/Automation/Commands/FolderGroup/ICanHandleFolderPath.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/ICanHandleFolderPath.cs rename to taskt/Core/Automation/Commands/FolderGroup/ICanHandleFolderPath.cs diff --git a/taskt/Core/Automation/Commands/Folder/IFolderCopyFolderProperties.cs b/taskt/Core/Automation/Commands/FolderGroup/IFolderCopyFolderProperties.cs similarity index 77% rename from taskt/Core/Automation/Commands/Folder/IFolderCopyFolderProperties.cs rename to taskt/Core/Automation/Commands/FolderGroup/IFolderCopyFolderProperties.cs index 147c34bc5..8f339d986 100644 --- a/taskt/Core/Automation/Commands/Folder/IFolderCopyFolderProperties.cs +++ b/taskt/Core/Automation/Commands/FolderGroup/IFolderCopyFolderProperties.cs @@ -3,7 +3,7 @@ /// /// copy folder commands properties /// - public interface IFolderCopyFolderProperties : ILExpandableProperties + public interface IFolderCopyFolderProperties : IExpandableProperties { /// /// copy sub folder or not diff --git a/taskt/Core/Automation/Commands/Folder/IFolderExistsFolderPathBeforeAfterPathResultProperties.cs b/taskt/Core/Automation/Commands/FolderGroup/IFolderExistsFolderPathBeforeAfterPathResultProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/IFolderExistsFolderPathBeforeAfterPathResultProperties.cs rename to taskt/Core/Automation/Commands/FolderGroup/IFolderExistsFolderPathBeforeAfterPathResultProperties.cs diff --git a/taskt/Core/Automation/Commands/Folder/IFolderExistsFolderPathPathResultProperties.cs b/taskt/Core/Automation/Commands/FolderGroup/IFolderExistsFolderPathPathResultProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/IFolderExistsFolderPathPathResultProperties.cs rename to taskt/Core/Automation/Commands/FolderGroup/IFolderExistsFolderPathPathResultProperties.cs diff --git a/taskt/Core/Automation/Commands/Folder/IFolderExistsFolderPathProperties.cs b/taskt/Core/Automation/Commands/FolderGroup/IFolderExistsFolderPathProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/IFolderExistsFolderPathProperties.cs rename to taskt/Core/Automation/Commands/FolderGroup/IFolderExistsFolderPathProperties.cs diff --git a/taskt/Core/Automation/Commands/Folder/IFolderPathProperties.cs b/taskt/Core/Automation/Commands/FolderGroup/IFolderPathProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/IFolderPathProperties.cs rename to taskt/Core/Automation/Commands/FolderGroup/IFolderPathProperties.cs diff --git a/taskt/Core/Automation/Commands/Folder/MoveFolderCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/MoveFolderCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/MoveFolderCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/MoveFolderCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/RenameFolderCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/RenameFolderCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/RenameFolderCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/RenameFolderCommand.cs diff --git a/taskt/Core/Automation/Commands/Folder/WaitForFolderToExistCommand.cs b/taskt/Core/Automation/Commands/FolderGroup/WaitForFolderToExistCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Folder/WaitForFolderToExistCommand.cs rename to taskt/Core/Automation/Commands/FolderGroup/WaitForFolderToExistCommand.cs diff --git a/taskt/Core/Automation/Commands/FormUIControls.cs b/taskt/Core/Automation/Commands/FormUIControls.cs index 4a0c5918a..3ec3c8b26 100644 --- a/taskt/Core/Automation/Commands/FormUIControls.cs +++ b/taskt/Core/Automation/Commands/FormUIControls.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Windows.Forms; +using taskt.UI.CustomControls; +using taskt.UI.Forms.ScriptBuilder.CommandEditor; using static taskt.UI.CustomControls.CommandControls; namespace taskt.Core.Automation.Commands @@ -56,7 +58,7 @@ public static T GetPropertyControl(this Dictionary controls, } else { - throw new Exception("Control '" + parameterName + "' does not exists."); + throw new Exception($"Control '{parameterName}' does not exists."); } } @@ -75,7 +77,7 @@ public static Label GetPropertyControlLabel(this Dictionary con } else { - throw new Exception("Label '" + LABEL_PREFIX + parameterName + "' does not exists."); + throw new Exception($"Label '{LABEL_PREFIX}{parameterName}' does not exists."); } } @@ -94,7 +96,7 @@ public static Label GetPropertyControl2ndLabel(this Dictionary } else { - throw new Exception("2nd Label '" + LABEL_2ND_PREFIX + parameterName + "' does not exists."); + throw new Exception($"2nd Label '{LABEL_2ND_PREFIX}{parameterName}' does not exists."); } } @@ -171,7 +173,7 @@ public static Dictionary Get2ndLabelTexts(this Label lbl) } else { - throw new Exception(lbl.Name + " does not has Dictionary item for 2nd-Label"); + throw new Exception($"{lbl.Name} does not has Dictionary item for 2nd-Label"); } } @@ -208,5 +210,26 @@ public static void SetVisibleParameterControlGroup(Dictionary c } } #endregion + + /// + /// get frmCommandEditor from control + /// + /// + /// + public static frmCommandEditor GetCommandEditorFromControl(Control ctrl) + { + return (frmCommandEditor)(ctrl.FindForm()); + } + + /// + /// get link target control + /// + /// + /// + /// + public static T GetLinkTargetControl(object ctrl) where T : Control + { + return (T)(((CommandItemControl)ctrl).Tag); + } } } diff --git a/taskt/Core/Automation/Commands/GeneralPropertyControls.cs b/taskt/Core/Automation/Commands/GeneralPropertyControls.cs index 11414831d..f9fae86c9 100644 --- a/taskt/Core/Automation/Commands/GeneralPropertyControls.cs +++ b/taskt/Core/Automation/Commands/GeneralPropertyControls.cs @@ -86,6 +86,14 @@ internal static class GeneralPropertyControls //[PropertyParameterOrder(5000)] public static string v_Result { get; } + /// + /// specify variable name to store result (optional) + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyIsOptional(true)] + [PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.None)] + public static string v_OptionalResult { get; set; } + /// /// input instance (variable) name for specify the variable /// @@ -102,22 +110,6 @@ internal static class GeneralPropertyControls [PropertyDisplayText(true, "Variable")] public static string v_InputInstanceName { get; } - ///// - ///// combobox has Error - ///// - //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - //[PropertyUISelectionOption("Error")] - //[PropertyDetailSampleUsage("**Error**", "Rise an Error")] - //public static string v_ComboBoxHasError { get; } - - ///// - ///// combobox has Error and Ignore - ///// - //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBoxHasError))] - //[PropertyUISelectionOption("Ignore")] - //[PropertyDetailSampleUsage("**Ignore**", "Nothing To Do")] - //public static string v_ComboBoxHasErrorIgnore { get; } - #endregion } } diff --git a/taskt/Core/Automation/Commands/IE/IEBrowserCloseCommand.cs b/taskt/Core/Automation/Commands/IEGroup/IEBrowserCloseCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/IE/IEBrowserCloseCommand.cs rename to taskt/Core/Automation/Commands/IEGroup/IEBrowserCloseCommand.cs diff --git a/taskt/Core/Automation/Commands/IE/IEBrowserCreateCommand.cs b/taskt/Core/Automation/Commands/IEGroup/IEBrowserCreateCommand.cs similarity index 77% rename from taskt/Core/Automation/Commands/IE/IEBrowserCreateCommand.cs rename to taskt/Core/Automation/Commands/IEGroup/IEBrowserCreateCommand.cs index 5e460ba19..521f3de5d 100644 --- a/taskt/Core/Automation/Commands/IE/IEBrowserCreateCommand.cs +++ b/taskt/Core/Automation/Commands/IEGroup/IEBrowserCreateCommand.cs @@ -21,14 +21,14 @@ public sealed class IEBrowserCreateCommand : ScriptCommand [Attributes.PropertyAttributes.PropertyParameterDirection(Attributes.PropertyAttributes.PropertyParameterDirection.ParameterDirection.Output)] public string v_InstanceName { get; set; } - [XmlAttribute] - [Attributes.PropertyAttributes.PropertyDescription("Instance Tracking (after task ends)")] - [Attributes.PropertyAttributes.PropertyUISelectionOption("Forget Instance")] - [Attributes.PropertyAttributes.PropertyUISelectionOption("Keep Instance Alive")] - [Attributes.PropertyAttributes.InputSpecification("Specify if taskt should remember this instance name after the script has finished executing.")] - [Attributes.PropertyAttributes.SampleUsage("Select **Forget Instance** to forget the instance or **Keep Instance Alive** to allow subsequent tasks to call the instance by name.")] - [Attributes.PropertyAttributes.Remarks("Calling the **Close Browser** command or ending the browser session will end the instance. This command only works during the lifetime of the application. If the application is closed, the references will be forgetten automatically.")] - public string v_InstanceTracking { get; set; } + //[XmlAttribute] + //[Attributes.PropertyAttributes.PropertyDescription("Instance Tracking (after task ends)")] + //[Attributes.PropertyAttributes.PropertyUISelectionOption("Forget Instance")] + //[Attributes.PropertyAttributes.PropertyUISelectionOption("Keep Instance Alive")] + //[Attributes.PropertyAttributes.InputSpecification("Specify if taskt should remember this instance name after the script has finished executing.")] + //[Attributes.PropertyAttributes.SampleUsage("Select **Forget Instance** to forget the instance or **Keep Instance Alive** to allow subsequent tasks to call the instance by name.")] + //[Attributes.PropertyAttributes.Remarks("Calling the **Close Browser** command or ending the browser session will end the instance. This command only works during the lifetime of the application. If the application is closed, the references will be forgetten automatically.")] + //public string v_InstanceTracking { get; set; } [XmlAttribute] [Attributes.PropertyAttributes.PropertyDescription("Please Enter the URL to navigate to")] @@ -59,14 +59,14 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) { } - //add app instance + // add app instance engine.AddAppInstance(instanceName, newBrowserSession); - //handle app instance tracking - if (v_InstanceTracking == "Keep Instance Alive") - { - GlobalAppInstances.AddInstance(instanceName, newBrowserSession); - } + // handle app instance tracking + //if (v_InstanceTracking == "Keep Instance Alive") + //{ + // GlobalAppInstances.AddInstance(instanceName, newBrowserSession); + //} } diff --git a/taskt/Core/Automation/Commands/IE/IEBrowserElementActionCommand.cs b/taskt/Core/Automation/Commands/IEGroup/IEBrowserElementActionCommand.cs similarity index 96% rename from taskt/Core/Automation/Commands/IE/IEBrowserElementActionCommand.cs rename to taskt/Core/Automation/Commands/IEGroup/IEBrowserElementActionCommand.cs index fef847f10..e78c88b40 100644 --- a/taskt/Core/Automation/Commands/IE/IEBrowserElementActionCommand.cs +++ b/taskt/Core/Automation/Commands/IEGroup/IEBrowserElementActionCommand.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Windows.Forms; using System.Xml.Serialization; +using taskt.Core.Script; using taskt.UI.CustomControls; namespace taskt.Core.Automation.Commands @@ -305,7 +306,25 @@ where rw.Field("Parameter Name") == "Y Adjustment" select rw.Field("Parameter Value")).FirstOrDefault()); //var ieClientLocation = User32Functions.GetWindowPosition(new IntPtr(browserInstance.HWND)); - var ieClientLocation = WindowControls.GetWindowRect(new IntPtr(browserInstance.HWND)); + + // force get IE pos + RECT ieClientLocation; + using (var x = new InnerScriptVariable(engine)) + { + using (var y = new InnerScriptVariable(engine)) + { + var getWinPos = new GetWindowPositionFromWindowHandleCommand() + { + v_WindowHandle = browserInstance.HWND.ToString(), + v_XPosition = x.VariableName, + v_YPosition = y.VariableName, + }; + getWinPos.RunCommand(engine); + ieClientLocation.left = (int)x.VariableValue; + ieClientLocation.top = (int)y.VariableValue; + } + } + //var ieClientLocation = WindowControls.GetWindowRect(new IntPtr(browserInstance.HWND)); MoveMouseCommand newMouseMove = new MoveMouseCommand(); diff --git a/taskt/Core/Automation/Commands/IE/IEBrowserFindBrowserCommand.cs b/taskt/Core/Automation/Commands/IEGroup/IEBrowserFindBrowserCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/IE/IEBrowserFindBrowserCommand.cs rename to taskt/Core/Automation/Commands/IEGroup/IEBrowserFindBrowserCommand.cs diff --git a/taskt/Core/Automation/Commands/IE/IEBrowserNavigateURLCommand.cs b/taskt/Core/Automation/Commands/IEGroup/IEBrowserNavigateURLCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/IE/IEBrowserNavigateURLCommand.cs rename to taskt/Core/Automation/Commands/IEGroup/IEBrowserNavigateURLCommand.cs diff --git a/taskt/Core/Automation/Commands/If/BeginIfCommand.cs b/taskt/Core/Automation/Commands/IfGroup/BeginIfCommand.cs similarity index 99% rename from taskt/Core/Automation/Commands/If/BeginIfCommand.cs rename to taskt/Core/Automation/Commands/IfGroup/BeginIfCommand.cs index 3bb228f74..266fc0278 100644 --- a/taskt/Core/Automation/Commands/If/BeginIfCommand.cs +++ b/taskt/Core/Automation/Commands/IfGroup/BeginIfCommand.cs @@ -194,7 +194,7 @@ private void linkWebBrowserInstanceSelector_Click(object sender, EventArgs e, UI { if (frm.ShowDialog() == DialogResult.OK) { - string selectedItem = frm.selectedItem.ToString(); + string selectedItem = frm.SelectedItem.ToString(); if (!DataTableControls.SetParameterValue(v_IfActionParameterTable, selectedItem, "Selenium Instance Name", "Parameter Name", "Parameter Value")) { throw new Exception("Fail update Selenium Instance Name"); @@ -225,7 +225,7 @@ private void linkWindowNameSelector_Click(object sender, EventArgs e, UI.Forms.S { if (frm.ShowDialog() == DialogResult.OK) { - string selectedItem = frm.selectedItem.ToString(); + string selectedItem = frm.SelectedItem.ToString(); if (!DataTableControls.SetParameterValue(v_IfActionParameterTable, selectedItem, "Window Name", "Parameter Name", "Parameter Value")) { throw new Exception("Fail update Window Name"); @@ -242,7 +242,7 @@ private void linkBooleanInstanceSelector_Click(object sender, EventArgs e, UI.Fo { if (frm.ShowDialog() == DialogResult.OK) { - string selectedItem = frm.selectedItem.ToString(); + string selectedItem = frm.SelectedItem.ToString(); //int currentRow = IfGridViewHelper.CurrentRow.Index; string parameterName = DataTableControls.GetFieldValue(v_IfActionParameterTable, IfGridViewHelper.CurrentRow.Index, "Parameter Name"); diff --git a/taskt/Core/Automation/Commands/If/BeginMutliIfCommand.cs b/taskt/Core/Automation/Commands/IfGroup/BeginMutliIfCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/If/BeginMutliIfCommand.cs rename to taskt/Core/Automation/Commands/IfGroup/BeginMutliIfCommand.cs diff --git a/taskt/Core/Automation/Commands/If/ElseCommand.cs b/taskt/Core/Automation/Commands/IfGroup/ElseCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/If/ElseCommand.cs rename to taskt/Core/Automation/Commands/IfGroup/ElseCommand.cs diff --git a/taskt/Core/Automation/Commands/If/EndIfCommand.cs b/taskt/Core/Automation/Commands/IfGroup/EndIfCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/If/EndIfCommand.cs rename to taskt/Core/Automation/Commands/IfGroup/EndIfCommand.cs diff --git a/taskt/Core/Automation/Commands/If/IHaveIfAdditionalCommands.cs b/taskt/Core/Automation/Commands/IfGroup/IHaveIfAdditionalCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/If/IHaveIfAdditionalCommands.cs rename to taskt/Core/Automation/Commands/IfGroup/IHaveIfAdditionalCommands.cs diff --git a/taskt/Core/Automation/Commands/Image/TakeScreenshotCommand.cs b/taskt/Core/Automation/Commands/Image/TakeScreenshotCommand.cs deleted file mode 100644 index 1d2e0de21..000000000 --- a/taskt/Core/Automation/Commands/Image/TakeScreenshotCommand.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using System.Collections.Generic; -using taskt.UI.CustomControls; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Image")] - [Attributes.ClassAttributes.CommandSettings("Take Screenshot")] - [Attributes.ClassAttributes.Description("This command takes a screenshot and saves it to a location")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to take and save a screenshot.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements User32 CaptureWindow to achieve automation")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_camera))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class TakeScreenshotCommand : ScriptCommand, ICanHandleFilePath - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] - [PropertyIsWindowNamesList(true, true, false, true)] - [PropertyAvailableSystemVariable(Engine.SystemVariables.LimitedSystemVariableNames.Window_Desktop)] - public string v_WindowName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(FilePathControls), nameof(FilePathControls.v_FilePath))] - [PropertyDescription("Image File Path")] - [PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] - [PropertyDetailSampleUsage("**C:\\temp\\myimages.png**", "File Path")] - [PropertyDetailSampleUsage("**{{{vFilePath}}}**", "File Path")] - [Remarks("If file does not contain extensin, suppliment png extension.\nIf file does not contain folder path, file will be saved in the same folder as script file.\nIf file path contains FileCounter variable, it will be replaced by a number that will become the name of a non-existent file.")] - [PropertyFilePathSetting(false, PropertyFilePathSetting.ExtensionBehavior.RequiredExtension, PropertyFilePathSetting.FileCounterBehavior.FirstNotExists)] - public string v_FilePath { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Activate Window Before Capture")] - [PropertyIsOptional(true, "No")] - [PropertyValidationRule("", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(false, "")] - public string v_ActivateWindowBeforeCapture { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Wait Time before Capture")] - [PropertyIsOptional(true, "500")] - [PropertyValidationRule("", PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] - [PropertyFirstValue("500")] - public string v_WaitTimeBeforeCapture { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] - public string v_TargetWindowIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] - public string v_WaitTimeForWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] - public string v_NameResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_HandleResult { get; set; } - - public TakeScreenshotCommand() - { - //this.CommandName = "ScreenshotCommand"; - //this.SelectionName = "Take Screenshot"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //string targetWindowName; - //if (v_WindowName == "Desktop") - //{ - // targetWindowName = "Desktop"; - //} - //else - //{ - // var wins = WindowNameControls.FindWindows(this, nameof(v_WindowName), nameof(v_SearchMethod), nameof(v_MatchMethod), nameof(v_TargetWindowIndex), nameof(v_WaitForWindow), engine); - // targetWindowName = wins[0].Item2; - //} - - ////var image = User32Functions.CaptureWindow(targetWindowName); - //var image = WindowNameControls.CaptureWindow(targetWindowName, engine); - - //var outputFile = this.ExpandValueOrUserVariableAsFilePath(nameof(v_FilePath), engine); - - //image.Save(outputFile); - - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - var whnd = wins[0].Item1; - - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateWindowBeforeCapture), engine)) - { - WindowControls.ActivateWindow(whnd); - } - - // wait time - var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeBeforeCapture), engine); - System.Threading.Thread.Sleep(waitTime); - - var image = WindowControls.CaptureWindow(whnd); - //var outputFile = this.ExpandValueOrUserVariableAsFilePath(nameof(v_FilePath), engine); - // MEMO: now, this.ExpandValueOrUserVariableAsFilePath has 2 methods - var outputFile = EM_CanHandleFilePathExtentionMethods.ExpandValueOrUserVariableAsFilePath(this, nameof(v_FilePath), engine); - - image.Save(outputFile); - }) - ); - - } - - private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - } - - public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - //ComboBox cmb = (ComboBox)ControlsList[nameof(v_ScreenshotWindowName)]; - //cmb.AddWindowNames(); - ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Image/ExecuteOCRCommand.cs b/taskt/Core/Automation/Commands/ImageGroup/ExecuteOCRCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Image/ExecuteOCRCommand.cs rename to taskt/Core/Automation/Commands/ImageGroup/ExecuteOCRCommand.cs diff --git a/taskt/Core/Automation/Commands/Image/ExecuteTesseractOCRCommand.cs b/taskt/Core/Automation/Commands/ImageGroup/ExecuteTesseractOCRCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Image/ExecuteTesseractOCRCommand.cs rename to taskt/Core/Automation/Commands/ImageGroup/ExecuteTesseractOCRCommand.cs diff --git a/taskt/Core/Automation/Commands/Image/FindPixelColourCommand].cs b/taskt/Core/Automation/Commands/ImageGroup/FindPixelColourCommand].cs similarity index 100% rename from taskt/Core/Automation/Commands/Image/FindPixelColourCommand].cs rename to taskt/Core/Automation/Commands/ImageGroup/FindPixelColourCommand].cs diff --git a/taskt/Core/Automation/Commands/Image/GetPixelColourCommand.cs b/taskt/Core/Automation/Commands/ImageGroup/GetPixelColourCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Image/GetPixelColourCommand.cs rename to taskt/Core/Automation/Commands/ImageGroup/GetPixelColourCommand.cs diff --git a/taskt/Core/Automation/Commands/Image/ImageRecognition.cs b/taskt/Core/Automation/Commands/ImageGroup/ImageRecognition.cs similarity index 100% rename from taskt/Core/Automation/Commands/Image/ImageRecognition.cs rename to taskt/Core/Automation/Commands/ImageGroup/ImageRecognition.cs diff --git a/taskt/Core/Automation/Commands/Image/ImageRecognitionCommand.cs b/taskt/Core/Automation/Commands/ImageGroup/ImageRecognitionCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Image/ImageRecognitionCommand.cs rename to taskt/Core/Automation/Commands/ImageGroup/ImageRecognitionCommand.cs diff --git a/taskt/Core/Automation/Commands/ImageGroup/TakeScreenshotCommand.cs b/taskt/Core/Automation/Commands/ImageGroup/TakeScreenshotCommand.cs new file mode 100644 index 000000000..8c8c5ee3f --- /dev/null +++ b/taskt/Core/Automation/Commands/ImageGroup/TakeScreenshotCommand.cs @@ -0,0 +1,201 @@ +using System; +using System.Drawing; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Image")] + [Attributes.ClassAttributes.CommandSettings("Take Screenshot")] + [Attributes.ClassAttributes.Description("This command takes a screenshot and saves it to a location")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to take and save a screenshot.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements User32 CaptureWindow to achieve automation")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_camera))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class TakeScreenshotCommand : AOneWindowNameActionCommands, ICanHandleFilePath + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + //[PropertyIsWindowNamesList(true, true, false, true)] + //[PropertyAvailableSystemVariable(Engine.SystemVariables.LimitedSystemVariableNames.Window_Desktop)] + //public string v_WindowName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(FilePathControls), nameof(FilePathControls.v_FilePath))] + [PropertyDescription("Image File Path")] + [PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] + [PropertyDetailSampleUsage("**C:\\temp\\myimages.png**", "File Path")] + [PropertyDetailSampleUsage("**{{{vFilePath}}}**", "File Path")] + [Remarks("If file does not contain extensin, suppliment png extension.\nIf file does not contain folder path, file will be saved in the same folder as script file.\nIf file path contains FileCounter variable, it will be replaced by a number that will become the name of a non-existent file.")] + [PropertyFilePathSetting(false, PropertyFilePathSetting.ExtensionBehavior.RequiredExtension, PropertyFilePathSetting.FileCounterBehavior.FirstNotExists)] + [PropertyParameterOrder(5100)] + public string v_FilePath { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Activate Window Before Capture")] + //[PropertyIsOptional(true, "No")] + //[PropertyValidationRule("", PropertyValidationRule.ValidationRuleFlags.None)] + //[PropertyDisplayText(false, "Activate Window")] + //[PropertyParameterOrder(5200)] + //public string v_ActivateWindowBeforeCapture { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Wait Time before Capture")] + //[PropertyIsOptional(true, "500")] + //[PropertyValidationRule("Before Capture", PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + //[PropertyFirstValue("500")] + //[PropertyDisplayText(false, "Wait Time before Capture")] + //[PropertyParameterOrder(5300)] + //public string v_WaitTimeBeforeCapture { get; set; } + + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] + //public string v_CompareMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] + //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + //public string v_MatchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + //public string v_TargetWindowIndex { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + //public string v_WaitTimeForWindow { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + //public string v_NameResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_HandleResult { get; set; } + + [XmlAttribute] + [PropertyIsOptional(true, "0.5")] + [PropertyFirstValue("0.5")] + public override string v_WaitTimeBetweenFindAndAction { get; set; } + + public TakeScreenshotCommand() + { + //this.CommandName = "ScreenshotCommand"; + //this.SelectionName = "Take Screenshot"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //string targetWindowName; + //if (v_WindowName == "Desktop") + //{ + // targetWindowName = "Desktop"; + //} + //else + //{ + // var wins = WindowNameControls.FindWindows(this, nameof(v_WindowName), nameof(v_SearchMethod), nameof(v_MatchMethod), nameof(v_TargetWindowIndex), nameof(v_WaitForWindow), engine); + // targetWindowName = wins[0].Item2; + //} + + ////var image = User32Functions.CaptureWindow(targetWindowName); + //var image = WindowNameControls.CaptureWindow(targetWindowName, engine); + + //var outputFile = this.ExpandValueOrUserVariableAsFilePath(nameof(v_FilePath), engine); + + //image.Save(outputFile); + + //WindowControls.WindowAction(this, engine, + // new Action>(wins => + // { + // var whnd = wins[0].Item1; + + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateWindowBeforeCapture), engine)) + // { + // WindowControls.ActivateWindow(whnd); + // } + + // // wait time + // var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeBeforeCapture), engine); + // System.Threading.Thread.Sleep(waitTime); + + // var image = CaptureWindow(whnd); + // //var outputFile = this.ExpandValueOrUserVariableAsFilePath(nameof(v_FilePath), engine); + // // MEMO: now, this.ExpandValueOrUserVariableAsFilePath has 2 methods + // var outputFile = EM_CanHandleFilePathExtentionMethods.ExpandValueOrUserVariableAsFilePath(this, nameof(v_FilePath), engine); + + // image.Save(outputFile); + // }) + //); + + //this.WindowNameActionAndWaitActivate(engine, new Action((whnd, name) => + //{ + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateWindowBeforeCapture), engine)) + // { + // var activate = new ActivateWindowByWindowHandleCommand() + // { + // v_WindowHandle = whnd.ToString(), + // }; + // activate.RunCommand(engine); + // } + + // // wait time + // var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeBeforeCapture), engine); + // System.Threading.Thread.Sleep(waitTime); + + // var image = CaptureWindow(whnd); + + // // MEMO: now, this.ExpandValueOrUserVariableAsFilePath has 2 methods + // var outputFile = EM_CanHandleFilePathExtentionMethods.ExpandValueOrUserVariableAsFilePath(this, nameof(v_FilePath), engine); + + // image.Save(outputFile); + //})); + + this.WindowNameAction(engine, new Action((whnd, name) => + { + this.ActivateWindowProcess(whnd, engine); + + this.WaitAfterFindWindowProcess(engine); + + var image = CaptureWindow(whnd); + + // MEMO: now, this.ExpandValueOrUserVariableAsFilePath has 2 methods + var outputFile = EM_CanHandleFilePathExtentionMethods.ExpandValueOrUserVariableAsFilePath(this, nameof(v_FilePath), engine); + + image.Save(outputFile); + })); + } + + private static Bitmap CaptureWindow(IntPtr whnd) + { + var r = EM_WindowRECTPropertiesExtentionMethods.GetWindowRect(whnd); + var bounds = new Rectangle(r.left, r.top, r.right - r.left, r.bottom - r.top); + var screenshot = new Bitmap(bounds.Width, bounds.Height); + + using (var graphics = Graphics.FromImage(screenshot)) + { + graphics.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size); + } + + return screenshot; + } + + //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + //} + + //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + //{ + // //ComboBox cmb = (ComboBox)ControlsList[nameof(v_ScreenshotWindowName)]; + // //cmb.AddWindowNames(); + // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/JSON/AJSONAddInsertSetJContainerCommands.cs b/taskt/Core/Automation/Commands/JSONGroup/AJSONAddInsertSetJContainerCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/AJSONAddInsertSetJContainerCommands.cs rename to taskt/Core/Automation/Commands/JSONGroup/AJSONAddInsertSetJContainerCommands.cs diff --git a/taskt/Core/Automation/Commands/JSON/AJSONGetFromJContainerCommands.cs b/taskt/Core/Automation/Commands/JSONGroup/AJSONGetFromJContainerCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/AJSONGetFromJContainerCommands.cs rename to taskt/Core/Automation/Commands/JSONGroup/AJSONGetFromJContainerCommands.cs diff --git a/taskt/Core/Automation/Commands/JSON/AJSONGetFromJSONCommands.cs b/taskt/Core/Automation/Commands/JSONGroup/AJSONGetFromJSONCommands.cs similarity index 94% rename from taskt/Core/Automation/Commands/JSON/AJSONGetFromJSONCommands.cs rename to taskt/Core/Automation/Commands/JSONGroup/AJSONGetFromJSONCommands.cs index 1a09e1930..d52ac263f 100644 --- a/taskt/Core/Automation/Commands/JSON/AJSONGetFromJSONCommands.cs +++ b/taskt/Core/Automation/Commands/JSONGroup/AJSONGetFromJSONCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for Get something from JSON commands /// - public abstract class AJSONGetFromJSONCommands : AJSONInputJSONCommands, ILResultProperties + public abstract class AJSONGetFromJSONCommands : AJSONInputJSONCommands, IResultProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] diff --git a/taskt/Core/Automation/Commands/JSON/AJSONInputJSONCommands.cs b/taskt/Core/Automation/Commands/JSONGroup/AJSONInputJSONCommands.cs similarity index 94% rename from taskt/Core/Automation/Commands/JSON/AJSONInputJSONCommands.cs rename to taskt/Core/Automation/Commands/JSONGroup/AJSONInputJSONCommands.cs index d5683d809..b98f5babd 100644 --- a/taskt/Core/Automation/Commands/JSON/AJSONInputJSONCommands.cs +++ b/taskt/Core/Automation/Commands/JSONGroup/AJSONInputJSONCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for Input JSON commands /// - public abstract class AJSONInputJSONCommands : ScriptCommand, ILJSONInputJSONProperties + public abstract class AJSONInputJSONCommands : ScriptCommand, IJSONInputJSONProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(JSONControls), nameof(JSONControls.v_InputJSONName))] diff --git a/taskt/Core/Automation/Commands/JSON/AJSONInsertValueToJContainerCommands.cs b/taskt/Core/Automation/Commands/JSONGroup/AJSONInsertValueToJContainerCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/AJSONInsertValueToJContainerCommands.cs rename to taskt/Core/Automation/Commands/JSONGroup/AJSONInsertValueToJContainerCommands.cs diff --git a/taskt/Core/Automation/Commands/JSON/AJSONJSONPathCommands.cs b/taskt/Core/Automation/Commands/JSONGroup/AJSONJSONPathCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/AJSONJSONPathCommands.cs rename to taskt/Core/Automation/Commands/JSONGroup/AJSONJSONPathCommands.cs diff --git a/taskt/Core/Automation/Commands/JSON/AJSONSetValueOfJContainerCommands.cs b/taskt/Core/Automation/Commands/JSONGroup/AJSONSetValueOfJContainerCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/AJSONSetValueOfJContainerCommands.cs rename to taskt/Core/Automation/Commands/JSONGroup/AJSONSetValueOfJContainerCommands.cs diff --git a/taskt/Core/Automation/Commands/JSON/AJSONValueActionCommands.cs b/taskt/Core/Automation/Commands/JSONGroup/AJSONValueActionCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/AJSONValueActionCommands.cs rename to taskt/Core/Automation/Commands/JSONGroup/AJSONValueActionCommands.cs diff --git a/taskt/Core/Automation/Commands/JSON/AddJSONArrayItemCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/AddJSONArrayItemCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/AddJSONArrayItemCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/AddJSONArrayItemCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/AddJSONObjectPropertyCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/AddJSONObjectPropertyCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/AddJSONObjectPropertyCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/AddJSONObjectPropertyCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/ConvertJSONToDataTableCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/ConvertJSONToDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/ConvertJSONToDataTableCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/ConvertJSONToDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/ConvertJSONToDictionaryCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/ConvertJSONToDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/ConvertJSONToDictionaryCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/ConvertJSONToDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/ConvertJSONToListCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/ConvertJSONToListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/ConvertJSONToListCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/ConvertJSONToListCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/CreateJSONVariableCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/CreateJSONVariableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/CreateJSONVariableCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/CreateJSONVariableCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/EM_CanHandleJContainerExtentionMethods.cs b/taskt/Core/Automation/Commands/JSONGroup/EM_CanHandleJContainerExtentionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/EM_CanHandleJContainerExtentionMethods.cs rename to taskt/Core/Automation/Commands/JSONGroup/EM_CanHandleJContainerExtentionMethods.cs diff --git a/taskt/Core/Automation/Commands/JSON/EM_CanHandleJSONArrayExtentionMethods.cs b/taskt/Core/Automation/Commands/JSONGroup/EM_CanHandleJSONArrayExtentionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/EM_CanHandleJSONArrayExtentionMethods.cs rename to taskt/Core/Automation/Commands/JSONGroup/EM_CanHandleJSONArrayExtentionMethods.cs diff --git a/taskt/Core/Automation/Commands/JSON/EM_CanHandleJSONObjectExtensionMethods.cs b/taskt/Core/Automation/Commands/JSONGroup/EM_CanHandleJSONObjectExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/EM_CanHandleJSONObjectExtensionMethods.cs rename to taskt/Core/Automation/Commands/JSONGroup/EM_CanHandleJSONObjectExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/JSON/EM_JSONJSONPathPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/JSONGroup/EM_JSONJSONPathPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/EM_JSONJSONPathPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/JSONGroup/EM_JSONJSONPathPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/JSON/EM_JSONValueActionPropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/JSONGroup/EM_JSONValueActionPropertiesExtentionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/EM_JSONValueActionPropertiesExtentionMethods.cs rename to taskt/Core/Automation/Commands/JSONGroup/EM_JSONValueActionPropertiesExtentionMethods.cs diff --git a/taskt/Core/Automation/Commands/JSON/EM_JsonInputJContainerExtensionMethods.cs b/taskt/Core/Automation/Commands/JSONGroup/EM_JsonInputJContainerExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/EM_JsonInputJContainerExtensionMethods.cs rename to taskt/Core/Automation/Commands/JSONGroup/EM_JsonInputJContainerExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/JSON/GetJSONValueCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/GetJSONValueCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/GetJSONValueCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/GetJSONValueCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/GetJSONValueFromJSONArrayCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/GetJSONValueFromJSONArrayCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/GetJSONValueFromJSONArrayCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/GetJSONValueFromJSONArrayCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/GetJSONValueFromJSONObjectCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/GetJSONValueFromJSONObjectCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/GetJSONValueFromJSONObjectCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/GetJSONValueFromJSONObjectCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/GetJSONValuesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/GetJSONValuesAsDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/GetJSONValuesAsDataTableCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/GetJSONValuesAsDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/GetJSONValuesAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/GetJSONValuesAsDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/GetJSONValuesAsDictionaryCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/GetJSONValuesAsDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/GetJSONValuesAsListCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/GetJSONValuesAsListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/GetJSONValuesAsListCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/GetJSONValuesAsListCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/GetMultiJSONValueListCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/GetMultiJSONValueListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/GetMultiJSONValueListCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/GetMultiJSONValueListCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/ICanHandleJContainer.cs b/taskt/Core/Automation/Commands/JSONGroup/ICanHandleJContainer.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/ICanHandleJContainer.cs rename to taskt/Core/Automation/Commands/JSONGroup/ICanHandleJContainer.cs diff --git a/taskt/Core/Automation/Commands/JSON/ICanHandleJSON.cs b/taskt/Core/Automation/Commands/JSONGroup/ICanHandleJSON.cs similarity index 57% rename from taskt/Core/Automation/Commands/JSON/ICanHandleJSON.cs rename to taskt/Core/Automation/Commands/JSONGroup/ICanHandleJSON.cs index af8aef1df..8c7d547f8 100644 --- a/taskt/Core/Automation/Commands/JSON/ICanHandleJSON.cs +++ b/taskt/Core/Automation/Commands/JSONGroup/ICanHandleJSON.cs @@ -1,6 +1,6 @@ namespace taskt.Core.Automation.Commands { - public interface ICanHandleJSON : ILExpandableProperties + public interface ICanHandleJSON : IExpandableProperties { // only imple } diff --git a/taskt/Core/Automation/Commands/JSON/ICanHandleJSONArray.cs b/taskt/Core/Automation/Commands/JSONGroup/ICanHandleJSONArray.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/ICanHandleJSONArray.cs rename to taskt/Core/Automation/Commands/JSONGroup/ICanHandleJSONArray.cs diff --git a/taskt/Core/Automation/Commands/JSON/ICanHandleJSONObject.cs b/taskt/Core/Automation/Commands/JSONGroup/ICanHandleJSONObject.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/ICanHandleJSONObject.cs rename to taskt/Core/Automation/Commands/JSONGroup/ICanHandleJSONObject.cs diff --git a/taskt/Core/Automation/Commands/JSON/ILJSONInputJSONProperties.cs b/taskt/Core/Automation/Commands/JSONGroup/IJSONInputJSONProperties.cs similarity index 73% rename from taskt/Core/Automation/Commands/JSON/ILJSONInputJSONProperties.cs rename to taskt/Core/Automation/Commands/JSONGroup/IJSONInputJSONProperties.cs index b9d5343b1..5b202130c 100644 --- a/taskt/Core/Automation/Commands/JSON/ILJSONInputJSONProperties.cs +++ b/taskt/Core/Automation/Commands/JSONGroup/IJSONInputJSONProperties.cs @@ -3,7 +3,7 @@ /// /// Json input properties /// - public interface ILJSONInputJSONProperties : ICanHandleJSON, ILExpandableProperties + public interface IJSONInputJSONProperties : ICanHandleJSON, IExpandableProperties { /// /// JSON Value or Variable Name diff --git a/taskt/Core/Automation/Commands/JSON/IJSONJSONPathProperties.cs b/taskt/Core/Automation/Commands/JSONGroup/IJSONJSONPathProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/IJSONJSONPathProperties.cs rename to taskt/Core/Automation/Commands/JSONGroup/IJSONJSONPathProperties.cs diff --git a/taskt/Core/Automation/Commands/JSON/IJSONValueActionProperties.cs b/taskt/Core/Automation/Commands/JSONGroup/IJSONValueActionProperties.cs similarity index 56% rename from taskt/Core/Automation/Commands/JSON/IJSONValueActionProperties.cs rename to taskt/Core/Automation/Commands/JSONGroup/IJSONValueActionProperties.cs index 47b4a1b05..feb16546b 100644 --- a/taskt/Core/Automation/Commands/JSON/IJSONValueActionProperties.cs +++ b/taskt/Core/Automation/Commands/JSONGroup/IJSONValueActionProperties.cs @@ -3,7 +3,7 @@ /// /// JSON Value Action properties /// - public interface IJSONValueActionProperties : ILJSONInputJSONProperties, ILJSONValueProperties, ICanHandleJContainer + public interface IJSONValueActionProperties : IJSONInputJSONProperties, IJSONValueProperties, ICanHandleJContainer { // only imple } diff --git a/taskt/Core/Automation/Commands/JSON/ILJSONValueProperties.cs b/taskt/Core/Automation/Commands/JSONGroup/IJSONValueProperties.cs similarity index 83% rename from taskt/Core/Automation/Commands/JSON/ILJSONValueProperties.cs rename to taskt/Core/Automation/Commands/JSONGroup/IJSONValueProperties.cs index 88b84e979..b2ac0ce16 100644 --- a/taskt/Core/Automation/Commands/JSON/ILJSONValueProperties.cs +++ b/taskt/Core/Automation/Commands/JSONGroup/IJSONValueProperties.cs @@ -3,7 +3,7 @@ /// /// JSON Value properties /// - public interface ILJSONValueProperties : ILExpandableProperties + public interface IJSONValueProperties : IExpandableProperties { /// /// JSON Value diff --git a/taskt/Core/Automation/Commands/JSON/IJsonInputJContainer.cs b/taskt/Core/Automation/Commands/JSONGroup/IJsonInputJContainer.cs similarity index 61% rename from taskt/Core/Automation/Commands/JSON/IJsonInputJContainer.cs rename to taskt/Core/Automation/Commands/JSONGroup/IJsonInputJContainer.cs index 1e049b43c..25f0398a6 100644 --- a/taskt/Core/Automation/Commands/JSON/IJsonInputJContainer.cs +++ b/taskt/Core/Automation/Commands/JSONGroup/IJsonInputJContainer.cs @@ -3,7 +3,7 @@ /// /// JContainer properties /// - public interface IJSONInputJContainer : ILJSONInputJSONProperties, ICanHandleJContainer + public interface IJSONInputJContainer : IJSONInputJSONProperties, ICanHandleJContainer { // only imple } diff --git a/taskt/Core/Automation/Commands/JSON/InsertJSONArrayItemCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/InsertJSONArrayItemCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/InsertJSONArrayItemCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/InsertJSONArrayItemCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/InsertJSONObjectPropertyCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/InsertJSONObjectPropertyCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/InsertJSONObjectPropertyCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/InsertJSONObjectPropertyCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/ReadJSONFileCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/ReadJSONFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/ReadJSONFileCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/ReadJSONFileCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/RemoveJSONArrayItemCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/RemoveJSONArrayItemCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/RemoveJSONArrayItemCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/RemoveJSONArrayItemCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/RemoveJSONObjectPropertyCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/RemoveJSONObjectPropertyCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/RemoveJSONObjectPropertyCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/RemoveJSONObjectPropertyCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/SetJSONValueCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/SetJSONValueCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/SetJSONValueCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/SetJSONValueCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/SetJSONValueOfJSONArrayCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/SetJSONValueOfJSONArrayCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/SetJSONValueOfJSONArrayCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/SetJSONValueOfJSONArrayCommand.cs diff --git a/taskt/Core/Automation/Commands/JSON/SetJSONValueOfJSONObjectCommand.cs b/taskt/Core/Automation/Commands/JSONGroup/SetJSONValueOfJSONObjectCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/JSON/SetJSONValueOfJSONObjectCommand.cs rename to taskt/Core/Automation/Commands/JSONGroup/SetJSONValueOfJSONObjectCommand.cs diff --git a/taskt/Core/Automation/Commands/KeyMouse/EnterKeysCommand.cs b/taskt/Core/Automation/Commands/KeyMouse/EnterKeysCommand.cs deleted file mode 100644 index 91bff51e3..000000000 --- a/taskt/Core/Automation/Commands/KeyMouse/EnterKeysCommand.cs +++ /dev/null @@ -1,287 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Collections.Generic; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Key/Mouse")] - [Attributes.ClassAttributes.SubGruop("Key")] - [Attributes.ClassAttributes.CommandSettings("Enter Keys")] - [Attributes.ClassAttributes.Description("Sends keystrokes to a targeted window")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send keystroke inputs to a window.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows.Forms.SendKeys' method to achieve automation.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class EnterKeysCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] - public string v_WindowName { get; set; } - - [XmlAttribute] - [PropertyDescription("Text or Keys to Send.")] - [PropertyCustomUIHelper("Keys Builder", nameof(lnkKeysBulider_Click))] - [PropertyCustomUIHelper("Encrypt Text", nameof(lnkEncryptText_Click))] - [InputSpecification("Text to Send", true)] - [PropertyDetailSampleUsage("**Hello, World!**", PropertyDetailSampleUsage.ValueType.Value, "Text")] - [PropertyDetailSampleUsage("**{{{vText}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Text")] - [PropertyDetailSampleUsage("**^s**", "Specify **Ctrl+S** for Enter Keys")] - [PropertyDetailSampleUsage("**{WIN_KEY}**", "Specify **Windows Key** for Enter Keys")] - [PropertyDetailSampleUsage("**{WIN_KEY+R}**", "Specify **Windows Key** and **R** for Enter Keys")] - [Remarks("")] - [PropertyShowSampleUsageInDescription(true)] - [PropertyIntermediateConvert(nameof(IntermediateControls.ConvertToIntermediate_CheckedVariableMarker), "")] - [PropertyDisplayText(true, "Text")] - public string v_TextToSend { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Text is Encrypted or Not")] - [PropertyUISelectionOption("Not Encrypted")] - [PropertyUISelectionOption("Encrypted")] - [PropertyIsOptional(true, "Not Encrypted")] - public string v_EncryptionOption { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Use Paste from Clipboard")] - [PropertyIsOptional(true, "No")] - [Remarks("When entering keys in combination with the Ctrl key, etc., It will NOT work correctly.")] - public string v_UseClipBoard { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] - public string v_TargetWindowIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] - public string v_WaitTimeForWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_WaitTimeAfterKeyEnter))] - public string v_WaitTime { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Try Activate Window, when Specifiy Current Window Variable")] - [PropertyIsOptional(true, "No")] - public string v_ActivateCurrentWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] - public string v_NameResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_HandleResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Clear Clipboard After Paste")] - [PropertyIsOptional(true, "No")] - [PropertyValidationRule("Clear Clipboard", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(false, "")] - public string v_ClearClipboardAfterPaste { get; set; } - - public EnterKeysCommand() - { - //this.CommandName = "SendKeysCommand"; - //this.SelectionName = "Send Keystrokes"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - //this.v_EncryptionOption = "Not Encrypted"; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //var targetWindow = v_WindowName.ExpandValueOrUserVariable(engine); - //if (targetWindow != engine.engineSettings.CurrentWindowKeyword) - //{ - // var activateWindow = new ActivateWindowCommand - // { - // v_WindowName = v_WindowName, - // v_SearchMethod = v_SearchMethod, - // v_MatchMethod= v_MatchMethod, - // v_TargetWindowIndex = v_TargetWindowIndex, - // v_WaitTime = v_WaitForWindow - // }; - // activateWindow.RunCommand(engine); - //} - - //var textToSend = v_TextToSend.ExpandValueOrUserVariable(engine); - - //var encryptOption = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_EncryptionOption), engine); - //if (encryptOption == "encrypted") - //{ - // textToSend = EncryptionServices.DecryptString(textToSend, "TASKT"); - //} - - //if (textToSend == "{WIN_KEY}") - //{ - // KeyMouseControls.KeyDown(Keys.LWin); - // KeyMouseControls.KeyUp(Keys.LWin); - //} - //else if (textToSend.StartsWith("{WIN_KEY+") && textToSend.EndsWith("}")) - //{ - // KeyMouseControls.KeyDown(Keys.LWin); - // var remainingText = textToSend.Replace("{WIN_KEY+", "").Replace("}",""); - - // foreach (var c in remainingText) - // { - // Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); - // KeyMouseControls.KeyDown(key); - // } - - // KeyMouseControls.KeyUp(Keys.LWin); - - // foreach (var c in remainingText) - // { - // Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); - // KeyMouseControls.KeyUp(key); - // } - //} - //else - //{ - // SendKeys.SendWait(textToSend); - //} - - //var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTime), engine); - //System.Threading.Thread.Sleep(waitTime); - - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - //if (WindowControls.GetActiveWindowHandle() != wins[0].Item1) - //{ - // // DBG - // Console.WriteLine($"#### strange win-handle. cur: {WindowControls.GetActiveWindowHandle()}, arg: {wins[0].Item1}"); - // WindowControls.ActivateWindow(wins[0].Item1); - //} - //else - //{ - // // DBG - // Console.WriteLine($"#### same win-handle. key: {v_TextToSend}"); - //} - //if (VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowName.VariableName, engine) == v_WindowName) - //{ - // // DBG - // Console.WriteLine($"#### same win-handle. key: {v_TextToSend}"); - //} - //else - //{ - // // DBG - // Console.WriteLine($"#### strange win-handle. cur: {WindowControls.GetActiveWindowHandle()}, arg: {wins[0].Item1}"); - // WindowControls.ActivateWindow(wins[0].Item1); - //} - - if (VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowName.VariableName, engine) == v_WindowName) - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateCurrentWindow), engine)) - { - WindowControls.ActivateWindow(wins[0].Item1); - } - } - else - { - WindowControls.ActivateWindow(wins[0].Item1); - } - - var textToSend = v_TextToSend.ExpandValueOrUserVariable(engine); - - var encryptOption = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_EncryptionOption), engine); - if (encryptOption == "encrypted") - { - textToSend = EncryptionServices.DecryptString(textToSend, "TASKT"); - } - - if (textToSend == "{WIN_KEY}") - { - KeyMouseControls.KeyDown(Keys.LWin); - KeyMouseControls.KeyUp(Keys.LWin); - } - else if (textToSend.StartsWith("{WIN_KEY+") && textToSend.EndsWith("}")) - { - KeyMouseControls.KeyDown(Keys.LWin); - var remainingText = textToSend.Replace("{WIN_KEY+", "").Replace("}", ""); - - foreach (var c in remainingText) - { - Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); - KeyMouseControls.KeyDown(key); - } - - KeyMouseControls.KeyUp(Keys.LWin); - - foreach (var c in remainingText) - { - Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); - KeyMouseControls.KeyUp(key); - } - } - else - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_UseClipBoard), engine)) - { - ClipboardControls.SetClipboardText(textToSend); - textToSend = "^v"; // Ctrl+V - } - SendKeys.SendWait(textToSend); - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ClearClipboardAfterPaste), engine)) - { - ClipboardControls.ClearClipboard(); - } - } - - var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTime), engine); - System.Threading.Thread.Sleep(waitTime); - }) - ); - } - - private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - } - - private void lnkEncryptText_Click(object sender, EventArgs e) - { - var inputText = ControlsList.GetPropertyControl(nameof(v_TextToSend)); - - if (string.IsNullOrEmpty(inputText.Text)) - { - MessageBox.Show("Text to send is empty.", "Notice"); - return; - } - - var encrypted = EncryptionServices.EncryptString(inputText.Text, "TASKT"); - this.v_EncryptionOption = "Encrypted"; - - inputText.Text = encrypted; - } - - private void lnkKeysBulider_Click(object sender, EventArgs e) - { - using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmKeysBuilder()) - { - if (fm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) - { - var inputText = ControlsList.GetPropertyControl(nameof(v_TextToSend)); - inputText.Text = fm.Result; - } - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/KeyMouse/EnterShortcutKeyCommand.cs b/taskt/Core/Automation/Commands/KeyMouse/EnterShortcutKeyCommand.cs deleted file mode 100644 index d93a65d11..000000000 --- a/taskt/Core/Automation/Commands/KeyMouse/EnterShortcutKeyCommand.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Key/Mouse")] - [Attributes.ClassAttributes.SubGruop("Key")] - [Attributes.ClassAttributes.CommandSettings("Enter Shortcut Key")] - [Attributes.ClassAttributes.Description("Sends keystrokes to a targeted window")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send keystroke inputs to a window.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows.Forms.SendKeys' method to achieve automation.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class EnterShortcutKeyCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] - public string v_WindowName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Shortcut Key to Enter")] - [PropertyUISelectionOption("New")] - [PropertyUISelectionOption("New Window")] - [PropertyUISelectionOption("Open")] - [PropertyUISelectionOption("Print")] - [PropertyUISelectionOption("Save")] - [PropertyUISelectionOption("Save As")] - [PropertyUISelectionOption("Undo")] - [PropertyUISelectionOption("Cut")] - [PropertyUISelectionOption("Copy")] - [PropertyUISelectionOption("Paste")] - [PropertyUISelectionOption("Delete")] - [PropertyUISelectionOption("Search")] - [PropertyUISelectionOption("Find")] - [PropertyUISelectionOption("Find Next")] - [PropertyUISelectionOption("Find Previous")] - [PropertyUISelectionOption("Replace")] - [PropertyUISelectionOption("Go To")] - [PropertyUISelectionOption("Select All")] - [PropertySecondaryLabel(true)] - [PropertyAddtionalParameterInfo("New", "Send Ctrl + N")] - [PropertyAddtionalParameterInfo("New Window", "Send Ctrl + Shift + N")] - [PropertyAddtionalParameterInfo("Open", "Send Ctrl + O")] - [PropertyAddtionalParameterInfo("Print", "Send Ctrl + P")] - [PropertyAddtionalParameterInfo("Save", "Send Ctrl + S")] - [PropertyAddtionalParameterInfo("Save As", "Send Ctrl + Shift + S")] - [PropertyAddtionalParameterInfo("Undo", "Send Ctrl + Z")] - [PropertyAddtionalParameterInfo("Cut", "Send Ctrl + X")] - [PropertyAddtionalParameterInfo("Copy", "Send Ctrl + C")] - [PropertyAddtionalParameterInfo("Paste", "Send Ctrl + V")] - [PropertyAddtionalParameterInfo("Delete", "Send Delete")] - [PropertyAddtionalParameterInfo("Search", "Send Ctrl + E")] - [PropertyAddtionalParameterInfo("Find", "Send Ctrl + F")] - [PropertyAddtionalParameterInfo("Find Next", "Send F3")] - [PropertyAddtionalParameterInfo("Find Previous", "Send Shift + F3")] - [PropertyAddtionalParameterInfo("Replace", "Send Ctrl + H")] - [PropertyAddtionalParameterInfo("Go To", "Send Ctrl + G")] - [PropertyAddtionalParameterInfo("Select All", "Send Ctrl + A")] - [PropertySelectionChangeEvent(nameof(cmbHotkey_SelectedIndexChanged))] - [PropertyValidationRule("Shortcut Key", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Shortcut")] - public string v_Hotkey { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] - public string v_TargetWindowIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] - public string v_WaitTimeForWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_WaitTimeAfterKeyEnter))] - public string v_WaitAfterKeyEnter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] - public string v_NameResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_HandleResult { get; set; } - - public EnterShortcutKeyCommand() - { - //this.CommandName = "SendHotkeyCommand"; - //this.SelectionName = "Send Hotkey"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - string sendKey = ""; - switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_Hotkey), engine)) - { - case "new": - sendKey = "^n"; - break; - case "new window": - sendKey = "^n"; - break; - case "open": - sendKey = "^o"; - break; - case "print": - sendKey = "^p"; - break; - case "save": - sendKey = "^s"; - break; - case "save as": - sendKey = "^+s"; - break; - case "undo": - sendKey = "^z"; - break; - case "cut": - sendKey = "^x"; - break; - case "copy": - sendKey = "^c"; - break; - case "paste": - sendKey = "^v"; - break; - case "delete": - sendKey = "{DEL}"; - break; - case "search": - sendKey = "^e"; - break; - case "find": - sendKey = "^f"; - break; - case "find next": - sendKey = "{F3}"; - break; - case "find previous": - sendKey = "+{F3}"; - break; - case "replace": - sendKey = "^h"; - break; - case "go to": - sendKey = "^g"; - break; - case "select all": - sendKey = "^a"; - break; - } - - var enterKeysCommand = new EnterKeysCommand - { - v_WindowName = this.v_WindowName, - v_CompareMethod = this.v_CompareMethod, - v_TextToSend = sendKey, - v_MatchMethod = this.v_MatchMethod, - v_TargetWindowIndex = this.v_TargetWindowIndex, - v_WaitTimeForWindow = this.v_WaitTimeForWindow, - v_WaitTime = this.v_WaitAfterKeyEnter, - v_NameResult = this.v_NameResult, - v_HandleResult = this.v_HandleResult, - }; - enterKeysCommand.RunCommand(engine); - } - - private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - } - - private void cmbHotkey_SelectedIndexChanged(object sender, EventArgs e) - { - var searchedKey = ((ComboBox)sender).SelectedItem?.ToString() ?? ""; - - ControlsList.SecondLabelProcess(nameof(v_Hotkey), nameof(v_Hotkey), searchedKey); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/KeyMouse/SendAdvancedKeyStrokesCommand.cs b/taskt/Core/Automation/Commands/KeyMouse/SendAdvancedKeyStrokesCommand.cs deleted file mode 100644 index cdab32211..000000000 --- a/taskt/Core/Automation/Commands/KeyMouse/SendAdvancedKeyStrokesCommand.cs +++ /dev/null @@ -1,305 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml.Serialization; -using System.Data; -using System.Windows.Forms; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Key/Mouse")] - [Attributes.ClassAttributes.SubGruop("Key")] - [Attributes.ClassAttributes.CommandSettings("Send Advanced Keystrokes")] - [Attributes.ClassAttributes.Description("Sends advanced keystrokes to a targeted window")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send advanced keystroke inputs to a window.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements 'User32' method to achieve automation.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SendAdvancedKeyStrokesCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] - public string v_WindowName { get; set; } - - [XmlElement] - [PropertyDescription("Keys and Action Type")] - [InputSpecification("")] - [SampleUsage("")] - [Remarks("")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] - [PropertyDataGridViewSetting(true, true, true, 400, 250)] - [PropertyDataGridViewColumnSettings("Key", "Key", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.ComboBox)] - [PropertyDataGridViewColumnSettings("Action", "Action", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.ComboBox, "Key Press (Down + Up)\nKey Down\nKey Up")] - [PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.AllEditableDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] - public DataTable v_KeyActions { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Return all keys to 'UP' position after execution")] - [PropertyIsOptional(true, "Yes")] - public string v_KeyUpDefault { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_WaitTimeAfterKeyEnter))] - public string v_WaitAfterKeyEnter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] - public string v_TargetWindowIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] - public string v_WaitTimeForWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Try Activate Window, when Specifiy Current Window Variable")] - [PropertyIsOptional(true, "No")] - public string v_ActivateCurrentWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] - public string v_NameResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_HandleResult { get; set; } - - public SendAdvancedKeyStrokesCommand() - { - //this.CommandName = "SendAdvancedKeyStrokesCommand"; - //this.SelectionName = "Send Advanced Keystrokes"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - //var whnd = wins[0].Item1; - //WindowControls.ActivateWindow(whnd); - if (VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowName.VariableName, engine) == v_WindowName) - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateCurrentWindow), engine)) - { - WindowControls.ActivateWindow(wins[0].Item1); - } - } - else - { - WindowControls.ActivateWindow(wins[0].Item1); - } - - //track all keys down - var keysDown = new List(); - - //run each selected item - foreach (DataRow rw in v_KeyActions.Rows) - { - //get key name - var keyName = rw.Field("Key"); - - //get key action - var action = rw.Field("Action"); - - //parse OEM key name - string oemKeyString = keyName.Split('[', ']')[1]; - - var oemKeyName = (Keys)Enum.Parse(typeof(Keys), oemKeyString); - - - //"Key Press (Down + Up)", "Key Down", "Key Up" - switch (action) - { - case "Key Press (Down + Up)": - //simulate press - KeyMouseControls.KeyDown(oemKeyName); - KeyMouseControls.KeyUp(oemKeyName); - - //key returned to UP position so remove if we added it to the keys down list - if (keysDown.Contains(oemKeyName)) - { - keysDown.Remove(oemKeyName); - } - break; - - case "Key Down": - //simulate down - KeyMouseControls.KeyDown(oemKeyName); - - //track via keys down list - if (!keysDown.Contains(oemKeyName)) - { - keysDown.Add(oemKeyName); - } - break; - - case "Key Up": - //simulate up - KeyMouseControls.KeyUp(oemKeyName); - - //remove from key down - if (keysDown.Contains(oemKeyName)) - { - keysDown.Remove(oemKeyName); - } - break; - - default: - break; - } - } - - //return key to up position if requested - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_KeyUpDefault), engine)) - { - foreach (var key in keysDown) - { - KeyMouseControls.KeyUp(key); - } - } - }) - ); - - //var targetWindow = v_WindowName.ExpandValueOrUserVariable(engine); - - //if (targetWindow != engine.engineSettings.CurrentWindowKeyword) - //{ - // var activateWindow = new ActivateWindowCommand - // { - // v_WindowName = v_WindowName, - // v_SearchMethod = v_SearchMethod, - // v_MatchMethod = v_MatchMethod, - // v_TargetWindowIndex = v_TargetWindowIndex, - // v_WaitTime = v_WaitForWindow - // }; - // activateWindow.RunCommand(engine); - //} - - ////track all keys down - //var keysDown = new List(); - - ////run each selected item - //foreach (DataRow rw in v_KeyActions.Rows) - //{ - // //get key name - // var keyName = rw.Field("Key"); - - // //get key action - // var action = rw.Field("Action"); - - // //parse OEM key name - // string oemKeyString = keyName.Split('[', ']')[1]; - - // var oemKeyName = (Keys)Enum.Parse(typeof(Keys), oemKeyString); - - - // //"Key Press (Down + Up)", "Key Down", "Key Up" - // switch (action) - // { - // case "Key Press (Down + Up)": - // //simulate press - // KeyMouseControls.KeyDown(oemKeyName); - // KeyMouseControls.KeyUp(oemKeyName); - - // //key returned to UP position so remove if we added it to the keys down list - // if (keysDown.Contains(oemKeyName)) - // { - // keysDown.Remove(oemKeyName); - // } - // break; - - // case "Key Down": - // //simulate down - // KeyMouseControls.KeyDown(oemKeyName); - - // //track via keys down list - // if (!keysDown.Contains(oemKeyName)) - // { - // keysDown.Add(oemKeyName); - // } - // break; - - // case "Key Up": - // //simulate up - // KeyMouseControls.KeyUp(oemKeyName); - - // //remove from key down - // if (keysDown.Contains(oemKeyName)) - // { - // keysDown.Remove(oemKeyName); - // } - // break; - - // default: - // break; - // } - //} - - ////return key to up position if requested - //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_KeyUpDefault), engine)) - //{ - // foreach (var key in keysDown) - // { - // KeyMouseControls.KeyUp(key); - // } - //} - } - - private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - var dgv = ControlsList.GetPropertyControl(nameof(v_KeyActions)); - - var column = (DataGridViewComboBoxColumn)dgv.Columns[0]; - column.DataSource = KeyMouseControls.KeysList; - } - - public override bool IsValidate(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - base.IsValidate(editor); - - for (int i = 0; i < v_KeyActions.Rows.Count; i++) - { - var row = v_KeyActions.Rows[i]; - if (string.IsNullOrEmpty(row.Field("Key"))) - { - this.validationResult += "Selected Key #" + (i + 1) + " is empty.\n"; - this.IsValid = false; - } - if (string.IsNullOrEmpty(row.Field("Action"))) - { - this.validationResult += "Selected Action #" + (i + 1) + " is empty.\n"; - this.IsValid = false; - } - } - - return this.IsValid; - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - - var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_KeyActions)); - DataTableControls.BeforeValidate(dgv, v_KeyActions); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/KeyMouseControls.cs b/taskt/Core/Automation/Commands/KeyMouseControls.cs index e2024f952..9ed306218 100644 --- a/taskt/Core/Automation/Commands/KeyMouseControls.cs +++ b/taskt/Core/Automation/Commands/KeyMouseControls.cs @@ -13,6 +13,7 @@ static public class KeyMouseControls /// wait after key enter /// [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time for After Key Enter")] [Remarks("When the Wait Time is less than **100** is specified, it will be **100**")] [PropertyIsOptional(true, "500")] [PropertyFirstValue("500")] diff --git a/taskt/Core/Automation/Commands/KeyMouse/ClickMouseCommand.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/ClickMouseCommand.cs similarity index 99% rename from taskt/Core/Automation/Commands/KeyMouse/ClickMouseCommand.cs rename to taskt/Core/Automation/Commands/KeyMouseGroup/ClickMouseCommand.cs index 4b36112cd..1f50648fa 100644 --- a/taskt/Core/Automation/Commands/KeyMouse/ClickMouseCommand.cs +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/ClickMouseCommand.cs @@ -8,7 +8,6 @@ namespace taskt.Core.Automation.Commands [Serializable] [Attributes.ClassAttributes.Group("Key/Mouse")] [Attributes.ClassAttributes.SubGruop("Mouse")] - [Attributes.ClassAttributes.CommandSettings("Click Mouse")] [Attributes.ClassAttributes.Description("Simulates mouse clicks.")] [Attributes.ClassAttributes.UsesDescription("Use this command to simulate multiple types of mouse clicks.")] diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/EnterKeysCommand.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/EnterKeysCommand.cs new file mode 100644 index 000000000..e1764aced --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/EnterKeysCommand.cs @@ -0,0 +1,264 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.KeyMouseGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Key/Mouse")] + [Attributes.ClassAttributes.SubGruop("Key")] + [Attributes.ClassAttributes.CommandSettings("Enter Keys")] + [Attributes.ClassAttributes.Description("Sends keystrokes to a targeted window")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send keystroke inputs to a window.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows.Forms.SendKeys' method to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class EnterKeysCommand : AOneWindowNameActionCommands, IEnterKeysProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + //public string v_WindowName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_TextToSend))] + //[PropertyDescription("Text or Keys to Send")] + //[PropertyCustomUIHelper("Keys Builder", nameof(lnkKeysBulider_Click))] + //[PropertyCustomUIHelper("Encrypt Text", nameof(lnkEncryptText_Click))] + //[InputSpecification("Text to Send", true)] + //[PropertyDetailSampleUsage("**Hello, World!**", PropertyDetailSampleUsage.ValueType.Value, "Text")] + //[PropertyDetailSampleUsage("**{{{vText}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Text")] + //[PropertyDetailSampleUsage("**^s**", "Specify **Ctrl+S** for Enter Keys")] + //[PropertyDetailSampleUsage("**{WIN_KEY}**", "Specify **Windows Key** for Enter Keys")] + //[PropertyDetailSampleUsage("**{WIN_KEY+R}**", "Specify **Windows Key** and **R** for Enter Keys")] + //[Remarks("")] + //[PropertyShowSampleUsageInDescription(true)] + //[PropertyIntermediateConvert(nameof(IntermediateControls.ConvertToIntermediate_CheckedVariableMarker), "")] + //[PropertyDisplayText(true, "Text")] + [PropertyParameterOrder(5100)] + public string v_TextToSend { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_EncryptionOption))] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Text is Encrypted")] + //[PropertyIsOptional(true, "No")] + //[PropertyDisplayText(false, "Encrypted")] + [PropertyParameterOrder(5200)] + public string v_EncryptionOption { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_UseClipBoard))] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Use Paste from Clipboard")] + //[PropertyIsOptional(true, "No")] + //[Remarks("When entering keys in combination with the Ctrl key, etc., It will NOT work correctly.")] + //[PropertyDisplayText(false, "Use Clipboard")] + [PropertyParameterOrder(5300)] + public string v_UseClipBoard { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] + //public string v_CompareMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] + //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + //public string v_MatchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + //public string v_TargetWindowIndex { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + //public string v_WaitTimeForWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_WaitTimeAfterKeyEnter))] + //[PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_WaitTimeAfterKeyEnter))] + [PropertyParameterOrder(8010)] + public string v_WaitTimeAfterKeyEnter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_ActivateCurrentWindow))] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Try Activate Window, when Specifiy Current Window Variable")] + //[PropertyIsOptional(true, "No")] + [PropertyParameterOrder(8020)] + public string v_ActivateCurrentWindow { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + //public string v_NameResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_HandleResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_ClearClipboardAfterPaste))] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Clear Clipboard After Paste")] + //[PropertyIsOptional(true, "No")] + //[PropertyValidationRule("Clear Clipboard", PropertyValidationRule.ValidationRuleFlags.None)] + //[PropertyDisplayText(false, "Clear Clipboard after Paste")] + [PropertyParameterOrder(9000)] + public string v_ClearClipboardAfterPaste { get; set; } + + [XmlAttribute] + [PropertyIsOptional(true, "Yes")] + [PropertyFirstValue("Yes")] + public override string v_ActivateBeforeAction { get; set; } + + public EnterKeysCommand() + { + //this.CommandName = "SendKeysCommand"; + //this.SelectionName = "Send Keystrokes"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + //this.v_EncryptionOption = "Not Encrypted"; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + // activate window + //void ActivateWindowProcess(IntPtr h) + //{ + // var activateWindow = new ActivateWindowByWindowHandleCommand() + // { + // v_WindowHandle = h.ToString(), + // }; + // activateWindow.RunCommand(engine); + //} + + this.WindowNameAction(engine, new Action((whnd, name) => + { + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateBeforeAction), engine)) + //{ + // if (VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowName.VariableName, engine) == v_WindowName) + // { + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateCurrentWindow), engine)) + // { + // ActivateWindowProcess(whnd); + // } + // } + // else + // { + // ActivateWindowProcess(whnd); + // } + //} + //this.WaitAfterFindWindowProcess(engine); + + //var textToSend = v_TextToSend.ExpandValueOrUserVariable(engine); + + ////var encryptOption = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_EncryptionOption), engine); + ////if (encryptOption == "encrypted") + ////{ + //// textToSend = EncryptionServices.DecryptString(textToSend, "TASKT"); + ////} + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_EncryptionOption), engine)) + //{ + // textToSend = EncryptionServices.DecryptString(textToSend, "TASKT"); + //} + + //if (textToSend == "{WIN_KEY}") + //{ + // KeyMouseControls.KeyDown(Keys.LWin); + // KeyMouseControls.KeyUp(Keys.LWin); + //} + //else if (textToSend.StartsWith("{WIN_KEY+") && textToSend.EndsWith("}")) + //{ + // KeyMouseControls.KeyDown(Keys.LWin); + // var remainingText = textToSend.Replace("{WIN_KEY+", "").Replace("}", ""); + + // foreach (var c in remainingText) + // { + // Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); + // KeyMouseControls.KeyDown(key); + // } + + // KeyMouseControls.KeyUp(Keys.LWin); + + // foreach (var c in remainingText) + // { + // Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); + // KeyMouseControls.KeyUp(key); + // } + //} + //else + //{ + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_UseClipBoard), engine)) + // { + // ClipboardControls.SetClipboardText(textToSend); + // textToSend = "^v"; // Ctrl+V + // } + // SendKeys.SendWait(textToSend); + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ClearClipboardAfterPaste), engine)) + // { + // ClipboardControls.ClearClipboard(); + // } + //} + + //var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeAfterKeyEnter), engine); + //System.Threading.Thread.Sleep(waitTime); + + string targetHandle; + //if (VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowName.VariableName, engine) == v_WindowName) + if (this.IsCurrentWindowNameKeyword(engine)) + { + targetHandle = VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowHandle.VariableName, engine); + } + else + { + targetHandle = whnd.ToString(); + } + + var enterKeys = new EnterKeysFromWindowHandleCommand() + { + v_WindowHandle = targetHandle, + v_TextToSend = this.v_TextToSend, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + v_ActivateCurrentWindow = this.v_ActivateCurrentWindow, + v_ClearClipboardAfterPaste = this.v_ClearClipboardAfterPaste, + v_EncryptionOption = this.v_EncryptionOption, + v_UseClipBoard = this.v_UseClipBoard, + v_WaitTimeAfterKeyEnter = this.v_WaitTimeAfterKeyEnter, + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_WindowNameResult = this.v_WindowName, + }; + enterKeys.RunCommand(engine); + })); + } + + //private void lnkEncryptText_Click(object sender, EventArgs e) + //{ + // var inputText = ControlsList.GetPropertyControl(nameof(v_TextToSend)); + + // if (string.IsNullOrEmpty(inputText.Text)) + // { + // MessageBox.Show("Text to send is empty.", "Notice"); + // return; + // } + + // var encrypted = EncryptionServices.EncryptString(inputText.Text, "TASKT"); + // this.v_EncryptionOption = "Encrypted"; + + // inputText.Text = encrypted; + //} + + //private void lnkKeysBulider_Click(object sender, EventArgs e) + //{ + // using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmKeysBuilder()) + // { + // if (fm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) + // { + // var inputText = ControlsList.GetPropertyControl(nameof(v_TextToSend)); + // inputText.Text = fm.Result; + // } + // } + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/EnterKeysFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/EnterKeysFromWindowHandleCommand.cs new file mode 100644 index 000000000..f2af8e7c1 --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/EnterKeysFromWindowHandleCommand.cs @@ -0,0 +1,139 @@ +using System; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.KeyMouseGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Key/Mouse")] + [Attributes.ClassAttributes.SubGruop("Key")] + [Attributes.ClassAttributes.CommandSettings("Enter Keys From Window Handle")] + [Attributes.ClassAttributes.Description("Sends keystrokes to a targeted window")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send keystroke inputs to a window.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows.Forms.SendKeys' method to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class EnterKeysFromWindowHandleCommand : AWindowHandleActionCommands, IEnterKeysProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_TextToSend))] + [PropertyParameterOrder(5100)] + public string v_TextToSend { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_EncryptionOption))] + [PropertyParameterOrder(5200)] + public string v_EncryptionOption { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_UseClipBoard))] + [PropertyParameterOrder(5300)] + public string v_UseClipBoard { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_WaitTimeAfterKeyEnter))] + [PropertyParameterOrder(8010)] + public string v_WaitTimeAfterKeyEnter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_ActivateCurrentWindow))] + [PropertyParameterOrder(8020)] + public string v_ActivateCurrentWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_ClearClipboardAfterPaste))] + [PropertyParameterOrder(9000)] + public string v_ClearClipboardAfterPaste { get; set; } + + [XmlAttribute] + [PropertyIsOptional(true, "Yes")] + [PropertyFirstValue("Yes")] + public override string v_ActivateBeforeAction { get; set; } + + public EnterKeysFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + // activate window + void ActivateWindowProcess(IntPtr h) + { + var activateWindow = new ActivateWindowByWindowHandleCommand() + { + v_WindowHandle = h.ToString(), + }; + activateWindow.RunCommand(engine); + } + + this.WindowHandleActionBeforeWaitActivate(engine, new Action((whnd) => + { + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateBeforeAction), engine)) + { + if (this.IsCurrentWindowHandleKeyword(engine)) + { + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateCurrentWindow), engine)) + { + ActivateWindowProcess(whnd); + } + } + else + { + ActivateWindowProcess(whnd); + } + } + + var textToSend = v_TextToSend.ExpandValueOrUserVariable(engine); + + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_EncryptionOption), engine)) + { + textToSend = EncryptionServices.DecryptString(textToSend, "TASKT"); + } + + if (textToSend == "{WIN_KEY}") + { + KeyMouseControls.KeyDown(Keys.LWin); + KeyMouseControls.KeyUp(Keys.LWin); + } + else if (textToSend.StartsWith("{WIN_KEY+") && textToSend.EndsWith("}")) + { + KeyMouseControls.KeyDown(Keys.LWin); + var remainingText = textToSend.Replace("{WIN_KEY+", "").Replace("}", ""); + + foreach (var c in remainingText) + { + Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); + KeyMouseControls.KeyDown(key); + } + + KeyMouseControls.KeyUp(Keys.LWin); + + foreach (var c in remainingText) + { + Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); + KeyMouseControls.KeyUp(key); + } + } + else + { + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_UseClipBoard), engine)) + { + ClipboardControls.SetClipboardText(textToSend); + textToSend = "^v"; // Ctrl+V + } + SendKeys.SendWait(textToSend); + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ClearClipboardAfterPaste), engine)) + { + ClipboardControls.ClearClipboard(); + } + } + + var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTimeAfterKeyEnter), engine); + System.Threading.Thread.Sleep(waitTime); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/EnterShortcutKeyCommand.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/EnterShortcutKeyCommand.cs new file mode 100644 index 000000000..f07e6c7d8 --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/EnterShortcutKeyCommand.cs @@ -0,0 +1,232 @@ +using System; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.KeyMouseGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Key/Mouse")] + [Attributes.ClassAttributes.SubGruop("Key")] + [Attributes.ClassAttributes.CommandSettings("Enter Shortcut Key")] + [Attributes.ClassAttributes.Description("Sends keystrokes to a targeted window")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send keystroke inputs to a window.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows.Forms.SendKeys' method to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class EnterShortcutKeyCommand : AOneWindowNameActionCommands, IEnterShortcutKeyProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + //public string v_WindowName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_Hotkey))] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("Shortcut Key to Enter")] + //[PropertyUISelectionOption("New")] + //[PropertyUISelectionOption("New Window")] + //[PropertyUISelectionOption("Open")] + //[PropertyUISelectionOption("Print")] + //[PropertyUISelectionOption("Save")] + //[PropertyUISelectionOption("Save As")] + //[PropertyUISelectionOption("Undo")] + //[PropertyUISelectionOption("Cut")] + //[PropertyUISelectionOption("Copy")] + //[PropertyUISelectionOption("Paste")] + //[PropertyUISelectionOption("Delete")] + //[PropertyUISelectionOption("Search")] + //[PropertyUISelectionOption("Find")] + //[PropertyUISelectionOption("Find Next")] + //[PropertyUISelectionOption("Find Previous")] + //[PropertyUISelectionOption("Replace")] + //[PropertyUISelectionOption("Go To")] + //[PropertyUISelectionOption("Select All")] + //[PropertySecondaryLabel(true)] + //[PropertyAddtionalParameterInfo("New", "Send Ctrl + N")] + //[PropertyAddtionalParameterInfo("New Window", "Send Ctrl + Shift + N")] + //[PropertyAddtionalParameterInfo("Open", "Send Ctrl + O")] + //[PropertyAddtionalParameterInfo("Print", "Send Ctrl + P")] + //[PropertyAddtionalParameterInfo("Save", "Send Ctrl + S")] + //[PropertyAddtionalParameterInfo("Save As", "Send Ctrl + Shift + S")] + //[PropertyAddtionalParameterInfo("Undo", "Send Ctrl + Z")] + //[PropertyAddtionalParameterInfo("Cut", "Send Ctrl + X")] + //[PropertyAddtionalParameterInfo("Copy", "Send Ctrl + C")] + //[PropertyAddtionalParameterInfo("Paste", "Send Ctrl + V")] + //[PropertyAddtionalParameterInfo("Delete", "Send Delete")] + //[PropertyAddtionalParameterInfo("Search", "Send Ctrl + E")] + //[PropertyAddtionalParameterInfo("Find", "Send Ctrl + F")] + //[PropertyAddtionalParameterInfo("Find Next", "Send F3")] + //[PropertyAddtionalParameterInfo("Find Previous", "Send Shift + F3")] + //[PropertyAddtionalParameterInfo("Replace", "Send Ctrl + H")] + //[PropertyAddtionalParameterInfo("Go To", "Send Ctrl + G")] + //[PropertyAddtionalParameterInfo("Select All", "Send Ctrl + A")] + //[PropertySelectionChangeEvent(nameof(cmbHotkey_SelectedIndexChanged))] + //[PropertyValidationRule("Shortcut Key", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "Shortcut")] + [PropertySelectionChangeEvent(nameof(cmbHotkey_SelectedIndexChanged))] + [PropertyParameterOrder(5100)] + public string v_Hotkey { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] + //public string v_CompareMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] + //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + //public string v_MatchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + //public string v_TargetWindowIndex { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + //public string v_WaitTimeForWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_WaitTimeAfterKeyEnter))] + //[PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_WaitTimeAfterKeyEnter))] + [PropertyParameterOrder(8010)] + public string v_WaitTimeAfterKeyEnter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_ActivateCurrentWindow))] + [PropertyParameterOrder(8020)] + public string v_ActivateCurrentWindow { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + //public string v_NameResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_HandleResult { get; set; } + + [XmlAttribute] + [PropertyIsOptional(true, "Yes")] + [PropertyFirstValue("Yes")] + public override string v_ActivateBeforeAction { get; set; } + + public EnterShortcutKeyCommand() + { + //this.CommandName = "SendHotkeyCommand"; + //this.SelectionName = "Send Hotkey"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //string sendKey = ""; + //switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_Hotkey), engine)) + //{ + // case "new": + // sendKey = "^n"; + // break; + // case "new window": + // sendKey = "^n"; + // break; + // case "open": + // sendKey = "^o"; + // break; + // case "print": + // sendKey = "^p"; + // break; + // case "save": + // sendKey = "^s"; + // break; + // case "save as": + // sendKey = "^+s"; + // break; + // case "undo": + // sendKey = "^z"; + // break; + // case "cut": + // sendKey = "^x"; + // break; + // case "copy": + // sendKey = "^c"; + // break; + // case "paste": + // sendKey = "^v"; + // break; + // case "delete": + // sendKey = "{DEL}"; + // break; + // case "search": + // sendKey = "^e"; + // break; + // case "find": + // sendKey = "^f"; + // break; + // case "find next": + // sendKey = "{F3}"; + // break; + // case "find previous": + // sendKey = "+{F3}"; + // break; + // case "replace": + // sendKey = "^h"; + // break; + // case "go to": + // sendKey = "^g"; + // break; + // case "select all": + // sendKey = "^a"; + // break; + //} + + //var enterKeysCommand = new EnterKeysCommand + //{ + // v_WindowName = this.v_WindowName, + // v_CompareMethod = this.v_CompareMethod, + // v_TextToSend = sendKey, + // v_MatchMethod = this.v_MatchMethod, + // v_TargetWindowIndex = this.v_TargetWindowIndex, + // v_WaitTimeForWindow = this.v_WaitTimeForWindow, + // v_WaitTimeAfterKeyEnter = this.v_WaitTimeAfterKeyEnter, + // v_NameResult = this.v_NameResult, + // v_HandleResult = this.v_HandleResult, + // v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + // v_ActivateBeforeAction = this.v_ActivateBeforeAction, + //}; + //enterKeysCommand.RunCommand(engine); + + this.WindowNameAction(engine, new Action((whnd, name) => + { + string sendHandle; + if (this.IsCurrentWindowNameKeyword(engine)) + { + sendHandle = VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowHandle.VariableName, engine); + } + else + { + sendHandle = whnd.ToString(); + } + + var sendKey = new EnterShortcutKeyFromWindowHandleCommand() + { + v_Hotkey = this.v_Hotkey, + v_WindowHandle = sendHandle, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + v_ActivateCurrentWindow = this.v_ActivateCurrentWindow, + v_WaitTimeAfterKeyEnter = this.v_WaitTimeAfterKeyEnter, + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + }; + sendKey.RunCommand(engine); + })); + } + + private void cmbHotkey_SelectedIndexChanged(object sender, EventArgs e) + { + var searchedKey = ((ComboBox)sender).SelectedItem?.ToString() ?? ""; + + ControlsList.SecondLabelProcess(nameof(v_Hotkey), nameof(v_Hotkey), searchedKey); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/EnterShortcutKeyFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/EnterShortcutKeyFromWindowHandleCommand.cs new file mode 100644 index 000000000..280f8cbe6 --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/EnterShortcutKeyFromWindowHandleCommand.cs @@ -0,0 +1,128 @@ +using System; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.KeyMouseGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Key/Mouse")] + [Attributes.ClassAttributes.SubGruop("Key")] + [Attributes.ClassAttributes.CommandSettings("Enter Shortcut Key From Window Handle")] + [Attributes.ClassAttributes.Description("Sends keystrokes to a targeted window")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send keystroke inputs to a window.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows.Forms.SendKeys' method to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class EnterShortcutKeyFromWindowHandleCommand : AWindowHandleActionCommands, IEnterShortcutKeyProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_Hotkey))] + [PropertySelectionChangeEvent(nameof(cmbHotkey_SelectedIndexChanged))] + [PropertyParameterOrder(5100)] + public string v_Hotkey { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_WaitTimeAfterKeyEnter))] + [PropertyParameterOrder(8010)] + public string v_WaitTimeAfterKeyEnter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_ActivateCurrentWindow))] + [PropertyParameterOrder(8020)] + public string v_ActivateCurrentWindow { get; set; } + + [XmlAttribute] + [PropertyIsOptional(true, "Yes")] + [PropertyFirstValue("Yes")] + public override string v_ActivateBeforeAction { get; set; } + + public EnterShortcutKeyFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + string sendKey = ""; + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_Hotkey), engine)) + { + case "new": + sendKey = "^n"; + break; + case "new window": + sendKey = "^n"; + break; + case "open": + sendKey = "^o"; + break; + case "print": + sendKey = "^p"; + break; + case "save": + sendKey = "^s"; + break; + case "save as": + sendKey = "^+s"; + break; + case "undo": + sendKey = "^z"; + break; + case "cut": + sendKey = "^x"; + break; + case "copy": + sendKey = "^c"; + break; + case "paste": + sendKey = "^v"; + break; + case "delete": + sendKey = "{DEL}"; + break; + case "search": + sendKey = "^e"; + break; + case "find": + sendKey = "^f"; + break; + case "find next": + sendKey = "{F3}"; + break; + case "find previous": + sendKey = "+{F3}"; + break; + case "replace": + sendKey = "^h"; + break; + case "go to": + sendKey = "^g"; + break; + case "select all": + sendKey = "^a"; + break; + } + + var enterKeysCommand = new EnterKeysFromWindowHandleCommand + { + v_WindowHandle = this.v_WindowHandle, + v_TextToSend = sendKey, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_WaitTimeAfterKeyEnter = this.v_WaitTimeAfterKeyEnter, + v_WindowNameResult = this.v_WindowNameResult, + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + v_ActivateCurrentWindow = this.v_ActivateCurrentWindow, + }; + enterKeysCommand.RunCommand(engine); + } + + private void cmbHotkey_SelectedIndexChanged(object sender, EventArgs e) + { + var searchedKey = ((ComboBox)sender).SelectedItem?.ToString() ?? ""; + + ControlsList.SecondLabelProcess(nameof(v_Hotkey), nameof(v_Hotkey), searchedKey); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/IEnterKeysProperties.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/IEnterKeysProperties.cs new file mode 100644 index 000000000..7fe521c13 --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/IEnterKeysProperties.cs @@ -0,0 +1,28 @@ +namespace taskt.Core.Automation.Commands.KeyMouseGroup +{ + /// + /// for enter keys properties + /// + public interface IEnterKeysProperties : IKeyActionCoreProperties + { + /// + /// text or key strokes to send + /// + string v_TextToSend { get; set; } + + /// + /// text encrypted + /// + string v_EncryptionOption { get; set; } + + /// + /// use clipboard when text send + /// + string v_UseClipBoard { get; set; } + + /// + /// clear clipboard after paste (when use clipboard) + /// + string v_ClearClipboardAfterPaste { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/IEnterShortcutKeyProperties.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/IEnterShortcutKeyProperties.cs new file mode 100644 index 000000000..45ca6c20d --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/IEnterShortcutKeyProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.KeyMouseGroup +{ + /// + /// enter shortcut key properties + /// + public interface IEnterShortcutKeyProperties : IKeyActionCoreProperties + { + /// + /// hot key (shortcut key) + /// + string v_Hotkey { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/IKeyActionCoreProperties.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/IKeyActionCoreProperties.cs new file mode 100644 index 000000000..bbbde9e9e --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/IKeyActionCoreProperties.cs @@ -0,0 +1,18 @@ +namespace taskt.Core.Automation.Commands.KeyMouseGroup +{ + /// + /// key action core properties + /// + public interface IKeyActionCoreProperties : IWindowActivateProperties + { + /// + /// wait time after keys enter + /// + string v_WaitTimeAfterKeyEnter { get; set; } + + /// + /// activate when specified current window + /// + string v_ActivateCurrentWindow { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/ISendAdvancedKeyStrokesProperties.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/ISendAdvancedKeyStrokesProperties.cs new file mode 100644 index 000000000..974b3869a --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/ISendAdvancedKeyStrokesProperties.cs @@ -0,0 +1,20 @@ +using System.Data; + +namespace taskt.Core.Automation.Commands.KeyMouseGroup +{ + /// + /// send advanced key strokes properties + /// + public interface ISendAdvancedKeyStrokesProperties : IKeyActionCoreProperties, IHaveDataTableElements + { + /// + /// key actions + /// + DataTable v_KeyActions { get; set; } + + /// + /// force key up after keys down + /// + string v_KeyUpDefault { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/KeyMouse/MoveMouseCommand.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/MoveMouseCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/KeyMouse/MoveMouseCommand.cs rename to taskt/Core/Automation/Commands/KeyMouseGroup/MoveMouseCommand.cs diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/SendAdvancedKeyStrokesCommand.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/SendAdvancedKeyStrokesCommand.cs new file mode 100644 index 000000000..64b88ca5b --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/SendAdvancedKeyStrokesCommand.cs @@ -0,0 +1,263 @@ +using System; +using System.Data; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.KeyMouseGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Key/Mouse")] + [Attributes.ClassAttributes.SubGruop("Key")] + [Attributes.ClassAttributes.CommandSettings("Send Advanced Keystrokes")] + [Attributes.ClassAttributes.Description("Sends advanced keystrokes to a targeted window")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send advanced keystroke inputs to a window.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements 'User32' method to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SendAdvancedKeyStrokesCommand : AOneWindowNameActionCommands, ISendAdvancedKeyStrokesProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + //public string v_WindowName { get; set; } + + [XmlElement] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_KeyActions))] + //[PropertyDescription("Keys and Action Type")] + //[InputSpecification("")] + //[SampleUsage("")] + //[Remarks("")] + //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + //[PropertyDataGridViewSetting(true, true, true, 400, 250)] + //[PropertyDataGridViewColumnSettings("Key", "Key", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.ComboBox)] + //[PropertyDataGridViewColumnSettings("Action", "Action", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.ComboBox, "Key Press (Down + Up)\nKey Down\nKey Up")] + //[PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.AllEditableDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] + [PropertyParameterOrder(5010)] + public DataTable v_KeyActions { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_KeyUpDefault))] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Return all keys to 'UP' position after execution")] + //[PropertyIsOptional(true, "Yes")] + [PropertyParameterOrder(5020)] + public string v_KeyUpDefault { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] + //public string v_CompareMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] + //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + //public string v_MatchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + //public string v_TargetWindowIndex { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + //public string v_WaitTimeForWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_WaitTimeAfterKeyEnter))] + [PropertyParameterOrder(8010)] + public string v_WaitTimeAfterKeyEnter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_ActivateCurrentWindow))] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Try Activate Window, when Specifiy Current Window Variable")] + //[PropertyIsOptional(true, "No")] + [PropertyParameterOrder(8020)] + public string v_ActivateCurrentWindow { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + //public string v_NameResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_HandleResult { get; set; } + + [XmlAttribute] + [PropertyIsOptional(true, "Yes")] + [PropertyFirstValue("Yes")] + public override string v_ActivateBeforeAction { get; set; } + + public SendAdvancedKeyStrokesCommand() + { + //this.CommandName = "SendAdvancedKeyStrokesCommand"; + //this.SelectionName = "Send Advanced Keystrokes"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //void ActivateWindowProcess(IntPtr h) + //{ + // var activateWindow = new ActivateWindowByWindowHandleCommand() + // { + // v_WindowHandle = h.ToString(), + // }; + // activateWindow.RunCommand(engine); + //} + + //this.WindowNameAction(engine, new Action((whnd, name) => + //{ + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateBeforeAction), engine)) + // { + // if (VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowName.VariableName, engine) == v_WindowName) + // { + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateCurrentWindow), engine)) + // { + // ActivateWindowProcess(whnd); + // } + // } + // else + // { + // ActivateWindowProcess(whnd); + // } + // } + // this.WaitAfterFindWindowProcess(engine); + + // // track all keys down + // var keysDown = new List(); + + // // run each selected item + // foreach (DataRow rw in v_KeyActions.Rows) + // { + // // get key name + // var keyName = rw.Field("Key"); + + // // get key action + // var action = rw.Field("Action"); + + // // parse OEM key name + // string oemKeyString = keyName.Split('[', ']')[1]; + + // var oemKeyName = (Keys)Enum.Parse(typeof(Keys), oemKeyString); + + + // // "Key Press (Down + Up)", "Key Down", "Key Up" + // switch (action) + // { + // case "Key Press (Down + Up)": + // // simulate press + // KeyMouseControls.KeyDown(oemKeyName); + // KeyMouseControls.KeyUp(oemKeyName); + + // // key returned to UP position so remove if we added it to the keys down list + // if (keysDown.Contains(oemKeyName)) + // { + // keysDown.Remove(oemKeyName); + // } + // break; + + // case "Key Down": + // // simulate down + // KeyMouseControls.KeyDown(oemKeyName); + + // // track via keys down list + // if (!keysDown.Contains(oemKeyName)) + // { + // keysDown.Add(oemKeyName); + // } + // break; + + // case "Key Up": + // // simulate up + // KeyMouseControls.KeyUp(oemKeyName); + + // // remove from key down + // if (keysDown.Contains(oemKeyName)) + // { + // keysDown.Remove(oemKeyName); + // } + // break; + + // default: + // break; + // } + // } + + // // return key to up position if requested + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_KeyUpDefault), engine)) + // { + // foreach (var key in keysDown) + // { + // KeyMouseControls.KeyUp(key); + // } + // } + //})); + + this.WindowNameAction(engine, new Action((whnd, name) => + { + string sendHandle; + if (this.IsCurrentWindowNameKeyword(engine)) + { + sendHandle = VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowHandle.VariableName, engine); + } + else + { + sendHandle = whnd.ToString(); + } + + var sendKeys = new SendAdvancedKeyStrokesFromWindowHandleCommand() + { + v_WindowHandle = sendHandle, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + v_ActivateCurrentWindow = this.v_ActivateCurrentWindow, + v_KeyActions = this.v_KeyActions, + v_KeyUpDefault = this.v_KeyUpDefault, + v_WaitTimeAfterKeyEnter = this.v_WaitTimeAfterKeyEnter, + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + }; + sendKeys.RunCommand(engine); + })); + } + + public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + var dgv = ControlsList.GetPropertyControl(nameof(v_KeyActions)); + + var column = (DataGridViewComboBoxColumn)dgv.Columns[0]; + column.DataSource = KeyMouseControls.KeysList; + } + + public override bool IsValidate(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + base.IsValidate(editor); + + for (int i = 0; i < v_KeyActions.Rows.Count; i++) + { + var row = v_KeyActions.Rows[i]; + if (string.IsNullOrEmpty(row.Field("Key"))) + { + this.validationResult += "Selected Key #" + (i + 1) + " is empty.\n"; + this.IsValid = false; + } + if (string.IsNullOrEmpty(row.Field("Action"))) + { + this.validationResult += "Selected Action #" + (i + 1) + " is empty.\n"; + this.IsValid = false; + } + } + + return this.IsValid; + } + + public override void BeforeValidate() + { + base.BeforeValidate(); + + var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_KeyActions)); + DataTableControls.BeforeValidate(dgv, v_KeyActions); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/SendAdvancedKeyStrokesFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/SendAdvancedKeyStrokesFromWindowHandleCommand.cs new file mode 100644 index 000000000..dafa575b3 --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/SendAdvancedKeyStrokesFromWindowHandleCommand.cs @@ -0,0 +1,277 @@ +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using System.Data; +using System.Windows.Forms; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.KeyMouseGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Key/Mouse")] + [Attributes.ClassAttributes.SubGruop("Key")] + [Attributes.ClassAttributes.CommandSettings("Send Advanced Keystrokes From Window Handle")] + [Attributes.ClassAttributes.Description("Sends advanced keystrokes to a targeted window")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to send advanced keystroke inputs to a window.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements 'User32' method to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_input))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SendAdvancedKeyStrokesFromWindowHandleCommand : AWindowHandleActionCommands, ISendAdvancedKeyStrokesProperties + { + [XmlElement] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_KeyActions))] + [PropertyParameterOrder(5010)] + public DataTable v_KeyActions { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_KeyUpDefault))] + [PropertyParameterOrder(5020)] + public string v_KeyUpDefault { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_WaitTimeAfterKeyEnter))] + [PropertyParameterOrder(8010)] + public string v_WaitTimeAfterKeyEnter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_KeyMouseControls), nameof(VP_KeyMouseControls.v_ActivateCurrentWindow))] + [PropertyParameterOrder(8020)] + public string v_ActivateCurrentWindow { get; set; } + + [XmlAttribute] + [PropertyIsOptional(true, "Yes")] + [PropertyFirstValue("Yes")] + public override string v_ActivateBeforeAction { get; set; } + + public SendAdvancedKeyStrokesFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + void ActivateWindowProcess(IntPtr h) + { + var activateWindow = new ActivateWindowByWindowHandleCommand() + { + v_WindowHandle = h.ToString(), + }; + activateWindow.RunCommand(engine); + } + + this.WindowHandleActionBeforeWaitActivate(engine, new Action((whnd) => + { + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateBeforeAction), engine)) + { + if (this.IsCurrentWindowHandleKeyword(engine)) + { + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateCurrentWindow), engine)) + { + ActivateWindowProcess(whnd); + } + } + else + { + ActivateWindowProcess(whnd); + } + } + this.WaitAfterFindWindowProcess(engine); + + // track all keys down + var keysDown = new List(); + + // run each selected item + foreach (DataRow rw in v_KeyActions.Rows) + { + // get key name + var keyName = rw.Field("Key"); + + // get key action + var action = rw.Field("Action"); + + // parse OEM key name + string oemKeyString = keyName.Split('[', ']')[1]; + + var oemKeyName = (Keys)Enum.Parse(typeof(Keys), oemKeyString); + + // "Key Press (Down + Up)", "Key Down", "Key Up" + switch (action) + { + case "Key Press (Down + Up)": + // simulate press + KeyMouseControls.KeyDown(oemKeyName); + KeyMouseControls.KeyUp(oemKeyName); + + // key returned to UP position so remove if we added it to the keys down list + if (keysDown.Contains(oemKeyName)) + { + keysDown.Remove(oemKeyName); + } + break; + + case "Key Down": + // simulate down + KeyMouseControls.KeyDown(oemKeyName); + + // track via keys down list + if (!keysDown.Contains(oemKeyName)) + { + keysDown.Add(oemKeyName); + } + break; + + case "Key Up": + // simulate up + KeyMouseControls.KeyUp(oemKeyName); + + // remove from key down + if (keysDown.Contains(oemKeyName)) + { + keysDown.Remove(oemKeyName); + } + break; + + default: + break; + } + } + + // return key to up position if requested + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_KeyUpDefault), engine)) + { + foreach (var key in keysDown) + { + KeyMouseControls.KeyUp(key); + } + } + })); + + //this.WindowNameAction(engine, new Action((whnd, name) => + //{ + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateBeforeAction), engine)) + // { + // if (VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowName.VariableName, engine) == v_WindowName) + // { + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateCurrentWindow), engine)) + // { + // ActivateWindowProcess(whnd); + // } + // } + // else + // { + // ActivateWindowProcess(whnd); + // } + // } + // this.WaitAfterFindWindowProcess(engine); + + // // track all keys down + // var keysDown = new List(); + + // // run each selected item + // foreach (DataRow rw in v_KeyActions.Rows) + // { + // // get key name + // var keyName = rw.Field("Key"); + + // // get key action + // var action = rw.Field("Action"); + + // // parse OEM key name + // string oemKeyString = keyName.Split('[', ']')[1]; + + // var oemKeyName = (Keys)Enum.Parse(typeof(Keys), oemKeyString); + + + // // "Key Press (Down + Up)", "Key Down", "Key Up" + // switch (action) + // { + // case "Key Press (Down + Up)": + // // simulate press + // KeyMouseControls.KeyDown(oemKeyName); + // KeyMouseControls.KeyUp(oemKeyName); + + // // key returned to UP position so remove if we added it to the keys down list + // if (keysDown.Contains(oemKeyName)) + // { + // keysDown.Remove(oemKeyName); + // } + // break; + + // case "Key Down": + // // simulate down + // KeyMouseControls.KeyDown(oemKeyName); + + // // track via keys down list + // if (!keysDown.Contains(oemKeyName)) + // { + // keysDown.Add(oemKeyName); + // } + // break; + + // case "Key Up": + // // simulate up + // KeyMouseControls.KeyUp(oemKeyName); + + // // remove from key down + // if (keysDown.Contains(oemKeyName)) + // { + // keysDown.Remove(oemKeyName); + // } + // break; + + // default: + // break; + // } + // } + + // // return key to up position if requested + // if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_KeyUpDefault), engine)) + // { + // foreach (var key in keysDown) + // { + // KeyMouseControls.KeyUp(key); + // } + // } + //})); + } + + public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + var dgv = ControlsList.GetPropertyControl(nameof(v_KeyActions)); + + var column = (DataGridViewComboBoxColumn)dgv.Columns[0]; + column.DataSource = KeyMouseControls.KeysList; + } + + public override bool IsValidate(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + base.IsValidate(editor); + + for (int i = 0; i < v_KeyActions.Rows.Count; i++) + { + var row = v_KeyActions.Rows[i]; + if (string.IsNullOrEmpty(row.Field("Key"))) + { + this.validationResult += "Selected Key #" + (i + 1) + " is empty.\n"; + this.IsValid = false; + } + if (string.IsNullOrEmpty(row.Field("Action"))) + { + this.validationResult += "Selected Action #" + (i + 1) + " is empty.\n"; + this.IsValid = false; + } + } + + return this.IsValid; + } + + public override void BeforeValidate() + { + base.BeforeValidate(); + + var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_KeyActions)); + DataTableControls.BeforeValidate(dgv, v_KeyActions); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/KeyMouseGroup/VP_KeyMouseControls.cs b/taskt/Core/Automation/Commands/KeyMouseGroup/VP_KeyMouseControls.cs new file mode 100644 index 000000000..6709467a3 --- /dev/null +++ b/taskt/Core/Automation/Commands/KeyMouseGroup/VP_KeyMouseControls.cs @@ -0,0 +1,208 @@ +using System; +using System.Windows.Forms; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.KeyMouseGroup +{ + /// + /// virtual propertyes for key mouse commands + /// + public static class VP_KeyMouseControls + { + /// + /// text to send + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_OneLineTextBox))] + [PropertyDescription("Text or Keys to Send")] + [PropertyCustomUIHelper("Keys Builder", nameof(VP_KeyMouseControls) + "+" + nameof(lnkKeysBulider_Click))] + [PropertyCustomUIHelper("Encrypt Text", nameof(VP_KeyMouseControls) + "+" + nameof(lnkEncryptText_Click))] + [InputSpecification("Text", true)] + [PropertyDetailSampleUsage("**Hello, World!**", PropertyDetailSampleUsage.ValueType.Value, "Text")] + [PropertyDetailSampleUsage("**{{{vText}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Text")] + [PropertyDetailSampleUsage("**^s**", "Specify **Ctrl+S** for Enter Keys")] + [PropertyDetailSampleUsage("**{WIN_KEY}**", "Specify **Windows Key** for Enter Keys")] + [PropertyDetailSampleUsage("**{WIN_KEY+R}**", "Specify **Windows Key** and **R** for Enter Keys")] + [PropertyShowSampleUsageInDescription(true)] + [PropertyIntermediateConvert(nameof(IntermediateControls.ConvertToIntermediate_CheckedVariableMarker), "")] + [PropertyDisplayText(true, "Text")] + public static string v_TextToSend { get; } + + /// + /// send text ins encrypted or not + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Text is Encrypted")] + [PropertyIsOptional(true, "No")] + [PropertyDisplayText(false, "Encrypted")] + public static string v_EncryptionOption { get; } + + /// + /// use clipbard to send text + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Use Paste from Clipboard")] + [PropertyIsOptional(true, "No")] + [Remarks("When entering keys in combination with the Ctrl key, etc., It will NOT work correctly.")] + [PropertyDisplayText(false, "Use Clipboard")] + public static string v_UseClipBoard { get; } + + /// + /// wait time after keys enter + /// + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time for After Keys Enter")] + [Remarks("When the Wait Time is less than **100** is specified, it will be **100**")] + [PropertyIsOptional(true, "500")] + [PropertyFirstValue("500")] + [PropertyDisplayText(false, "Wait Time after Keys Enter")] + public static string v_WaitTimeAfterKeyEnter { get; } + + /// + /// activate window when specified Current Window Variable + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Try Activate Window, when Specified Current Window Variable")] + [PropertyIsOptional(true, "No")] + [PropertyDisplayText(false, "Try Activate when Specified Current Window")] + public static string v_ActivateCurrentWindow { get; } + + /// + /// clear clipboard after paste + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Clear Clipboard After Paste")] + [PropertyIsOptional(true, "No")] + [PropertyValidationRule("Clear Clipboard", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Clear Clipboard after Paste")] + public static string v_ClearClipboardAfterPaste { get; } + + /// + /// shortcut keys + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Shortcut Key to Enter")] + [PropertyUISelectionOption("New")] + [PropertyUISelectionOption("New Window")] + [PropertyUISelectionOption("Open")] + [PropertyUISelectionOption("Print")] + [PropertyUISelectionOption("Save")] + [PropertyUISelectionOption("Save As")] + [PropertyUISelectionOption("Undo")] + [PropertyUISelectionOption("Cut")] + [PropertyUISelectionOption("Copy")] + [PropertyUISelectionOption("Paste")] + [PropertyUISelectionOption("Delete")] + [PropertyUISelectionOption("Search")] + [PropertyUISelectionOption("Find")] + [PropertyUISelectionOption("Find Next")] + [PropertyUISelectionOption("Find Previous")] + [PropertyUISelectionOption("Replace")] + [PropertyUISelectionOption("Go To")] + [PropertyUISelectionOption("Select All")] + [PropertySecondaryLabel(true)] + [PropertyAddtionalParameterInfo("New", "Send Ctrl + N")] + [PropertyAddtionalParameterInfo("New Window", "Send Ctrl + Shift + N")] + [PropertyAddtionalParameterInfo("Open", "Send Ctrl + O")] + [PropertyAddtionalParameterInfo("Print", "Send Ctrl + P")] + [PropertyAddtionalParameterInfo("Save", "Send Ctrl + S")] + [PropertyAddtionalParameterInfo("Save As", "Send Ctrl + Shift + S")] + [PropertyAddtionalParameterInfo("Undo", "Send Ctrl + Z")] + [PropertyAddtionalParameterInfo("Cut", "Send Ctrl + X")] + [PropertyAddtionalParameterInfo("Copy", "Send Ctrl + C")] + [PropertyAddtionalParameterInfo("Paste", "Send Ctrl + V")] + [PropertyAddtionalParameterInfo("Delete", "Send Delete")] + [PropertyAddtionalParameterInfo("Search", "Send Ctrl + E")] + [PropertyAddtionalParameterInfo("Find", "Send Ctrl + F")] + [PropertyAddtionalParameterInfo("Find Next", "Send F3")] + [PropertyAddtionalParameterInfo("Find Previous", "Send Shift + F3")] + [PropertyAddtionalParameterInfo("Replace", "Send Ctrl + H")] + [PropertyAddtionalParameterInfo("Go To", "Send Ctrl + G")] + [PropertyAddtionalParameterInfo("Select All", "Send Ctrl + A")] + [PropertySelectionChangeEvent(nameof(VP_KeyMouseControls) + "+" + nameof(cmbHotkey_SelectedIndexChanged))] + [PropertyValidationRule("Shortcut Key", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Shortcut")] + [PropertyParameterOrder(5100)] + public static string v_Hotkey { get; } + + /// + /// advanced keystrokes keya and actions (actually data type is DataTable) + /// + [PropertyDescription("Keys and Action Type")] + [InputSpecification("")] + [SampleUsage("")] + [Remarks("")] + [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + [PropertyDataGridViewSetting(true, true, true, 400, 250)] + [PropertyDataGridViewColumnSettings("Key", "Key", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.ComboBox)] + [PropertyDataGridViewColumnSettings("Action", "Action", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.ComboBox, "Key Press (Down + Up)\nKey Down\nKey Up")] + [PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.AllEditableDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] + public static string v_KeyActions { get; } + + /// + /// all keys up after execution + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Return all keys to 'UP' position after execution")] + [PropertyIsOptional(true, "Yes")] + [PropertyDisplayText(false, "Keys UP")] + public static string v_KeyUpDefault { get; } + + /// + /// encrypt text to send keys + /// + /// + /// + public static void lnkEncryptText_Click(object sender, EventArgs e) + { + //var inputText = ControlsList.GetPropertyControl(nameof(v_TextToSend)); + //var inputText = (TextBox)((CommandItemControl)sender).Tag; + var inputText = FormUIControls.GetLinkTargetControl(sender); + + if (string.IsNullOrEmpty(inputText.Text)) + { + MessageBox.Show("Text to send is empty.", "Notice"); + return; + } + + var encrypted = EncryptionServices.EncryptString(inputText.Text, "TASKT"); + inputText.Text = encrypted; + + //this.v_EncryptionOption = "Encrypted"; + //var cmd = (IEnterKeysProperties)((frmCommandEditor)((Control)sender).FindForm()).editingCommand; + var fm = FormUIControls.GetCommandEditorFromControl((Control)sender); + var cmd = (IEnterKeysProperties)fm.editingCommand; + + cmd.v_EncryptionOption = "Yes"; + } + + /// + /// key builder clicked + /// + /// + /// + public static void lnkKeysBulider_Click(object sender, EventArgs e) + { + using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmKeysBuilder()) + { + if (fm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) + { + //var inputText = ControlsList.GetPropertyControl(nameof(v_TextToSend)); + //var inputText = (TextBox)((CommandItemControl)sender).Tag; + var inputText = FormUIControls.GetLinkTargetControl(sender); + + inputText.Text = fm.Result; + } + } + } + + private static void cmbHotkey_SelectedIndexChanged(object sender, EventArgs e) + { + var searchedKey = ((ComboBox)sender).SelectedItem?.ToString() ?? ""; + + var fm = FormUIControls.GetCommandEditorFromControl((Control)sender); + + // TODO: make it. second label process + //ControlsList.SecondLabelProcess(nameof(v_Hotkey), nameof(v_Hotkey), searchedKey); + } + } +} diff --git a/taskt/Core/Automation/Commands/List/AListBothListCommands.cs b/taskt/Core/Automation/Commands/ListGroup/AListBothListCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/AListBothListCommands.cs rename to taskt/Core/Automation/Commands/ListGroup/AListBothListCommands.cs diff --git a/taskt/Core/Automation/Commands/List/AListCreateFromListCommands.cs b/taskt/Core/Automation/Commands/ListGroup/AListCreateFromListCommands.cs similarity index 95% rename from taskt/Core/Automation/Commands/List/AListCreateFromListCommands.cs rename to taskt/Core/Automation/Commands/ListGroup/AListCreateFromListCommands.cs index dfa5a8732..dca018797 100644 --- a/taskt/Core/Automation/Commands/List/AListCreateFromListCommands.cs +++ b/taskt/Core/Automation/Commands/ListGroup/AListCreateFromListCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for Create List From List commands /// - public abstract class AListCreateFromListCommands : ScriptCommand, ILListCreateFromListProperties + public abstract class AListCreateFromListCommands : ScriptCommand, IListCreateFromListProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_InputListName))] diff --git a/taskt/Core/Automation/Commands/List/AListGetFromListCommands.cs b/taskt/Core/Automation/Commands/ListGroup/AListGetFromListCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/AListGetFromListCommands.cs rename to taskt/Core/Automation/Commands/ListGroup/AListGetFromListCommands.cs diff --git a/taskt/Core/Automation/Commands/List/AListGetFromValueCommands.cs b/taskt/Core/Automation/Commands/ListGroup/AListGetFromValueCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/AListGetFromValueCommands.cs rename to taskt/Core/Automation/Commands/ListGroup/AListGetFromValueCommands.cs diff --git a/taskt/Core/Automation/Commands/List/AListGetMathResultFromListCommands.cs b/taskt/Core/Automation/Commands/ListGroup/AListGetMathResultFromListCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/AListGetMathResultFromListCommands.cs rename to taskt/Core/Automation/Commands/ListGroup/AListGetMathResultFromListCommands.cs diff --git a/taskt/Core/Automation/Commands/List/AListIndexCommands.cs b/taskt/Core/Automation/Commands/ListGroup/AListIndexCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/AListIndexCommands.cs rename to taskt/Core/Automation/Commands/ListGroup/AListIndexCommands.cs diff --git a/taskt/Core/Automation/Commands/List/AListInputListCommands.cs b/taskt/Core/Automation/Commands/ListGroup/AListInputListCommands.cs similarity index 96% rename from taskt/Core/Automation/Commands/List/AListInputListCommands.cs rename to taskt/Core/Automation/Commands/ListGroup/AListInputListCommands.cs index 16bafc62e..16a56e768 100644 --- a/taskt/Core/Automation/Commands/List/AListInputListCommands.cs +++ b/taskt/Core/Automation/Commands/ListGroup/AListInputListCommands.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for List Input Commands /// - public abstract class AListInputListCommands : ScriptCommand, ILListProperties + public abstract class AListInputListCommands : ScriptCommand, IListProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_InputListName))] diff --git a/taskt/Core/Automation/Commands/List/AddListItemCommand.cs b/taskt/Core/Automation/Commands/ListGroup/AddListItemCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/AddListItemCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/AddListItemCommand.cs diff --git a/taskt/Core/Automation/Commands/List/CheckListItemExistsCommand.cs b/taskt/Core/Automation/Commands/ListGroup/CheckListItemExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/CheckListItemExistsCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/CheckListItemExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/List/CheckValidListIndexCommand.cs b/taskt/Core/Automation/Commands/ListGroup/CheckValidListIndexCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/CheckValidListIndexCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/CheckValidListIndexCommand.cs diff --git a/taskt/Core/Automation/Commands/List/ConcatenateListsCommand.cs b/taskt/Core/Automation/Commands/ListGroup/ConcatenateListsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/ConcatenateListsCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/ConcatenateListsCommand.cs diff --git a/taskt/Core/Automation/Commands/List/ConvertListToDataTableCommand.cs b/taskt/Core/Automation/Commands/ListGroup/ConvertListToDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/ConvertListToDataTableCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/ConvertListToDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/List/ConvertListToDictionaryCommand.cs b/taskt/Core/Automation/Commands/ListGroup/ConvertListToDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/ConvertListToDictionaryCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/ConvertListToDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/List/ConvertListToJSONCommand.cs b/taskt/Core/Automation/Commands/ListGroup/ConvertListToJSONCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/ConvertListToJSONCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/ConvertListToJSONCommand.cs diff --git a/taskt/Core/Automation/Commands/List/CopyListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/CopyListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/CopyListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/CopyListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/CovnertListToTextCommand.cs b/taskt/Core/Automation/Commands/ListGroup/CovnertListToTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/CovnertListToTextCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/CovnertListToTextCommand.cs diff --git a/taskt/Core/Automation/Commands/List/CovnertListToVisualizedTextCommand.cs b/taskt/Core/Automation/Commands/ListGroup/CovnertListToVisualizedTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/CovnertListToVisualizedTextCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/CovnertListToVisualizedTextCommand.cs diff --git a/taskt/Core/Automation/Commands/List/CreateListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/CreateListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/CreateListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/CreateListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/EM_CanHandleListExtensionMethods.cs b/taskt/Core/Automation/Commands/ListGroup/EM_CanHandleListExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/EM_CanHandleListExtensionMethods.cs rename to taskt/Core/Automation/Commands/ListGroup/EM_CanHandleListExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/List/EM_ListCreateFromListPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ListGroup/EM_ListCreateFromListPropertiesExtensionMethods.cs similarity index 78% rename from taskt/Core/Automation/Commands/List/EM_ListCreateFromListPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ListGroup/EM_ListCreateFromListPropertiesExtensionMethods.cs index 82c60a1ec..99044a98d 100644 --- a/taskt/Core/Automation/Commands/List/EM_ListCreateFromListPropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/ListGroup/EM_ListCreateFromListPropertiesExtensionMethods.cs @@ -10,7 +10,7 @@ public static class EM_ListCreateFromListPropertiesExtensionMethods /// /// /// - public static List ExpandUserVariableAsList(this ILListCreateFromListProperties command, Engine.AutomationEngineInstance engine) + public static List ExpandUserVariableAsList(this IListCreateFromListProperties command, Engine.AutomationEngineInstance engine) { return command.ExpandUserVariableAsList(nameof(command.v_TargetList), engine); } @@ -21,7 +21,7 @@ public static List ExpandUserVariableAsList(this ILListCreateFromListPro /// /// /// - public static void StoreListInUserVariable(this ILListCreateFromListProperties command, List list, Engine.AutomationEngineInstance engine) + public static void StoreListInUserVariable(this IListCreateFromListProperties command, List list, Engine.AutomationEngineInstance engine) { command.StoreListInUserVariable(list, nameof(command.v_NewList), engine); } diff --git a/taskt/Core/Automation/Commands/List/EM_ListGetMathResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ListGroup/EM_ListGetMathResultPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/EM_ListGetMathResultPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ListGroup/EM_ListGetMathResultPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/List/EM_ListIndexPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ListGroup/EM_ListIndexPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/EM_ListIndexPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ListGroup/EM_ListIndexPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/List/EM_ListPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ListGroup/EM_ListPropertiesExtensionMethods.cs similarity index 88% rename from taskt/Core/Automation/Commands/List/EM_ListPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ListGroup/EM_ListPropertiesExtensionMethods.cs index 245609417..3fa77355d 100644 --- a/taskt/Core/Automation/Commands/List/EM_ListPropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/ListGroup/EM_ListPropertiesExtensionMethods.cs @@ -10,7 +10,7 @@ public static class EM_ListPropertiesExtensionMethods /// /// /// - public static List ExpandUserVariableAsList(this ILListProperties command, Engine.AutomationEngineInstance engine) + public static List ExpandUserVariableAsList(this IListProperties command, Engine.AutomationEngineInstance engine) { return command.ExpandUserVariableAsList(nameof(command.v_List), engine); } diff --git a/taskt/Core/Automation/Commands/List/EM_ListResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/ListGroup/EM_ListResultPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/EM_ListResultPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/ListGroup/EM_ListResultPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/List/ExportListAsTextFileCommand.cs b/taskt/Core/Automation/Commands/ListGroup/ExportListAsTextFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/ExportListAsTextFileCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/ExportListAsTextFileCommand.cs diff --git a/taskt/Core/Automation/Commands/List/FilterListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/FilterListCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/List/FilterListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/FilterListCommand.cs index 000a9f6fa..073dbcd1c 100644 --- a/taskt/Core/Automation/Commands/List/FilterListCommand.cs +++ b/taskt/Core/Automation/Commands/ListGroup/FilterListCommand.cs @@ -17,7 +17,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_function))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class FilterListCommand : AListCreateFromListCommands, ILFilterValueProperties, IHaveDataTableElements + public sealed class FilterListCommand : AListCreateFromListCommands, IFilterValueProperties, IHaveDataTableElements { [XmlAttribute] //[PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_InputListName))] diff --git a/taskt/Core/Automation/Commands/List/GetAverageFromListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetAverageFromListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/GetAverageFromListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetAverageFromListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/GetCommonValuesOfListsCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetCommonValuesOfListsCommand.cs similarity index 98% rename from taskt/Core/Automation/Commands/List/GetCommonValuesOfListsCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetCommonValuesOfListsCommand.cs index 235be592e..0a91a963e 100644 --- a/taskt/Core/Automation/Commands/List/GetCommonValuesOfListsCommand.cs +++ b/taskt/Core/Automation/Commands/ListGroup/GetCommonValuesOfListsCommand.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; using taskt.Core.Script; namespace taskt.Core.Automation.Commands @@ -45,7 +46,7 @@ public sealed class GetCommonValuesOfListsCommand : ScriptCommand, ICanHandleLis public string v_CommonValues { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveNo))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveNo))] [PropertyIsOptional(true, "Yes")] public string v_CaseSenstive { get; set; } diff --git a/taskt/Core/Automation/Commands/List/GetListCountCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetListCountCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/GetListCountCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetListCountCommand.cs diff --git a/taskt/Core/Automation/Commands/List/GetListIndexCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetListIndexCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/GetListIndexCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetListIndexCommand.cs diff --git a/taskt/Core/Automation/Commands/List/GetListIndexFromValueCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetListIndexFromValueCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/GetListIndexFromValueCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetListIndexFromValueCommand.cs diff --git a/taskt/Core/Automation/Commands/List/GetListItemCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetListItemCommand.cs similarity index 99% rename from taskt/Core/Automation/Commands/List/GetListItemCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetListItemCommand.cs index 89d471610..b41bf7902 100644 --- a/taskt/Core/Automation/Commands/List/GetListItemCommand.cs +++ b/taskt/Core/Automation/Commands/ListGroup/GetListItemCommand.cs @@ -14,7 +14,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_function))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetListItemCommand : AListIndexCommands, ILResultProperties + public sealed class GetListItemCommand : AListIndexCommands, IResultProperties { //[XmlAttribute] //[PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_InputListName))] diff --git a/taskt/Core/Automation/Commands/List/GetListWithDuplicateItemsRemovedCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetListWithDuplicateItemsRemovedCommand.cs similarity index 95% rename from taskt/Core/Automation/Commands/List/GetListWithDuplicateItemsRemovedCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetListWithDuplicateItemsRemovedCommand.cs index ed90df534..a3b2ac577 100644 --- a/taskt/Core/Automation/Commands/List/GetListWithDuplicateItemsRemovedCommand.cs +++ b/taskt/Core/Automation/Commands/ListGroup/GetListWithDuplicateItemsRemovedCommand.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; namespace taskt.Core.Automation.Commands { @@ -29,7 +30,7 @@ public sealed class GetListWithDuplicateItemsRemoved : AListCreateFromListComman //public string v_NewList { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveNo))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveNo))] [PropertyParameterOrder(11000)] [PropertyIsOptional(true, "Yes")] public string v_CaseSenstive { get; set; } diff --git a/taskt/Core/Automation/Commands/List/GetMaxFromListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetMaxFromListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/GetMaxFromListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetMaxFromListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/GetMedianFromListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetMedianFromListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/GetMedianFromListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetMedianFromListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/GetMinFromListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetMinFromListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/GetMinFromListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetMinFromListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/GetSumFromListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetSumFromListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/GetSumFromListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetSumFromListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/GetVarianceFromListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/GetVarianceFromListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/GetVarianceFromListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/GetVarianceFromListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/ICanHandleList.cs b/taskt/Core/Automation/Commands/ListGroup/ICanHandleList.cs similarity index 69% rename from taskt/Core/Automation/Commands/List/ICanHandleList.cs rename to taskt/Core/Automation/Commands/ListGroup/ICanHandleList.cs index 55920064a..c95669db5 100644 --- a/taskt/Core/Automation/Commands/List/ICanHandleList.cs +++ b/taskt/Core/Automation/Commands/ListGroup/ICanHandleList.cs @@ -3,7 +3,7 @@ /// /// for handle List /// - public interface ICanHandleList : ILExpandableProperties + public interface ICanHandleList : IExpandableProperties { // nothing } diff --git a/taskt/Core/Automation/Commands/List/ILListCreateFromListProperties.cs b/taskt/Core/Automation/Commands/ListGroup/IListCreateFromListProperties.cs similarity index 81% rename from taskt/Core/Automation/Commands/List/ILListCreateFromListProperties.cs rename to taskt/Core/Automation/Commands/ListGroup/IListCreateFromListProperties.cs index b7d01a50e..3f5769981 100644 --- a/taskt/Core/Automation/Commands/List/ILListCreateFromListProperties.cs +++ b/taskt/Core/Automation/Commands/ListGroup/IListCreateFromListProperties.cs @@ -3,7 +3,7 @@ /// /// Create List from List properties /// - public interface ILListCreateFromListProperties : ICanHandleList, ILExpandableProperties + public interface IListCreateFromListProperties : ICanHandleList, IExpandableProperties { /// /// List variable name to Create New List diff --git a/taskt/Core/Automation/Commands/List/IListGetFromListProperties.cs b/taskt/Core/Automation/Commands/ListGroup/IListGetFromListProperties.cs similarity index 63% rename from taskt/Core/Automation/Commands/List/IListGetFromListProperties.cs rename to taskt/Core/Automation/Commands/ListGroup/IListGetFromListProperties.cs index 7f125ff6a..25b69d2be 100644 --- a/taskt/Core/Automation/Commands/List/IListGetFromListProperties.cs +++ b/taskt/Core/Automation/Commands/ListGroup/IListGetFromListProperties.cs @@ -3,7 +3,7 @@ /// /// Get From List properties /// - public interface IListGetFromListProperties : ILListProperties, ILResultProperties + public interface IListGetFromListProperties : IListProperties, IResultProperties { // only imple } diff --git a/taskt/Core/Automation/Commands/List/IListGetFromValueProperties.cs b/taskt/Core/Automation/Commands/ListGroup/IListGetFromValueProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/IListGetFromValueProperties.cs rename to taskt/Core/Automation/Commands/ListGroup/IListGetFromValueProperties.cs diff --git a/taskt/Core/Automation/Commands/List/IListGetMathResultFromListProperties.cs b/taskt/Core/Automation/Commands/ListGroup/IListGetMathResultFromListProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/IListGetMathResultFromListProperties.cs rename to taskt/Core/Automation/Commands/ListGroup/IListGetMathResultFromListProperties.cs diff --git a/taskt/Core/Automation/Commands/List/IListIndexProperties.cs b/taskt/Core/Automation/Commands/ListGroup/IListIndexProperties.cs similarity index 79% rename from taskt/Core/Automation/Commands/List/IListIndexProperties.cs rename to taskt/Core/Automation/Commands/ListGroup/IListIndexProperties.cs index 98389fda5..e6cf901a4 100644 --- a/taskt/Core/Automation/Commands/List/IListIndexProperties.cs +++ b/taskt/Core/Automation/Commands/ListGroup/IListIndexProperties.cs @@ -3,7 +3,7 @@ /// /// List Index properties /// - public interface IListIndexProperties : ILListProperties + public interface IListIndexProperties : IListProperties { /// /// List Index diff --git a/taskt/Core/Automation/Commands/List/ILListProperties.cs b/taskt/Core/Automation/Commands/ListGroup/IListProperties.cs similarity index 75% rename from taskt/Core/Automation/Commands/List/ILListProperties.cs rename to taskt/Core/Automation/Commands/ListGroup/IListProperties.cs index 73e50045d..201a3640a 100644 --- a/taskt/Core/Automation/Commands/List/ILListProperties.cs +++ b/taskt/Core/Automation/Commands/ListGroup/IListProperties.cs @@ -3,7 +3,7 @@ /// /// List commands properties /// - public interface ILListProperties : ICanHandleList, ILExpandableProperties + public interface IListProperties : ICanHandleList, IExpandableProperties { /// /// List variable name diff --git a/taskt/Core/Automation/Commands/List/IListResultProperties.cs b/taskt/Core/Automation/Commands/ListGroup/IListResultProperties.cs similarity index 65% rename from taskt/Core/Automation/Commands/List/IListResultProperties.cs rename to taskt/Core/Automation/Commands/ListGroup/IListResultProperties.cs index a2d3749ff..cd3d121a6 100644 --- a/taskt/Core/Automation/Commands/List/IListResultProperties.cs +++ b/taskt/Core/Automation/Commands/ListGroup/IListResultProperties.cs @@ -3,7 +3,7 @@ /// /// List is Result Properties /// - public interface IListResultProperties : ILResultProperties, ICanHandleList + public interface IListResultProperties : IResultProperties, ICanHandleList { // only imple } diff --git a/taskt/Core/Automation/Commands/List/JoinListValuesAsTextCommand.cs b/taskt/Core/Automation/Commands/ListGroup/JoinListValuesAsTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/JoinListValuesAsTextCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/JoinListValuesAsTextCommand.cs diff --git a/taskt/Core/Automation/Commands/List/RemoveListItemCommand.cs b/taskt/Core/Automation/Commands/ListGroup/RemoveListItemCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/RemoveListItemCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/RemoveListItemCommand.cs diff --git a/taskt/Core/Automation/Commands/List/ReplaceListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/ReplaceListCommand.cs similarity index 99% rename from taskt/Core/Automation/Commands/List/ReplaceListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/ReplaceListCommand.cs index aff14935f..7fc27b289 100644 --- a/taskt/Core/Automation/Commands/List/ReplaceListCommand.cs +++ b/taskt/Core/Automation/Commands/ListGroup/ReplaceListCommand.cs @@ -16,7 +16,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_function))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ReplaceListCommand : AListBothListCommands, ILReplaceValueProperties, IHaveDataTableElements + public sealed class ReplaceListCommand : AListBothListCommands, IReplaceValueProperties, IHaveDataTableElements { [XmlAttribute] //[PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_BothListName))] diff --git a/taskt/Core/Automation/Commands/List/ReverseListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/ReverseListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/ReverseListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/ReverseListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/SetListIndexCommand.cs b/taskt/Core/Automation/Commands/ListGroup/SetListIndexCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/SetListIndexCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/SetListIndexCommand.cs diff --git a/taskt/Core/Automation/Commands/List/SetListItemCommand.cs b/taskt/Core/Automation/Commands/ListGroup/SetListItemCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/SetListItemCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/SetListItemCommand.cs diff --git a/taskt/Core/Automation/Commands/List/SliceListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/SliceListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/SliceListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/SliceListCommand.cs diff --git a/taskt/Core/Automation/Commands/List/SortListCommand.cs b/taskt/Core/Automation/Commands/ListGroup/SortListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/List/SortListCommand.cs rename to taskt/Core/Automation/Commands/ListGroup/SortListCommand.cs diff --git a/taskt/Core/Automation/Commands/LocalListener/CallLocalListenerAPICommand.cs b/taskt/Core/Automation/Commands/LocalListenerGroup/CallLocalListenerAPICommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/LocalListener/CallLocalListenerAPICommand.cs rename to taskt/Core/Automation/Commands/LocalListenerGroup/CallLocalListenerAPICommand.cs diff --git a/taskt/Core/Automation/Commands/LocalListener/RemoteAPICommand.cs b/taskt/Core/Automation/Commands/LocalListenerGroup/RemoteAPICommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/LocalListener/RemoteAPICommand.cs rename to taskt/Core/Automation/Commands/LocalListenerGroup/RemoteAPICommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginContinousLoopCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginContinousLoopCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginContinousLoopCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginContinousLoopCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginLoopCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopCommand.cs similarity index 99% rename from taskt/Core/Automation/Commands/Loop/BeginLoopCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginLoopCommand.cs index 68a28261f..b190a0165 100644 --- a/taskt/Core/Automation/Commands/Loop/BeginLoopCommand.cs +++ b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopCommand.cs @@ -303,7 +303,7 @@ private void linkWebBrowserInstanceSelector_Click(object sender, EventArgs e, UI { if (frm.ShowDialog() == DialogResult.OK) { - string selectedItem = frm.selectedItem.ToString(); + string selectedItem = frm.SelectedItem.ToString(); if (!DataTableControls.SetParameterValue(v_LoopActionParameterTable, selectedItem, "Selenium Instance Name", "Parameter Name", "Parameter Value")) { throw new Exception("Fail update Selenium Instance Name"); @@ -335,7 +335,7 @@ private void linkWindowNameSelector_Click(object sender, EventArgs e, UI.Forms.S { if (frm.ShowDialog() == DialogResult.OK) { - string selectedItem = frm.selectedItem.ToString(); + string selectedItem = frm.SelectedItem.ToString(); if (!DataTableControls.SetParameterValue(v_LoopActionParameterTable, selectedItem, "Window Name", "Parameter Name", "Parameter Value")) { throw new Exception("Fail update Window Name"); @@ -352,7 +352,7 @@ private void linkBooleanInstanceSelector_Click(object sender, EventArgs e, UI.Fo { if (frm.ShowDialog() == DialogResult.OK) { - string selectedItem = frm.selectedItem.ToString(); + string selectedItem = frm.SelectedItem.ToString(); //int currentRow = IfGridViewHelper.CurrentRow.Index; string parameterName = DataTableControls.GetFieldValue(v_LoopActionParameterTable, LoopGridViewHelper.CurrentRow.Index, "Parameter Name"); diff --git a/taskt/Core/Automation/Commands/Loop/BeginLoopForComplexDataTypesCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopForComplexDataTypesCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginLoopForComplexDataTypesCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginLoopForComplexDataTypesCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableColumnAsDataTableCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableColumnAsDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableColumnAsDataTableCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableColumnAsDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableColumnAsListCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableColumnAsListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableColumnAsListCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableColumnAsListCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableRowAsDataTableCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableRowAsDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableRowAsDataTableCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableRowAsDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableRowAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableRowAsDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginLoopForDataTableRowAsDictionaryCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDataTableRowAsDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginLoopForDictionaryCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDictionaryCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginLoopForDictionaryCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginLoopForDictionaryCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginLoopForListCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginLoopForListCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginLoopForListCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginLoopForListCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginMultiLoopCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginMultiLoopCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginMultiLoopCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginMultiLoopCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/BeginNumberOfTimesLoopCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/BeginNumberOfTimesLoopCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/BeginNumberOfTimesLoopCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/BeginNumberOfTimesLoopCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/EndLoopCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/EndLoopCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/EndLoopCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/EndLoopCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/ExitLoopCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/ExitLoopCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/ExitLoopCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/ExitLoopCommand.cs diff --git a/taskt/Core/Automation/Commands/Loop/IHaveLoopAdditionalCommands.cs b/taskt/Core/Automation/Commands/LoopGroup/IHaveLoopAdditionalCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/IHaveLoopAdditionalCommands.cs rename to taskt/Core/Automation/Commands/LoopGroup/IHaveLoopAdditionalCommands.cs diff --git a/taskt/Core/Automation/Commands/Loop/NextLoopCommand.cs b/taskt/Core/Automation/Commands/LoopGroup/NextLoopCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Loop/NextLoopCommand.cs rename to taskt/Core/Automation/Commands/LoopGroup/NextLoopCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/AInverseTrignometricCommands.cs b/taskt/Core/Automation/Commands/MathGroup/AInverseTrignometricCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/AInverseTrignometricCommands.cs rename to taskt/Core/Automation/Commands/MathGroup/AInverseTrignometricCommands.cs diff --git a/taskt/Core/Automation/Commands/Math/AMathValueResultCommands.cs b/taskt/Core/Automation/Commands/MathGroup/AMathValueResultCommands.cs similarity index 96% rename from taskt/Core/Automation/Commands/Math/AMathValueResultCommands.cs rename to taskt/Core/Automation/Commands/MathGroup/AMathValueResultCommands.cs index 78f66c3bc..c39206d7a 100644 --- a/taskt/Core/Automation/Commands/Math/AMathValueResultCommands.cs +++ b/taskt/Core/Automation/Commands/MathGroup/AMathValueResultCommands.cs @@ -8,7 +8,7 @@ namespace taskt.Core.Automation.Commands /// abstruct command class for Math commands. only Value, Result parameters /// [Serializable] - public abstract class AMathValueResultCommands : ScriptCommand, ILMathValueResultProperties + public abstract class AMathValueResultCommands : ScriptCommand, IMathValueResultProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(NumberControls), nameof(NumberControls.v_Value))] diff --git a/taskt/Core/Automation/Commands/Math/ATrignometricCommands.cs b/taskt/Core/Automation/Commands/MathGroup/ATrignometricCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/ATrignometricCommands.cs rename to taskt/Core/Automation/Commands/MathGroup/ATrignometricCommands.cs diff --git a/taskt/Core/Automation/Commands/Math/EM_InverseTrignometricPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/MathGroup/EM_InverseTrignometricPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/EM_InverseTrignometricPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/MathGroup/EM_InverseTrignometricPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Math/EM_MathValueResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/MathGroup/EM_MathValueResultPropertiesExtensionMethods.cs similarity index 89% rename from taskt/Core/Automation/Commands/Math/EM_MathValueResultPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/MathGroup/EM_MathValueResultPropertiesExtensionMethods.cs index b5f26eee1..a051e309d 100644 --- a/taskt/Core/Automation/Commands/Math/EM_MathValueResultPropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/MathGroup/EM_MathValueResultPropertiesExtensionMethods.cs @@ -10,7 +10,7 @@ public static class EM_MathValueResultPropertiesExtensionMethods /// /// /// - public static double ExpandValueOrVariableAsValue(this ILMathValueResultProperties command, AutomationEngineInstance engine) + public static double ExpandValueOrVariableAsValue(this IMathValueResultProperties command, AutomationEngineInstance engine) { return (double)command.ToScriptCommand().ExpandValueOrUserVariableAsDecimal(nameof(command.v_Value), engine); } diff --git a/taskt/Core/Automation/Commands/Math/EM_TrignometricPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/MathGroup/EM_TrignometricPropertiesExtensionMethods.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/EM_TrignometricPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/MathGroup/EM_TrignometricPropertiesExtensionMethods.cs diff --git a/taskt/Core/Automation/Commands/Math/GetAbsoluteCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetAbsoluteCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetAbsoluteCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetAbsoluteCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetArccosCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetArccosCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetArccosCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetArccosCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetArcsinCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetArcsinCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetArcsinCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetArcsinCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetArctanCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetArctanCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetArctanCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetArctanCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetCosCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetCosCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetCosCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetCosCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetExponentialCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetExponentialCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetExponentialCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetExponentialCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetLogarithmCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetLogarithmCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetLogarithmCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetLogarithmCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetPowerCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetPowerCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetPowerCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetPowerCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetSinCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetSinCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetSinCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetSinCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetSquareRootCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetSquareRootCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetSquareRootCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetSquareRootCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/GetTanCommand.cs b/taskt/Core/Automation/Commands/MathGroup/GetTanCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/GetTanCommand.cs rename to taskt/Core/Automation/Commands/MathGroup/GetTanCommand.cs diff --git a/taskt/Core/Automation/Commands/Math/IInverseTrignometricProperties.cs b/taskt/Core/Automation/Commands/MathGroup/IInverseTrignometricProperties.cs similarity index 100% rename from taskt/Core/Automation/Commands/Math/IInverseTrignometricProperties.cs rename to taskt/Core/Automation/Commands/MathGroup/IInverseTrignometricProperties.cs diff --git a/taskt/Core/Automation/Commands/Math/ILMathValueResultProperties.cs b/taskt/Core/Automation/Commands/MathGroup/IMathValueResultProperties.cs similarity index 82% rename from taskt/Core/Automation/Commands/Math/ILMathValueResultProperties.cs rename to taskt/Core/Automation/Commands/MathGroup/IMathValueResultProperties.cs index f4fa2a43a..0ad7d8c02 100644 --- a/taskt/Core/Automation/Commands/Math/ILMathValueResultProperties.cs +++ b/taskt/Core/Automation/Commands/MathGroup/IMathValueResultProperties.cs @@ -3,7 +3,7 @@ /// /// Math commands value-result /// - public interface ILMathValueResultProperties : ILExpandableProperties + public interface IMathValueResultProperties : IExpandableProperties { /// /// value diff --git a/taskt/Core/Automation/Commands/Math/ITrignometricProperties.cs b/taskt/Core/Automation/Commands/MathGroup/ITrignometricProperties.cs similarity index 71% rename from taskt/Core/Automation/Commands/Math/ITrignometricProperties.cs rename to taskt/Core/Automation/Commands/MathGroup/ITrignometricProperties.cs index 72820e35a..6c92bb9bc 100644 --- a/taskt/Core/Automation/Commands/Math/ITrignometricProperties.cs +++ b/taskt/Core/Automation/Commands/MathGroup/ITrignometricProperties.cs @@ -1,6 +1,6 @@ namespace taskt.Core.Automation.Commands { - public interface ITrignometricProperties : ILMathValueResultProperties + public interface ITrignometricProperties : IMathValueResultProperties { /// /// agnle type Radian or Degree diff --git a/taskt/Core/Automation/Commands/Misc/ClearClipboardTextCommand.cs b/taskt/Core/Automation/Commands/MiscGroup/ClearClipboardTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Misc/ClearClipboardTextCommand.cs rename to taskt/Core/Automation/Commands/MiscGroup/ClearClipboardTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Misc/CreateShortcutCommand.cs b/taskt/Core/Automation/Commands/MiscGroup/CreateShortcutCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Misc/CreateShortcutCommand.cs rename to taskt/Core/Automation/Commands/MiscGroup/CreateShortcutCommand.cs diff --git a/taskt/Core/Automation/Commands/Misc/GetClipboardTextCommand.cs b/taskt/Core/Automation/Commands/MiscGroup/GetClipboardTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Misc/GetClipboardTextCommand.cs rename to taskt/Core/Automation/Commands/MiscGroup/GetClipboardTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Misc/PingCommand.cs b/taskt/Core/Automation/Commands/MiscGroup/PingCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Misc/PingCommand.cs rename to taskt/Core/Automation/Commands/MiscGroup/PingCommand.cs diff --git a/taskt/Core/Automation/Commands/Misc/PlaySystemSoundCommand.cs b/taskt/Core/Automation/Commands/MiscGroup/PlaySystemSoundCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Misc/PlaySystemSoundCommand.cs rename to taskt/Core/Automation/Commands/MiscGroup/PlaySystemSoundCommand.cs diff --git a/taskt/Core/Automation/Commands/Misc/SMTPSendEmailCommand.cs b/taskt/Core/Automation/Commands/MiscGroup/SMTPSendEmailCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Misc/SMTPSendEmailCommand.cs rename to taskt/Core/Automation/Commands/MiscGroup/SMTPSendEmailCommand.cs diff --git a/taskt/Core/Automation/Commands/Misc/SetClipboardTextCommand.cs b/taskt/Core/Automation/Commands/MiscGroup/SetClipboardTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Misc/SetClipboardTextCommand.cs rename to taskt/Core/Automation/Commands/MiscGroup/SetClipboardTextCommand.cs diff --git a/taskt/Core/Automation/Commands/NLG/NLGCreateNLGInstanceCommand.cs b/taskt/Core/Automation/Commands/NLGGroup/NLGCreateNLGInstanceCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/NLG/NLGCreateNLGInstanceCommand.cs rename to taskt/Core/Automation/Commands/NLGGroup/NLGCreateNLGInstanceCommand.cs diff --git a/taskt/Core/Automation/Commands/NLG/NLGGenerateNLGPhraseCommand.cs b/taskt/Core/Automation/Commands/NLGGroup/NLGGenerateNLGPhraseCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/NLG/NLGGenerateNLGPhraseCommand.cs rename to taskt/Core/Automation/Commands/NLGGroup/NLGGenerateNLGPhraseCommand.cs diff --git a/taskt/Core/Automation/Commands/NLG/NLGSetNLGParameterCommand.cs b/taskt/Core/Automation/Commands/NLGGroup/NLGSetNLGParameterCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/NLG/NLGSetNLGParameterCommand.cs rename to taskt/Core/Automation/Commands/NLGGroup/NLGSetNLGParameterCommand.cs diff --git a/taskt/Core/Automation/Commands/NumberControls.cs b/taskt/Core/Automation/Commands/NumberControls.cs index 5ff2ab63c..53770e3cd 100644 --- a/taskt/Core/Automation/Commands/NumberControls.cs +++ b/taskt/Core/Automation/Commands/NumberControls.cs @@ -52,6 +52,7 @@ internal static class NumberControls /// /// for output numerical variable name /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] [PropertyDescription("Numerical Variable Name to Store Result")] [PropertyDetailSampleUsage("**vNum**", PropertyDetailSampleUsage.ValueType.VariableName)] [PropertyDetailSampleUsage("**{{{vNum}}}**", PropertyDetailSampleUsage.ValueType.VariableName)] diff --git a/taskt/Core/Automation/Commands/Numerical/CheckNumberCommand.cs b/taskt/Core/Automation/Commands/NumericalGroup/CheckNumberCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Numerical/CheckNumberCommand.cs rename to taskt/Core/Automation/Commands/NumericalGroup/CheckNumberCommand.cs diff --git a/taskt/Core/Automation/Commands/Numerical/CreateNumericalVariableCommand.cs b/taskt/Core/Automation/Commands/NumericalGroup/CreateNumericalVariableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Numerical/CreateNumericalVariableCommand.cs rename to taskt/Core/Automation/Commands/NumericalGroup/CreateNumericalVariableCommand.cs diff --git a/taskt/Core/Automation/Commands/Numerical/DecreaseNumericalVariableCommand.cs b/taskt/Core/Automation/Commands/NumericalGroup/DecreaseNumericalVariableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Numerical/DecreaseNumericalVariableCommand.cs rename to taskt/Core/Automation/Commands/NumericalGroup/DecreaseNumericalVariableCommand.cs diff --git a/taskt/Core/Automation/Commands/Numerical/FormatNumberCommand.cs b/taskt/Core/Automation/Commands/NumericalGroup/FormatNumberCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Numerical/FormatNumberCommand.cs rename to taskt/Core/Automation/Commands/NumericalGroup/FormatNumberCommand.cs diff --git a/taskt/Core/Automation/Commands/Numerical/IncreaseNumericalVariableCommand.cs b/taskt/Core/Automation/Commands/NumericalGroup/IncreaseNumericalVariableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Numerical/IncreaseNumericalVariableCommand.cs rename to taskt/Core/Automation/Commands/NumericalGroup/IncreaseNumericalVariableCommand.cs diff --git a/taskt/Core/Automation/Commands/Numerical/MathCalculationCommand.cs b/taskt/Core/Automation/Commands/NumericalGroup/MathCalculationCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Numerical/MathCalculationCommand.cs rename to taskt/Core/Automation/Commands/NumericalGroup/MathCalculationCommand.cs diff --git a/taskt/Core/Automation/Commands/Numerical/RandomNumberCommand.cs b/taskt/Core/Automation/Commands/NumericalGroup/RandomNumberCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Numerical/RandomNumberCommand.cs rename to taskt/Core/Automation/Commands/NumericalGroup/RandomNumberCommand.cs diff --git a/taskt/Core/Automation/Commands/Numerical/RoundNumberCommand.cs b/taskt/Core/Automation/Commands/NumericalGroup/RoundNumberCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Numerical/RoundNumberCommand.cs rename to taskt/Core/Automation/Commands/NumericalGroup/RoundNumberCommand.cs diff --git a/taskt/Core/Automation/Commands/Outlook/OutlookDeleteEmailsCommand.cs b/taskt/Core/Automation/Commands/OutlookGroup/OutlookDeleteEmailsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Outlook/OutlookDeleteEmailsCommand.cs rename to taskt/Core/Automation/Commands/OutlookGroup/OutlookDeleteEmailsCommand.cs diff --git a/taskt/Core/Automation/Commands/Outlook/OutlookEmailCommand.cs b/taskt/Core/Automation/Commands/OutlookGroup/OutlookEmailCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Outlook/OutlookEmailCommand.cs rename to taskt/Core/Automation/Commands/OutlookGroup/OutlookEmailCommand.cs diff --git a/taskt/Core/Automation/Commands/Outlook/OutlookForwardEmailsCommand.cs b/taskt/Core/Automation/Commands/OutlookGroup/OutlookForwardEmailsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Outlook/OutlookForwardEmailsCommand.cs rename to taskt/Core/Automation/Commands/OutlookGroup/OutlookForwardEmailsCommand.cs diff --git a/taskt/Core/Automation/Commands/Outlook/OutlookGetEmailsCommand.cs b/taskt/Core/Automation/Commands/OutlookGroup/OutlookGetEmailsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Outlook/OutlookGetEmailsCommand.cs rename to taskt/Core/Automation/Commands/OutlookGroup/OutlookGetEmailsCommand.cs diff --git a/taskt/Core/Automation/Commands/Outlook/OutlookMoveEmailsCommand.cs b/taskt/Core/Automation/Commands/OutlookGroup/OutlookMoveEmailsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Outlook/OutlookMoveEmailsCommand.cs rename to taskt/Core/Automation/Commands/OutlookGroup/OutlookMoveEmailsCommand.cs diff --git a/taskt/Core/Automation/Commands/Outlook/OutlookReplyToEmailsCommand.cs b/taskt/Core/Automation/Commands/OutlookGroup/OutlookReplyToEmailsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Outlook/OutlookReplyToEmailsCommand.cs rename to taskt/Core/Automation/Commands/OutlookGroup/OutlookReplyToEmailsCommand.cs diff --git a/taskt/Core/Automation/Commands/PropertyControls.cs b/taskt/Core/Automation/Commands/PropertyControls.cs index ccec8e298..df7ca6585 100644 --- a/taskt/Core/Automation/Commands/PropertyControls.cs +++ b/taskt/Core/Automation/Commands/PropertyControls.cs @@ -9,7 +9,7 @@ namespace taskt.Core.Automation.Commands /// /// PropertyInfo methods to ScriptCommand /// - internal static class PropertyControls + public static class PropertyControls { #region Property methods /// @@ -41,7 +41,7 @@ public static List GetParameterProperties(this ScriptCommand comma /// public static PropertyInfo GetProperty(this ScriptCommand command, string propertyName) { - return command.GetType().GetProperty(propertyName) ?? throw new Exception("Property '" + propertyName + "' does not exists. Command: " + command.CommandName); + return command.GetType().GetProperty(propertyName) ?? throw new Exception($"Property '{propertyName}' does not exists. Command: '{command.CommandName}'"); } /// @@ -109,7 +109,8 @@ public static PropertyInfo GetVirtualProperty(this PropertyInfo propInfo) { return null; } - var tp = Type.GetType("taskt.Core.Automation.Commands." + attrVP.className); + //var tp = Type.GetType("taskt.Core.Automation.Commands." + attrVP.className); + var tp = Type.GetType(CommandClassesControl.GetClassFullName(attrVP.className)); return tp.GetProperty(attrVP.propertyName, BindingFlags.Public | BindingFlags.Static); } diff --git a/taskt/Core/Automation/Commands/Regex/GetRegexMatchesCommand.cs b/taskt/Core/Automation/Commands/RegexGroup/GetRegexMatchesCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Regex/GetRegexMatchesCommand.cs rename to taskt/Core/Automation/Commands/RegexGroup/GetRegexMatchesCommand.cs diff --git a/taskt/Core/Automation/Commands/ScriptCommand.cs b/taskt/Core/Automation/Commands/ScriptCommand.cs index a7674637d..4055f2358 100644 --- a/taskt/Core/Automation/Commands/ScriptCommand.cs +++ b/taskt/Core/Automation/Commands/ScriptCommand.cs @@ -11,7 +11,7 @@ namespace taskt.Core.Automation.Commands { [Serializable] - public abstract class ScriptCommand : ILUIParameterProperties, ICommandIDProperties + public abstract class ScriptCommand : IUIParameterProperties, ICommandIDProperties { [XmlAttribute] public string CommandID { get; set; } @@ -124,6 +124,7 @@ public virtual void RunCommand(Engine.AutomationEngineInstance engine) { System.Threading.Thread.Sleep(DefaultPause); } + public virtual void RunCommand(Engine.AutomationEngineInstance engine, Script.ScriptAction command) { System.Threading.Thread.Sleep(DefaultPause); @@ -174,14 +175,13 @@ public virtual List Render() RenderedControls = new List(); return RenderedControls; } + public virtual void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) { - } public virtual void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) { - } #endregion diff --git a/taskt/Core/Automation/Commands/ScriptCommandInformation.cs b/taskt/Core/Automation/Commands/ScriptCommandInformation.cs new file mode 100644 index 000000000..877247859 --- /dev/null +++ b/taskt/Core/Automation/Commands/ScriptCommandInformation.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using taskt.Core.Automation.Attributes.ClassAttributes; + +namespace taskt.Core.Automation.Commands +{ + /// + /// script commands information for forms etc + /// + public class ScriptCommandInformation + { + /// + /// command name that contains namespace + /// + public string FullName { get; private set; } + + /// + /// command class name + /// + public string CommandName { get; private set; } + + /// + /// display name (selection name) + /// + public string DisplayName { get; private set; } + + /// + /// command group name + /// + public string GruopName { get; private set; } + + /// + /// command subgroup name + /// + public string SubGroupName { get; private set; } + + /// + /// constractor + /// + /// + public ScriptCommandInformation(Type command) + { + this.FullName = command.FullName; + + this.CommandName = this.FullName.Substring(this.FullName.LastIndexOf('.') + 1); + + var groupingAttribute = command.GetCustomAttribute(); + if (groupingAttribute != null) + { + var attr = groupingAttribute.groupName; + if (attr.EndsWith(" Commands")) + { + this.GruopName = attr; + } + else + { + this.GruopName = $"{attr} Commands"; + } + } + + var subGroupAttr = command.GetCustomAttribute(); + this.SubGroupName = (subGroupAttr != null) ? subGroupAttr.subGruopName : ""; + + var tcmd = (ScriptCommand)Activator.CreateInstance(command); + this.DisplayName = tcmd.SelectionName; + } + + /// + /// create all ScriptCommands informations + /// + /// + public static List CreateScriptCommandInformations() + { + var commandTypes = Assembly.GetAssembly(typeof(ScriptCommand)).GetTypes() + .Where(t => + { + return t.IsSubclassOf(typeof(ScriptCommand)) && !t.IsAbstract; + }); + + var ret = new List(); + foreach (var cmd in commandTypes) + { + ret.Add(new ScriptCommandInformation(cmd)); + } + + return ret; + } + } +} diff --git a/taskt/Core/Automation/Commands/Script/CommentCommand.cs b/taskt/Core/Automation/Commands/ScriptGroup/CommentCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Script/CommentCommand.cs rename to taskt/Core/Automation/Commands/ScriptGroup/CommentCommand.cs diff --git a/taskt/Core/Automation/Commands/Script/IHaveSequenceAdditionalCommands.cs b/taskt/Core/Automation/Commands/ScriptGroup/IHaveSequenceAdditionalCommands.cs similarity index 100% rename from taskt/Core/Automation/Commands/Script/IHaveSequenceAdditionalCommands.cs rename to taskt/Core/Automation/Commands/ScriptGroup/IHaveSequenceAdditionalCommands.cs diff --git a/taskt/Core/Automation/Commands/Script/SequenceCommand.cs b/taskt/Core/Automation/Commands/ScriptGroup/SequenceCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Script/SequenceCommand.cs rename to taskt/Core/Automation/Commands/ScriptGroup/SequenceCommand.cs diff --git a/taskt/Core/Automation/Commands/SelectionItemsControls.cs b/taskt/Core/Automation/Commands/SelectionItemsControls.cs index 565b61e03..50586c3a4 100644 --- a/taskt/Core/Automation/Commands/SelectionItemsControls.cs +++ b/taskt/Core/Automation/Commands/SelectionItemsControls.cs @@ -42,6 +42,14 @@ internal static class SelectionItemsControls [PropertyDetailSampleUsage("**Ignore**", "Nothing To Do")] public static string v_ComboBoxHasErrorIgnore { get; } + /// + /// combobox has Error, Ignore, Set Empty + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnore))] + [PropertyUISelectionOption("Set Emtpy")] + [PropertyDetailSampleUsage("**Set Empty**", "Set Empty Value")] + public static string v_ComboBoxHasErrorIgnoreSetEmpty { get; } + #endregion /// diff --git a/taskt/Core/Automation/Commands/SeleniumBrowserControls.cs b/taskt/Core/Automation/Commands/SeleniumBrowserControls.cs index b9e67ab94..5fb670ec8 100644 --- a/taskt/Core/Automation/Commands/SeleniumBrowserControls.cs +++ b/taskt/Core/Automation/Commands/SeleniumBrowserControls.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Data; -using System.Linq; -using System.Windows.Forms; -using OpenQA.Selenium; -using taskt.Core.Automation.Attributes.PropertyAttributes; +using OpenQA.Selenium; namespace taskt.Core.Automation.Commands { @@ -16,226 +9,300 @@ internal static class SeleniumBrowserControls { #region Virtual Property - /// - /// webbrowser instance name - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_InputInstanceName))] - [PropertyDescription("WebBrowser Instance Name")] - [InputSpecification("WebBrowser Instance Name", true)] - [PropertyDetailSampleUsage("**RPABrowser**", PropertyDetailSampleUsage.ValueType.Value, "WebBrowser Instance")] - [PropertyDetailSampleUsage("**{{{vInstance}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebBrowser Instance")] - [Remarks("Failure to enter the correct instance name or failure to first call **Create Broser** command will cause an error")] - [PropertyInstanceType(PropertyInstanceType.InstanceType.WebBrowser)] - [PropertyValidationRule("WebBrowser Instance", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Instance")] - [PropertyFirstValue("%kwd_default_browser_instance%")] - //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Input)] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyParameterOrder(5000)] - public static string v_InputInstanceName { get; } - - /// - /// search method property - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Element Search Method")] - [PropertyUISelectionOption("Find Element By XPath")] - [PropertyUISelectionOption("Find Element By ID")] - [PropertyUISelectionOption("Find Element By Name")] - [PropertyUISelectionOption("Find Element By Tag Name")] - [PropertyUISelectionOption("Find Element By Class Name")] - [PropertyUISelectionOption("Find Element By CSS Selector")] - [PropertyUISelectionOption("Find Element By Link Text")] - [PropertyUISelectionOption("Find Elements By XPath")] - [PropertyUISelectionOption("Find Elements By ID")] - [PropertyUISelectionOption("Find Elements By Name")] - [PropertyUISelectionOption("Find Elements By Tag Name")] - [PropertyUISelectionOption("Find Elements By Class Name")] - [PropertyUISelectionOption("Find Elements By CSS Selector")] - [PropertyUISelectionOption("Find Elements By Link Text")] - [Remarks("Select the specific search type that you want to use to isolate the element in the web page.")] - [PropertyValidationRule("Search Method", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Search Method")] - //[InputSpecification("", true)] - //[PropertyShowSampleUsageInDescription(false)] - //[SampleUsage("Select **Find Element By XPath**, **Find Element By ID**, **Find Element By Name**, **Find Element By Tag Name**, **Find Element By Class Name**, **Find Element By CSS Selector**, **Find Element By Link Text**")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterOrder(5000)] - public static string v_SearchMethod { get; } - - /// - /// search parameter property - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Element Search Parameter")] - [InputSpecification("Element Search Parameter", true)] - [PropertyValidationRule("Search Parameter", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Search Parameter")] - [Remarks("Specifies the parameter text that matches to the element based on the previously selected search type.")] - //[SampleUsage("")] - //[PropertyShowSampleUsageInDescription(false)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] - public static string v_SearchParameter { get; } - - /// - /// element index - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Element Index")] - [InputSpecification("Element Index", true)] - [PropertyDetailSampleUsage("**0**", "Specify the First Element Index")] - [PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "Element Index")] - [PropertyDetailSampleUsage("**{{{vIndex}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Element Index")] + ///// + ///// webbrowser instance name + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_InputInstanceName))] + //[PropertyDescription("WebBrowser Instance Name")] + //[InputSpecification("WebBrowser Instance Name", true)] + //[PropertyDetailSampleUsage("**RPABrowser**", PropertyDetailSampleUsage.ValueType.Value, "WebBrowser Instance")] + //[PropertyDetailSampleUsage("**{{{vInstance}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebBrowser Instance")] + //[Remarks("Failure to enter the correct instance name or failure to first call **Create Broser** command will cause an error")] + //[PropertyInstanceType(PropertyInstanceType.InstanceType.WebBrowser)] + //[PropertyValidationRule("WebBrowser Instance", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "Instance")] + //[PropertyFirstValue("%kwd_default_browser_instance%")] + ////[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Input)] + ////[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyParameterOrder(5000)] + //public static string v_InputInstanceName { get; } + + ///// + ///// search method property + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("Element Search Method")] + //[PropertyUISelectionOption("Find Element By XPath")] + //[PropertyUISelectionOption("Find Element By ID")] + //[PropertyUISelectionOption("Find Element By Name")] + //[PropertyUISelectionOption("Find Element By Tag Name")] + //[PropertyUISelectionOption("Find Element By Class Name")] + //[PropertyUISelectionOption("Find Element By CSS Selector")] + //[PropertyUISelectionOption("Find Element By Link Text")] + //[PropertyUISelectionOption("Find Elements By XPath")] + //[PropertyUISelectionOption("Find Elements By ID")] + //[PropertyUISelectionOption("Find Elements By Name")] + //[PropertyUISelectionOption("Find Elements By Tag Name")] + //[PropertyUISelectionOption("Find Elements By Class Name")] + //[PropertyUISelectionOption("Find Elements By CSS Selector")] + //[PropertyUISelectionOption("Find Elements By Link Text")] + //[Remarks("Select the specific search type that you want to use to isolate the element in the web page.")] + //[PropertyValidationRule("Search Method", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "Search Method")] + ////[InputSpecification("", true)] + ////[PropertyShowSampleUsageInDescription(false)] + ////[SampleUsage("Select **Find Element By XPath**, **Find Element By ID**, **Find Element By Name**, **Find Element By Tag Name**, **Find Element By Class Name**, **Find Element By CSS Selector**, **Find Element By Link Text**")] + ////[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] + ////[PropertyParameterOrder(5000)] + //public static string v_SearchMethod { get; } + + ///// + ///// search parameter property + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Element Search Parameter")] + //[InputSpecification("Element Search Parameter", true)] + //[PropertyValidationRule("Search Parameter", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "Search Parameter")] + //[Remarks("Specifies the parameter text that matches to the element based on the previously selected search type.")] + ////[SampleUsage("")] + ////[PropertyShowSampleUsageInDescription(false)] + ////[PropertyTextBoxSetting(1, false)] + ////[PropertyParameterOrder(5000)] + //public static string v_SearchParameter { get; } + + ///// + ///// element index + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Element Index")] + //[InputSpecification("Element Index", true)] + //[PropertyDetailSampleUsage("**0**", "Specify the First Element Index")] + //[PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "Element Index")] + //[PropertyDetailSampleUsage("**{{{vIndex}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Element Index")] + ////[Remarks("")] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyTextBoxSetting(1, false)] + ////[PropertyParameterOrder(5000)] + //public static string v_ElementIndex { get; } + + ///// + ///// Attributes Name + ///// + //[PropertyDescription("Attributes Name to Get")] + //[InputSpecification("Attributes Name", true)] + //[PropertyDetailSampleUsage("**id**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] + //[PropertyDetailSampleUsage("**title**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] + //[PropertyDetailSampleUsage("**textContent**", "Specify the Element **Text Content** Value")] + //[PropertyDetailSampleUsage("**{{{vAttribute}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Attribute")] + //[PropertyDetailSampleUsage("**Displayed**", "Get the Specified Element is Displayed or Not", false)] + //[PropertyDetailSampleUsage("**Enabled**", "Get the Specified Element is Enabled or Not", false)] + //[PropertyDetailSampleUsage("**Location**", "Get the Specified Element Location. like **X,Y**, comma separated.", false)] + //[PropertyDetailSampleUsage("**Selected**", "Get the Specified Element is Selected or Not", false)] + //[PropertyDetailSampleUsage("**Size**", "Get the Specified Element Size. like **W,H**, comma separated.", false)] + //[PropertyDetailSampleUsage("**TagName**", "Get the Specified Element Tag Name.", false)] + //[PropertyDetailSampleUsage("**Text**", "Get the Specified Element innerText.", false)] //[Remarks("")] //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] - public static string v_ElementIndex { get; } - - /// - /// Attributes Name - /// - [PropertyDescription("Attributes Name to Get")] - [InputSpecification("Attributes Name", true)] - [PropertyDetailSampleUsage("**id**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] - [PropertyDetailSampleUsage("**title**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] - [PropertyDetailSampleUsage("**textContent**", "Specify the Element **Text Content** Value")] - [PropertyDetailSampleUsage("**{{{vAttribute}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Attribute")] - [PropertyDetailSampleUsage("**Displayed**", "Get the Specified Element is Displayed or Not", false)] - [PropertyDetailSampleUsage("**Enabled**", "Get the Specified Element is Enabled or Not", false)] - [PropertyDetailSampleUsage("**Location**", "Get the Specified Element Location. like **X,Y**, comma separated.", false)] - [PropertyDetailSampleUsage("**Selected**", "Get the Specified Element is Selected or Not", false)] - [PropertyDetailSampleUsage("**Size**", "Get the Specified Element Size. like **W,H**, comma separated.", false)] - [PropertyDetailSampleUsage("**TagName**", "Get the Specified Element Tag Name.", false)] - [PropertyDetailSampleUsage("**Text**", "Get the Specified Element innerText.", false)] - [Remarks("")] - [PropertyShowSampleUsageInDescription(true)] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] - [PropertyDataGridViewSetting(true, true, true)] - [PropertyDataGridViewColumnSettings("AttributeName", "Attribute Name")] - [PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.AllEditableDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] - [PropertyParameterOrder(5000)] - public static string v_AttributesName { get; } - - /// - /// attribute name - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Attributes Name to Get")] - [InputSpecification("Attributes Name", true)] - [PropertyDetailSampleUsage("**id**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] - [PropertyDetailSampleUsage("**title**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] - [PropertyDetailSampleUsage("**textContent**", "Specify the Element **Text Content** Value")] - [PropertyDetailSampleUsage("**{{{vAttribute}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Attribute")] - [PropertyDetailSampleUsage("**Displayed**", "Get the Specified Element is Displayed or Not", false)] - [PropertyDetailSampleUsage("**Enabled**", "Get the Specified Element is Enabled or Not", false)] - [PropertyDetailSampleUsage("**Location**", "Get the Specified Element Location. like **X,Y**, comma separated.", false)] - [PropertyDetailSampleUsage("**Selected**", "Get the Specified Element is Selected or Not", false)] - [PropertyDetailSampleUsage("**Size**", "Get the Specified Element Size. like **W,H**, comma separated.", false)] - [PropertyDetailSampleUsage("**TagName**", "Get the Specified Element Tag Name.", false)] - [PropertyDetailSampleUsage("**Text**", "Get the Specified Element innerText.", false)] - [PropertyValidationRule("Attribute", PropertyValidationRule.ValidationRuleFlags.Empty)] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] - public static string v_AttributeName { get; } - - /// - /// element wait time - /// - [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] - [PropertyDescription("Wait Time for the WebElement to Exist (sec)")] - [Remarks("Specify how long to Wait before an Error will occur because the WebElement is Not Found.")] - [PropertyIsOptional(true, "120")] - [PropertyFirstValue("120")] - //[InputSpecification("Wait Time", true)] - //[PropertyDetailSampleUsage("**120**", PropertyDetailSampleUsage.ValueType.Value, "Wait Time")] - //[PropertyDetailSampleUsage("**{{{vTime}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Wait Time")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] + //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + //[PropertyDataGridViewSetting(true, true, true)] + //[PropertyDataGridViewColumnSettings("AttributeName", "Attribute Name")] + //[PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.AllEditableDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] //[PropertyParameterOrder(5000)] - public static string v_WaitTime { get; } - - /// - /// input WebElement property - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_InputInstanceName))] - [PropertyDescription("WebElement Variable Name")] - [InputSpecification("WebElement Variable Name", true)] - [PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyInstanceType(PropertyInstanceType.InstanceType.WebElement, true)] - [PropertyValidationRule("WebElement", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Element")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Input)] - //[PropertyParameterOrder(5000)] - public static string v_InputWebElementName { get; } - - /// - /// output WebElement property - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Store WebElement")] - [InputSpecification("WebElement Variable Name", true)] - [PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyInstanceType(PropertyInstanceType.InstanceType.WebElement, true)] - [PropertyValidationRule("WebElement", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "WebElement")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] - //[PropertyParameterOrder(5000)] - public static string v_OutputWebElementName { get; } - - /// - /// scroll to element - /// - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Scroll to WebElement")] - [PropertyIsOptional(true, "No")] - [PropertyDisplayText(false, "Scroll")] - //[InputSpecification("", true)] - //[Remarks("")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyUISelectionOption("Yes")] - //[PropertyUISelectionOption("No")] - //[PropertyParameterOrder(5000)] - public static string v_ScrollToElement { get; } + //public static string v_AttributesName { get; } + + ///// + ///// attribute name + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Attributes Name to Get")] + //[InputSpecification("Attributes Name", true)] + //[PropertyDetailSampleUsage("**id**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] + //[PropertyDetailSampleUsage("**title**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] + //[PropertyDetailSampleUsage("**textContent**", "Specify the Element **Text Content** Value")] + //[PropertyDetailSampleUsage("**{{{vAttribute}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Attribute")] + //[PropertyDetailSampleUsage("**Displayed**", "Get the Specified Element is Displayed or Not", false)] + //[PropertyDetailSampleUsage("**Enabled**", "Get the Specified Element is Enabled or Not", false)] + //[PropertyDetailSampleUsage("**Location**", "Get the Specified Element Location. like **X,Y**, comma separated.", false)] + //[PropertyDetailSampleUsage("**Selected**", "Get the Specified Element is Selected or Not", false)] + //[PropertyDetailSampleUsage("**Size**", "Get the Specified Element Size. like **W,H**, comma separated.", false)] + //[PropertyDetailSampleUsage("**TagName**", "Get the Specified Element Tag Name.", false)] + //[PropertyDetailSampleUsage("**Text**", "Get the Specified Element innerText.", false)] + //[PropertyValidationRule("Attribute", PropertyValidationRule.ValidationRuleFlags.Empty)] + ////[Remarks("")] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyTextBoxSetting(1, false)] + ////[PropertyParameterOrder(5000)] + //public static string v_AttributeName { get; } + + ///// + ///// element wait time + ///// + //[PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + //[PropertyDescription("Wait Time for the WebElement to Exist (sec)")] + //[Remarks("Specify how long to Wait before an Error will occur because the WebElement is Not Found.")] + //[PropertyIsOptional(true, "120")] + //[PropertyFirstValue("120")] + ////[InputSpecification("Wait Time", true)] + ////[PropertyDetailSampleUsage("**120**", PropertyDetailSampleUsage.ValueType.Value, "Wait Time")] + ////[PropertyDetailSampleUsage("**{{{vTime}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Wait Time")] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyTextBoxSetting(1, false)] + ////[PropertyParameterOrder(5000)] + //public static string v_WaitTime { get; } + + ///// + ///// input WebElement property + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_InputInstanceName))] + //[PropertyDescription("WebElement Variable Name")] + //[InputSpecification("WebElement Variable Name", true)] + //[PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] + //[PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + //[PropertyInstanceType(PropertyInstanceType.InstanceType.WebElement, true)] + //[PropertyValidationRule("WebElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "Element")] + ////[Remarks("")] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] + ////[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Input)] + ////[PropertyParameterOrder(5000)] + //public static string v_InputWebElementName { get; } + + ///// + ///// output WebElement property + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyDescription("Variable Name to Store WebElement")] + //[InputSpecification("WebElement Variable Name", true)] + //[PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] + //[PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + //[PropertyInstanceType(PropertyInstanceType.InstanceType.WebElement, true)] + //[PropertyValidationRule("WebElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "WebElement")] + ////[Remarks("")] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] + ////[PropertyParameterOrder(5000)] + //public static string v_OutputWebElementName { get; } + + ///// + ///// scroll to element + ///// + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Scroll to WebElement")] + //[PropertyIsOptional(true, "No")] + //[PropertyDisplayText(false, "Scroll")] + ////[InputSpecification("", true)] + ////[Remarks("")] + ////[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] + ////[PropertyUISelectionOption("Yes")] + ////[PropertyUISelectionOption("No")] + ////[PropertyParameterOrder(5000)] + //public static string v_ScrollToElement { get; } #endregion #region methods #region convert store methods + ///// + ///// expand user variable as WebElement and WebDriver + ///// + ///// + ///// + ///// + ///// + ///// + //public static (IWebElement, IWebDriver) ExpandUserVariableAsWebElementAndWebDriver(this string str, string parameterName, Engine.AutomationEngineInstance engine) + //{ + // var v = str.GetRawVariable(engine); + + // if (v.VariableValue is ValueTuple webs) + // { + // return webs; + // } + // else + // { + // throw new Exception($"{parameterName} '{str}' is not a WebElement-WebDriver tuple."); + // } + //} + + ///// + ///// expand user variable as WebElement + ///// + ///// + ///// + ///// + ///// + ///// + //public static IWebElement ExpandUserVariableAsWebElement(this string str, string parameterName, Engine.AutomationEngineInstance engine) + //{ + // //var v = str.GetRawVariable(engine); + // ////var tp = typeof((IWebElement, IWebDriver)); + // ////var vtp = v.VariableValue.GetType(); + // ////if (v.VariableValue is (IWebElement, IWebDriver)) + // ////{ + // //// return webs.Item1; + // ////} + // ////else + // ////{ + // //// throw new Exception($"{parameterName} '{str}' is not a WebElement."); + // ////} + // ////try + // ////{ + // //// var webs = ((IWebElement, IWebDrier))v.VariableValue; + // ////} + // ////catch + // ////{ + // //// throw new Exception($"{parameterName} '{str}' is not a WebElement."); + // ////} + // //if (v.VariableValue is ValueTuple webs) + // //{ + // // return webs.Item1; + // //} + // //else + // //{ + // // throw new Exception($"{parameterName} '{str}' is not a WebElement."); + // //} + + // (var e, _) = ExpandUserVariableAsWebElementAndWebDriver(str, parameterName, engine); + // return e; + //} + + ///// + ///// expand user variable as webDriver from WebElement + ///// + ///// + ///// + ///// + ///// + ///// + //public static IWebDriver ExpandUserVariableAsWebDriverFromWebElement(this string str, string parameterName, Engine.AutomationEngineInstance engine) + //{ + // //var v = str.GetRawVariable(engine); + + // //if (v.VariableValue is ValueTuple webs) + // //{ + // // return webs.Item2; + // //} + // //else + // //{ + // // throw new Exception($"{parameterName} '{str}' is not a WebElement."); + // //} + + // (_, var d) = ExpandUserVariableAsWebElementAndWebDriver(str, parameterName, engine); + // return d; + //} + /// - /// expand user variable as WebElement + /// store WebElement (and WebDriver) to user variable /// - /// - /// + /// /// - /// - /// - public static IWebElement ExpandUserVariableAsWebElement(this string str, string parameterName, Engine.AutomationEngineInstance engine) - { - var v = str.GetRawVariable(engine); - if (v.VariableValue is IWebElement e) - { - return e; - } - else - { - throw new Exception(parameterName + " '" + str + "' is not a WebElement."); - } - } - - public static void StoreInUserVariable(this IWebElement value, Core.Automation.Engine.AutomationEngineInstance engine, string targetVariable) + /// + public static void StoreInUserVariable(this (IWebElement, IWebDriver) value, Engine.AutomationEngineInstance engine, string targetVariable) { ExtensionMethods.StoreInUserVariable(targetVariable, value, engine, false); } @@ -243,477 +310,478 @@ public static void StoreInUserVariable(this IWebElement value, Core.Automation.E #endregion #region instance methods - /// - /// get WebBrowser Instance - /// - /// - /// - /// - /// - public static IWebDriver ExpandValueOrUserVariableAsSeleniumBrowserInstance(this string instanceName, Engine.AutomationEngineInstance engine) - { - var vInstance = instanceName.ExpandValueOrUserVariable(engine); - var browserObject = engine.GetAppInstance(vInstance); - - if (browserObject is IWebDriver wd) - { - return wd; - } - else - { - throw new Exception("Instance Name '" + instanceName + "' is not WebBrowser Instance. Parsed Value: '" + vInstance + "'"); - } - } + ///// + ///// get WebBrowser Instance + ///// + ///// + ///// + ///// + ///// + //public static IWebDriver ExpandValueOrUserVariableAsSeleniumBrowserInstance(this string instanceName, Engine.AutomationEngineInstance engine) + //{ + // var vInstance = instanceName.ExpandValueOrUserVariable(engine); + // var browserObject = engine.GetAppInstance(vInstance); + + // if (browserObject is ValueTuple pair) + // { + // return pair.Item1; + // } + // else + // { + // throw new Exception($"Instance Name '{instanceName}' is not WebBrowser Instance. Parsed Value: '{vInstance}'"); + // } + //} #endregion #region search element(s) methods - /// - /// get web element search method by specified search method - /// - /// - /// - /// - private static Func GetWebElementSearchMethod(string searchMethod) - { - switch (searchMethod.ToLower()) - { - case "find element by xpath": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.XPath(parameter)); - }); - - case "find element by id": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.Id(parameter)); - }); - - case "find element by name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.Name(parameter)); - }); - - case "find element by tag name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.TagName(parameter)); - }); - - case "find element by class name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.ClassName(parameter)); - }); - - case "find element by css selector": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.CssSelector(parameter)); - }); - - case "find element by link text": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.LinkText(parameter)); - }); - - case "find elements by xpath": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.XPath(parameter)); - }); - - case "find elements by id": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.Id(parameter)); - }); - - case "find elements by name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.Name(parameter)); - }); - - case "find elements by tag name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.TagName(parameter)); - }); - - case "find elements by class name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.ClassName(parameter)); - }); - - case "find elements by css selector": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.CssSelector(parameter)); - }); - - case "find elements by link text": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.LinkText(parameter)); - }); - - default: - throw new Exception("Strange Search Method '" + searchMethod + "'"); - } - } - - /// - /// expand value or user variable as instance and searched an webElement - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static (IWebDriver, IWebElement) ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(IWebDriver seleniumInstance, string searchMethod, string searchParameter, int index, int waitTime, Engine.AutomationEngineInstance engine) - { - var searchFunc = GetWebElementSearchMethod(searchMethod); - - var ret = WaitControls.WaitProcess(waitTime, "WebElement", new Func<(bool, object)>(() => - { - try - { - var t = searchFunc(seleniumInstance, searchParameter); - if (t is IWebElement elem) - { - return (true, elem); - } - else if (t is ReadOnlyCollection elems) - { - if (index < 0) - { - index += elems.Count; - } - if ((index >= 0) && (index < elems.Count)) - { - return (true, elems[index]); - } - else - { - return (false, null); - } - } - else - { - return (false, null); - } - } - catch - { - return (false, null); - } - }), engine); - - if (ret is IWebElement e) - { - return (seleniumInstance, e); - } - else - { - throw new Exception("WebElement Not Found."); - } - } - - /// - /// expand value or user variable as instance and searched an webElement - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static (IWebDriver, IWebElement) ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(ScriptCommand command, string instanceParameterName, string searchMethodName, string searchParameterName, string elementIndexName, string waitTimeName, Engine.AutomationEngineInstance engine) - { - var instanceName = command.ExpandValueOrUserVariable(instanceParameterName, "WebBrowser Instance Name", engine); - var seleniumInstance = instanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - - var searchParameter = command.ExpandValueOrUserVariable(searchParameterName, "Search Parameter", engine); - var searchMethod = command.ExpandValueOrUserVariable(searchMethodName, "Search Method", engine); - - var waitTime = command.ExpandValueOrUserVariableAsInteger(waitTimeName, engine); - - var indexString = command.GetRawPropertyValueAsString(elementIndexName, "Index"); - int index; - if (string.IsNullOrEmpty(indexString)) - { - index = 0; - } - else - { - index = command.ExpandValueOrUserVariableAsInteger(elementIndexName, engine); - } - - return ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(seleniumInstance, searchMethod, searchParameter, index, waitTime, engine); - } - - /// - /// expand value or user variable as instance and searched an webElements - /// - /// - /// - /// - /// - /// - /// - /// - public static (IWebDriver, List) ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(IWebDriver seleniumInstance, string searchMethod, string searchParameter, int waitTime, Engine.AutomationEngineInstance engine) - { - var searchFunc = GetWebElementSearchMethod(searchMethod); - - var ret = WaitControls.WaitProcess(waitTime, "WebElement", new Func<(bool, object)>(() => - { - try - { - var t = searchFunc(seleniumInstance, searchParameter); - if (t is IWebElement elem) - { - return (true, new List() { elem }); - } - else if (t is ReadOnlyCollection elems) - { - if (elems.Count > 0) - { - return (true, elems.ToList()); - } - else - { - return (false, null); - } - } - else - { - return (false, null); - } - } - catch - { - return (false, null); - } - }), engine); - - if (ret is List e) - { - return (seleniumInstance, e); - } - else - { - throw new Exception("WebElement(s) Not Found."); - } - } - - /// - /// expand value or user variable as instance and searched an webElements - /// - /// - /// - /// - /// - /// - /// - /// - public static (IWebDriver, List) ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(ScriptCommand command, string instanceParameterName, string searchMethodName, string searchParameterName, string waitTimeName, Engine.AutomationEngineInstance engine) - { - var instanceName = command.ExpandValueOrUserVariable(instanceParameterName, "WebBrowser Instance Name", engine); - var seleniumInstance = instanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - - var searchParameter = command.ExpandValueOrUserVariable(searchParameterName, "Search Parameter", engine); - var searchMethod = command.ExpandValueOrUserVariable(searchMethodName, "Search Method", engine); - - var waitTime = command.ExpandValueOrUserVariableAsInteger(waitTimeName, engine); - - return ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(seleniumInstance, searchMethod, searchParameter, waitTime, engine); - } + ///// + ///// get web element search method by specified search method + ///// + ///// + ///// + ///// + //private static Func GetWebElementSearchMethod(string searchMethod) + //{ + // switch (searchMethod.ToLower()) + // { + // case "find element by xpath": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.XPath(parameter)); + // }); + + // case "find element by id": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.Id(parameter)); + // }); + + // case "find element by name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.Name(parameter)); + // }); + + // case "find element by tag name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.TagName(parameter)); + // }); + + // case "find element by class name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.ClassName(parameter)); + // }); + + // case "find element by css selector": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.CssSelector(parameter)); + // }); + + // case "find element by link text": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.LinkText(parameter)); + // }); + + // case "find elements by xpath": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.XPath(parameter)); + // }); + + // case "find elements by id": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.Id(parameter)); + // }); + + // case "find elements by name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.Name(parameter)); + // }); + + // case "find elements by tag name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.TagName(parameter)); + // }); + + // case "find elements by class name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.ClassName(parameter)); + // }); + + // case "find elements by css selector": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.CssSelector(parameter)); + // }); + + // case "find elements by link text": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.LinkText(parameter)); + // }); + + // default: + // throw new Exception($"Strange Search Method '{searchMethod}'"); + // } + //} + + ///// + ///// expand value or user variable as instance and searched an webElement + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + //public static (IWebDriver, IWebElement) ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(IWebDriver seleniumInstance, string searchMethod, string searchParameter, int index, int waitTime, Engine.AutomationEngineInstance engine) + //{ + // var searchFunc = GetWebElementSearchMethod(searchMethod); + + // var ret = WaitControls.WaitProcess(waitTime, "WebElement", new Func<(bool, object)>(() => + // { + // try + // { + // var t = searchFunc(seleniumInstance, searchParameter); + // if (t is IWebElement elem) + // { + // return (true, elem); + // } + // else if (t is ReadOnlyCollection elems) + // { + // if (index < 0) + // { + // index += elems.Count; + // } + // if ((index >= 0) && (index < elems.Count)) + // { + // return (true, elems[index]); + // } + // else + // { + // return (false, null); + // } + // } + // else + // { + // return (false, null); + // } + // } + // catch + // { + // return (false, null); + // } + // }), engine); + + // if (ret is IWebElement e) + // { + // return (seleniumInstance, e); + // } + // else + // { + // throw new Exception("WebElement Not Found."); + // } + //} + + ///// + ///// expand value or user variable as instance and searched an webElement + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + //public static (IWebDriver, IWebElement) ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(ScriptCommand command, string instanceParameterName, string searchMethodName, string searchParameterName, string elementIndexName, string waitTimeName, Engine.AutomationEngineInstance engine) + //{ + // var instanceName = command.ExpandValueOrUserVariable(instanceParameterName, "WebBrowser Instance Name", engine); + // var seleniumInstance = instanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + + // var searchParameter = command.ExpandValueOrUserVariable(searchParameterName, "Search Parameter", engine); + // var searchMethod = command.ExpandValueOrUserVariable(searchMethodName, "Search Method", engine); + + // var waitTime = command.ExpandValueOrUserVariableAsInteger(waitTimeName, engine); + + // var indexString = command.GetRawPropertyValueAsString(elementIndexName, "Index"); + // int index; + // if (string.IsNullOrEmpty(indexString)) + // { + // index = 0; + // } + // else + // { + // index = command.ExpandValueOrUserVariableAsInteger(elementIndexName, engine); + // } + + // return ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(seleniumInstance, searchMethod, searchParameter, index, waitTime, engine); + //} + + ///// + ///// expand value or user variable as instance and searched an webElements + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + //public static (IWebDriver, List) ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(IWebDriver seleniumInstance, string searchMethod, string searchParameter, int waitTime, Engine.AutomationEngineInstance engine) + //{ + // var searchFunc = GetWebElementSearchMethod(searchMethod); + + // var ret = WaitControls.WaitProcess(waitTime, "WebElement", new Func<(bool, object)>(() => + // { + // try + // { + // var t = searchFunc(seleniumInstance, searchParameter); + // if (t is IWebElement elem) + // { + // return (true, new List() { elem }); + // } + // else if (t is ReadOnlyCollection elems) + // { + // if (elems.Count > 0) + // { + // return (true, elems.ToList()); + // } + // else + // { + // return (false, null); + // } + // } + // else + // { + // return (false, null); + // } + // } + // catch + // { + // return (false, null); + // } + // }), engine); + + // if (ret is List e) + // { + // return (seleniumInstance, e); + // } + // else + // { + // throw new Exception("WebElement(s) Not Found."); + // } + //} + + ///// + ///// expand value or user variable as instance and searched an webElements + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + //public static (IWebDriver, List) ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(ScriptCommand command, string instanceParameterName, string searchMethodName, string searchParameterName, string waitTimeName, Engine.AutomationEngineInstance engine) + //{ + // var instanceName = command.ExpandValueOrUserVariable(instanceParameterName, "WebBrowser Instance Name", engine); + // var seleniumInstance = instanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + + // var searchParameter = command.ExpandValueOrUserVariable(searchParameterName, "Search Parameter", engine); + // var searchMethod = command.ExpandValueOrUserVariable(searchMethodName, "Search Method", engine); + + // var waitTime = command.ExpandValueOrUserVariableAsInteger(waitTimeName, engine); + + // return ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(seleniumInstance, searchMethod, searchParameter, waitTime, engine); + //} #endregion #region Attribute methods - /// - /// get element attributes specified DataTable - /// - /// - /// - /// - /// - public static void GetElementAttributes(IWebElement elem, DataTable attributes, Engine.AutomationEngineInstance engine, Action setValueFunc) - { - int rows = attributes.Rows.Count; - for (int i = 0; i < rows; i++) - { - string attrName = (attributes.Rows[i][0]?.ToString() ?? "").ExpandValueOrUserVariable(engine); - if (attrName != "") - { - setValueFunc(attrName, GetAttribute(elem, attrName, engine)); - } - } - } - - /// - /// get Elements attribute specified by argument - /// - /// - /// - /// - /// - public static void GetElementsAttribute(List elems, string attributeValue, Engine.AutomationEngineInstance engine, Action setValueFunc) - { - var attr = attributeValue.ExpandValueOrUserVariable(engine); - for (int i = 0; i < elems.Count; i++) - { - setValueFunc(i, attr, GetAttribute(elems[i], attr, engine)); - } - } - - /// - /// get element attribute - /// - /// - /// - /// - /// - /// - public static string GetAttribute(IWebElement element, string attributeName, Engine.AutomationEngineInstance engine) - { - attributeName = attributeName.ExpandValueOrUserVariable(engine); - if (string.IsNullOrEmpty(attributeName)) - { - throw new Exception("Attribute Name is empty."); - } - - switch (attributeName.ToLower()) - { - case "enabled": - return element.Enabled.ToString(); - - case "displayed": - return element.Displayed.ToString(); - - case "selected": - return element.Selected.ToString(); - - case "text": - return element.Text; - - case "tag": - case "tag name": - case "tagname": - return element.TagName; - - case "location": - System.Drawing.Point lc = element.Location; - return lc.X.ToString() + "," + lc.Y.ToString(); - - case "size": - System.Drawing.Size sz = element.Size; - return sz.Width.ToString() + "," + sz.Height.ToString(); - - default: - var attr = element.GetDomAttribute(attributeName) ?? element.GetDomProperty(attributeName); - if (attr != null) - { - return attr; - } - else - { - throw new Exception("Attribute '" + attributeName + "' does not exists."); - } - } - } + ///// + ///// get element attributes specified DataTable + ///// + ///// + ///// + ///// + ///// + //public static void GetElementAttributes(IWebElement elem, DataTable attributes, Engine.AutomationEngineInstance engine, Action setValueFunc) + //{ + // int rows = attributes.Rows.Count; + // for (int i = 0; i < rows; i++) + // { + // string attrName = (attributes.Rows[i][0]?.ToString() ?? "").ExpandValueOrUserVariable(engine); + // if (attrName != "") + // { + // setValueFunc(attrName, GetAttribute(elem, attrName, engine)); + // } + // } + //} + + ///// + ///// get Elements attribute specified by argument + ///// + ///// + ///// + ///// + ///// + //public static void GetElementsAttribute(List elems, string attributeValue, Engine.AutomationEngineInstance engine, Action setValueFunc) + //{ + // var attr = attributeValue.ExpandValueOrUserVariable(engine); + // for (int i = 0; i < elems.Count; i++) + // { + // setValueFunc(i, attr, GetAttribute(elems[i], attr, engine)); + // } + //} + + ///// + ///// get element attribute + ///// + ///// + ///// + ///// + ///// + ///// + //public static string GetAttribute(IWebElement element, string attributeName, Engine.AutomationEngineInstance engine) + //{ + // attributeName = attributeName.ExpandValueOrUserVariable(engine); + // if (string.IsNullOrEmpty(attributeName)) + // { + // throw new Exception("Attribute Name is empty."); + // } + + // switch (attributeName.ToLower()) + // { + // case "enabled": + // return element.Enabled.ToString(); + + // case "displayed": + // return element.Displayed.ToString(); + + // case "selected": + // return element.Selected.ToString(); + + // case "text": + // return element.Text; + + // case "tag": + // case "tag name": + // case "tagname": + // return element.TagName; + + // case "location": + // System.Drawing.Point lc = element.Location; + // return $"{lc.X},{lc.Y}"; + + // case "size": + // System.Drawing.Size sz = element.Size; + // return $"{sz.Width},{sz.Height}"; + + // default: + // var attr = element.GetDomAttribute(attributeName) ?? element.GetDomProperty(attributeName); + // if (attr != null) + // { + // return attr; + // } + // else + // { + // throw new Exception($"Attribute '{attributeName}' does not exists."); + // } + // } + //} #endregion #region WebElement methods - public static string CreateXPath(IWebElement elem) - { - // MEMO: it's probably works fine. :-) - - string path = ""; - - var curElem = elem; - var curElemId = curElem.ToString(); - - // DBG - //Debug.WriteLine($"curElem: {curElem.ToString()}, {curElem.GetHashCode()}"); - - var pElem = curElem.FindElement(By.XPath("parent::*")); - while (true) - { - var cElems = pElem.FindElements(By.XPath($"{curElem.TagName.ToLower()}")); - if (cElems.Count > 1) - { - int index = 1; - foreach (var e in cElems) - { - if (e.ToString() == curElemId) - { - break; - } - index++; - } - path = $"/{curElem.TagName.ToLower()}[{index}]{path}"; - } - else - { - path = $"/{curElem.TagName.ToLower()}{path}"; - } - - // DGB - //Debug.WriteLine($"totyu: {path}"); - - if (curElem.TagName.ToLower() == "body") - { - path = $"/html{path}"; - break; - } - else - { - curElem = pElem; - curElemId = curElem.ToString(); - pElem = curElem.FindElement(By.XPath("parent::*")); - } - } - - // DBG - //Debug.WriteLine($"XPath: {path}"); - - return path; - } + //public static string CreateXPath(IWebElement elem) + //{ + // // MEMO: it's probably works fine. :-) + // string path = string.Empty; + + // var curElem = elem; + // var curElemId = curElem.ToString(); + + // // DBG + // //Debug.WriteLine($"curElem: {curElem.ToString()}, {curElem.GetHashCode()}"); + + // var pElem = curElem.FindElement(By.XPath("parent::*")); + // while (true) + // { + // var cTag = curElem.TagName.ToLower(); + + // var cElems = pElem.FindElements(By.XPath($"{cTag}")); + // if (cElems.Count > 1) + // { + // int index = 1; + // foreach (var e in cElems) + // { + // if (e.ToString() == curElemId) + // { + // break; + // } + // index++; + // } + // path = $"/{cTag}[{index}]{path}"; + // } + // else + // { + // path = $"/{cTag}{path}"; + // } + + // // DGB + // //Debug.WriteLine($"totyu: {path}"); + + // if (cTag == "body") + // { + // path = $"/html{path}"; + // break; + // } + // else + // { + // curElem = pElem; + // curElemId = curElem.ToString(); + // pElem = curElem.FindElement(By.XPath("parent::*")); + // } + // } + + // // DBG + // //Debug.WriteLine($"XPath: {path}"); + + // return path; + //} #endregion #region tag methods - public static bool CheckTagName(this IWebElement elem, string tagName) - { - return (elem.TagName.ToLower() == tagName.ToLower()); - } + //public static bool CheckTagName(this IWebElement elem, string tagName) + //{ + // return (elem.TagName.ToLower() == tagName.ToLower()); + //} #endregion #region JS execute - public static object ExcecuteScript(IWebDriver seleniumInstance, string script) - { - var js = seleniumInstance as IJavaScriptExecutor; - return js.ExecuteScript(script); - } + //public static object ExcecuteScript(IWebDriver seleniumInstance, string script) + //{ + // var js = seleniumInstance as IJavaScriptExecutor; + // return js.ExecuteScript(script); + //} #endregion @@ -721,16 +789,16 @@ public static object ExcecuteScript(IWebDriver seleniumInstance, string script) #region events - public static void SearchMethodComboBox_SelectionChangeCommitted(Dictionary controlsList, ComboBox searchMethodComboBox, string indexParameterName) - { - string item = searchMethodComboBox.SelectedItem?.ToString().ToLower() ?? ""; - FormUIControls.SetVisibleParameterControlGroup(controlsList, indexParameterName, item.StartsWith("find elements")); - } + //public static void SearchMethodComboBox_SelectionChangeCommitted(Dictionary controlsList, ComboBox searchMethodComboBox, string indexParameterName) + //{ + // string item = searchMethodComboBox.SelectedItem?.ToString().ToLower() ?? ""; + // FormUIControls.SetVisibleParameterControlGroup(controlsList, indexParameterName, item.StartsWith("find elements")); + //} - public static void ScrollToWebElement_SelectionChange(ComboBox scrollParameter, Dictionary controlsList, string instanceParameterName) - { - FormUIControls.SetVisibleParameterControlGroup(controlsList, instanceParameterName, ((scrollParameter.SelectedItem?.ToString().ToLower() ?? "") != "no")); - } + //public static void ScrollToWebElement_SelectionChange(ComboBox scrollParameter, Dictionary controlsList, string instanceParameterName) + //{ + // FormUIControls.SetVisibleParameterControlGroup(controlsList, instanceParameterName, ((scrollParameter.SelectedItem?.ToString().ToLower() ?? "") != "no")); + //} #endregion } diff --git a/taskt/Core/Automation/Commands/StopWatch/StopwatchCommand.cs b/taskt/Core/Automation/Commands/StopWatchGroup/StopwatchCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/StopWatch/StopwatchCommand.cs rename to taskt/Core/Automation/Commands/StopWatchGroup/StopwatchCommand.cs diff --git a/taskt/Core/Automation/Commands/System/GetEnvironmentVariableCommand.cs b/taskt/Core/Automation/Commands/SystemGroup/GetEnvironmentVariableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/System/GetEnvironmentVariableCommand.cs rename to taskt/Core/Automation/Commands/SystemGroup/GetEnvironmentVariableCommand.cs diff --git a/taskt/Core/Automation/Commands/System/GetOSVariableCommand.cs b/taskt/Core/Automation/Commands/SystemGroup/GetOSVariableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/System/GetOSVariableCommand.cs rename to taskt/Core/Automation/Commands/SystemGroup/GetOSVariableCommand.cs diff --git a/taskt/Core/Automation/Commands/System/LaunchRemoteDesktopCommand.cs b/taskt/Core/Automation/Commands/SystemGroup/LaunchRemoteDesktopCommand.cs similarity index 93% rename from taskt/Core/Automation/Commands/System/LaunchRemoteDesktopCommand.cs rename to taskt/Core/Automation/Commands/SystemGroup/LaunchRemoteDesktopCommand.cs index b6be425e6..65446464a 100644 --- a/taskt/Core/Automation/Commands/System/LaunchRemoteDesktopCommand.cs +++ b/taskt/Core/Automation/Commands/SystemGroup/LaunchRemoteDesktopCommand.cs @@ -134,9 +134,14 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) break; } - var result = engine.tasktEngineUI.Invoke(new Action(() => + //var result = engine.tasktEngineUI.Invoke(new Action(() => + //{ + // engine.tasktEngineUI.LaunchRDPSession(machineName, userName, password, credSsp, width, height, keyboardHook); + //})); + engine.tasktEngineUI.Invoke(new Action(() => { - engine.tasktEngineUI.LaunchRDPSession(machineName, userName, password, credSsp, width, height, keyboardHook); + var remoteDesktopForm = new UI.Forms.ScriptEngine.Supplemental.frmRemoteDesktopViewer(machineName, userName, password, credSsp, width, height, false, false, keyboardHook); + remoteDesktopForm.Show(); })); } } diff --git a/taskt/Core/Automation/Commands/System/SystemActionCommand.cs b/taskt/Core/Automation/Commands/SystemGroup/SystemActionCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/System/SystemActionCommand.cs rename to taskt/Core/Automation/Commands/SystemGroup/SystemActionCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/CheckTextCommand.cs b/taskt/Core/Automation/Commands/TextGroup/CheckTextCommand.cs similarity index 88% rename from taskt/Core/Automation/Commands/Text/CheckTextCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/CheckTextCommand.cs index b417b8304..b2f442d0a 100644 --- a/taskt/Core/Automation/Commands/Text/CheckTextCommand.cs +++ b/taskt/Core/Automation/Commands/TextGroup/CheckTextCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; namespace taskt.Core.Automation.Commands { @@ -14,13 +15,13 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_function))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class CheckTextCommand : ScriptCommand, ITextCompareProperties + public sealed class CheckTextCommand : ScriptCommand, ITextCheckProperties, IResultProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(TextControls), nameof(TextControls.v_Text_MultiLine))] [PropertyDescription("Text to be Checked")] [PropertyDisplayText(true, "Text to be Checked")] - public string v_userVariableName { get; set; } + public string v_Text { get; set; } [XmlAttribute] //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] @@ -45,8 +46,8 @@ public sealed class CheckTextCommand : ScriptCommand, ITextCompareProperties //[PropertyAddtionalParameterInfo("Has Value", "Result is **TRUE** or **FALSE**")] //[PropertyAddtionalParameterInfo("Is a Number", "Result is **TRUE** or **FALSE**")] //[PropertyAddtionalParameterInfo("Is a Boolean", "Result is **TRUE** or **FALSE**")] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CheckMethod))] + public string v_CheckMethod { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(TextControls), nameof(TextControls.v_Text))] @@ -56,7 +57,7 @@ public sealed class CheckTextCommand : ScriptCommand, ITextCompareProperties [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_applyToVariableName { get; set; } + public string v_Result { get; set; } [XmlAttribute] //[PropertyDescription("Case sensitive")] @@ -67,12 +68,12 @@ public sealed class CheckTextCommand : ScriptCommand, ITextCompareProperties //[PropertyUISelectionOption("No")] //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] //[PropertyIsOptional(true, "Yes")] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveYes))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveYes))] public string v_CaseSensitive { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_TrimBeforeCompare))] - public string v_TrimBeforeCompare { get; set; } + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_TrimBeforeCheck))] + public string v_TrimBeforeCheck { get; set; } public CheckTextCommand() { @@ -126,12 +127,12 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) //resultValue.StoreInUserVariable(engine, v_applyToVariableName); - var targetText = v_userVariableName.ExpandValueOrUserVariable(engine); + var targetText = v_Text.ExpandValueOrUserVariable(engine); var searchText = v_CheckParameter.ExpandValueOrUserVariable(engine); - var compreFunc = this.GetCompareFunction(engine); + var compreFunc = this.GetTextCheckFunction(engine); - compreFunc(targetText, searchText).StoreInUserVariable(engine, v_applyToVariableName); + compreFunc(targetText, searchText).StoreInUserVariable(engine, v_Result); } //private void cmbCheckMethod_SelectionChanged(object sender, EventArgs e) diff --git a/taskt/Core/Automation/Commands/Text/ConcatenateTextVariableCommand.cs b/taskt/Core/Automation/Commands/TextGroup/ConcatenateTextVariableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/ConcatenateTextVariableCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/ConcatenateTextVariableCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/CountWordInTextCommand.cs b/taskt/Core/Automation/Commands/TextGroup/CountWordInTextCommand.cs similarity index 95% rename from taskt/Core/Automation/Commands/Text/CountWordInTextCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/CountWordInTextCommand.cs index 644b8ab36..63891c965 100644 --- a/taskt/Core/Automation/Commands/Text/CountWordInTextCommand.cs +++ b/taskt/Core/Automation/Commands/TextGroup/CountWordInTextCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; namespace taskt.Core.Automation.Commands { @@ -35,7 +36,7 @@ public class CountWordInTextCommand : ScriptCommand public string v_Result { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveYes))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveYes))] public string v_CaseSensitive { get; set; } [XmlAttribute] diff --git a/taskt/Core/Automation/Commands/Text/CreateTextVariableCommand.cs b/taskt/Core/Automation/Commands/TextGroup/CreateTextVariableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/CreateTextVariableCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/CreateTextVariableCommand.cs diff --git a/taskt/Core/Automation/Commands/_General/EM_TextComparePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/TextGroup/EM_TextCheckPropertiesExtensionMethods.cs similarity index 92% rename from taskt/Core/Automation/Commands/_General/EM_TextComparePropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/TextGroup/EM_TextCheckPropertiesExtensionMethods.cs index f0bd93ad8..c2e629068 100644 --- a/taskt/Core/Automation/Commands/_General/EM_TextComparePropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/TextGroup/EM_TextCheckPropertiesExtensionMethods.cs @@ -1,18 +1,18 @@ using System; using System.Text.RegularExpressions; -namespace taskt.Core.Automation.Commands +namespace taskt.Core.Automation.Commands.TextGroup { - public static class EM_TextComparePropertiesExtensionMethods + public static class EM_TextCheckPropertiesExtensionMethods { /// - /// Get Pre Function for Text Compare + /// Get Pre Function for Text check /// /// /// /// /// - private static Func GetPreFunction(ITextCompareProperties command, Engine.AutomationEngineInstance engine) + private static Func GetPreFunction(ITextCheckProperties command, Engine.AutomationEngineInstance engine) { var sc = command.ToScriptCommand(); @@ -27,7 +27,7 @@ private static Func GetPreFunction(ITextCompareProperties comman caseFunc = new Func(str => str.ToLower()); } - var trim = sc.ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_TrimBeforeCompare), engine); + var trim = sc.ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_TrimBeforeCheck), engine); Func preFunc; switch (trim) { @@ -56,7 +56,7 @@ private static Func GetPreFunction(ITextCompareProperties comman }); break; default: - throw new Exception($"Strange Trim Method. Value: '{command.v_TrimBeforeCompare}', Expand: '{trim}'"); + throw new Exception($"Strange Trim Method. Value: '{command.v_TrimBeforeCheck}', Expand: '{trim}'"); } return preFunc; @@ -100,18 +100,18 @@ private static string ConvertWildcardToRegex(string str) } /// - /// create compare function + /// create/get text check function /// /// /// /// Func(targetString, conditionString, bool) /// - public static Func GetCompareFunction(this ITextCompareProperties command, Engine.AutomationEngineInstance engine) + public static Func GetTextCheckFunction(this ITextCheckProperties command, Engine.AutomationEngineInstance engine) { var preFunc = GetPreFunction(command, engine); Func ret; - var compareMethod = command.ToScriptCommand().ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_CompareMethod), engine); + var compareMethod = command.ToScriptCommand().ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_CheckMethod), engine); switch (compareMethod) { case "contains": @@ -225,7 +225,7 @@ public static Func GetCompareFunction(this ITextComparePro }); break; default: - throw new Exception($"Strange Compare Method. Value: '{command.v_CompareMethod}', Expand: '{compareMethod}'"); + throw new Exception($"Strange Check Method. Value: '{command.v_CheckMethod}', Expand: '{compareMethod}'"); } return ret; } diff --git a/taskt/Core/Automation/Commands/Text/EncryptDecryptTextCommand.cs b/taskt/Core/Automation/Commands/TextGroup/EncryptDecryptTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/EncryptDecryptTextCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/EncryptDecryptTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/ExtractionTextCommand.cs b/taskt/Core/Automation/Commands/TextGroup/ExtractionTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/ExtractionTextCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/ExtractionTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/GetTextIndexOfCommand.cs b/taskt/Core/Automation/Commands/TextGroup/GetTextIndexOfCommand.cs similarity index 96% rename from taskt/Core/Automation/Commands/Text/GetTextIndexOfCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/GetTextIndexOfCommand.cs index 6fbb4c327..5351f4973 100644 --- a/taskt/Core/Automation/Commands/Text/GetTextIndexOfCommand.cs +++ b/taskt/Core/Automation/Commands/TextGroup/GetTextIndexOfCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; namespace taskt.Core.Automation.Commands { @@ -35,7 +36,7 @@ public class GetTextIndexOfCommand : ScriptCommand public string v_Result { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveYes))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveYes))] public string v_CaseSensitive { get; set; } [XmlAttribute] diff --git a/taskt/Core/Automation/Commands/Text/GetTextLastIndexOfCommand.cs b/taskt/Core/Automation/Commands/TextGroup/GetTextLastIndexOfCommand.cs similarity index 96% rename from taskt/Core/Automation/Commands/Text/GetTextLastIndexOfCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/GetTextLastIndexOfCommand.cs index 357e7065a..8386f7978 100644 --- a/taskt/Core/Automation/Commands/Text/GetTextLastIndexOfCommand.cs +++ b/taskt/Core/Automation/Commands/TextGroup/GetTextLastIndexOfCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; namespace taskt.Core.Automation.Commands { @@ -35,7 +36,7 @@ public class GetTextLastIndexOfCommand : ScriptCommand public string v_Result { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveYes))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveYes))] public string v_CaseSensitive { get; set; } [XmlAttribute] diff --git a/taskt/Core/Automation/Commands/Text/GetTextLengthCommand.cs b/taskt/Core/Automation/Commands/TextGroup/GetTextLengthCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/GetTextLengthCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/GetTextLengthCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/GetTextNthIndexOfCommand.cs b/taskt/Core/Automation/Commands/TextGroup/GetTextNthIndexOfCommand.cs similarity index 96% rename from taskt/Core/Automation/Commands/Text/GetTextNthIndexOfCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/GetTextNthIndexOfCommand.cs index 8edcb9bc2..a7b2d54ce 100644 --- a/taskt/Core/Automation/Commands/Text/GetTextNthIndexOfCommand.cs +++ b/taskt/Core/Automation/Commands/TextGroup/GetTextNthIndexOfCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; namespace taskt.Core.Automation.Commands { @@ -47,7 +48,7 @@ public class GetTextNthIndexOfCommand : ScriptCommand public string v_Result { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveYes))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveYes))] public string v_CaseSensitive { get; set; } [XmlAttribute] diff --git a/taskt/Core/Automation/Commands/Text/GetWordCountCommand.cs b/taskt/Core/Automation/Commands/TextGroup/GetWordCountCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/GetWordCountCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/GetWordCountCommand.cs diff --git a/taskt/Core/Automation/Commands/TextGroup/ITextCheckProperties.cs b/taskt/Core/Automation/Commands/TextGroup/ITextCheckProperties.cs new file mode 100644 index 000000000..30cb2814e --- /dev/null +++ b/taskt/Core/Automation/Commands/TextGroup/ITextCheckProperties.cs @@ -0,0 +1,18 @@ +namespace taskt.Core.Automation.Commands.TextGroup +{ + /// + /// text check properties + /// + public interface ITextCheckProperties : ICheckProperties + { + /// + /// check method is case sensitive or not + /// + string v_CaseSensitive { get; set; } + + /// + /// trim text before check + /// + string v_TrimBeforeCheck { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/Text/ModifyTextCommand.cs b/taskt/Core/Automation/Commands/TextGroup/ModifyTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/ModifyTextCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/ModifyTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/ReadTextFileCommand.cs b/taskt/Core/Automation/Commands/TextGroup/ReadTextFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/ReadTextFileCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/ReadTextFileCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/RegExExtractionTextCommand.cs b/taskt/Core/Automation/Commands/TextGroup/RegExExtractionTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/RegExExtractionTextCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/RegExExtractionTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/ReplaceTextCommand.cs b/taskt/Core/Automation/Commands/TextGroup/ReplaceTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/ReplaceTextCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/ReplaceTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/SplitTextCommand.cs b/taskt/Core/Automation/Commands/TextGroup/SplitTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/SplitTextCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/SplitTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Text/SubstringTextCommand.cs b/taskt/Core/Automation/Commands/TextGroup/SubstringTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/SubstringTextCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/SubstringTextCommand.cs diff --git a/taskt/Core/Automation/Commands/TextCompareSelectMethodControls.cs b/taskt/Core/Automation/Commands/TextGroup/VP_TextCheckMethodControls.cs similarity index 53% rename from taskt/Core/Automation/Commands/TextCompareSelectMethodControls.cs rename to taskt/Core/Automation/Commands/TextGroup/VP_TextCheckMethodControls.cs index 1e3f3ea49..6fb3aca60 100644 --- a/taskt/Core/Automation/Commands/TextCompareSelectMethodControls.cs +++ b/taskt/Core/Automation/Commands/TextGroup/VP_TextCheckMethodControls.cs @@ -1,14 +1,14 @@ using taskt.Core.Automation.Attributes.PropertyAttributes; -namespace taskt.Core.Automation.Commands +namespace taskt.Core.Automation.Commands.TextGroup { - public static class TextCompareSelectMethodControls + public static class VP_TextCheckMethodControls { /// - /// compare method + /// text check method /// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Compare Method")] + [PropertyDescription("Check Method")] [PropertyUISelectionOption("Contains")] [PropertyUISelectionOption("Starts with")] [PropertyUISelectionOption("Ends with")] @@ -46,54 +46,33 @@ public static class TextCompareSelectMethodControls [PropertyDetailSampleUsage("**Is Not Number**", "This determines whether it is **Not** a number.")] [PropertyDetailSampleUsage("**Is Not Boolean**", "This determines whether it is **Not** a boolean, such as **True** or **False**.")] [PropertyDetailSampleUsage("**Is Not Boolean Loose**", "This determines whether it is **Not** a loose boolean, such as **True**, **False**, **Yes**, **No**, **1**, or **0**.")] - [PropertyDisplayText(true, "Compare Method")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[InputSpecification("", true)] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(false)] - //[PropertyParameterOrder(5000)] - public static string v_CompareMethod { get; } + [PropertyDisplayText(true, "Check Method")] + public static string v_CheckMethod { get; } /// - /// compare method is case sensitive or not + /// check method is case sensitive or not /// [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] [PropertyDescription("Case Sensitive")] [PropertyIsOptional(true, "No")] [PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] - [PropertyDetailSampleUsage("**Yes**", "Comparison Method is Case Sensitive")] - [PropertyDetailSampleUsage("**No**", "Comparison Method is NOT Case Sensitive")] + [PropertyDetailSampleUsage("**Yes**", "Check Method is Case Sensitive")] + [PropertyDetailSampleUsage("**No**", "Check Method is NOT Case Sensitive")] [PropertyDisplayText(false, "Case Sensitive")] - //[InputSpecification("", true)] - //[Remarks("")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyUISelectionOption("Yes")] - //[PropertyUISelectionOption("No")] - //[PropertyParameterOrder(5000)] public static string v_CaseSensitiveNo { get; } /// - /// compare method is case sensitive or not + /// check method is case sensitive or not /// - [PropertyVirtualProperty(nameof(TextCompareSelectMethodControls), nameof(TextCompareSelectMethodControls.v_CaseSensitiveNo))] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveNo))] [PropertyIsOptional(true, "Yes")] - //[PropertyDescription("Case Sensitive")] - //[InputSpecification("", true)] - //[Remarks("")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyUISelectionOption("Yes")] - //[PropertyUISelectionOption("No")] - //[PropertyDetailSampleUsage("**Yes**", "Comparison Method is Case Sensitive")] - //[PropertyDetailSampleUsage("**No**", "Comparison Method is NOT Case Sensitive")] - //[PropertyDisplayText(false, "Case Sensitive")] - //[PropertyParameterOrder(5000)] public static string v_CaseSensitiveYes { get; } /// - /// trim before compare + /// trim before check /// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Trim Before Compare")] + [PropertyDescription("Trim Before Check")] [PropertyUISelectionOption("Trim")] [PropertyUISelectionOption("Trim Start")] [PropertyUISelectionOption("Trim End")] @@ -103,46 +82,7 @@ public static class TextCompareSelectMethodControls [PropertyDetailSampleUsage("**Trim Start**", "Remove White Space at the Start of Text")] [PropertyDetailSampleUsage("**Trim End**", "Remove White Space at the End of Text")] [PropertyDetailSampleUsage("**No**", "Not Trim")] - [PropertyDisplayText(false, "Trim Before Compare")] - //[InputSpecification("", true)] - //[Remarks("")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterOrder(5000)] - public static string v_TrimBeforeCompare { get; } - - /// - /// select method, select one item - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Select Method")] - [PropertyUISelectionOption("First")] - [PropertyUISelectionOption("Last")] - [PropertyUISelectionOption("Index")] - [PropertyDetailSampleUsage("**First**", "Specify the First Item")] - [PropertyDetailSampleUsage("**Last**", "Specify the Last Item")] - [PropertyDetailSampleUsage("**Index**", "the Item specifed by Index. **0** means First Item")] - [PropertyIsOptional(true, "First")] - [PropertyDisplayText(false, "Select Method")] - //[InputSpecification("", true)] - //[Remarks("")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterOrder(5000)] - public static string v_SelectMethod { get; } - - /// - /// select item index - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Selection Item Index")] - [InputSpecification("Selection Item Index", true)] - [PropertyDetailSampleUsage("**0**", "Specify the First Item")] - [PropertyDetailSampleUsage("**{{{vIndex}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Item Index")] - //[PropertyIsOptional(true, "0")] - //[PropertyFirstValue("0")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] - public static string v_SelectItemIndex { get; } + [PropertyDisplayText(false, "Trim Before Check")] + public static string v_TrimBeforeCheck { get; } } } diff --git a/taskt/Core/Automation/Commands/Text/WriteTextFileCommand.cs b/taskt/Core/Automation/Commands/TextGroup/WriteTextFileCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Text/WriteTextFileCommand.cs rename to taskt/Core/Automation/Commands/TextGroup/WriteTextFileCommand.cs diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationCheckUIElementExistsByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationCheckUIElementExistsByXPathCommand.cs deleted file mode 100644 index 0f7621fa1..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationCheckUIElementExistsByXPathCommand.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement")] - [Attributes.ClassAttributes.CommandSettings("Check UIElement Exists By XPath")] - [Attributes.ClassAttributes.Description("This command allows you to check UIElement existence.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to check UIElement existence.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationCheckUIElementExistsByXPathCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] - public string v_SearchXPath { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] - [Remarks("When the UIElement exists, Result value is **True**")] - public string v_Result { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] - [PropertyIsOptional(true, "0")] - [PropertyFirstValue("0")] - public string v_WaitTime { get; set; } - - public UIAutomationCheckUIElementExistsByXPathCommand() - { - //this.CommandName = "UIAutomationCheckElementExistByXPathCommand"; - //this.SelectionName = "Check Element Exist By XPath"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - try - { - UIElementControls.SearchGUIElementByXPath(this, engine); - true.StoreInUserVariable(engine, v_Result); - } - catch - { - false.StoreInUserVariable(engine, v_Result); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationCheckUIElementExistsCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationCheckUIElementExistsCommand.cs deleted file mode 100644 index 57009f6e7..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationCheckUIElementExistsCommand.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Data; -using System.Windows.Forms; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement")] - [Attributes.ClassAttributes.CommandSettings("Check UIElement Exists")] - [Attributes.ClassAttributes.Description("This command allows you to to check UIElement existence.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to check UIElement existence")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationCheckUIElementExistsCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] - public DataTable v_SearchParameters { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] - [Remarks("When the UIElement exists, Result value is **True**")] - public string v_Result { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] - [PropertyIsOptional(true, "0")] - [PropertyFirstValue("0")] - public string v_WaitTime { get; set; } - - public UIAutomationCheckUIElementExistsCommand() - { - //this.CommandName = "UIAutomationCheckElementExistCommand"; - //this.SelectionName = "Check Element Exist"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - try - { - UIElementControls.SearchGUIElement(this, engine); - true.StoreInUserVariable(engine, v_Result); - } - catch - { - false.StoreInUserVariable(engine, v_Result); - } - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); - UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - - var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); - DataTableControls.BeforeValidate_NoRowAdding(dgv, v_SearchParameters); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationClickUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationClickUIElementCommand.cs deleted file mode 100644 index 39c2aaff3..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationClickUIElementCommand.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("UIElement Action")] - [Attributes.ClassAttributes.CommandSettings("Click UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to Click UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Click UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationClickUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_MouseClickType))] - public string v_ClickType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_XOffsetAdjustment))] - public string v_XOffset { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_YOffsetAdjustment))] - public string v_YOffset { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Activate Window before Click")] - [PropertyIsOptional(true, "Yes")] - public string v_ActivateWindow { get; set; } - - public UIAutomationClickUIElementCommand() - { - //this.CommandName = "UIAutomationClickElementCommand"; - //this.SelectionName = "Click Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - string windowName = UIElementControls.GetWindowName(targetElement); - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateWindow), engine)) - { - var activateWindow = new ActivateWindowCommand() - { - v_WindowName = windowName - }; - activateWindow.RunCommand(engine); - } - - System.Windows.Point point; - try - { - if (!targetElement.TryGetClickablePoint(out point)) - { - var moveWindow = new MoveWindowCommand() - { - v_WindowName = windowName, - v_XPosition = "0", - v_YPosition = "0" - }; - moveWindow.RunCommand(engine); - targetElement.TryGetClickablePoint(out point); - } - if ((point.X < 0.0) || (point.Y < 0.0)) - { - var moveWindow = new MoveWindowCommand() - { - v_WindowName = windowName, - v_XPosition = "0", - v_YPosition = "0" - }; - moveWindow.RunCommand(engine); - - if (!targetElement.TryGetClickablePoint(out point)) - { - throw new Exception("No Clickable Point in UIElement '" + v_TargetElement + "'"); - } - } - } - catch (Exception) - { - throw new Exception("No Clickable Point in UIElement '" + v_TargetElement + "'"); - } - - var click = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ClickType), engine); - var xAd = this.ExpandValueOrUserVariableAsInteger(nameof(v_XOffset), engine); - var yAd = this.ExpandValueOrUserVariableAsInteger(nameof(v_YOffset), engine); - - var mouseClick = new MoveMouseCommand() - { - v_MouseClick = click, - v_XMousePosition = (point.X + xAd).ToString(), - v_YMousePosition = (point.Y + yAd).ToString() - }; - mouseClick.RunCommand(engine); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationExpandCollapseItemsInUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationExpandCollapseItemsInUIElementCommand.cs deleted file mode 100644 index 56054fcd2..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationExpandCollapseItemsInUIElementCommand.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Windows.Automation; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("UIElement Action")] - [Attributes.ClassAttributes.CommandSettings("Expand Collapse Items In UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to Expand or Collapse Items in UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Expand or Collapse Items in UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationExpandCollapseItemsInUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyDescription("Items State")] - [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)] - [InputSpecification("", true)] - [PropertyUISelectionOption("Expand")] - [PropertyUISelectionOption("Collapse")] - [Remarks("")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - [PropertyValidationRule("Items State", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "State")] - public string v_ItemsState { get; set; } - - public UIAutomationExpandCollapseItemsInUIElementCommand() - { - //this.CommandName = "UIAutomationExpandCollapseItemsInElementCommand"; - //this.SelectionName = "Expand Collapse Items In Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - //var state = v_ItemsState.ExpandValueOrUserVariableAsSelectionItem("v_ItemsState", this, engine); - var state = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ItemsState), engine); - - if (targetElement.TryGetCurrentPattern(ExpandCollapsePattern.Pattern, out object exColPtn)) - { - switch (state) - { - case "expand": - ((ExpandCollapsePattern)exColPtn).Expand(); - break; - case "collapse": - ((ExpandCollapsePattern)exColPtn).Collapse(); - break; - } - } - else - { - throw new Exception("UIElement '" + v_TargetElement + "' does not support Expand/Collapse"); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetChildrenUIElementsInformationCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetChildrenUIElementsInformationCommand.cs deleted file mode 100644 index f8cbd25e8..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetChildrenUIElementsInformationCommand.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Data; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using System.Windows.Forms; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Get From UIElement")] - [Attributes.ClassAttributes.CommandSettings("Get Children Elements Information")] - [Attributes.ClassAttributes.Description("This command allows you to get Children UIElements Information from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Children UIElements Information from UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationGetChildrenUIElementsInformationCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_RootElement { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] - public DataTable v_SearchParameters { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_ResultVariable { get; set; } - - public UIAutomationGetChildrenUIElementsInformationCommand() - { - //this.CommandName = "UIAutomationGetChildrenElementsInformationCommand"; - //this.SelectionName = "Get Children Elements Information"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_RootElement.ExpandUserVariableAsUIElement(engine); - - var elems = UIElementControls.GetChildrenUIElements(targetElement, v_SearchParameters, engine); - - string result = ""; - - int counts = elems.Count; - for (int i = 0; i < counts; i++) - { - var elem = elems[i]; - result += "Index: " + i + ", Name: " + elem.Current.Name + ", LocalizedControlType: " + elem.Current.LocalizedControlType + ", ControlType: " + UIElementControls.GetControlTypeText(elem.Current.ControlType) + "\n"; - } - result.Trim().StoreInUserVariable(engine, v_ResultVariable); - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); - UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - - var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); - DataTableControls.BeforeValidate_NoRowAdding(dgv, v_SearchParameters); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetPropertyValueFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetPropertyValueFromUIElementCommand.cs deleted file mode 100644 index 7fa2bb351..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetPropertyValueFromUIElementCommand.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.Windows.Automation; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Get From UIElement")] - [Attributes.ClassAttributes.CommandSettings("Get Property Value From UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to get Property Value from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Property Value from UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationGetPropertyValueFromUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Property Name")] - [PropertyUISelectionOption("Name")] - [PropertyUISelectionOption("ControlType")] - [PropertyUISelectionOption("LocalizedControlType")] - [PropertyUISelectionOption("IsEnabled")] - [PropertyUISelectionOption("IsOffscreen")] - [PropertyUISelectionOption("IsKeyboardFocusable")] - [PropertyUISelectionOption("HasKeyboardFocusable")] - [PropertyUISelectionOption("AccessKey")] - [PropertyUISelectionOption("ProcessId")] - [PropertyUISelectionOption("AutomationId")] - [PropertyUISelectionOption("FrameworkId")] - [PropertyUISelectionOption("ClassName")] - [PropertyUISelectionOption("IsContentElement")] - [PropertyUISelectionOption("IsPassword")] - [PropertyUISelectionOption("AcceleratorKey")] - [PropertyUISelectionOption("HelpText")] - [PropertyUISelectionOption("IsControlElement")] - [PropertyUISelectionOption("IsRequiredForForm")] - [PropertyUISelectionOption("ItemStatus")] - [PropertyUISelectionOption("ItemType")] - [PropertyUISelectionOption("NativeWindowHandle")] - [PropertyValidationRule("Property", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Property")] - public string v_PropertyName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_Result { get; set; } - - public UIAutomationGetPropertyValueFromUIElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - var propName = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PropertyName), engine); - switch (propName) - { - case "name": - propName = "Name"; - break; - case "controltype": - propName = "ControlType"; - break; - case "localizedcontroltype": - propName = "LocalizedControlType"; - break; - case "isenabled": - propName = "IsEnabled"; - break; - case "isoffscreen": - propName = "IsOffscreen"; - break; - case "iskeyboardfocusable": - propName = "IsKeyboardFocusable"; - break; - case "haskeyboardfocusable": - propName = "HasKeyboardFocusable"; - break; - case "accesskey": - propName = "AccessKey"; - break; - case "processid": - propName = "ProcessId"; - break; - case "automationid": - propName = "AutomationId"; - break; - case "frameworkid": - propName = "FrameworkId"; - break; - case "classname": - propName = "ClassName"; - break; - case "iscontentelement": - propName = "IsContentElement"; - break; - case "ispassword": - propName = "IsPassword"; - break; - case "acceleratorkey": - propName = "AcceleratorKey"; - break; - case "helptext": - propName = "HelpText"; - break; - case "iscontrolelement": - propName = "IsControlElement"; - break; - case "isrequiredforform": - propName = "IsRequiredForForm"; - break; - case "itemstatus": - propName = "ItemStatus"; - break; - case "itemtype": - propName = "ItemType"; - break; - case "nativewindowhandle": - propName = "NativeWindowHandle"; - break; - } - - string v; - if (propName == "ControlType") - { - var c = (ControlType)targetElement.Current.GetType().GetProperty(propName).GetValue(targetElement.Current); - v = UIElementControls.GetControlTypeText(c); - } - else - { - v = targetElement.Current.GetType().GetProperty(propName)?.GetValue(targetElement.Current)?.ToString() ?? ""; - } - - v.StoreInUserVariable(engine, v_Result); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetSelectedStateFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetSelectedStateFromUIElementCommand.cs deleted file mode 100644 index 5e0babdb9..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetSelectedStateFromUIElementCommand.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Windows.Automation; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Get From UIElement")] - [Attributes.ClassAttributes.CommandSettings("Get Selected State From UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to get Selected State from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Selected State from UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationGetSelectedStateFromUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] - [Remarks("When UIElement is Selected, Result is **True**")] - public string v_ResultVariable { get; set; } - - public UIAutomationGetSelectedStateFromUIElementCommand() - { - //this.CommandName = "UIAutomationGetSelectedStateFromElementCommand"; - //this.SelectionName = "Get Selected State From Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - bool checkState; - if (targetElement.TryGetCurrentPattern(TogglePattern.Pattern, out object patternObj)) - { - checkState = (((TogglePattern)patternObj).Current.ToggleState == ToggleState.On); - } - else if (targetElement.TryGetCurrentPattern(SelectionItemPattern.Pattern, out patternObj)) - { - checkState = ((SelectionItemPattern)patternObj).Current.IsSelected; - } - else - { - throw new Exception("Thie UIElement does not have Selected State"); - } - checkState.StoreInUserVariable(engine, v_ResultVariable); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetSelectionItemsFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetSelectionItemsFromUIElementCommand.cs deleted file mode 100644 index 2f0deec94..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetSelectionItemsFromUIElementCommand.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Get From UIElement")] - [Attributes.ClassAttributes.CommandSettings("Get Selection Items From UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to get Selection Items Name from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Selection Items Name from UIElement. Search for only Child Elements.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationGetSelectionItemsFromUIElementCommand : ScriptCommand, ICanHandleList - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] - public string v_ListVariable { get; set; } - - public UIAutomationGetSelectionItemsFromUIElementCommand() - { - //this.CommandName = "UIAutomationGetSelectionItemsFromElementCommand"; - //this.SelectionName = "Get Selection Items From Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - var items = UIElementControls.GetSelectionItems(targetElement); - - var res = new List(); - foreach(var item in items) - { - res.Add(item.Current.Name); - } - //res.StoreInUserVariable(engine, v_ListVariable); - this.StoreListInUserVariable(res, nameof(v_ListVariable), engine); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetTextFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetTextFromUIElementCommand.cs deleted file mode 100644 index d3f8bf0ab..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetTextFromUIElementCommand.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Get From UIElement")] - [Attributes.ClassAttributes.CommandSettings("Get Text From UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to get Text Value from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Text Value from UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationGetTextFromUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_TextVariable { get; set; } - - public UIAutomationGetTextFromUIElementCommand() - { - //this.CommandName = "UIAutomationGetTextFromElementCommand"; - //this.SelectionName = "Get Text From Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - string res = UIElementControls.GetTextValue(targetElement); - res.StoreInUserVariable(engine, v_TextVariable); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetUIElementPositionCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetUIElementPositionCommand.cs deleted file mode 100644 index 9943e0e64..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetUIElementPositionCommand.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Get From UIElement")] - [Attributes.ClassAttributes.CommandSettings("Get UIElement Position")] - [Attributes.ClassAttributes.Description("This command allows you to get UIElement Position.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement Position.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationGetUIElementPositionCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] - [PropertyDescription("Variable Name to Store X Position")] - [PropertyIsOptional(true)] - [PropertyValidationRule("X Position", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(true, "X")] - public string v_XPosition { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] - [PropertyDescription("Variable Name to Store Y Position")] - [PropertyIsOptional(true)] - [PropertyValidationRule("Y Position", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(true, "Y Position")] - public string v_YPosition { get; set; } - - [XmlAttribute] - [PropertyDescription("Base position")] - [InputSpecification("", true)] - [SampleUsage("")] - [Remarks("")] - [PropertyUISelectionOption("Top Left")] - [PropertyUISelectionOption("Bottom Right")] - [PropertyUISelectionOption("Top Right")] - [PropertyUISelectionOption("Bottom Left")] - [PropertyUISelectionOption("Center")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - [PropertyIsOptional(true, "Top Left")] - public string v_PositionBase { get; set; } - - public UIAutomationGetUIElementPositionCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - var rct = targetElement.Current.BoundingRectangle; - - double x = 0.0, y = 0.0; - switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) - { - case "top left": - x = rct.Left; - y = rct.Top; - break; - case "bottom right": - x = rct.Right; - y = rct.Bottom; - break; - case "top right": - x = rct.Right; - y = rct.Top; - break; - case "bottom left": - x = rct.Left; - y = rct.Bottom; - break; - case "center": - x = (rct.Right - rct.Left) / 2.0; - y = (rct.Bottom - rct.Top) / 2.0; - break; - } - - if (!string.IsNullOrEmpty(v_XPosition)) - { - x.StoreInUserVariable(engine, v_XPosition); - } - if (!string.IsNullOrEmpty(v_YPosition)) - { - y.StoreInUserVariable(engine, v_YPosition); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetUIElementSizeCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetUIElementSizeCommand.cs deleted file mode 100644 index 94460ae9b..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetUIElementSizeCommand.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Get From UIElement")] - [Attributes.ClassAttributes.CommandSettings("Get UIElement Size")] - [Attributes.ClassAttributes.Description("This command allows you to get UIElement Size.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement Size.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationGetUIElementSizeCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] - [PropertyDescription("Variable Name to Store Width")] - [PropertyIsOptional(true)] - [PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(true, "Width")] - public string v_Width { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] - [PropertyDescription("Variable Name to Store Height")] - [PropertyIsOptional(true)] - [PropertyValidationRule("Height", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(true, "Height")] - public string v_Height { get; set; } - - public UIAutomationGetUIElementSizeCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - var rct = targetElement.Current.BoundingRectangle; - if (!string.IsNullOrEmpty(v_Width)) - { - rct.Width.StoreInUserVariable(engine, v_Width); - } - if (!string.IsNullOrEmpty(v_Height)) - { - rct.Height.StoreInUserVariable(engine, v_Height); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetUIElementTreeXMLFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetUIElementTreeXMLFromUIElementCommand.cs deleted file mode 100644 index a2bf05bde..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetUIElementTreeXMLFromUIElementCommand.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Get From UIElement")] - [Attributes.ClassAttributes.CommandSettings("Get UIElement Tree XML From UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to get UIElement Tree XML from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement Tree XML from UIElement. XML content is based on WinAppDriver UI Recorder.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationGetUIElementTreeXMLFromUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyDescription("Variable Name to store XML")] - [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)] - [InputSpecification("Variable Name", true)] - [PropertyDetailSampleUsage("**vXML**", PropertyDetailSampleUsage.ValueType.VariableName)] - [PropertyDetailSampleUsage("**{{{vXML}}}**", PropertyDetailSampleUsage.ValueType.VariableName)] - [Remarks("XML content is based on WinAppDriver UI Recorder.")] - [PropertyShowSampleUsageInDescription(true)] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - [PropertyIsVariablesList(true)] - [PropertyValidationRule("Variable", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Store")] - public string v_XMLVariable { get; set; } - - public UIAutomationGetUIElementTreeXMLFromUIElementCommand() - { - //this.CommandName = "UIAutomationGetElementTreeXMLFromElementCommand"; - //this.SelectionName = "Get Element Tree XML From Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - //var xml = AutomationElementControls.GetElementXml(targetElement, out _); - (var xml, _) = UIElementControls.GetElementXml(targetElement); - using(System.IO.StringWriter sw = new System.IO.StringWriter()) - { - xml.Save(sw); - sw.ToString().StoreInUserVariable(engine, v_XMLVariable); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationScrollUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationScrollUIElementCommand.cs deleted file mode 100644 index 283759bb8..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationScrollUIElementCommand.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Windows.Automation; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("UIElement Action")] - [Attributes.ClassAttributes.CommandSettings("Scroll UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to Scroll UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Scroll UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationScrollUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyDescription("ScrollBar Type")] - [InputSpecification("", true)] - [PropertyUISelectionOption("Vertical")] - [PropertyUISelectionOption("Horizonal")] - [Remarks("")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - [PropertyValidationRule("ScrollBar Type", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Type")] - public string v_ScrollBarType { get; set; } - - [XmlAttribute] - [PropertyDescription("Scroll Method")] - [InputSpecification("", true)] - [PropertyUISelectionOption("Scroll Small Down or Right")] - [PropertyUISelectionOption("Scroll Large Down or Right")] - [PropertyUISelectionOption("Scroll Small Up or Left")] - [PropertyUISelectionOption("Scroll Large Up or Left")] - [Remarks("")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - [PropertyValidationRule("Scroll Method", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Method")] - public string v_DirectionAndAmount{ get; set; } - - public UIAutomationScrollUIElementCommand() - { - //this.CommandName = "UIAutomationScrollElementCommand"; - //this.SelectionName = "Scroll Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - //var scrollbarType = v_ScrollBarType.ExpandValueOrUserVariableAsSelectionItem("v_ScrollBarType", this, engine); - var scrollbarType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ScrollBarType), engine); - - //var dirAndAmo = v_DirectionAndAmount.ExpandValueOrUserVariableAsSelectionItem("v_DirectionAndAmount", this, engine); - var dirAndAmo = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_DirectionAndAmount), engine); - ScrollAmount amount = ScrollAmount.NoAmount; - switch (dirAndAmo) - { - case "scroll small down or right": - amount = ScrollAmount.SmallIncrement; - break; - case "scroll large down or right": - amount = ScrollAmount.LargeIncrement; - break; - case "scroll small up or left": - amount = ScrollAmount.SmallDecrement; - break; - case "scroll large up or left": - amount = ScrollAmount.LargeDecrement; - break; - } - - if (!targetElement.TryGetCurrentPattern(ScrollPattern.Pattern, out object scrollPtn)) - { - if (targetElement.Current.ControlType == ControlType.ScrollBar) - { - var parentElement = UIElementControls.GetParentUIElement(targetElement); - if (!parentElement.TryGetCurrentPattern(ScrollPattern.Pattern, out scrollPtn)) - { - throw new Exception("UIElement '" + v_TargetElement + "' does not have ScrollBar"); - } - } - else - { - throw new Exception("UIElement '" + v_TargetElement + "' is not ScrollBar and does not have ScrollBar"); - } - } - ScrollPattern sp = (ScrollPattern)scrollPtn; - switch (scrollbarType) - { - case "horizonal": - sp.ScrollHorizontal(amount); - break; - case "vertical": - sp.ScrollVertical(amount); - break; - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchChildUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchChildUIElementCommand.cs deleted file mode 100644 index 638bf09d3..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchChildUIElementCommand.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Data; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using System.Windows.Forms; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement")] - [Attributes.ClassAttributes.CommandSettings("Search Child UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to get Child Element from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Child UIElement from UIElement. Search only for Child UIElements.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSearchChildUIElementCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - [PropertyDescription("Root UIElement Variable")] - public string v_RootElement { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] - public DataTable v_SearchParameters { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Child UIElement Index")] - [InputSpecification("Index", true)] - [PropertyDetailSampleUsage("**0**", "Specfity the First UIElement")] - [PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "Index")] - [PropertyDetailSampleUsage("**{{{vIndex}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Index")] - [Remarks("")] - [PropertyShowSampleUsageInDescription(true)] - [PropertyValidationRule("Index", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] - [PropertyDisplayText(true, "Index")] - public string v_Index { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_NewOutputUIElementName))] - [PropertyDescription("UIElement Variable Name to Store Child UIElement")] - public string v_AutomationElementVariable { get; set; } - - public UIAutomationSearchChildUIElementCommand() - { - //this.CommandName = "UIAutomationGetChildElementCommand"; - //this.SelectionName = "Get Child Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var rootElement = v_RootElement.ExpandUserVariableAsUIElement(engine); - int index = v_Index.ExpandValueOrUserVariableAsInteger("v_Index", engine); - - var elems = UIElementControls.GetChildrenUIElements(rootElement, v_SearchParameters, engine); - if (elems.Count > 0) - { - elems[index].StoreInUserVariable(engine, v_AutomationElementVariable); - } - else - { - throw new Exception("UIElement not found"); - } - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); - UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - - var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); - DataTableControls.BeforeValidate_NoRowAdding(dgv, v_SearchParameters); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchParentUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchParentUIElementCommand.cs deleted file mode 100644 index 443a301e1..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchParentUIElementCommand.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Windows.Automation; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement")] - [Attributes.ClassAttributes.CommandSettings("Search Parent UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to get Parent UIElement from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Parent UIElement from UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSearchParentUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_NewOutputUIElementName))] - [PropertyDescription("UIElement Variable Name to Store Parent UIElement")] - public string v_AutomationElementVariable { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public UIAutomationSearchParentUIElementCommand() - { - //this.CommandName = "UIAutomationGetParentElementCommand"; - //this.SelectionName = "Get Parent Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var rootElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTime), engine); - object ret = WaitControls.WaitProcess(waitTime, "Parent Element", - new Func<(bool, object)>(() => - { - try - { - var root = UIElementControls.GetParentUIElement(rootElement); - return (true, root); - } - catch - { - return (false, null); - } - }), engine - ); - if (ret is AutomationElement parent) - { - parent.StoreInUserVariable(engine, v_AutomationElementVariable); - } - else - { - throw new Exception("Parent UIElement not Found"); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementAndWindowByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementAndWindowByXPathCommand.cs deleted file mode 100644 index 06c0f44ae..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementAndWindowByXPathCommand.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Windows.Forms; -using taskt.UI.CustomControls; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using taskt.Core.Script; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement & Window")] - [Attributes.ClassAttributes.CommandSettings("Search UIElement And Window By XPath")] - [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Window Name using by XPath.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Window Name. XPath does not support to use parent and sibling for root element.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSearchUIElementAndWindowByXPathCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] - public string v_WindowName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] - public string v_SearchXPath { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_OutputUIElementName))] - public string v_AutomationElementVariable { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] - public string v_TargetWindowIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] - public string v_WaitTimeForWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - public string v_ElementWaitTime { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] - public string v_NameResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_HandleResult { get; set; } - - public UIAutomationSearchUIElementAndWindowByXPathCommand() - { - //this.CommandName = "UIAutomationGetElementFromWindowByXPathCommand"; - //this.SelectionName = "Get Element From Window By XPath"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //var winElem = AutomationElementControls.GetWindowAutomationElement(this, engine); - - //var waitTime = this.ConvertToUserVariableAsInteger(nameof(v_ElementWaitTime), engine); - //var xpath = v_SearchXPath.ConvertToUserVariableAsXPath(engine); - - //var elem = AutomationElementControls.SearchGUIElementByXPath(winElem, xpath, waitTime, engine); - - //elem.StoreInUserVariable(engine, v_AutomationElementVariable); - - //var varName = VariableNameControls.GetInnerVariableName(0, engine, false); - - //var winSearch = new UIAutomationSearchUIElementFromWindowCommand() - //{ - // v_WindowName = this.v_WindowName, - // v_CompareMethod = this.v_CompareMethod, - // v_MatchMethod = this.v_MatchMethod, - // v_TargetWindowIndex = this.v_TargetWindowIndex, - // v_WaitTimeForWindow = this.v_WaitTimeForWindow, - // v_AutomationElementVariable = varName, - // v_NameResult = this.v_NameResult, - // v_HandleResult = this.v_HandleResult, - //}; - //winSearch.RunCommand(engine); - - //var searchElem = new UIAutomationSearchUIElementFromUIElementByXPathCommand() - //{ - // v_TargetElement = varName, - // v_SearchXPath = this.v_SearchXPath, - // v_AutomationElementVariable = this.v_AutomationElementVariable, - // v_WaitTime = this.v_ElementWaitTime - //}; - //searchElem.RunCommand(engine); - - using(var myVar = new InnerScriptVariable(engine)) - { - var winSearch = new UIAutomationSearchUIElementFromWindowCommand() - { - v_WindowName = this.v_WindowName, - v_CompareMethod = this.v_CompareMethod, - v_MatchMethod = this.v_MatchMethod, - v_TargetWindowIndex = this.v_TargetWindowIndex, - v_WaitTimeForWindow = this.v_WaitTimeForWindow, - v_AutomationElementVariable = myVar.VariableName, - v_NameResult = this.v_NameResult, - v_HandleResult = this.v_HandleResult, - }; - winSearch.RunCommand(engine); - - var searchElem = new UIAutomationSearchUIElementFromUIElementByXPathCommand() - { - v_TargetElement = myVar.VariableName, - v_SearchXPath = this.v_SearchXPath, - v_AutomationElementVariable = this.v_AutomationElementVariable, - v_WaitTime = this.v_ElementWaitTime - }; - searchElem.RunCommand(engine); - } - } - - private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - } - - public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementAndWindowCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementAndWindowCommand.cs deleted file mode 100644 index 110af75b9..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementAndWindowCommand.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using System.Data; -using System.Xml.Serialization; -using System.Windows.Forms; -using taskt.UI.CustomControls; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using taskt.Core.Script; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement & Window")] - [Attributes.ClassAttributes.CommandSettings("Search UIElement And Window")] - [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Window Name.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Window Name.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSearchUIElementAndWindowCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] - public string v_WindowName { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] - public DataTable v_SearchParameters { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_OutputUIElementName))] - public string v_AutomationElementVariable { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] - public string v_TargetWindowIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] - public string v_WaitTimeForWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - public string v_ElementWaitTime { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] - public string v_NameResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_HandleResult { get; set; } - - public UIAutomationSearchUIElementAndWindowCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //var winElem = AutomationElementControls.GetWindowAutomationElement(this, engine); - - //var waitTile = this.ConvertToUserVariableAsInteger(nameof(v_ElementWaitTime), engine); - - //var elem = AutomationElementControls.SearchGUIElement(winElem, v_SearchParameters, waitTile, engine); - - //elem.StoreInUserVariable(engine, v_AutomationElementVariable); - - //var varName = VariableNameControls.GetInnerVariableName(0, engine, false); - - //var winSearch = new UIAutomationSearchUIElementFromWindowCommand() - //{ - // v_WindowName = this.v_WindowName, - // v_CompareMethod = this.v_CompareMethod, - // v_MatchMethod = this.v_MatchMethod, - // v_TargetWindowIndex = this.v_TargetWindowIndex, - // v_WaitTimeForWindow = this.v_WaitTimeForWindow, - // v_AutomationElementVariable = varName, - // v_NameResult = this.v_NameResult, - // v_HandleResult = this.v_HandleResult, - //}; - //winSearch.RunCommand(engine); - - //var searchElem = new UIAutomationSearchUIElementFromUIElementCommand() - //{ - // v_TargetElement = varName, - // v_SearchParameters = this.v_SearchParameters, - // v_AutomationElementVariable = this.v_AutomationElementVariable, - // v_WaitTime = this.v_ElementWaitTime - //}; - //searchElem.RunCommand(engine); - - using (var myVar = new InnerScriptVariable(engine)) - { - var winSearch = new UIAutomationSearchUIElementFromWindowCommand() - { - v_WindowName = this.v_WindowName, - v_CompareMethod = this.v_CompareMethod, - v_MatchMethod = this.v_MatchMethod, - v_TargetWindowIndex = this.v_TargetWindowIndex, - v_WaitTimeForWindow = this.v_WaitTimeForWindow, - v_AutomationElementVariable = myVar.VariableName, - v_NameResult = this.v_NameResult, - v_HandleResult = this.v_HandleResult, - }; - winSearch.RunCommand(engine); - - var searchElem = new UIAutomationSearchUIElementFromUIElementCommand() - { - v_TargetElement = myVar.VariableName, - v_SearchParameters = this.v_SearchParameters, - v_AutomationElementVariable = this.v_AutomationElementVariable, - v_WaitTime = this.v_ElementWaitTime - }; - searchElem.RunCommand(engine); - } - } - - private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - } - - public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); - UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); - } - - public override void BeforeValidate() - { - var dgvSearch = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); - DataTableControls.BeforeValidate(dgvSearch, v_SearchParameters); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromTableUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromTableUIElementCommand.cs deleted file mode 100644 index a0bce8fb6..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromTableUIElementCommand.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Windows.Automation; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement")] - [Attributes.ClassAttributes.CommandSettings("Search UIElement From Table UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Table UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Table UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSearchUIElementFromTableUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDetailSampleUsage("**0**", "Specify the First Row Index")] - [PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "Row Index")] - [PropertyDetailSampleUsage("**{{{vRow}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Row Index")] - [PropertyDescription("Row Index")] - [InputSpecification("Row Index", true)] - [PropertyValidationRule("Row", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Row")] - public string v_Row { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDetailSampleUsage("**0**", "Specify the First Column Index")] - [PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "Column Index")] - [PropertyDetailSampleUsage("**{{{vColumn}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Column Index")] - [PropertyDescription("Column Index")] - [InputSpecification("Column Index", true)] - [PropertyValidationRule("Column", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Column")] - public string v_Column { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_NewOutputUIElementName))] - public string v_AutomationElementVariable { get; set; } - - public UIAutomationSearchUIElementFromTableUIElementCommand() - { - //this.CommandName = "UIAutomationGetElementFromTableElementCommand"; - //this.SelectionName = "Get Element From Table Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - int row = v_Row.ExpandValueOrUserVariableAsInteger("v_Row", engine); - int column = v_Column.ExpandValueOrUserVariableAsInteger("v_Column", engine); - - AutomationElement cellElem = UIElementControls.GetTableUIElement(targetElement, row, column); - cellElem.StoreInUserVariable(engine, v_AutomationElementVariable); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromUIElementByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromUIElementByXPathCommand.cs deleted file mode 100644 index 88d98f700..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromUIElementByXPathCommand.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement")] - [Attributes.ClassAttributes.CommandSettings("Search UIElement From UIElement By XPath")] - [Attributes.ClassAttributes.Description("This command allows you to get UIElement from UIElement using by XPath.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from UIElement. XPath does not support to use parent and sibling for root element.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSearchUIElementFromUIElementByXPathCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - [PropertyDescription("UIElement Variable Name to Search")] - public string v_TargetElement { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] - public string v_SearchXPath { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_NewOutputUIElementName))] - public string v_AutomationElementVariable { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - //[XmlIgnore] - //[NonSerialized] - //private TextBox XPathTextBox; - - public UIAutomationSearchUIElementFromUIElementByXPathCommand() - { - //this.CommandName = "UIAutomationGetElementFromElementByXPathCommand"; - //this.SelectionName = "Get Element From Element By XPath"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var elem = UIElementControls.SearchGUIElementByXPath(this, engine); - elem.StoreInUserVariable(engine, v_AutomationElementVariable); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromUIElementCommand.cs deleted file mode 100644 index 1234ba159..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromUIElementCommand.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Data; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using System.Windows.Forms; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement")] - [Attributes.ClassAttributes.CommandSettings("Search UIElement From UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to get UIElement from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from UIElement. Search for Descendants Elements.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSearchUIElementFromUIElementCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - [PropertyDescription("UIElement Variable Name to Search")] - public string v_TargetElement { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] - public DataTable v_SearchParameters { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_NewOutputUIElementName))] - public string v_AutomationElementVariable { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public UIAutomationSearchUIElementFromUIElementCommand() - { - //this.CommandName = "UIAutomationGetElementFromElementCommand"; - //this.SelectionName = "Get Element From Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var elem = UIElementControls.SearchGUIElement(this, engine); - elem.StoreInUserVariable(engine, v_AutomationElementVariable); - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); - UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - - var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); - DataTableControls.BeforeValidate_NoRowAdding(dgv, v_SearchParameters); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromWindowCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromWindowCommand.cs deleted file mode 100644 index 419948b77..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSearchUIElementFromWindowCommand.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Windows.Forms; -using taskt.UI.CustomControls; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search Window")] - [Attributes.ClassAttributes.CommandSettings("Search UIElement From Window")] - [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Window Name using by XPath.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Window Name. XPath does not support to use parent and sibling for root element.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSearchUIElementFromWindowCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] - public string v_WindowName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_OutputUIElementName))] - public string v_AutomationElementVariable { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] - public string v_TargetWindowIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] - public string v_WaitTimeForWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] - public string v_NameResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_HandleResult { get; set; } - - public UIAutomationSearchUIElementFromWindowCommand() - { - //this.CommandName = "UIAutomationGetElementFromWindowCommand"; - //this.SelectionName = "Get Element From Window"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - UIElementControls.GetWindowUIElement(this, engine); - } - - private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - } - - public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - //var cmb = (ComboBox)ControlsList[nameof(v_WindowName)]; - //cmb.AddWindowNames(); - ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSelectItemInUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSelectItemInUIElementCommand.cs deleted file mode 100644 index 1788f9806..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSelectItemInUIElementCommand.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Windows.Automation; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("UIElement Action")] - [Attributes.ClassAttributes.CommandSettings("Select Item In UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to Select a Item in UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Select a Item in UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSelectItemInUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Item Value to Select")] - [InputSpecification("Item Value", true)] - [PropertyDetailSampleUsage("**Yes**", PropertyDetailSampleUsage.ValueType.Value)] - [PropertyDetailSampleUsage("**Hello**", PropertyDetailSampleUsage.ValueType.Value)] - [PropertyDetailSampleUsage("**{{{vItem}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyDisplayText(true, "Item")] - public string v_Item { get; set; } - - public UIAutomationSelectItemInUIElementCommand() - { - //this.CommandName = "UIAutomationSelectItemInElementCommand"; - //this.SelectionName = "Select Item In Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - var itemName = v_Item.ExpandValueOrUserVariable(engine); - - var items = UIElementControls.GetSelectionItems(targetElement); - bool isSelected = false; - foreach(var item in items) - { - if (item.Current.Name == itemName) - { - SelectionItemPattern selPtn = (SelectionItemPattern)item.GetCurrentPattern(SelectionItemPattern.Pattern); - selPtn.Select(); - isSelected = true; - break; - } - } - - if (!isSelected) - { - throw new Exception("Item '" + v_Item + "' does not exists"); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSelectUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSelectUIElementCommand.cs deleted file mode 100644 index 4ff979732..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSelectUIElementCommand.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Windows.Automation; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("UIElement Action")] - [Attributes.ClassAttributes.CommandSettings("Select UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to Select UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Select UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSelectUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - public UIAutomationSelectUIElementCommand() - { - //this.CommandName = "UIAutomationSelectElementCommand"; - //this.SelectionName = "Select Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - if (targetElement.TryGetCurrentPattern(TogglePattern.Pattern, out object checkPtn)) - { - TogglePattern ptn = (TogglePattern)checkPtn; - switch (ptn.Current.ToggleState) - { - case ToggleState.Off: - case ToggleState.Indeterminate: - do - { - ptn.Toggle(); - } while (ptn.Current.ToggleState != ToggleState.On); - break; - } - } - else if (targetElement.TryGetCurrentPattern(SelectionItemPattern.Pattern, out checkPtn)) - { - ((SelectionItemPattern)checkPtn).Select(); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSetTextToUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSetTextToUIElementCommand.cs deleted file mode 100644 index 0aa4438c1..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationSetTextToUIElementCommand.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Windows.Automation; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using System.Windows.Forms; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("UIElement Action")] - [Attributes.ClassAttributes.CommandSettings("Set Text To UIElement")] - [Attributes.ClassAttributes.Description("This command allows you to set Text Value from UIElement.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to set Text Value from UIElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationSetTextToUIElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_OneLineTextBox))] - [PropertyDescription("Text to Set")] - [InputSpecification("Text", true)] - [PropertyDetailSampleUsage("**Hello**", PropertyDetailSampleUsage.ValueType.Value)] - [PropertyDetailSampleUsage("**{{{vText}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyDisplayText(true, "Text")] - public string v_TextVariable { get; set; } - - public UIAutomationSetTextToUIElementCommand() - { - //this.CommandName = "UIAutomationSetTextToElementCommand"; - //this.SelectionName = "Set Text To Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - - var ct = targetElement.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty) as ControlType; - if (ct == ControlType.Spinner) - { - //targetElement = UIElementControls.SearchGUIElementByXPath(targetElement, "/Edit[1]", 10, engine); - targetElement = targetElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit)); - } - - string textValue = v_TextVariable.ExpandValueOrUserVariable(engine); - - if (targetElement.TryGetCurrentPattern(ValuePattern.Pattern, out object valPtn)) - { - ((ValuePattern)valPtn).SetValue(textValue); - } - else if (targetElement.TryGetCurrentPattern(TextPattern.Pattern, out _)) - { - targetElement.SetFocus(); - System.Threading.Thread.Sleep(100); - SendKeys.SendWait("^{HOME}"); - SendKeys.SendWait("^+{END}"); - SendKeys.SendWait("{DEL}"); - SendKeys.SendWait(textValue); - } - else - { - throw new Exception("UIElement '" + v_TargetElement + "' can not set Text"); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationUIElementActionByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationUIElementActionByXPathCommand.cs deleted file mode 100644 index 23262b75d..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationUIElementActionByXPathCommand.cs +++ /dev/null @@ -1,587 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using System.Data; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using taskt.Core.Script; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("UIElement Action")] - [Attributes.ClassAttributes.CommandSettings("UIElement Action By XPath")] - [Attributes.ClassAttributes.Description("Combined implementation of the ThickAppClick/GetText command but includes an advanced Window Recorder to record the required element.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows UI Automation' to find elements and invokes a Variable Command to assign data and achieve automation")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationUIElementActionByXPathCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] - public string v_WindowName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("UIElement Action")] - [PropertyUISelectionOption("Click UIElement")] - [PropertyUISelectionOption("Expand Collapse Items In UIElement")] - [PropertyUISelectionOption("Scroll UIElement")] - [PropertyUISelectionOption("Select UIElement")] - [PropertyUISelectionOption("Select Item In UIElement")] - [PropertyUISelectionOption("Set Text To UIElement")] - [PropertyUISelectionOption("Get Property Value From UIElement")] - [PropertyUISelectionOption("Check UIElement Exists")] - [PropertyUISelectionOption("Get Text From UIElement")] - [PropertyUISelectionOption("Get Selected State From UIElement")] - [PropertyUISelectionOption("Get Text From Table UIElement")] - [PropertyUISelectionOption("Get UIElement Position")] - [PropertyUISelectionOption("Get UIElement Size")] - [PropertyUISelectionOption("Wait For UIElement To Exists")] - [PropertyUISelectionOption("Wait For UIElement To Exists")] - [PropertySelectionChangeEvent(nameof(cmbActionType_SelectedItemChange))] - [PropertyDisplayText(true, "Action")] - public string v_AutomationType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] - public string v_UIASearchParameters { get; set; } - - [XmlElement] - [PropertyDescription("Action Parameters")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] - [PropertyDataGridViewSetting(false, false, true, 400, 250)] - [PropertyDataGridViewColumnSettings("Parameter Name", "Parameter Name", true)] - [PropertyDataGridViewColumnSettings("Parameter Value", "Parameter Value", false)] - public DataTable v_UIAActionParameters { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] - public string v_TargetWindowIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] - public string v_WaitTimeForWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - public string v_ElementWaitTime { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] - public string v_NameResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_HandleResult { get; set; } - - public UIAutomationUIElementActionByXPathCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var elemAction = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_AutomationType), engine); - - //var winElemVar = VariableNameControls.GetInnerVariableName(0, engine); - //var winElem = new UIAutomationSearchUIElementFromWindowCommand() - //{ - // v_WindowName = this.v_WindowName, - // v_CompareMethod = this.v_CompareMethod, - // v_MatchMethod = this.v_MatchMethod, - // v_TargetWindowIndex = this.v_TargetWindowIndex, - // v_WaitTimeForWindow = this.v_WaitTimeForWindow, - // v_AutomationElementVariable = winElemVar, - // v_NameResult = this.v_NameResult, - // v_HandleResult = this.v_HandleResult, - //}; - //winElem.RunCommand(engine); - - //var p = DataTableControls.GetFieldValues(v_UIAActionParameters, "Parameter Name", "Parameter Value", false, engine); - //var trgElemVar = VariableNameControls.GetInnerVariableName(1, engine); - - //switch (elemAction) - //{ - // case "check uielement exists": - // var chkElem = new UIAutomationCheckUIElementExistByXPathCommand() - // { - // v_TargetElement = winElemVar, - // v_SearchXPath = this.v_UIASearchParameters, - // v_WaitTime = this.v_ElementWaitTime, - // v_Result = p["Apply To Variable"], - // }; - // chkElem.RunCommand(engine); - // return; - - // default: - // var trgElem = new UIAutomationSearchUIElementFromUIElementByXPathCommand() - // { - // v_TargetElement = winElemVar, - // v_SearchXPath = this.v_UIASearchParameters, - // v_WaitTime = this.v_ElementWaitTime, - // v_AutomationElementVariable = trgElemVar, - // }; - // trgElem.RunCommand(engine); - // break; - //} - - //switch (elemAction) - //{ - // case "click uielement": - // var clickCmd = new UIAutomationClickUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_ClickType = p["Click Type"], - // v_XOffset = p["X Offset"], - // v_YOffset = p["Y Offset"], - // }; - // clickCmd.RunCommand(engine); - // break; - // case "expand collapse items in uielement": - // var expandCmd = new UIAutomationExpandCollapseItemsInUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_ItemsState = p["Items State"], - // }; - // expandCmd.RunCommand(engine); - // break; - // case "scroll uielement": - // var scrollCmd = new UIAutomationScrollUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_ScrollBarType = p["ScrollBar Type"], - // v_DirectionAndAmount = p["Scroll Method"], - // }; - // scrollCmd.RunCommand(engine); - // break; - // case "select uielement": - // var selectCmd = new UIAutomationSelectUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // }; - // selectCmd.RunCommand(engine); - // break; - // case "select item in uielement": - // var selectItemCmd = new UIAutomationSelectItemInUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_Item = p["Item Value"], - // }; - // selectItemCmd.RunCommand(engine); - // break; - // case "set text to uielement": - // var setTextCmd = new UIAutomationSetTextToUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_TextVariable = p["Text To Set"], - // }; - // setTextCmd.RunCommand(engine); - // break; - // case "get property value from uielement": - // var propValueCmd = new UIAutomationGetPropertyValueFromUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_PropertyName = p["Property Name"], - // v_Result = p["Apply To Variable"], - // }; - // propValueCmd.RunCommand(engine); - // break; - // case "check uielement exists": - // true.StoreInUserVariable(engine, p["Apply To Variable"]); - // break; - // case "get text from uielement": - // var getTextCmd = new UIAutomationGetTextFromUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_TextVariable = p["Apply To Variable"], - // }; - // getTextCmd.RunCommand(engine); - // break; - // case "get selected state from uielement": - // var getSelectedCmd = new UIAutomationGetSelectedStateFromUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_ResultVariable = p["Apply To Variable"], - // }; - // getSelectedCmd.RunCommand(engine); - // break; - // case "get text from table uielement": - // var getTableCmd = new UIAutomationGetTextFromTableUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_Row = p["Row"], - // v_Column = p["Column"], - // v_TextVariable = p["Apply To Variable"], - // }; - // getTableCmd.RunCommand(engine); - // break; - // case "get uielement position": - // var getElemPosCmd = new UIAutomationGetUIElementPositionCommand() - // { - // v_TargetElement = trgElemVar, - // v_XPosition = p["X Variable"], - // v_YPosition = p["Y Variable"], - // v_PositionBase = p["Base Position"], - // }; - // getElemPosCmd.RunCommand(engine); - // break; - // case "get uielement size": - // var getElemSizeCmd = new UIAutomationGetUIElementSizeCommand() - // { - // v_TargetElement = trgElemVar, - // v_Width = p["Width Variable"], - // v_Height = p["Height Variable"], - // }; - // getElemSizeCmd.RunCommand(engine); - // break; - //} - - using(var myWinElem = new InnerScriptVariable(engine)) - { - var winElem = new UIAutomationSearchUIElementFromWindowCommand() - { - v_WindowName = this.v_WindowName, - v_CompareMethod = this.v_CompareMethod, - v_MatchMethod = this.v_MatchMethod, - v_TargetWindowIndex = this.v_TargetWindowIndex, - v_WaitTimeForWindow = this.v_WaitTimeForWindow, - v_AutomationElementVariable = myWinElem.VariableName, - v_NameResult = this.v_NameResult, - v_HandleResult = this.v_HandleResult, - }; - winElem.RunCommand(engine); - - var p = DataTableControls.GetFieldValues(v_UIAActionParameters, "Parameter Name", "Parameter Value", false, engine); - - using (var myTrgElem = new InnerScriptVariable(engine)) - { - switch (elemAction) - { - case "check uielement exists": - var chkElem = new UIAutomationCheckUIElementExistsByXPathCommand() - { - v_TargetElement = myWinElem.VariableName, - v_SearchXPath = this.v_UIASearchParameters, - v_WaitTime = this.v_ElementWaitTime, - v_Result = p["Apply To Variable"], - }; - chkElem.RunCommand(engine); - return; - - default: - var trgElem = new UIAutomationSearchUIElementFromUIElementByXPathCommand() - { - v_TargetElement = myWinElem.VariableName, - v_SearchXPath = this.v_UIASearchParameters, - v_WaitTime = this.v_ElementWaitTime, - v_AutomationElementVariable = myTrgElem.VariableName, - }; - trgElem.RunCommand(engine); - break; - } - - switch (elemAction) - { - case "click uielement": - var clickCmd = new UIAutomationClickUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_ClickType = p["Click Type"], - v_XOffset = p["X Offset"], - v_YOffset = p["Y Offset"], - }; - clickCmd.RunCommand(engine); - break; - case "expand collapse items in uielement": - var expandCmd = new UIAutomationExpandCollapseItemsInUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_ItemsState = p["Items State"], - }; - expandCmd.RunCommand(engine); - break; - case "scroll uielement": - var scrollCmd = new UIAutomationScrollUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_ScrollBarType = p["ScrollBar Type"], - v_DirectionAndAmount = p["Scroll Method"], - }; - scrollCmd.RunCommand(engine); - break; - case "select uielement": - var selectCmd = new UIAutomationSelectUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - }; - selectCmd.RunCommand(engine); - break; - case "select item in uielement": - var selectItemCmd = new UIAutomationSelectItemInUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_Item = p["Item Value"], - }; - selectItemCmd.RunCommand(engine); - break; - case "set text to uielement": - var setTextCmd = new UIAutomationSetTextToUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_TextVariable = p["Text To Set"], - }; - setTextCmd.RunCommand(engine); - break; - case "get property value from uielement": - var propValueCmd = new UIAutomationGetPropertyValueFromUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_PropertyName = p["Property Name"], - v_Result = p["Apply To Variable"], - }; - propValueCmd.RunCommand(engine); - break; - case "check uielement exists": - true.StoreInUserVariable(engine, p["Apply To Variable"]); - break; - case "get text from uielement": - var getTextCmd = new UIAutomationGetTextFromUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_TextVariable = p["Apply To Variable"], - }; - getTextCmd.RunCommand(engine); - break; - case "get selected state from uielement": - var getSelectedCmd = new UIAutomationGetSelectedStateFromUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_ResultVariable = p["Apply To Variable"], - }; - getSelectedCmd.RunCommand(engine); - break; - case "get text from table uielement": - var getTableCmd = new UIAutomationGetTextFromTableUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_Row = p["Row"], - v_Column = p["Column"], - v_TextVariable = p["Apply To Variable"], - }; - getTableCmd.RunCommand(engine); - break; - case "get uielement position": - var getElemPosCmd = new UIAutomationGetUIElementPositionCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_XPosition = p["X Variable"], - v_YPosition = p["Y Variable"], - v_PositionBase = p["Base Position"], - }; - getElemPosCmd.RunCommand(engine); - break; - case "get uielement size": - var getElemSizeCmd = new UIAutomationGetUIElementSizeCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_Width = p["Width Variable"], - v_Height = p["Height Variable"], - }; - getElemSizeCmd.RunCommand(engine); - break; - } - } - } - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - var cmb = FormUIControls.GetPropertyControl(ControlsList, nameof(v_AutomationType)); - var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); - actionParameterProcess(dgv, cmb.SelectedItem?.ToString() ?? ""); - } - - private void cmbActionType_SelectedItemChange(object sender, EventArgs e) - { - var a = ((ComboBox)sender).SelectedItem?.ToString() ?? ""; - - var dgv = FormUIControls.GetPropertyControl(this.ControlsList, nameof(v_UIAActionParameters)); - var table = v_UIAActionParameters; - table.Rows.Clear(); - switch (a.ToLower()) - { - case "click uielement": - table.Rows.Add(new string[] { "Click Type", "" }); - table.Rows.Add(new string[] { "X Offset", "" }); - table.Rows.Add(new string[] { "Y Offset", "" }); - break; - - case "expand collapse items in uielement": - table.Rows.Add(new string[] { "Items State", "" }); - break; - - case "scroll uielement": - table.Rows.Add(new string[] { "ScrollBar Type", "" }); - table.Rows.Add(new string[] { "Scroll Method", "" }); - break; - - case "select item in uielement": - table.Rows.Add(new string[] { "Item Value", "" }); - break; - - case "set text to uielement": - table.Rows.Add(new string[] { "Text To Set", "" }); - break; - - case "get property value from uielement": - table.Rows.Add(new string[] { "Property Name", "" }); - table.Rows.Add(new string[] { "Apply To Variable", "" }); - break; - - case "get text from table uielement": - table.Rows.Add(new string[] { "Row", "" }); - table.Rows.Add(new string[] { "Column", "" }); - table.Rows.Add(new string[] { "Apply To Variable", "" }); - break; - - case "get uielement position": - table.Rows.Add(new string[] { "X Variable", "" }); - table.Rows.Add(new string[] { "Y Variable", "" }); - table.Rows.Add(new string[] { "Base Position", "" }); - break; - - case "get uielement size": - table.Rows.Add(new string[] { "Width Variable", "" }); - table.Rows.Add(new string[] { "Height Variable", "" }); - break; - - case "check uielement exists": - case "get text from uielement": - case "get selected state from uielement": - table.Rows.Add(new string[] { "Apply To Variable", "" }); - break; - - case "select uielement": - case "wait for uielement to exists": - // nothing - break; - } - - actionParameterProcess(dgv, a); - } - - private static void actionParameterProcess(DataGridView dgv, string actionType) - { - switch (actionType.ToLower()) - { - case "click uielement": - var clickType = new DataGridViewComboBoxCell(); - clickType.Items.AddRange(new string[] - { - "Left Click", - "Middle Click", - "Right Click", - "Left Down", - "Middle Down", - "Right Down", - "Left Up", - "Middle Up", - "Right Up", - "Double Left Click", - "None", - }); - dgv.Rows[0].Cells[1] = clickType; - break; - case "expand collapse items in uielement": - var itemState = new DataGridViewComboBoxCell(); - itemState.Items.AddRange(new string[] - { - "Expand", - "Collapse" - }); - dgv.Rows[0].Cells[1] = itemState; - break; - case "scroll uielement": - var barType = new DataGridViewComboBoxCell(); - barType.Items.AddRange(new string[] - { - "Vertical", - "Horizonal", - }); - var scrollMethod = new DataGridViewComboBoxCell(); - scrollMethod.Items.AddRange(new string[] - { - "Scroll Small Down or Right", - "Scroll Large Down or Right", - "Scroll Small Up or Left", - "Scroll Large Up or Left", - }); - dgv.Rows[0].Cells[1] = barType; - dgv.Rows[1].Cells[1] = scrollMethod; - break; - case "get property value from uielement": - var propNames = new DataGridViewComboBoxCell(); - propNames.Items.AddRange(new string[] - { - "Name", - "ControlType", - "LocalizedControlType", - "IsEnabled", - "IsOffscreen", - "IsKeyboardFocusable", - "HasKeyboardFocusable", - "AccessKey", - "ProcessId", - "AutomationId", - "FrameworkId", - "ClassName", - "IsContentElement", - "IsPassword", - "AcceleratorKey", - "HelpText", - "IsControlElement", - "IsRequiredForForm", - "ItemStatus", - "ItemType", - "NativeWindowHandle", - }); - dgv.Rows[0].Cells[1] = propNames; - break; - case "get uielement position": - var positionName = new DataGridViewComboBoxCell(); - positionName.Items.AddRange(new string[] - { - "Top Left", - "Bottom Right", - "Top Right", - "Bottom Left", - "Center", - }); - dgv.Rows[2].Cells[1] = positionName; - break; - } - } - - private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - } - - public override void BeforeValidate() - { - var dgvAction = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); - DataTableControls.BeforeValidate(dgvAction, v_UIAActionParameters); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationUIElementActionCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationUIElementActionCommand.cs deleted file mode 100644 index 6f89d2c1c..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationUIElementActionCommand.cs +++ /dev/null @@ -1,795 +0,0 @@ -using System; -using System.Linq; -using System.Xml.Serialization; -using System.Data; -using System.Windows.Forms; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using taskt.Core.Script; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("UIElement Action")] - [Attributes.ClassAttributes.CommandSettings("UIElement Action")] - [Attributes.ClassAttributes.Description("Combined implementation of the ThickAppClick/GetText command but includes an advanced Window Recorder to record the required element.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements 'Windows UI Automation' to find elements and invokes a Variable Command to assign data and achieve automation")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationUIElementActionCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] - public string v_WindowName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("UIElement Action")] - [PropertyUISelectionOption("Click UIElement")] - [PropertyUISelectionOption("Expand Collapse Items In UIElement")] - [PropertyUISelectionOption("Scroll UIElement")] - [PropertyUISelectionOption("Select UIElement")] - [PropertyUISelectionOption("Select Item In UIElement")] - [PropertyUISelectionOption("Set Text To UIElement")] - [PropertyUISelectionOption("Get Property Value From UIElement")] - [PropertyUISelectionOption("Check UIElement Exists")] - [PropertyUISelectionOption("Get Text From UIElement")] - [PropertyUISelectionOption("Get Selected State From UIElement")] - [PropertyUISelectionOption("Get Text From Table UIElement")] - [PropertyUISelectionOption("Get UIElement Position")] - [PropertyUISelectionOption("Get UIElement Size")] - [PropertyUISelectionOption("Wait For UIElement To Exists")] - [PropertySelectionChangeEvent(nameof(cmbActionType_SelectedItemChange))] - [PropertyDisplayText(true, "Action")] - public string v_AutomationType { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] - public DataTable v_UIASearchParameters { get; set; } - - [XmlElement] - [PropertyDescription("Action Parameters")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] - [PropertyDataGridViewSetting(false, false, true, 400, 250)] - [PropertyDataGridViewColumnSettings("Parameter Name", "Parameter Name", true)] - [PropertyDataGridViewColumnSettings("Parameter Value", "Parameter Value", false)] - public DataTable v_UIAActionParameters { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] - public string v_CompareMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] - public string v_TargetWindowIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] - public string v_WaitTimeForWindow { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - public string v_ElementWaitTime { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] - public string v_NameResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_HandleResult { get; set; } - - public UIAutomationUIElementActionCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var elemAction = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_AutomationType), engine); - - //var winElemVar = VariableNameControls.GetInnerVariableName(0, engine); - //var winElem = new UIAutomationSearchUIElementFromWindowCommand() - //{ - // v_WindowName = this.v_WindowName, - // v_CompareMethod = this.v_CompareMethod, - // v_MatchMethod = this.v_MatchMethod, - // v_TargetWindowIndex = this.v_TargetWindowIndex, - // v_WaitTimeForWindow = this.v_WaitTimeForWindow, - // v_AutomationElementVariable = winElemVar, - // v_NameResult = this.v_NameResult, - // v_HandleResult = this.v_HandleResult, - //}; - //winElem.RunCommand(engine); - - //var p = DataTableControls.GetFieldValues(v_UIAActionParameters, "Parameter Name", "Parameter Value", false, engine); - //var trgElemVar = VariableNameControls.GetInnerVariableName(1, engine); - - //switch (elemAction) - //{ - // case "check uielement exists": - // var chkElem = new UIAutomationCheckUIElementExistCommand() - // { - // v_TargetElement = winElemVar, - // v_SearchParameters = this.v_UIASearchParameters, - // v_WaitTime = this.v_ElementWaitTime, - // v_Result = p["Apply To Variable"], - // }; - // chkElem.RunCommand(engine); - // return; - - // default: - // var trgElem = new UIAutomationSearchUIElementFromUIElementCommand() - // { - // v_TargetElement = winElemVar, - // v_SearchParameters = this.v_UIASearchParameters, - // v_WaitTime = this.v_ElementWaitTime, - // v_AutomationElementVariable = trgElemVar, - // }; - // trgElem.RunCommand(engine); - // break; - //} - - //// todo: use same method - //switch (elemAction) - //{ - // case "click uielement": - // var clickCmd = new UIAutomationClickUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_ClickType = p["Click Type"], - // v_XOffset = p["X Offset"], - // v_YOffset = p["Y Offset"], - // }; - // clickCmd.RunCommand(engine); - // break; - // case "expand collapse items in uielement": - // var expandCmd = new UIAutomationExpandCollapseItemsInUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_ItemsState = p["Items State"], - // }; - // expandCmd.RunCommand(engine); - // break; - // case "scroll uielement": - // var scrollCmd = new UIAutomationScrollUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_ScrollBarType = p["ScrollBar Type"], - // v_DirectionAndAmount = p["Scroll Method"], - // }; - // scrollCmd.RunCommand(engine); - // break; - // case "select uielement": - // var selectCmd = new UIAutomationSelectUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // }; - // selectCmd.RunCommand(engine); - // break; - // case "select item in uielement": - // var selectItemCmd = new UIAutomationSelectItemInUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_Item = p["Item Value"], - // }; - // selectItemCmd.RunCommand(engine); - // break; - // case "set text to uielement": - // var setTextCmd = new UIAutomationSetTextToUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_TextVariable = p["Text To Set"], - // }; - // setTextCmd.RunCommand(engine); - // break; - // case "get property value from uielement": - // var propValueCmd = new UIAutomationGetPropertyValueFromUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_PropertyName = p["Property Name"], - // v_Result = p["Apply To Variable"], - // }; - // propValueCmd.RunCommand(engine); - // break; - // case "check uielement exists": - // true.StoreInUserVariable(engine, p["Apply To Variable"]); - // break; - // case "get text from uielement": - // var getTextCmd = new UIAutomationGetTextFromUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_TextVariable = p["Apply To Variable"], - // }; - // getTextCmd.RunCommand(engine); - // break; - // case "get selected state from uielement": - // var getSelectedCmd = new UIAutomationGetSelectedStateFromUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_ResultVariable = p["Apply To Variable"], - // }; - // getSelectedCmd.RunCommand(engine); - // break; - // case "get text from table uielement": - // var getTableCmd = new UIAutomationGetTextFromTableUIElementCommand() - // { - // v_TargetElement = trgElemVar, - // v_Row = p["Row"], - // v_Column = p["Column"], - // v_TextVariable = p["Apply To Variable"], - // }; - // getTableCmd.RunCommand(engine); - // break; - // case "get uielement position": - // var getElemPosCmd = new UIAutomationGetUIElementPositionCommand() - // { - // v_TargetElement = trgElemVar, - // v_XPosition = p["X Variable"], - // v_YPosition = p["Y Variable"], - // v_PositionBase = p["Base Position"], - // }; - // getElemPosCmd.RunCommand(engine); - // break; - // case "get uielement size": - // var getElemSizeCmd = new UIAutomationGetUIElementSizeCommand() - // { - // v_TargetElement = trgElemVar, - // v_Width = p["Width Variable"], - // v_Height = p["Height Variable"], - // }; - // getElemSizeCmd.RunCommand(engine); - // break; - //} - - using(var myWinElem = new InnerScriptVariable(engine)) - { - var winElem = new UIAutomationSearchUIElementFromWindowCommand() - { - v_WindowName = this.v_WindowName, - v_CompareMethod = this.v_CompareMethod, - v_MatchMethod = this.v_MatchMethod, - v_TargetWindowIndex = this.v_TargetWindowIndex, - v_WaitTimeForWindow = this.v_WaitTimeForWindow, - v_AutomationElementVariable = myWinElem.VariableName, - v_NameResult = this.v_NameResult, - v_HandleResult = this.v_HandleResult, - }; - winElem.RunCommand(engine); - - var p = DataTableControls.GetFieldValues(v_UIAActionParameters, "Parameter Name", "Parameter Value", false, engine); - - using (var myTrgElem = new InnerScriptVariable(engine)) - { - switch (elemAction) - { - case "check uielement exists": - var chkElem = new UIAutomationCheckUIElementExistsCommand() - { - v_TargetElement = myWinElem.VariableName, - v_SearchParameters = this.v_UIASearchParameters, - v_WaitTime = this.v_ElementWaitTime, - v_Result = p["Apply To Variable"], - }; - chkElem.RunCommand(engine); - return; - - default: - var trgElem = new UIAutomationSearchUIElementFromUIElementCommand() - { - v_TargetElement = myWinElem.VariableName, - v_SearchParameters = this.v_UIASearchParameters, - v_WaitTime = this.v_ElementWaitTime, - v_AutomationElementVariable = myTrgElem.VariableName, - }; - trgElem.RunCommand(engine); - break; - } - - // todo: use same method - switch (elemAction) - { - case "click uielement": - var clickCmd = new UIAutomationClickUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_ClickType = p["Click Type"], - v_XOffset = p["X Offset"], - v_YOffset = p["Y Offset"], - }; - clickCmd.RunCommand(engine); - break; - case "expand collapse items in uielement": - var expandCmd = new UIAutomationExpandCollapseItemsInUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_ItemsState = p["Items State"], - }; - expandCmd.RunCommand(engine); - break; - case "scroll uielement": - var scrollCmd = new UIAutomationScrollUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_ScrollBarType = p["ScrollBar Type"], - v_DirectionAndAmount = p["Scroll Method"], - }; - scrollCmd.RunCommand(engine); - break; - case "select uielement": - var selectCmd = new UIAutomationSelectUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - }; - selectCmd.RunCommand(engine); - break; - case "select item in uielement": - var selectItemCmd = new UIAutomationSelectItemInUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_Item = p["Item Value"], - }; - selectItemCmd.RunCommand(engine); - break; - case "set text to uielement": - var setTextCmd = new UIAutomationSetTextToUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_TextVariable = p["Text To Set"], - }; - setTextCmd.RunCommand(engine); - break; - case "get property value from uielement": - var propValueCmd = new UIAutomationGetPropertyValueFromUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_PropertyName = p["Property Name"], - v_Result = p["Apply To Variable"], - }; - propValueCmd.RunCommand(engine); - break; - case "check uielement exists": - true.StoreInUserVariable(engine, p["Apply To Variable"]); - break; - case "get text from uielement": - var getTextCmd = new UIAutomationGetTextFromUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_TextVariable = p["Apply To Variable"], - }; - getTextCmd.RunCommand(engine); - break; - case "get selected state from uielement": - var getSelectedCmd = new UIAutomationGetSelectedStateFromUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_ResultVariable = p["Apply To Variable"], - }; - getSelectedCmd.RunCommand(engine); - break; - case "get text from table uielement": - var getTableCmd = new UIAutomationGetTextFromTableUIElementCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_Row = p["Row"], - v_Column = p["Column"], - v_TextVariable = p["Apply To Variable"], - }; - getTableCmd.RunCommand(engine); - break; - case "get uielement position": - var getElemPosCmd = new UIAutomationGetUIElementPositionCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_XPosition = p["X Variable"], - v_YPosition = p["Y Variable"], - v_PositionBase = p["Base Position"], - }; - getElemPosCmd.RunCommand(engine); - break; - case "get uielement size": - var getElemSizeCmd = new UIAutomationGetUIElementSizeCommand() - { - v_TargetElement = myTrgElem.VariableName, - v_Width = p["Width Variable"], - v_Height = p["Height Variable"], - }; - getElemSizeCmd.RunCommand(engine); - break; - } - } - } - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - var cmb = FormUIControls.GetPropertyControl(ControlsList, nameof(v_AutomationType)); - var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); - actionParameterProcess(dgv, cmb.SelectedItem?.ToString() ?? ""); - } - - private void cmbActionType_SelectedItemChange(object sender, EventArgs e) - { - var a = ((ComboBox)sender).SelectedItem?.ToString() ?? ""; - - var dgv = FormUIControls.GetPropertyControl(this.ControlsList, nameof(v_UIAActionParameters)); - var table = v_UIAActionParameters; - table.Rows.Clear(); - switch (a.ToLower()) - { - case "click uielement": - table.Rows.Add(new string[] { "Click Type", "" }); - table.Rows.Add(new string[] { "X Offset", "" }); - table.Rows.Add(new string[] { "Y Offset", "" }); - break; - - case "expand collapse items in uielement": - table.Rows.Add(new string[] { "Items State", "" }); - break; - case "scroll uielement": - table.Rows.Add(new string[] { "ScrollBar Type", "" }); - table.Rows.Add(new string[] { "Scroll Method", "" }); - break; - - case "select item in uielement": - table.Rows.Add(new string[] { "Item Value", "" }); - break; - - case "set text to uielement": - table.Rows.Add(new string[] { "Text To Set", "" }); - break; - - case "get property value from uielement": - table.Rows.Add(new string[] { "Property Name", "" }); - table.Rows.Add(new string[] { "Apply To Variable", "" }); - break; - - case "get text from table uielement": - table.Rows.Add(new string[] { "Row", "" }); - table.Rows.Add(new string[] { "Column", "" }); - table.Rows.Add(new string[] { "Apply To Variable", "" }); - break; - - case "get uielement position": - table.Rows.Add(new string[] { "X Variable", "" }); - table.Rows.Add(new string[] { "Y Variable", "" }); - table.Rows.Add(new string[] { "Base Position", ""}); - break; - - case "get uielement size": - table.Rows.Add(new string[] { "Width Variable", "" }); - table.Rows.Add(new string[] { "Height Variable", "" }); - break; - - case "check uielement exists": - case "get text from uielement": - case "get selected state from uielement": - table.Rows.Add(new string[] { "Apply To Variable", "" }); - break; - - case "select uielement": - case "wait for uielement to exists": - // nothing - break; - } - - actionParameterProcess(dgv, a); - } - - private static void actionParameterProcess(DataGridView dgv, string actionType) - { - switch (actionType.ToLower()) - { - case "click uielement": - var clickType = new DataGridViewComboBoxCell(); - clickType.Items.AddRange(new string[] - { - "Left Click", - "Middle Click", - "Right Click", - "Left Down", - "Middle Down", - "Right Down", - "Left Up", - "Middle Up", - "Right Up", - "Double Left Click", - "None", - }); - dgv.Rows[0].Cells[1] = clickType; - break; - case "expand collapse items in uielement": - var itemState = new DataGridViewComboBoxCell(); - itemState.Items.AddRange(new string[] - { - "Expand", - "Collapse" - }); - dgv.Rows[0].Cells[1] = itemState; - break; - case "scroll uielement": - var barType = new DataGridViewComboBoxCell(); - barType.Items.AddRange(new string[] - { - "Vertical", - "Horizonal", - }); - var scrollMethod = new DataGridViewComboBoxCell(); - scrollMethod.Items.AddRange(new string[] - { - "Scroll Small Down or Right", - "Scroll Large Down or Right", - "Scroll Small Up or Left", - "Scroll Large Up or Left", - }); - dgv.Rows[0].Cells[1] = barType; - dgv.Rows[1].Cells[1] = scrollMethod; - break; - case "get property value from uielement": - var propNames = new DataGridViewComboBoxCell(); - propNames.Items.AddRange(new string[] - { - "Name", - "ControlType", - "LocalizedControlType", - "IsEnabled", - "IsOffscreen", - "IsKeyboardFocusable", - "HasKeyboardFocusable", - "AccessKey", - "ProcessId", - "AutomationId", - "FrameworkId", - "ClassName", - "IsContentElement", - "IsPassword", - "AcceleratorKey", - "HelpText", - "IsControlElement", - "IsRequiredForForm", - "ItemStatus", - "ItemType", - "NativeWindowHandle", - }); - dgv.Rows[0].Cells[1] = propNames; - break; - case "get uielement position": - var positionName = new DataGridViewComboBoxCell(); - positionName.Items.AddRange(new string[] - { - "Top Left", - "Bottom Right", - "Top Right", - "Bottom Left", - "Center", - }); - dgv.Rows[2].Cells[1] = positionName; - break; - } - } - - private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - } - - public override void BeforeValidate() - { - var dgvAction = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); - DataTableControls.BeforeValidate(dgvAction, v_UIAActionParameters); - - var dgvSearch = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIASearchParameters)); - DataTableControls.BeforeValidate(dgvSearch, v_UIASearchParameters); - } - - //public override string GetDisplayValue() - //{ - // if (v_AutomationType == "Click Element") - // { - // //create search params - // var clickType = (from rw in v_UIAActionParameters.AsEnumerable() - // where rw.Field("Parameter Name") == "Click Type" - // select rw.Field("Parameter Value")).FirstOrDefault(); - - - // return base.GetDisplayValue() + " [" + clickType + " element in window '" + v_WindowName + "']"; - // } - // else if(v_AutomationType == "Check If Element Exists") - // { - - // //apply to variable - // var applyToVariable = (from rw in v_UIAActionParameters.AsEnumerable() - // where rw.Field("Parameter Name") == "Apply To Variable" - // select rw.Field("Parameter Value")).FirstOrDefault(); - - // return base.GetDisplayValue() + " [Check for element in window '" + v_WindowName + "' and apply to '" + applyToVariable + "']"; - // } - // else if (v_AutomationType == "Get Text Value From Element") - // { - // //apply to variable - // var applyToVariable = (from rw in v_UIAActionParameters.AsEnumerable() - // where rw.Field("Parameter Name") == "Apply To Variable" - // select rw.Field("Parameter Value")).FirstOrDefault(); - - // return base.GetDisplayValue() + " [Text Value for element in window '" + v_WindowName + "' and apply to '" + applyToVariable + "']"; - // } - // else if (v_AutomationType == "Get Selected State From Element") - // { - // //apply to variable - // var applyToVariable = (from rw in v_UIAActionParameters.AsEnumerable() - // where rw.Field("Parameter Name") == "Apply To Variable" - // select rw.Field("Parameter Value")).FirstOrDefault(); - - // return base.GetDisplayValue() + " [Selected State for element in window '" + v_WindowName + "' and apply to '" + applyToVariable + "']"; - // } - // else - // { - // //get value from property - // var propertyName = (from rw in v_UIAActionParameters.AsEnumerable() - // where rw.Field("Parameter Name") == "Get Value From" - // select rw.Field("Parameter Value")).FirstOrDefault(); - - // //apply to variable - // var applyToVariable = (from rw in v_UIAActionParameters.AsEnumerable() - // where rw.Field("Parameter Name") == "Apply To Variable" - // select rw.Field("Parameter Value")).FirstOrDefault(); - - // return base.GetDisplayValue() + " [Get value from '" + propertyName + "' in window '" + v_WindowName + "' and apply to '" + applyToVariable + "']"; - // } - //} - - //public override bool IsValidate(frmCommandEditor editor) - //{ - // base.IsValidate(editor); - - // if (String.IsNullOrEmpty(this.v_WindowName)) - // { - // this.validationResult += "Window Name is empty.\n"; - // this.IsValid = false; - // } - // if (String.IsNullOrEmpty(this.v_AutomationType)) - // { - // this.validationResult += "Action is empty.\n"; - // this.IsValid = false; - // } - // else - // { - // switch (this.v_AutomationType) - // { - // case "Click Element": - // ClickElementValidate(); - // break; - // case "Get Value From Element": - // GetValueFromElementValidate(); - // break; - // case "Check If Element Exists": - // case "Get Text Value From Element": - // case "Get Selected State From Element": - // CheckIfElementExistsValidate(); - // break; - - // case "Get Value From Table Element": - // GetValueFromTableElement(); - // break; - - // default: - // break; - // } - // } - - // return this.IsValid; - //} - - private void ClickElementValidate() - { - var clickType = (from rw in v_UIAActionParameters.AsEnumerable() - where rw.Field("Parameter Name") == "Click Type" - select rw.Field("Parameter Value")).FirstOrDefault(); - if (String.IsNullOrEmpty(clickType)) - { - this.validationResult += "Click Type is empty.\n"; - this.IsValid = false; - } - - var x = (from rw in v_UIAActionParameters.AsEnumerable() - where rw.Field("Parameter Name") == "X Adjustment" - select rw.Field("Parameter Value")).FirstOrDefault(); - var y = (from rw in v_UIAActionParameters.AsEnumerable() - where rw.Field("Parameter Name") == "Y Adjustment" - select rw.Field("Parameter Value")).FirstOrDefault(); - - if (String.IsNullOrEmpty(x)) - { - this.validationResult += "X Adjustment is empty.\n"; - this.IsValid = false; - } - if (String.IsNullOrEmpty(y)) - { - this.validationResult += "Y Adjustment is empty.\n"; - this.IsValid = false; - } - } - - private void GetValueFromElementValidate() - { - var valueFrom = (from rw in v_UIAActionParameters.AsEnumerable() - where rw.Field("Parameter Name") == "Get Value From" - select rw.Field("Parameter Value")).FirstOrDefault(); - var variable = (from rw in v_UIAActionParameters.AsEnumerable() - where rw.Field("Parameter Name") == "Apply To Variable" - select rw.Field("Parameter Value")).FirstOrDefault(); - - if (String.IsNullOrEmpty(valueFrom)) - { - this.validationResult += "Get Value From is empty.\n"; - this.IsValid = false; - } - if (String.IsNullOrEmpty(variable)) - { - this.validationResult += "Variable is empty.\n"; - this.IsValid = false; - } - } - - private void CheckIfElementExistsValidate() - { - var variable = (from rw in v_UIAActionParameters.AsEnumerable() - where rw.Field("Parameter Name") == "Apply To Variable" - select rw.Field("Parameter Value")).FirstOrDefault(); - if (String.IsNullOrEmpty(variable)) - { - this.validationResult += "Variable is empty.\n"; - this.IsValid = false; - } - } - - private void GetValueFromTableElement() - { - var row = (from rw in v_UIAActionParameters.AsEnumerable() - where rw.Field("Parameter Name") == "Row" - select rw.Field("Parameter Value")).FirstOrDefault(); - var column = (from rw in v_UIAActionParameters.AsEnumerable() - where rw.Field("Parameter Name") == "Column" - select rw.Field("Parameter Value")).FirstOrDefault(); - var variable = (from rw in v_UIAActionParameters.AsEnumerable() - where rw.Field("Parameter Name") == "Apply To Variable" - select rw.Field("Parameter Value")).FirstOrDefault(); - - if (String.IsNullOrEmpty(row)) - { - this.validationResult += "Row is empty.\n"; - this.IsValid = false; - } - if (String.IsNullOrEmpty(column)) - { - this.validationResult += "Column is empty.\n"; - this.IsValid = false; - } - if (String.IsNullOrEmpty(variable)) - { - this.validationResult += "Variable is empty.\n"; - this.IsValid = false; - } - } - - //public override void ConvertToIntermediate(EngineSettings settings, List variables) - //{ - // var cnv = new Dictionary(); - // cnv.Add("v_WindowName", "convertToIntermediateWindowName"); - // ConvertToIntermediate(settings, cnv, variables); - //} - - //public override void ConvertToRaw(EngineSettings settings) - //{ - // var cnv = new Dictionary(); - // cnv.Add("v_WindowName", "convertToRawWindowName"); - // ConvertToRaw(settings, cnv); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationWaitForUIElementToExistsByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationWaitForUIElementToExistsByXPathCommand.cs deleted file mode 100644 index 447ade469..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationWaitForUIElementToExistsByXPathCommand.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement")] - [Attributes.ClassAttributes.CommandSettings("Wait For UIElement To Exists By XPath")] - [Attributes.ClassAttributes.Description("This command allows you to Wait until the UIElement exists using by XPath.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Wait until the UIElement exists using by XPath.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationWaitForUIElementToExistsByXPathCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] - public string v_SearchXPath { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public UIAutomationWaitForUIElementToExistsByXPathCommand() - { - //this.CommandName = "UIAutomationWaitForElementExistByXPathCommand"; - //this.SelectionName = "Wait For Element Exist By XPath"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - UIElementControls.SearchGUIElementByXPath(this, engine); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationWaitForUIElementToExistsCommand.cs b/taskt/Core/Automation/Commands/UIAutomation/UIAutomationWaitForUIElementToExistsCommand.cs deleted file mode 100644 index 7fca5ce2d..000000000 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationWaitForUIElementToExistsCommand.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Data; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using System.Windows.Forms; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("UIAutomation")] - [Attributes.ClassAttributes.SubGruop("Search UIElement")] - [Attributes.ClassAttributes.CommandSettings("Wait For UIElement To Exists")] - [Attributes.ClassAttributes.Description("This command allows you to Wait until the UIElement exists.")] - [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Wait until the UIElement exists.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationWaitForUIElementToExistsCommand : ScriptCommand, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] - public DataTable v_SearchParameters { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public UIAutomationWaitForUIElementToExistsCommand() - { - //this.CommandName = "UIAutomationWaitForElementExistCommand"; - //this.SelectionName = "Wait For Element Exist"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - UIElementControls.SearchGUIElement(this, engine); - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); - UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - - var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); - DataTableControls.BeforeValidate_NoRowAdding(dgv, v_SearchParameters); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromSomethingByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromSomethingByTreeWalkerCommands.cs new file mode 100644 index 000000000..17e4a1a33 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromSomethingByTreeWalkerCommands.cs @@ -0,0 +1,61 @@ +using System.Data; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for children search UIElements from Something by TreeWalker commands + /// + public abstract class AChildrenSearchUIElementsFromSomethingByTreeWalkerCommands : ScriptCommand, IUIElementChildrenSearchParametersProperties + { + [XmlElement] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_SearchParameters))] + [PropertyParameterOrder(6000)] + public virtual DataTable v_SearchParameters { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeForUIElement))] + [PropertyParameterOrder(7990)] + public virtual string v_WaitTimeForUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxSiblings))] + [PropertyParameterOrder(7991)] + public virtual string v_MaxSiblings { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxNumberUIElements))] + [PropertyParameterOrder(7995)] + public virtual string v_MaxNumberUIElements { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_SiblingsDirection))] + [PropertyParameterOrder(7996)] + public virtual string v_SiblingsDirection { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + [PropertyParameterOrder(10000)] + public virtual string v_WindowNameResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + [PropertyParameterOrder(10100)] + public virtual string v_WindowHandleResult { get; set; } + + public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.RenderUIElementSearchParameter(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); + } + + public override void BeforeValidate() + { + base.BeforeValidate(); + + var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); + DataTableControls.BeforeValidate_NoRowAdding(dgv, v_SearchParameters); + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromSomethingByXPathCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromSomethingByXPathCommands.cs new file mode 100644 index 000000000..fd1702b17 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromSomethingByXPathCommands.cs @@ -0,0 +1,37 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WindowGroup; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for children search UIELement from something by XPath commands + /// + public abstract class AChildrenSearchUIElementsFromSomethingByXPathCommands : ScriptCommand, IUIElementChildrenSearchXPathProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_SearchXPath))] + [PropertyParameterOrder(6000)] + public virtual string v_SearchXPath { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeForUIElement))] + [PropertyParameterOrder(7990)] + public virtual string v_WaitTimeForUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxSiblings))] + [PropertyParameterOrder(7991)] + public virtual string v_MaxSiblings { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + [PropertyParameterOrder(10000)] + public virtual string v_WindowNameResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + [PropertyParameterOrder(10100)] + public virtual string v_WindowHandleResult { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromUIElementByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromUIElementByTreeWalkerCommands.cs new file mode 100644 index 000000000..ae36fa46e --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromUIElementByTreeWalkerCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for children search UIElements from UIElements by TreeWalker commands + /// + public abstract class AChildrenSearchUIElementsFromUIElementByTreeWalkerCommands : AChildrenSearchUIElementsFromSomethingByTreeWalkerCommands, IDoSomethingUIElementProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_InputUIElementName))] + [PropertyParameterOrder(5000)] + public virtual string v_TargetElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromUIElementByXPathCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromUIElementByXPathCommands.cs new file mode 100644 index 000000000..54fe802ca --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AChildrenSearchUIElementsFromUIElementByXPathCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for children search UIElements from UIElement by XPath commands + /// + public abstract class AChildrenSearchUIElementsFromUIElementByXPathCommands : AChildrenSearchUIElementsFromSomethingByXPathCommands, IDoSomethingUIElementProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_InputUIElementName))] + [PropertyParameterOrder(5000)] + public virtual string v_TargetElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromSomethingByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromSomethingByTreeWalkerCommands.cs new file mode 100644 index 000000000..4acee5c89 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromSomethingByTreeWalkerCommands.cs @@ -0,0 +1,20 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for Descendants Search any-one UIElement from UIElement by TreeWalker commands + /// + public abstract class ADescendantsSearchAnyUIElementFromSomethingByTreeWalkerCommands : ADescendantsSearchUIElementsFromSomethingByTreeWalkerCommands, IUIElementDescendantsSearchAnyUIElementProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_TargetUIElementIndex))] + [PropertyParameterOrder(6100)] + public virtual string v_TargetUIElementIndex { get; set; } + + [XmlAttribute] + [PropertyIsOptional(true, "Same Value of UIElement Index")] + public override string v_MaxNumberUIElements { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromUIElementByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromUIElementByTreeWalkerCommands.cs new file mode 100644 index 000000000..0a8b1f283 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromUIElementByTreeWalkerCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for descendants search any-one UIElement from UIElement by TreeWalker commands + /// + public abstract class ADescendantsSearchAnyUIElementFromUIElementByTreeWalkerCommands : ADescendantsSearchAnyUIElementFromSomethingByTreeWalkerCommands, IDoSomethingUIElementProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_InputUIElementName))] + [PropertyParameterOrder(5000)] + public virtual string v_TargetElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromWindowHandleByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromWindowHandleByTreeWalkerCommands.cs new file mode 100644 index 000000000..baa4a9fc5 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromWindowHandleByTreeWalkerCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for descendants search any-one UIElement From Window handle by TreeWalker commands + /// + public abstract class ADescendantsSearchAnyUIElementFromWindowHandleByTreeWalkerCommands : ADescendantsSearchUIElementsFromWindowHandleByTreeWalkerCommands, IUIElementIndexProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_TargetUIElementIndex))] + [PropertyParameterOrder(6100)] + public virtual string v_TargetUIElementIndex { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromWindowNameByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromWindowNameByTreeWalkerCommands.cs new file mode 100644 index 000000000..fde4f9237 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchAnyUIElementFromWindowNameByTreeWalkerCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for descendants Search Any-one UIElement from Window Name by TreeWalker commands + /// + public abstract class ADescendantsSearchAnyUIElementFromWindowNameByTreeWalkerCommands : ADescendantsSearchUIElementsFromWindowNameByTreeWalkerCommands, IUIElementIndexProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_TargetUIElementIndex))] + [PropertyParameterOrder(6100)] + public virtual string v_TargetUIElementIndex { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromSomethingByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromSomethingByTreeWalkerCommands.cs new file mode 100644 index 000000000..d55c15a75 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromSomethingByTreeWalkerCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for descendants search UIElements from Something by TreeWalker commands + /// + public abstract class ADescendantsSearchUIElementsFromSomethingByTreeWalkerCommands : AChildrenSearchUIElementsFromSomethingByTreeWalkerCommands, IUIElementDescendantsSearchParametersProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxDepth))] + [PropertyParameterOrder(7992)] + public virtual string v_MaxDepth { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromSomethingByXPathCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromSomethingByXPathCommands.cs new file mode 100644 index 000000000..d57b1a15a --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromSomethingByXPathCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for descendants search UIElement from something by XPath commands + /// + public abstract class ADescendantsSearchUIElementsFromSomethingByXPathCommands : AChildrenSearchUIElementsFromSomethingByXPathCommands, IUIElementDescendantsSearchXPathProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxDepth))] + [PropertyParameterOrder(7992)] + public virtual string v_MaxDepth { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromUIElementByXPathCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromUIElementByXPathCommands.cs new file mode 100644 index 000000000..3e044aa3a --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromUIElementByXPathCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for descendants search UIElement from UIElement by XPath commands + /// + public abstract class ADescendantsSearchUIElementsFromUIElementByXPathCommands : ADescendantsSearchUIElementsFromSomethingByXPathCommands, IUIElementCoreProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_InputUIElementName))] + [PropertyParameterOrder(5000)] + public virtual string v_TargetElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowHandleByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowHandleByTreeWalkerCommands.cs new file mode 100644 index 000000000..05877101f --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowHandleByTreeWalkerCommands.cs @@ -0,0 +1,27 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for descendants search UIELements From Window Handle by TreeWalker commands + /// + public abstract class ADescendantsSearchUIElementsFromWindowHandleByTreeWalkerCommands : ADescendantsSearchUIElementsFromSomethingByTreeWalkerCommands, IWindowHandleProperties, IUIElementSearchUIElementFromWindowSomethingByAnywayProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWindowHandle))] + [PropertyParameterOrder(5000)] + + public virtual string v_WindowHandle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + [PropertyParameterOrder(8200)] + public virtual string v_WaitTimeForWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WindowUIElementName))] + [PropertyParameterOrder(10200)] + public virtual string v_WindowUIElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowHandleByXPathCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowHandleByXPathCommands.cs new file mode 100644 index 000000000..cc98b9d20 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowHandleByXPathCommands.cs @@ -0,0 +1,27 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for descendants search UIELements From Window Handle by TreeWalker commands + /// + public abstract class ADescendantsSearchUIElementsFromWindowHandleByXPathCommands : ADescendantsSearchUIElementsFromSomethingByXPathCommands, IWindowHandleProperties, IUIElementSearchUIElementFromWindowSomethingByAnywayProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWindowHandle))] + [PropertyParameterOrder(5000)] + + public virtual string v_WindowHandle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + [PropertyParameterOrder(8200)] + public virtual string v_WaitTimeForWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WindowUIElementName))] + [PropertyParameterOrder(10200)] + public virtual string v_WindowUIElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowNameByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowNameByTreeWalkerCommands.cs new file mode 100644 index 000000000..dc513327d --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowNameByTreeWalkerCommands.cs @@ -0,0 +1,94 @@ +using System; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; +using taskt.UI.CustomControls; + +namespace taskt.Core.Automation.Commands +{ + /// + /// for descendants search UIElements from Window Name by TreeWalker commands + /// + public abstract class ADescendantsSearchUIElementsFromWindowNameByTreeWalkerCommands : ADescendantsSearchUIElementsFromSomethingByTreeWalkerCommands, IOneWindowNameProperties, IUIElementSearchUIElementFromWindowSomethingByAnywayProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + [PropertyParameterOrder(5000)] + public virtual string v_WindowName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CheckMethod))] + [PropertyParameterOrder(8100)] + public virtual string v_CheckMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_SelectionMethod_Single))] + [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + [PropertyParameterOrder(8200)] + public virtual string v_SelectionMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + [PropertyParameterOrder(8300)] + public virtual string v_TargetWindowIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + [PropertyParameterOrder(8400)] + public virtual string v_WaitTimeForWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WindowUIElementName))] + [PropertyParameterOrder(10200)] + public virtual string v_WindowUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CaseSensitive))] + [PropertyParameterOrder(11000)] + public virtual string v_CaseSensitive { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TrimBeforeCheck))] + [PropertyParameterOrder(11100)] + public virtual string v_TrimBeforeCheck { get; set; } + + protected void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + { + WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + } + + public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); + } + + /// + /// search window UIElement after action + /// + /// + /// action process, arg1 is Window UIElement + protected void SearchWindowAfterAction(Engine.AutomationEngineInstance engine, Func actionFunc) + { + this.SearchWindowAfterActionCore(engine, + new Func(winElem => + { + return new UIAutomationGetWindowUIElementFromWindowNameCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_SelectionMethod = this.v_SelectionMethod, + v_TargetWindowIndex = this.v_TargetWindowIndex, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = winElem.VariableName, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + v_CaseSensitive = this.v_CaseSensitive, + v_TrimBeforeCheck = this.v_TrimBeforeCheck, + }; + }), + actionFunc); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowNameByXPathCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowNameByXPathCommands.cs new file mode 100644 index 000000000..bb408e017 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADescendantsSearchUIElementsFromWindowNameByXPathCommands.cs @@ -0,0 +1,93 @@ +using System; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; +using taskt.UI.CustomControls; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for descendants search UIElements from Window name by XPath commands + /// + public abstract class ADescendantsSearchUIElementsFromWindowNameByXPathCommands : ADescendantsSearchUIElementsFromSomethingByXPathCommands, IOneWindowNameProperties, IUIElementSearchUIElementFromWindowSomethingByAnywayProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + [PropertyParameterOrder(5000)] + public virtual string v_WindowName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CheckMethod))] + [PropertyParameterOrder(8100)] + public virtual string v_CheckMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_SelectionMethod_Single))] + [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + [PropertyParameterOrder(8200)] + public virtual string v_SelectionMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + [PropertyParameterOrder(8300)] + public virtual string v_TargetWindowIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + [PropertyParameterOrder(8300)] + public virtual string v_WaitTimeForWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WindowUIElementName))] + [PropertyParameterOrder(10200)] + public virtual string v_WindowUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CaseSensitive))] + [PropertyParameterOrder(11000)] + public virtual string v_CaseSensitive { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TrimBeforeCheck))] + [PropertyParameterOrder(11100)] + public virtual string v_TrimBeforeCheck { get; set; } + + protected void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + { + WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + } + + public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); + } + + /// + /// search window UIElement after action + /// + /// + /// action process, arg1 is Window UIElement + protected void SearchWindowAfterAction(Engine.AutomationEngineInstance engine, Func actionFunc) + { + this.SearchWindowAfterActionCore(engine, + new Func(winElem => + { + return new UIAutomationGetWindowUIElementFromWindowNameCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_SelectionMethod = this.v_SelectionMethod, + v_TargetWindowIndex = this.v_TargetWindowIndex, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = winElem.VariableName, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + v_CaseSensitive = this.v_CaseSensitive, + v_TrimBeforeCheck = this.v_TrimBeforeCheck, + }; + }), + actionFunc); + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ADoSomethingUIElementCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ADoSomethingUIElementCommands.cs new file mode 100644 index 000000000..5fa56d769 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ADoSomethingUIElementCommands.cs @@ -0,0 +1,21 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for Get from UIElement or UIElement Action commands base + /// + public abstract class ADoSomethingUIElementCommands : AUIElementCoreCommands, IDoSomethingUIElementProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + [PropertyParameterOrder(10000)] + public virtual string v_WindowNameResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + [PropertyParameterOrder(10100)] + public virtual string v_WindowHandleResult { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AGetFromUIElementCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AGetFromUIElementCommands.cs new file mode 100644 index 000000000..292c60375 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AGetFromUIElementCommands.cs @@ -0,0 +1,20 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// get something from UIElement commands + /// + public abstract class AGetFromUIElementCommands : ADoSomethingUIElementCommands, IGetFromUIElementProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnoreSetEmpty))] + [PropertyDescription("When the Value(s) can not Retrieved")] + [PropertyDisplayText(true, "When can not Retrieved")] + [PropertyIsOptional(true, "Error")] + [PropertyValidationRule("When Value can not Retrieved", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyParameterOrder(10000)] + public virtual string v_WhenValueCanNotRetrieved { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionCommands.cs new file mode 100644 index 000000000..b4cc32907 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionCommands.cs @@ -0,0 +1,31 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// UIElement action commands + /// + public abstract class AUIElementActionCommands : ADoSomethingUIElementCommands, IUIElementActionProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_ActivateWindow))] + [PropertyParameterOrder(8000)] + public virtual string v_ActivateWindowBeforeAction { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeBeforeAction))] + [PropertyParameterOrder(9000)] + public virtual string v_WaitTimeBeforeAction { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeAfterAction))] + [PropertyParameterOrder(9000)] + public virtual string v_WaitTimeAfterAction { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WhenActionIsNotSupported))] + [PropertyParameterOrder(11000)] + public virtual string v_WhenActionIsNotSupported { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromSomethingByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromSomethingByTreeWalkerCommands.cs new file mode 100644 index 000000000..7bbd8fd8f --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromSomethingByTreeWalkerCommands.cs @@ -0,0 +1,40 @@ +using System.Data; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for UIElement Action from Something, Search By TreeWalker commands + /// + public abstract class AUIElementActionFromSomethingByTreeWalkerCommands : AUIElementActionSomewayCommands, IUIElementChildrenSearchParametersProperties, IUIElementDescendantsSearchAnyUIElementProperties + { + [XmlElement] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_SearchParameters))] + [PropertyParameterOrder(6000)] + public DataTable v_SearchParameters { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_TargetUIElementIndex))] + [PropertyParameterOrder(6100)] + public string v_TargetUIElementIndex { get; set; } + + [XmlAttribute] + [PropertyParameterOrder(6200)] + public override string v_AutomationType { get; set; } + + [XmlElement] + [PropertyParameterOrder(7900)] + public override DataTable v_UIAActionParameters { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxNumberUIElements))] + [PropertyParameterOrder(7995)] + public string v_MaxNumberUIElements { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_SiblingsDirection))] + [PropertyParameterOrder(7996)] + public string v_SiblingsDirection { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromSomethingByXPathCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromSomethingByXPathCommands.cs new file mode 100644 index 000000000..95c781e8e --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromSomethingByXPathCommands.cs @@ -0,0 +1,25 @@ +using System.Data; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for UIElement Action from something by XPath commands + /// + public abstract class AUIElementActionFromSomethingByXPathCommands : AUIElementActionSomewayCommands, IUIElementChildrenSearchXPathProperties, IUIElementDescendantsSearchXPathProperties + { + [XmlAttribute] + [PropertyParameterOrder(5500)] + public override string v_AutomationType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_SearchXPath))] + [PropertyParameterOrder(6000)] + public virtual string v_SearchXPath { get; set; } + + [XmlElement] + [PropertyParameterOrder(6500)] + public override DataTable v_UIAActionParameters { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromWindowSomethingByTreeWalkerCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromWindowSomethingByTreeWalkerCommands.cs new file mode 100644 index 000000000..2ab3cd3de --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromWindowSomethingByTreeWalkerCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for UIElement Action from Window something By TreeWalker commands + /// + public abstract class AUIElementActionFromWindowSomethingByTreeWalkerCommands : AUIElementActionFromSomethingByTreeWalkerCommands, IWindowUIElementResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WindowUIElementName))] + [PropertyParameterOrder(10200)] + public string v_WindowUIElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromWindowSomethingByXPathCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromWindowSomethingByXPathCommands.cs new file mode 100644 index 000000000..a6e287d40 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionFromWindowSomethingByXPathCommands.cs @@ -0,0 +1,13 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public abstract class AUIElementActionFromWindowSomethingByXPathCommands : AUIElementActionFromSomethingByXPathCommands, IWindowUIElementResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WindowUIElementName))] + [PropertyParameterOrder(10200)] + public string v_WindowUIElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionSomewayCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionSomewayCommands.cs new file mode 100644 index 000000000..569c6d854 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementActionSomewayCommands.cs @@ -0,0 +1,722 @@ +using System; +using System.Data; +using System.Windows.Automation; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WindowGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for UIElement Action By/From someway commands + /// + public abstract class AUIElementActionSomewayCommands : ScriptCommand, IUIElementUIElementActionSomewayProperties, IFromWindowNameResultsProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_AutomationType))] + [PropertySelectionChangeEvent(nameof(cmbActionType_SelectedItemChange))] + public abstract string v_AutomationType { get; set; } + + [XmlElement] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_UIAActionParameters))] + public abstract DataTable v_UIAActionParameters { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeForUIElement))] + [PropertyParameterOrder(7990)] + public string v_WaitTimeForUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxSiblings))] + [PropertyParameterOrder(7991)] + public string v_MaxSiblings { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxDepth))] + [PropertyParameterOrder(7992)] + public string v_MaxDepth { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyIsOptional(true, "")] + [PropertyValidationRule("UIElement Result", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "UIElement Result")] + [PropertyParameterOrder(10000)] + public virtual string v_TargetUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + [PropertyParameterOrder(10100)] + public virtual string v_WindowNameResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + [PropertyParameterOrder(10200)] + public virtual string v_WindowHandleResult { get; set; } + + /// + /// UIElement Action Process + /// + /// arg1 is a Variable to Store root UIElement + /// arg1 is a Variable has root UIElement, arg2 is Variable Name to Store Result + /// arg1 is a Variable has root UIElement, arg2 is Variable to Store Target UIElement + /// + protected void UIElementActionProcess(Engine.AutomationEngineInstance engine, Action rootElemAction, Action existsElemAction, Action searchElemAction) + { + var elemAction = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_AutomationType), engine); + + void StoreUIElementResultInUserVariable(InnerScriptVariable v, Engine.AutomationEngineInstance egn) + { + if (!string.IsNullOrEmpty(v_TargetUIElement)) + { + if (v.VariableValue is AutomationElement elm) + { + elm.StoreInUserVariable(engine, v_TargetUIElement); + } + else + { + throw new Exception("Strange UIElement Result Value."); + } + } + } + + using (var myRootElem = new InnerScriptVariable(engine)) + { + rootElemAction(myRootElem); + + var p = DataTableControls.GetFieldValues(v_UIAActionParameters, "Parameter Name", "Parameter Value", false, engine); + + using (var myTrgElem = new InnerScriptVariable(engine)) + { + switch (elemAction) + { + case "check uielement exists": + existsElemAction(myRootElem, p["Apply To Variable"]); + StoreUIElementResultInUserVariable(myTrgElem, engine); + return; + + default: + searchElemAction(myRootElem, myTrgElem); + StoreUIElementResultInUserVariable(myTrgElem, engine); + break; + } + + switch (elemAction) + { + case "click uielement": + var clickCmd = new UIAutomationClickUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_ClickType = p["Click Type"], + v_XOffset = p["X Offset"], + v_YOffset = p["Y Offset"], + }; + clickCmd.RunCommand(engine); + break; + case "expand collapse items in uielement": + var expandCmd = new UIAutomationExpandCollapseItemsInUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_ItemsState = p["Items State"], + }; + expandCmd.RunCommand(engine); + break; + case "scroll uielement": + var scrollCmd = new UIAutomationScrollUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_ScrollBarType = p["ScrollBar Type"], + v_DirectionAndAmount = p["Scroll Method"], + }; + scrollCmd.RunCommand(engine); + break; + case "scroll percent uielement": + var scrollPerCmd = new UIAutomationScrollPercentUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_ScrollBarType = p["ScrollBar Type"], + v_ScrollValue = p["Scroll Value"], + }; + scrollPerCmd.RunCommand(engine); + break; + case "select item in uielement": + var selectItemCmd = new UIAutomationSelectItemInUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_Item = p["Item Value"], + }; + selectItemCmd.RunCommand(engine); + break; + case "select uielement": + var selectCmd = new UIAutomationSelectUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + }; + selectCmd.RunCommand(engine); + break; + case "set selected state to uielement": + var selectStateCmd = new UIAutomationSetSelectedStateToUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_State = p["Selected State"], + }; + selectStateCmd.RunCommand(engine); + break; + case "set text to uielement": + var setTextCmd = new UIAutomationSetTextToUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_TextToSet = p["Text To Set"], + }; + setTextCmd.RunCommand(engine); + break; + case "get parent uielement": + var getPrentCmd = new UIAutomationGetParentUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_Result = p["Apply To Variable"], + }; + getPrentCmd.RunCommand(engine); + break; + case "get property value from uielement": + var propValueCmd = new UIAutomationGetPropertyValueFromUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_PropertyName = p["Property Name"], + v_Result = p["Apply To Variable"], + }; + propValueCmd.RunCommand(engine); + break; + case "check uielement exists": + true.StoreInUserVariable(engine, p["Apply To Variable"]); + break; + case "get text from uielement": + var getTextCmd = new UIAutomationGetTextFromUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_Result = p["Apply To Variable"], + }; + getTextCmd.RunCommand(engine); + break; + case "get scrollbar information from uielement": + var getScrollInfoCmd = new UIAutomationGetScrollBarInformationFromUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_InformationType = p["Information Type"], + v_Result = p["Result"], + }; + getScrollInfoCmd.RunCommand(engine); + break; + case "get selected state from uielement": + var getSelectedCmd = new UIAutomationGetSelectedStateFromUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_Result = p["Apply To Variable"], + }; + getSelectedCmd.RunCommand(engine); + break; + case "get selection items value from uielement": + var getSelectionItemsCmd = new UIAutomationGetSelectionItemsValueFromUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_Result = p["Apply To Variable"], + }; + getSelectionItemsCmd.RunCommand(engine); + break; + case "get table information from uielement": + var getTableInfoCmd = new UIAutomationGetTableInformationFromUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_InformationType = p["Information Type"], + v_Result = p["Result"], + }; + getTableInfoCmd.RunCommand(engine); + break; + case "get text from table uielement": + var getTableCmd = new UIAutomationGetTextFromTableUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_Row = p["Row"], + v_Column = p["Column"], + v_Result = p["Apply To Variable"], + }; + getTableCmd.RunCommand(engine); + break; + case "get uielement from table uielement": + var getTableElemCmd = new UIAutomationGetUIElementFromTableUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_Row = p["Row"], + v_Column = p["Column"], + v_Result = p["Apply To Variable"], + }; + getTableElemCmd.RunCommand(engine); + break; + case "get uielement position": + var getElemPosCmd = new UIAutomationGetUIElementPositionCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_XPosition = p["X Variable"], + v_YPosition = p["Y Variable"], + v_PositionBase = p["Base Position"], + }; + getElemPosCmd.RunCommand(engine); + break; + case "get uielement size": + var getElemSizeCmd = new UIAutomationGetUIElementSizeCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_Width = p["Width Variable"], + v_Height = p["Height Variable"], + }; + getElemSizeCmd.RunCommand(engine); + break; + case "get window handle from uielement": + var getWinHandleCmd = new UIAutomationGetWindowHandleFromUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_WindowHandleResult = p["Apply To Variable"], + }; + getWinHandleCmd.RunCommand(engine); + break; + case "get window name from uielement": + var getWinNameCmd = new UIAutomationGetWindowNameFromUIElementCommand() + { + v_TargetElement = myTrgElem.VariableName, + v_WindowNameResult = p["Apply To Variable"], + }; + getWinNameCmd.RunCommand(engine); + break; + } + } + } + } + + public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + var cmb = FormUIControls.GetPropertyControl(ControlsList, nameof(v_AutomationType)); + var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); + SetComboBoxParameterProcess(dgv, cmb.SelectedItem?.ToString() ?? ""); + } + + protected void cmbActionType_SelectedItemChange(object sender, EventArgs e) + { + var a = ((ComboBox)sender).SelectedItem?.ToString() ?? ""; + + var dgv = FormUIControls.GetPropertyControl(this.ControlsList, nameof(v_UIAActionParameters)); + var table = v_UIAActionParameters; + table.Rows.Clear(); + switch (a.ToLower()) + { + case "click uielement": + //table.Rows.Add(new string[] { "Click Type", "" }); + //table.Rows.Add(new string[] { "X Offset", "" }); + //table.Rows.Add(new string[] { "Y Offset", "" }); + AddDataTableRows(table, new string[] + { + "Click Type", + "X Offset", + "Y Offset", + }); + break; + + case "expand collapse items in uielement": + //table.Rows.Add(new string[] { "Items State", "" }); + AddDataTableRows(table, new string[] + { + "Items State", + }); + break; + + case "scroll uielement": + //table.Rows.Add(new string[] { "ScrollBar Type", "" }); + //table.Rows.Add(new string[] { "Scroll Method", "" }); + AddDataTableRows(table, new string[] + { + "ScrollBar Type", + "Scroll Method", + }); + break; + + case "scroll percent uielement": + //table.Rows.Add(new string[] { "ScrollBar Type", "" }); + //table.Rows.Add(new string[] { "Scroll Value", "" }); + AddDataTableRows(table, new string[] + { + "ScrollBar Type", + "Scroll Value", + }); + break; + + case "select item in uielement": + //table.Rows.Add(new string[] { "Item Value", "" }); + AddDataTableRows(table, new string[] + { + "Item Value", + }); + break; + + case "set selected state to uielement": + //table.Rows.Add(new string[] { "Selected State", "" }); + AddDataTableRows(table, new string[] + { + "Selected State", + }); + break; + + case "set text to uielement": + //table.Rows.Add(new string[] { "Text To Set", "" }); + AddDataTableRows(table, new string[] + { + "Text To Set", + }); + break; + + case "get property value from uielement": + //table.Rows.Add(new string[] { "Property Name", "" }); + //table.Rows.Add(new string[] { "Apply To Variable", "" }); + AddDataTableRows(table, new string[] + { + "Property Name", + "Apply To Variable", + }); + break; + + case "get scrollbar information from uielement": + case "get table information from uielement": + //table.Rows.Add(new string[] { "Information Type", "" }); + //table.Rows.Add(new string[] { "Result", "" }); + AddDataTableRows(table, new string[] + { + "Information Type", + "Result", + }); + break; + + case "get text from table uielement": + case "get uielement from table uielement": + //table.Rows.Add(new string[] { "Row", "" }); + //table.Rows.Add(new string[] { "Column", "" }); + //table.Rows.Add(new string[] { "Apply To Variable", "" }); + AddDataTableRows(table, new string[] + { + "Row", + "Column", + "Apply To Variable", + }); + break; + + case "get uielement position": + //table.Rows.Add(new string[] { "X Variable", "" }); + //table.Rows.Add(new string[] { "Y Variable", "" }); + //table.Rows.Add(new string[] { "Base Position", "" }); + AddDataTableRows(table, new string[] + { + "X Variable", + "Y Variable", + "Base Position", + }); + break; + + case "get uielement size": + //table.Rows.Add(new string[] { "Width Variable", "" }); + //table.Rows.Add(new string[] { "Height Variable", "" }); + AddDataTableRows(table, new string[] + { + "Width Variable", + "Height Variable", + }); + break; + + case "check uielement exists": + case "get parent uielement": + case "get selected state from uielement": + case "get selection items value from uielement": + case "get text from uielement": + case "get window handle from uielement": + case "get window name from uielement": + //table.Rows.Add(new string[] { "Apply To Variable", "" }); + AddDataTableRows(table, new string[] + { + "Apply To Variable", + }); + break; + + case "select uielement": + case "wait for uielement to exists": + // nothing + break; + } + + SetComboBoxParameterProcess(dgv, a); + } + + /// + /// Add DataTable rows process + /// + /// + /// + protected static void AddDataTableRows(DataTable table, string[] rows) + { + foreach(var r in rows) + { + table.Rows.Add(new string[] { r, "" }); + } + } + + /// + /// set DataGridView combobox parameter process + /// + /// + /// + protected static void SetComboBoxParameterProcess(DataGridView dgv, string actionType) + { + switch (actionType.ToLower()) + { + case "click uielement": + //var clickType = new DataGridViewComboBoxCell(); + //clickType.Items.AddRange(new string[] + //{ + // "Left Click", + // "Middle Click", + // "Right Click", + // "Left Down", + // "Middle Down", + // "Right Down", + // "Left Up", + // "Middle Up", + // "Right Up", + // "Double Left Click", + // "None", + //}); + //dgv.Rows[0].Cells[1] = clickType; + ApplyDGVCombBox(dgv, 0, new string[] + { + "Left Click", + "Middle Click", + "Right Click", + "Left Down", + "Middle Down", + "Right Down", + "Left Up", + "Middle Up", + "Right Up", + "Double Left Click", + "None", + }); + break; + + case "expand collapse items in uielement": + //var itemState = new DataGridViewComboBoxCell(); + //itemState.Items.AddRange(new string[] + //{ + // "Expand", + // "Collapse" + //}); + //dgv.Rows[0].Cells[1] = itemState; + ApplyDGVCombBox(dgv, 0, new string[] + { + "Expand", + "Collapse" + }); + break; + + case "scroll uielement": + //var barType = new DataGridViewComboBoxCell(); + //barType.Items.AddRange(new string[] + //{ + // "Vertical", + // "Horizonal", + //}); + //var scrollMethod = new DataGridViewComboBoxCell(); + //scrollMethod.Items.AddRange(new string[] + //{ + // "Scroll Small Down or Right", + // "Scroll Large Down or Right", + // "Scroll Small Up or Left", + // "Scroll Large Up or Left", + //}); + //dgv.Rows[0].Cells[1] = barType; + //dgv.Rows[1].Cells[1] = scrollMethod; + ApplyDGVCombBox(dgv, 0, new string[] + { + "Vertical", + "Horizonal", + }); + ApplyDGVCombBox(dgv, 1, new string[] + { + "Scroll Small Down or Right", + "Scroll Large Down or Right", + "Scroll Small Up or Left", + "Scroll Large Up or Left", + }); + break; + + case "scroll percent uielement": + //var perBarType = new DataGridViewComboBoxCell(); + //perBarType.Items.AddRange(new string[] + //{ + // "Vertical", + // "Horizonal", + //}); + //dgv.Rows[0].Cells[1] = perBarType; + ApplyDGVCombBox(dgv, 0, new string[] + { + "Vertical", + "Horizonal", + }); + break; + + case "set selected state to uielement": + //var selectedState = new DataGridViewComboBoxCell(); + //selectedState.Items.AddRange(new string[] + //{ + // "Selected", + // "Unselected" + //}); + //dgv.Rows[0].Cells[1] = selectedState; + ApplyDGVCombBox(dgv, 0, new string[] + { + "Selected", + "Unselected", + }); + break; + + case "get property value from uielement": + //var propNames = new DataGridViewComboBoxCell(); + //propNames.Items.AddRange(new string[] + //{ + // "Name", + // "ControlType", + // "LocalizedControlType", + // "IsEnabled", + // "IsOffscreen", + // "IsKeyboardFocusable", + // "HasKeyboardFocusable", + // "AccessKey", + // "ProcessId", + // "AutomationId", + // "FrameworkId", + // "ClassName", + // "IsContentElement", + // "IsPassword", + // "AcceleratorKey", + // "HelpText", + // "IsControlElement", + // "IsRequiredForForm", + // "ItemStatus", + // "ItemType", + // "NativeWindowHandle", + //}); + //dgv.Rows[0].Cells[1] = propNames; + ApplyDGVCombBox(dgv, 0, new string[] + { + "Name", + "ControlType", + "LocalizedControlType", + "IsEnabled", + "IsOffscreen", + "IsKeyboardFocusable", + "HasKeyboardFocusable", + "AccessKey", + "ProcessId", + "AutomationId", + "FrameworkId", + "ClassName", + "IsContentElement", + "IsPassword", + "AcceleratorKey", + "HelpText", + "IsControlElement", + "IsRequiredForForm", + "ItemStatus", + "ItemType", + "NativeWindowHandle", + }); + break; + + case "get scrollbar information from uielement": + //dgv.Rows[0].Cells[1] = CreateDGVComboBox(new string[] + //{ + // "Horizontally Scrollable", + // "Horizontal Scroll Percent", + // "Vertically Scrollable", + // "Vertical Scroll Percent", + //}); + ApplyDGVCombBox(dgv, 0, new string[] + { + "Horizontally Scrollable", + "Horizontal Scroll Percent", + "Vertically Scrollable", + "Vertical Scroll Percent", + }); + break; + + case "get table information from uielement": + //dgv.Rows[0].Cells[1] = CreateDGVComboBox(new string[] + //{ + // "Column Count", + // "Row Count", + //}); + ApplyDGVCombBox(dgv, 0, new string[] + { + "Column Count", + "Row Count", + }); + break; + + case "get uielement position": + //var positionName = new DataGridViewComboBoxCell(); + //positionName.Items.AddRange(new string[] + //{ + // "Top Left", + // "Bottom Right", + // "Top Right", + // "Bottom Left", + // "Center", + //}); + //dgv.Rows[2].Cells[1] = positionName; + ApplyDGVCombBox(dgv, 2, new string[] + { + "Top Left", + "Bottom Right", + "Top Right", + "Bottom Left", + "Center", + }); + break; + } + } + + /// + /// apply DataGridViewComboBox and insert items + /// + /// + /// + /// + protected static void ApplyDGVCombBox(DataGridView dgv, int row, string[] items) + { + dgv.Rows[row].Cells[1] = CreateDGVComboBox(items); + } + + /// + /// create DataGridViewComboBoxCell and insert items + /// + /// + /// + protected static DataGridViewComboBoxCell CreateDGVComboBox(string[] items) + { + var cmb = new DataGridViewComboBoxCell(); + cmb.Items.AddRange(items); + return cmb; + } + + public override void BeforeValidate() + { + var dgvAction = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); + DataTableControls.BeforeValidate(dgvAction, v_UIAActionParameters); + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementCoreCommands.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementCoreCommands.cs new file mode 100644 index 000000000..9b506deb6 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/AUIElementCoreCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for UIElement commands core (UIElement action or get from UIElement) + /// + public abstract class AUIElementCoreCommands : ScriptCommand, IUIElementCoreProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_InputUIElementName))] + [PropertyParameterOrder(5000)] + public virtual string v_TargetElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_CanHandleUIElementExtentionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_CanHandleUIElementExtentionMethods.cs new file mode 100644 index 000000000..00644f6eb --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_CanHandleUIElementExtentionMethods.cs @@ -0,0 +1,179 @@ +using System; +using System.Windows.Automation; +using taskt.Core.Automation.Commands.WindowGroup; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_CanHandleUIElementExtentionMethods + { + public enum AutomationElementPropertyValueTypes + { + String, + Bool, + Int, + } + + /// + /// check specified object is UIElement + /// + /// + /// + /// + public static bool IsUIElement(object obj, out AutomationElement e) + { + if (obj is AutomationElement te) + { + e = te; + return true; + } + else + { + e = null; + return false; + } + } + + /// + /// get window name from UIElement + /// + /// + /// + public static (string, IntPtr) GetWindowNameAndHandle(AutomationElement targetElement) + { + // already specify window + if (targetElement.Current.ControlType == ControlType.Window) + { + return (targetElement.Current.Name, (IntPtr)targetElement.Current.NativeWindowHandle); + } + + var walker = TreeWalker.RawViewWalker; + try + { + var desktopHandle = EM_CanHandleDesktopWindowHandleExtensionMethods.GetDesktopWindowHandle(); + + var currentElement = targetElement; + while (true) + { + var tparent = walker.GetParent(currentElement); + if (tparent != null) + { + var myHandle = (IntPtr)tparent.Current.NativeWindowHandle; + if (myHandle == desktopHandle) + { + // tparent is Desktop, currentElement is window(?) + return (currentElement.Current.Name, (IntPtr)currentElement.Current.NativeWindowHandle); + } + else if (tparent.Current.ControlType == ControlType.Window) + { + // tparent is window + return (tparent.Current.Name, myHandle); + } + else + { + currentElement = tparent; + } + } + else + { + throw new Exception("Parent Element is null"); + } + } + + //var parent = walker.GetParent(targetElement); + //while (parent.Current.ControlType != ControlType.Window) + //{ + // parent = walker.GetParent(parent); + //} + //return (parent.Current.Name, (IntPtr)parent.Current.NativeWindowHandle); + } + catch + { + // try other method + var windowNames = EM_CanHandleWindowNameExtensionMethods.GetAllWindowNames(); + if ((targetElement.Current.NativeWindowHandle != 0) && (windowNames.Contains(targetElement.Current.Name))) + { + return (targetElement.Current.Name, (IntPtr)targetElement.Current.NativeWindowHandle); + } + + try + { + var parent = walker.GetParent(targetElement); + while ((parent.Current.NativeWindowHandle == 0) || (!windowNames.Contains(parent.Current.Name))) + { + parent = walker.GetParent(parent); + } + return (parent.Current.Name, (IntPtr)parent.Current.NativeWindowHandle); + } + catch + { + throw new Exception("Fail Get Window Name and Window Handle from UIElement"); + } + } + } + + /// + /// get ControlType text + /// + /// + /// + public static string GetControlTypeText(AutomationElement elem) + { + // MEMO: UIA_AppBarControlTypeId is null, why? + var fullName = elem.Current.ControlType?.ProgrammaticName ?? ".UNKNOWN"; + return fullName.Substring(fullName.LastIndexOf('.') + 1); + } + + /// + /// get parent UIElement + /// + /// + /// + /// + public static AutomationElement GetParentUIElement(AutomationElement targetElement) + { + var walker = TreeWalker.RawViewWalker; + + var parent = walker.GetParent(targetElement); + if (parent != null) + { + return parent; + } + else + { + throw new Exception("Parent UIElement does not exists"); + } + } + + /// + /// get property value + /// + /// + /// + /// + /// + public static string GetPropertyValueAsString(AutomationElement targetElement, AutomationProperty propName, AutomationElementPropertyValueTypes tp) + { + try + { + return targetElement.GetCurrentPropertyValue(propName).ToString(); + } + catch + { + switch (tp) + { + case AutomationElementPropertyValueTypes.String: + return string.Empty; + + case AutomationElementPropertyValueTypes.Bool: + return "false"; + + case AutomationElementPropertyValueTypes.Int: + return "0"; + + default: + return string.Empty; + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_CanHandleUIElementScrollBarExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_CanHandleUIElementScrollBarExtensionMethods.cs new file mode 100644 index 000000000..8ff7fd952 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_CanHandleUIElementScrollBarExtensionMethods.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Automation; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_CanHandleUIElementScrollBarExtensionMethods + { + public static ScrollPattern GetScrollPattern(AutomationElement targetElement, Action notScrollBarAction) + { + if (!targetElement.TryGetCurrentPattern(ScrollPattern.Pattern, out object scrollPtn)) + { + if (targetElement.Current.ControlType == ControlType.ScrollBar) + { + var parentElement = EM_CanHandleUIElementExtentionMethods.GetParentUIElement(targetElement); + if (!parentElement.TryGetCurrentPattern(ScrollPattern.Pattern, out scrollPtn)) + { + notScrollBarAction(); + return null; + } + } + else + { + notScrollBarAction(); + return null; + } + } + return (ScrollPattern)scrollPtn; + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_CanHandleUIElementXMLExtentionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_CanHandleUIElementXMLExtentionMethods.cs new file mode 100644 index 000000000..71de550ac --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_CanHandleUIElementXMLExtentionMethods.cs @@ -0,0 +1,48 @@ +using System.Windows.Automation; +using System.Xml.Linq; +using static taskt.Core.Automation.Commands.UIAutomationGroup.EM_CanHandleUIElementExtentionMethods; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_CanHandleUIElementXMLExtentionMethods + { + /// + /// create XML Element from UIElement + /// + /// + /// specify hash if dup + /// + public static XElement CreateXmlElement(AutomationElement targetElement, string hash = "") + { + var node = new XElement(EM_CanHandleUIElementExtentionMethods.GetControlTypeText(targetElement)); + + var cur = targetElement.Current; + + node.SetAttributeValue("AcceleratorKey", cur.AcceleratorKey); + node.SetAttributeValue("AccessKey", cur.AccessKey); + node.SetAttributeValue("AutomationId", cur.AutomationId); + node.SetAttributeValue("ClassName", cur.ClassName); + node.SetAttributeValue("FrameworkId", cur.FrameworkId); + node.SetAttributeValue("HasKeyboardFocus", cur.HasKeyboardFocus.ToString()); + node.SetAttributeValue("HelpText", cur.HelpText); + node.SetAttributeValue("IsContentElement", cur.IsContentElement.ToString()); + node.SetAttributeValue("IsControlElement", cur.IsControlElement.ToString()); + node.SetAttributeValue("IsEnabled", cur.IsEnabled.ToString()); + node.SetAttributeValue("IsKeyboardFocusable", cur.IsKeyboardFocusable.ToString()); + node.SetAttributeValue("IsOffscreen", cur.IsOffscreen.ToString()); + node.SetAttributeValue("IsPassword", cur.IsPassword.ToString()); + node.SetAttributeValue("IsRequiredForForm", cur.IsRequiredForForm.ToString()); + node.SetAttributeValue("ItemStatus", cur.ItemStatus); + node.SetAttributeValue("LocalizedControlType", cur.LocalizedControlType); + + node.SetAttributeValue("Name", GetPropertyValueAsString(targetElement, AutomationElement.NameProperty, AutomationElementPropertyValueTypes.String)); ; + + node.SetAttributeValue("NativeWindowHandle", cur.NativeWindowHandle.ToString()); + node.SetAttributeValue("ProcessId", cur.ProcessId.ToString()); + + node.SetAttributeValue("Hash", (string.IsNullOrEmpty(hash) ? targetElement.GetHashCode().ToString() : hash)); + + return node; + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_DoSomethingUIElementPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_DoSomethingUIElementPropertiesExtensionMethods.cs new file mode 100644 index 000000000..ad9d32696 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_DoSomethingUIElementPropertiesExtensionMethods.cs @@ -0,0 +1,32 @@ +using System; +using System.Windows.Automation; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_DoSomethingUIElementPropertiesExtensionMethods + { + /// + /// UIElement action + /// + /// + /// + /// + public static void UIElementAction(this IDoSomethingUIElementProperties command, AutomationEngineInstance engine, Action actionFunc) + { + var targetElement = command.ExpandUserVariableAsUIElement(engine); + + // core process + actionFunc(targetElement); + + //if (command.IsWindowNameOrWindowHandleResultsSpecified()) + //{ + // // get window name and window handle + // (var windowName, var whnd) = EM_CanHandleUIElementExtentionMethods.GetWindowNameAndHandle(targetElement); + + // command.StoreWindowNameAndWindowHandleResultsInUserVariables(windowName, whnd, engine); + //} + command.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(targetElement, engine); + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_GetFromUIElementPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_GetFromUIElementPropertiesExtensionMethods.cs new file mode 100644 index 000000000..37adf1398 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_GetFromUIElementPropertiesExtensionMethods.cs @@ -0,0 +1,30 @@ +using System; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_GetFromUIElementPropertiesExtensionMethods + { + /// + /// when value(s) can not retrieved from UIElement process + /// + /// + /// + /// + public static void ValueCanNotRetrievedProcess(this IGetFromUIElementProperties command, string valueName, Action setEmptyFunc, AutomationEngineInstance engine) + { + switch(command.ToScriptCommand().ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_WhenValueCanNotRetrieved), engine)) + { + case "error": + throw new Exception($"Error. Fail get {valueName} Value(s)."); + + case "ignore": + return; + + case "set empty": + setEmptyFunc(); + break; + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_GetUIElementsInformationPropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_GetUIElementsInformationPropertiesExtentionMethods.cs new file mode 100644 index 000000000..c8d2cf8dd --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_GetUIElementsInformationPropertiesExtentionMethods.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Windows.Automation; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_GetUIElementsInformationPropertiesExtentionMethods + { + /// + /// store UIElements Information in user variable + /// + /// + /// + /// + public static void StoreUIElementsInformationInUserVariable(this IGetUIElementsInformationProperties command, List elems, Engine.AutomationEngineInstance engine) + { + string result = ""; + + int counts = elems.Count; + for (int i = 0; i < counts; i++) + { + var elem = elems[i]; + result += $"Index: {i}, Name: {elem.Current.Name}, LocalizedControlType: {elem.Current.LocalizedControlType}, ControlType: {EM_CanHandleUIElementExtentionMethods.GetControlTypeText(elem)}\n"; + } + result.Trim().StoreInUserVariable(engine, command.v_Result); + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_GetUIElementsTreeXMLFromSomethingPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_GetUIElementsTreeXMLFromSomethingPropertiesExtensionMethods.cs new file mode 100644 index 000000000..ca8417ae0 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_GetUIElementsTreeXMLFromSomethingPropertiesExtensionMethods.cs @@ -0,0 +1,45 @@ +using System; +using System.Windows.Automation; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_GetUIElementsTreeXMLFromSomethingPropertiesExtensionMethods + { + /// + /// store UIElements XML Tree in User Variable from UIElement + /// + /// + /// + /// + public static void StoreUIElementsTreeXMLInUserVariableFromUIElement(this IGetUIElementsXMLTreeFromSomethingProperties command, AutomationElement targetElement, AutomationEngineInstance engine) + { + var maxTime = command.ExpandValueOrUserVariableAsWaitTimeForUIElement(engine); + var finishTime = (maxTime > 0) ? DateTime.Now.AddSeconds(maxTime) : DateTime.Now; + Func timeFunc = (maxTime <= 0) ? + new Func(() => false) : + new Func(() => + { + return (DateTime.Now >= finishTime); + }); + + var cmd = new UIAutomationSearchUIElementFromUIElementByXPathCommand() + { + v_MaxDepth = command.v_MaxDepth, + v_MaxSiblings = command.v_MaxSiblings, + v_WaitTimeForUIElement = command.v_WaitTimeForUIElement, + v_WindowNameResult = command.v_WindowNameResult, + v_WindowHandleResult = command.v_WindowHandleResult, + }; + (var xml, _) = cmd.DeepCreateUIElementXMLCore(targetElement, timeFunc, engine); + + using (var sw = new System.IO.StringWriter()) + { + xml.Save(sw); + sw.ToString().StoreInUserVariable(engine, command.v_Result); + } + + cmd.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(targetElement, engine); + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementActionPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementActionPropertiesExtensionMethods.cs new file mode 100644 index 000000000..a8344186a --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementActionPropertiesExtensionMethods.cs @@ -0,0 +1,108 @@ +using System; +using System.Windows.Automation; +using taskt.Core.Automation.Commands.WindowGroup; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementActionPropertiesExtensionMethods + { + /// + /// wait process + /// + /// + private static void WaitProcess(decimal t) + { + if (t > 0) + { + int waitTime = (int)(t * 1000); + System.Threading.Thread.Sleep(waitTime); + } + } + + /// + /// wait before action + /// + /// + /// + private static void WaitBeforeAction(this IUIElementActionProperties command, AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(command.v_WaitTimeBeforeAction)) + { + var wait = command.ToScriptCommand().ExpandValueOrUserVariableAsDecimal(nameof(command.v_WaitTimeBeforeAction), engine); + WaitProcess(wait); + } + } + + /// + /// wait after action + /// + /// + /// + private static void WaitAfterAction(this IUIElementActionProperties command, AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(command.v_WaitTimeAfterAction)) + { + var wait = command.ToScriptCommand().ExpandValueOrUserVariableAsDecimal(nameof(command.v_WaitTimeAfterAction), engine); + WaitProcess(wait); + } + } + + /// + /// action not supported process + /// + /// + /// + /// + /// + public static void ActionNotSupportedProcess(this IUIElementActionProperties command, string actionName, AutomationEngineInstance engine) + { + switch(command.ToScriptCommand().ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_WhenActionIsNotSupported), engine)) + { + case "error": + throw new Exception($"UIElement '{command.v_TargetElement}' does Not Support or can not execute {actionName} action"); + + case "ignore": + break; + } + } + + /// + /// UIElement action and wait + /// + /// + /// + /// + public static void UIElementActionAndWait(this IUIElementActionProperties command, AutomationEngineInstance engine, Action actionFunc) + { + var targetElement = command.ExpandUserVariableAsUIElement(engine); + + // before action + command.WaitBeforeAction(engine); + + // get window name and window handle + (var windowName, var whnd) = EM_CanHandleUIElementExtentionMethods.GetWindowNameAndHandle(targetElement); + + // activate before action + if (command.ToScriptCommand().ExpandValueOrUserVariableAsYesNo(nameof(command.v_ActivateWindowBeforeAction), engine)) + { + var activateWindow = new ActivateWindowByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + }; + activateWindow.RunCommand(engine); + } + + // core process + actionFunc(targetElement, whnd); + + // wait after action + command.WaitAfterAction(engine); + + //// store window name, handle + //command.StoreWindowNameResultInUserVariable(windowName, engine); + //command.StoreWindowHandleResultInUserVariable(whnd, engine); + command.StoreWindowNameAndWindowHandleResultsInUserVariables(windowName, whnd, engine); + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.cs new file mode 100644 index 000000000..1063a65ba --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.cs @@ -0,0 +1,410 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Windows.Automation; +using System.Windows.Forms; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementChildrenSearchParametersPropertiesExtensionMethods + { + /// + /// UIElement type for Reflection + /// + private static readonly Type TypeOfAutomationElement = typeof(AutomationElement); + + /// + /// ControlType type for Reflection + /// + private static readonly Type TypeOfControlType = typeof(ControlType); + + /// + /// UIElement search DataGridView target properties + /// + public static readonly string[] TargetControlProperties = new string[] + { + "AcceleratorKey", "AccessKey", "AutomationId", "ClassName", "ControlType", + "FrameworkId", "HasKeyboardFocus", "HelpText", "IsContentElement", + "IsControlElement", "IsEnabled", "IsKeyboardFocusable", "IsOffscreen", + "IsPassword", "IsRequiredForForm", "ItemStatus", "ItemType", + "LocalizedControlType", "Name", "NativeWindowHandle", "ProcessId", + }; + + /// + /// get interface, dgv from control + /// + /// + /// + public static (IUIElementChildrenSearchParametersProperties, DataGridView) GetCommandAndSearchDataGridView(Control ctl) + { + var editor = FormUIControls.GetCommandEditorFromControl(ctl); + var command = (IUIElementChildrenSearchParametersProperties)editor.selectedCommand; + //var dgv = FormUIControls.GetPropertyControl(editor.us.ControlsList, nameof(IUIElementSearchParametersProperties.v_SearchParameters)); + var dgv = (DataGridView)editor.ParameterBindingControls[nameof(command.v_SearchParameters)]; + + return (command, dgv); + } + + /// + /// search parameters update process + /// + /// + /// + public static void SearchParametersUpdateProcess(this IUIElementChildrenSearchParametersProperties command, DataGridView dgv, Action updateFunc) + { + updateFunc(command.v_SearchParameters); + RenderUIElementSearchParameter(dgv); + } + + /// + /// render UIElement search parameter + /// + /// + public static void RenderUIElementSearchParameter(DataGridView dgv) + { + DataGridViewRow r = null; + foreach (DataGridViewRow row in dgv.Rows) + { + if ((row.Cells[1].Value?.ToString() ?? "") == "ControlType") + { + r = row; + break; + } + } + + if (r != null) + { + var cmb = new DataGridViewComboBoxCell(); + + var fields = typeof(ControlType).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static).Select(f => f.Name).ToList(); + + cmb.Items.Add(""); + cmb.Items.AddRange(fields.ToArray()); + cmb.Items.Add("UNKNOWN"); // MEMO: when ContolType is null, this value is 'UNKNOWN' + + r.Cells[2] = cmb; + } + } + + /// + /// create AutomationElement search condition + /// + /// + /// + /// + /// + private static PropertyCondition CreatePropertyCondition(string propertyName, object propertyValue) + { + if (TargetControlProperties.Contains(propertyName)) + { + var conditionProp = (AutomationProperty)TypeOfAutomationElement.GetField($"{propertyName}Property").GetValue(null); + + switch (propertyName) + { + case "ControlType": + var controlValue = TypeOfControlType.GetField(propertyValue.ToString())?.GetValue(null) ?? throw new Exception($"ControlType '{propertyValue.ToString()}' does not Exists"); + return new PropertyCondition(conditionProp, controlValue); + + default: + return new PropertyCondition(conditionProp, propertyValue); + } + } + else + { + throw new Exception($"Property '{propertyName}' does not Exists or not Supported property"); + } + } + + /// + /// create AutomationElement search condition from DataTable + /// + /// + /// + /// + public static List CreateSearchCondition(this IUIElementChildrenSearchParametersProperties comamnd, Engine.AutomationEngineInstance engine) + { + var table = comamnd.v_SearchParameters; + + // create and populate condition list + var conditionList = new List(); + foreach (DataRow row in table.Rows) + { + var isEnabled = row.Field("Enabled") ?? "false"; + if (bool.TryParse(isEnabled, out bool res)) + { + if (!res) + { + continue; + } + } + else + { + continue; + } + + var parameterName = row.Field("ParameterName") ?? ""; + var parameterValue = (row.Field("ParameterValue") ?? "").ExpandValueOrUserVariable(engine); + + // value collection + switch (parameterName) + { + case "HasKeyboardFocus": + case "IsContentElement": + case "IsControlElement": + case "IsEnabled": + case "IsKeyboardFocusable": + case "IsOffscreen": + case "IsPassword": + case "IsRequiredForForm": + if (string.IsNullOrEmpty(parameterValue)) + { + parameterValue = "False"; + } + else + { + switch (parameterValue.ToLower()) + { + case "yes": + parameterValue = "True"; + break; + case "no": + parameterValue = "False"; + break; + } + } + if (!bool.TryParse(parameterValue, out _)) + { + throw new Exception($"Invalid ParamterValue. Value must be 'True' or 'False'. ParameterName: '{parameterName}', ParameteValue: '{parameterValue}'"); + } + break; + + case "NativeWindowHandle": + case "ProcessId": + if (string.IsNullOrEmpty(parameterValue)) + { + parameterValue = "0"; + } + if (!Int32.TryParse(parameterValue, out _)) + { + throw new Exception($"Invalid ParamterValue. Value must be Int32 value. ParameterName: '{parameterName}', ParameteValue: '{parameterValue}'"); + } + break; + } + + // DBG + //Debug.WriteLine($"Name: '{parameterName}', Value: '{parameterValue}'"); + + PropertyCondition propCondition = null; + + switch (parameterName) + { + case "HasKeyboardFocus": + case "IsContentElement": + case "IsControlElement": + case "IsEnabled": + case "IsKeyboardFocusable": + case "IsOffscreen": + case "IsPassword": + case "IsRequiredForForm": + propCondition = CreatePropertyCondition(parameterName, bool.Parse(parameterValue)); + break; + + case "NativeWindowHandle": + case "ProcessId": + propCondition = CreatePropertyCondition(parameterName, Int32.Parse(parameterValue)); + break; + + case "AcceleratorKey": + case "AccessKey": + case "AutomationId": + case "ClassName": + case "ControlType": + case "FrameworkId": + case "HelpText": + case "ItemStatus": + case "ItemType": + case "LocalizedControlType": + case "Name": + propCondition = CreatePropertyCondition(parameterName, parameterValue); + break; + } + + conditionList.Add(propCondition); + } + + return conditionList; + } + + /// + /// search children UIElement (!!children elements only!!) + /// + /// + /// + /// + /// + public static List SearchChildrenUIElements(this IUIElementChildrenSearchParametersProperties command, AutomationElement rootElement, Engine.AutomationEngineInstance engine) + { + var searchConditions = command.CreateSearchCondition(engine); + + (var firstChildFunc, var nextChildFunc) = command.GetSiblingNodeFunc(engine); + + var waitTime = command.ExpandValueOrUserVariableAsWaitTimeForUIElement(engine); + + var maxSiblingsFunc = command.GetMaxSiblingsFunc(engine); + var maxUIElementsFunc = command.GetMaxNumberUIElementsFunc(engine); + + var ret = WaitControls.WaitProcess(waitTime, "Children UIElement", new Func, (bool, object)>((timeOutFunc) => + { + var walker = TreeWalker.RawViewWalker; + var elems = new List(); + var node = firstChildFunc(rootElement, walker); + int sibCnt = 0; + while (node != null) + { + CheckAndAddProcess(node, searchConditions, elems); + if (timeOutFunc() || maxUIElementsFunc(elems)) + { + return ((elems.Count > 0), elems); + } + + node = nextChildFunc(node, walker); + sibCnt++; + if (maxSiblingsFunc(sibCnt)) + { + return ((elems.Count > 0), elems); + } + } + return ((elems.Count > 0), elems); + }), engine); + + if (ret is List e) + { + return e; + } + else + { + // not found + return new List(); + } + } + + /// + /// expand value or user varaible as Max Number of UIElements to search + /// + /// + /// + /// + public static int ExpandValueOrUserVariableAsMaxNumberUIElements(this IUIElementChildrenSearchParametersProperties command, Engine.AutomationEngineInstance engine) + { + if (string.IsNullOrEmpty(command.v_MaxNumberUIElements)) + { + command.v_MaxNumberUIElements = "0"; + } + return command.ToScriptCommand().ExpandValueOrUserVariableAsInteger(nameof(command.v_MaxNumberUIElements), engine); + } + + /// + /// get check max number of UIElements function + /// + /// + /// + /// When Func returns true, max UIElements + public static Func, bool> GetMaxNumberUIElementsFunc(this IUIElementChildrenSearchParametersProperties command, Engine.AutomationEngineInstance engine) + { + var maxElements = command.ExpandValueOrUserVariableAsMaxNumberUIElements(engine); + if (maxElements == 0) + { + return new Func, bool>((e) => false); + } + else + { + return new Func, bool>((e) => (e.Count >= maxElements)); + } + } + + /// + /// get UIElement siblings node search Funcs + /// + /// + /// + /// (First-Child, Next-Child) + public static (Func, Func) GetSiblingNodeFunc(this IUIElementChildrenSearchParametersProperties command, Engine.AutomationEngineInstance engine) + { + switch(command.ToScriptCommand().ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_SiblingsDirection), engine)) + { + case "last to first": + return ( + new Func((e, w) => + { + return w.GetLastChild(e); + }), + new Func((e, w) => + { + return w.GetPreviousSibling(e); + }) + ); + case "fist to last": + default: // default not works + return ( + new Func((e, w) => + { + return w.GetFirstChild(e); + }), + new Func((e, w) => + { + return w.GetNextSibling(e); + }) + ); + } + } + + /// + /// check if UIElement matches specified conditions, and when matches add to List + /// + /// + /// + /// + public static void CheckAndAddProcess(AutomationElement targetElement, List conditions, List matchedElements) + { + if (CheckAutomationElementCondition(targetElement, conditions)) + { + matchedElements.Add(targetElement); + } + } + + /// + /// check if UIElement matches specified PropertyConditions + /// + /// + /// + /// + private static bool CheckAutomationElementCondition(AutomationElement targetElement, List conditions) + { + bool result = true; + foreach (var c in conditions) + { + object p = targetElement.GetCurrentPropertyValue(c.Property); + + switch (c.Property.ProgrammaticName) + { + case "AutomationElementIdentifiers.ControlTypeProperty": + // ControlType compare + result &= (c.Value.ToString() == ((ControlType)p).Id.ToString()); + break; + + default: + // normal compare + result &= (c.Value.ToString() == p.ToString()); + break; + } + + if (!result) + { + break; + } + } + return result; + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementChildrenSearchSomewayPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementChildrenSearchSomewayPropertiesExtensionMethods.cs new file mode 100644 index 000000000..ceb27758e --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementChildrenSearchSomewayPropertiesExtensionMethods.cs @@ -0,0 +1,82 @@ +using System; +using System.Windows.Automation; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementChildrenSearchSomewayPropertiesExtensionMethods + { + /// + /// expand value or user variable as wait time for UIElement + /// + /// + /// + /// + public static int ExpandValueOrUserVariableAsWaitTimeForUIElement(this IUIElementChildrenSearchSomewayProperties command, Engine.AutomationEngineInstance engine) + { + return command.ToScriptCommand().ExpandValueOrUserVariableAsInteger(nameof(command.v_WaitTimeForUIElement), engine); + } + + /// + /// expand value or user variable as Max Siblings + /// + /// + /// + /// + public static int ExpandValueOrUserVariableAsMaxSiblings(this IUIElementChildrenSearchSomewayProperties command, Engine.AutomationEngineInstance engine) + { + if (string.IsNullOrEmpty(command.v_MaxSiblings)) + { + command.v_MaxSiblings = "64"; + } + return command.ToScriptCommand().ExpandValueOrUserVariableAsInteger(nameof(command.v_MaxSiblings), engine); + } + + /// + /// get check max siblings function + /// + /// + /// + /// When Func returns true, max siblings + public static Func GetMaxSiblingsFunc(this IUIElementChildrenSearchSomewayProperties command, Engine.AutomationEngineInstance engine) + { + var maxSiblings = command.ExpandValueOrUserVariableAsMaxSiblings(engine); + if (maxSiblings == 0) + { + return new Func((n) => false); + } + else + { + return new Func((n) => (n > maxSiblings)); + } + } + + /// + /// search someway any-one UIElement Action core + /// + /// + /// + /// + /// + /// + public static void SearchAnyUIElementActionCore(this IUIElementChildrenSearchSomewayProperties command, Engine.AutomationEngineInstance engine, Func searchFunc, Action actionFunc, Action errorFunc = null) + { + try + { + var elem = searchFunc(); + actionFunc(elem); + command.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(elem, engine); + } + catch (Exception ex) + { + if (errorFunc != null) + { + errorFunc(ex); + } + else + { + throw ex; + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementChildrenSearchXPathPropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementChildrenSearchXPathPropertiesExtentionMethods.cs new file mode 100644 index 000000000..4da1aab35 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementChildrenSearchXPathPropertiesExtentionMethods.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Windows.Automation; +using System.Xml.Linq; +using System.Xml.XPath; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementChildrenSearchXPathPropertiesExtentionMethods + { + /// + /// expand value or user variable string as XPath + /// + /// + /// + /// + public static string ExpandValueOrUserVariableAsXPath(this IUIElementChildrenSearchXPathProperties command, Engine.AutomationEngineInstance engine) + { + var p = command.ToScriptCommand().ExpandValueOrUserVariable(nameof(command.v_SearchXPath), "XPath", engine); + if (!p.StartsWith(".")) + { + p = $".{p}"; + } + return p; + } + + /// + /// search UIElement by xpath + /// + /// + /// UIElement XML + /// UIElement dic + /// + public static AutomationElement SearchUIElementByXPath(string xpath, XElement xml, Dictionary elemsDic) + { + var e = xml.XPathSelectElement(xpath); + if (e != null) + { + return elemsDic[e.Attribute("Hash").Value]; + } + else + { + return null; + } + } + + /// + /// searchi children UIlement action + /// + /// + /// + /// + /// + /// + public static void SearchChildrenUIElementAction(this IUIElementChildrenSearchXPathProperties command, Engine.AutomationEngineInstance engine, AutomationElement targetElement, Action actionFunc, Action errorFunc = null) + { + //try + //{ + // var elem = command.SearchChildrenUIElementByXPath(targetElement, engine); + // actionFunc(elem); + // command.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(elem, engine); + //} + //catch (Exception ex) + //{ + // if (errorFunc != null) + // { + // errorFunc(ex); + // } + // else + // { + // throw ex; + // } + //} + + command.SearchAnyUIElementActionCore(engine, + new Func(() => command.SearchChildrenUIElementByXPath(targetElement, engine)), + actionFunc, errorFunc); + } + + /// + /// chidren search UIElement by XPath + /// + /// + /// + /// + /// + /// + public static AutomationElement SearchChildrenUIElementByXPath(this IUIElementChildrenSearchXPathProperties command, AutomationElement rootElement, Engine.AutomationEngineInstance engine) + { + var waitTime = command.ExpandValueOrUserVariableAsWaitTimeForUIElement(engine); + + var xpath = command.ExpandValueOrUserVariableAsXPath(engine); + + var r = WaitControls.WaitProcess(waitTime, "UIElement", new Func, (bool, object)>(waitFunc => + { + (var xml, var dic) = command.CreateChildrenXMLCore(rootElement, waitFunc, engine); + var elem = SearchUIElementByXPath(xpath, xml, dic); + if (elem != null) + { + return (true, elem); + } + else + { + return (false, null); + } + }), engine); + if (r is AutomationElement e) + { + return e; + } + else + { + throw new Exception($"AutomationElement not Found. XPath: '{command.v_SearchXPath}', Expand Value: '{xpath}'"); + } + } + + /// + /// create children xml + /// + /// + /// + /// when Func returns true, time out + /// + /// + public static (XElement, Dictionary) CreateChildrenXMLCore(this IUIElementChildrenSearchXPathProperties command, AutomationElement rootElement, Func waitFunc, Engine.AutomationEngineInstance engine) + { + var parentXMLNode = EM_CanHandleUIElementXMLExtentionMethods.CreateXmlElement(rootElement); + var elemsDic = new Dictionary() + { + { parentXMLNode.GetHashCode().ToString(), rootElement } + }; + + var siblingFunc = command.GetMaxSiblingsFunc(engine); + var walker = TreeWalker.RawViewWalker; + + var targetElement = walker.GetFirstChild(rootElement); + int sibCnt = 0; + while (targetElement != null) + { + // check hash dup + string hash = targetElement.GetHashCode().ToString(); + if (elemsDic.ContainsKey(hash)) + { + int i = 1; + while (elemsDic.ContainsKey($"{hash}-{i}")) + { + i++; + } + hash += $"-{i}"; + } + + var childNode = EM_CanHandleUIElementXMLExtentionMethods.CreateXmlElement(targetElement, hash); + parentXMLNode.Add(childNode); + elemsDic.Add(hash, targetElement); + + sibCnt++; + if (siblingFunc(sibCnt) || waitFunc()) + { + break; + } + + targetElement = walker.GetNextSibling(targetElement); + } + + return (parentXMLNode, elemsDic); + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementCorePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementCorePropertiesExtensionMethods.cs new file mode 100644 index 000000000..925b8761f --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementCorePropertiesExtensionMethods.cs @@ -0,0 +1,29 @@ +using System; +using System.Windows.Automation; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementCorePropertiesExtensionMethods + { + /// + /// expand user variable as UIElement + /// + /// + /// + /// + /// + public static AutomationElement ExpandUserVariableAsUIElement(this IUIElementCoreProperties command, Engine.AutomationEngineInstance engine) + { + var variableName = command.v_TargetElement; + var v = variableName.GetRawVariable(engine); + if (EM_CanHandleUIElementExtentionMethods.IsUIElement(v.VariableValue, out AutomationElement e)) + { + return e; + } + else + { + throw new Exception($"Variable '{variableName}' is not UIElement"); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchAnyUIElementPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchAnyUIElementPropertiesExtensionMethods.cs new file mode 100644 index 000000000..4c4dde971 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchAnyUIElementPropertiesExtensionMethods.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Windows.Automation; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementDescendantsSearchAnyUIElementPropertiesExtensionMethods + { + /// + /// get Check Found func, max UIElements func + /// + /// + /// + /// (found-func, max-func) + public static (Func, bool>, Func, bool>) GetCheckFoundAndMaxUIElementsFunc(this IUIElementDescendantsSearchAnyUIElementProperties command, Engine.AutomationEngineInstance engine) + { + var index = command.ExpandValueOrUserVariableAsUIElementIndex(engine); + if (string.IsNullOrEmpty(command.v_MaxNumberUIElements)) + { + if (index >= 0) + { + command.v_MaxNumberUIElements = (index + 1).ToString(); + } + else + { + command.v_MaxNumberUIElements = "0"; // all UIElements + } + } + // max uielements + var maxFunc = command.GetMaxNumberUIElementsFunc(engine); + + + Func, bool> foundFunc; + if (index >= 0) + { + foundFunc = new Func, bool>(elems => + { + return (elems.Count >= index); + }); + } + else + { + foundFunc = new Func, bool>(elems => + { + return (elems.Count > 0); + }); + } + return (foundFunc, maxFunc); + } + + /// + /// Deep search UIElements + /// + /// + /// + /// + /// + public static List DeepSearchUIElements(this IUIElementDescendantsSearchAnyUIElementProperties command, AutomationElement rootElement, Engine.AutomationEngineInstance engine) + { + (var foundFunc, var maxElementsFunc) = command.GetCheckFoundAndMaxUIElementsFunc(engine); + + return EM_UIElementDescendantsSearchParametersPropertiesExtensionMethods.DeepSearchUIElementsCore(command, rootElement, foundFunc, maxElementsFunc, engine); + } + + /// + /// Get UIElement from Deep Search UIElements Result + /// + /// + /// + /// + /// + public static AutomationElement GetUIElementFromDeepSearchUIElements(this IUIElementDescendantsSearchAnyUIElementProperties command, AutomationElement rootElement, Engine.AutomationEngineInstance engine) + { + var elems = command.DeepSearchUIElements(rootElement, engine); + return command.GetUIElementFromList(elems, engine); + } + + /// + /// deep seach any-one UIElement action + /// + /// + /// + /// + /// + /// + public static void DeepSearchAnyUIElementAction(this IUIElementDescendantsSearchAnyUIElementProperties command, AutomationElement rootElement, Engine.AutomationEngineInstance engine, Action actionFunc, Action errorFunc = null) + { + //try + //{ + // var elem = GetUIElementFromDeepSearchUIElements(command, rootElement, engine); + // actionFunc(elem); + + // command.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(rootElement, engine); + //} + //catch (Exception ex) + //{ + // { + // if (errorFunc != null) + // { + // errorFunc(ex); + // } + // else + // { + // throw ex; + // } + // } + //} + + command.SearchAnyUIElementActionCore(engine, + new Func(() => GetUIElementFromDeepSearchUIElements(command, rootElement, engine)), + actionFunc, errorFunc); + } + + ///// + ///// deep search UIElements action + ///// + ///// + ///// + ///// + ///// + ///// + //public static void DeepSearchUIElementsAction(this IUIElementDescendantsSearchAnyUIElementProperties command, AutomationElement rootElement, Engine.AutomationEngineInstance engine, Action> actionFunc, Action errorFunc = null) + //{ + // try + // { + // var elem = DeepSearchUIElements(command, rootElement, engine); + // actionFunc(elem); + // command.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(rootElement, engine); + // } + // catch (Exception ex) + // { + // { + // if (errorFunc != null) + // { + // errorFunc(ex); + // } + // else + // { + // throw ex; + // } + // } + // } + //} + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchParametersPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchParametersPropertiesExtensionMethods.cs new file mode 100644 index 000000000..d0f7e08c4 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchParametersPropertiesExtensionMethods.cs @@ -0,0 +1,174 @@ +using System; +using System.Collections.Generic; +using System.Windows.Automation; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementDescendantsSearchParametersPropertiesExtensionMethods + { + /// + /// Deep search UIElements + /// + /// + /// + /// + /// + public static List DeepSearchUIElements(this IUIElementDescendantsSearchParametersProperties command, AutomationElement rootElement, Engine.AutomationEngineInstance engine) + { + var foundFunc = new Func, bool>(elems => (elems.Count > 0)); + var maxElementsFunc = command.GetMaxNumberUIElementsFunc(engine); + + return DeepSearchUIElementsCore(command, rootElement, foundFunc, maxElementsFunc, engine); + } + + /// + /// Deep Search UIElements core process + /// + /// + /// + /// when func returns true, found + /// when func returns true, max UIElements + /// + /// + public static List DeepSearchUIElementsCore(this IUIElementDescendantsSearchParametersProperties command, AutomationElement rootElement, + Func, bool> foundFunc, Func, bool> maxElementsFunc, + Engine.AutomationEngineInstance engine) + { + var conditions = command.CreateSearchCondition(engine); + (var firstChildFunc, var nextChildFunc) = command.GetSiblingNodeFunc(engine); + var maxSiblingsFunc = command.GetMaxSiblingsFunc(engine); + var maxDepthFunc = command.GetMaxDepthFunc(engine); + + var waitTime = command.ExpandValueOrUserVariableAsWaitTimeForUIElement(engine); + + var r = WaitControls.WaitProcess(waitTime, "UIElements", new Func, (bool, object)>((timeoutFunc) => + { + var walker = TreeWalker.RawViewWalker; + + var elems = new List(); + EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.CheckAndAddProcess(rootElement, conditions, elems); + if (timeoutFunc() || maxElementsFunc(elems)) + { + return (foundFunc(elems), elems); + } + + int depth = 1; + if (maxDepthFunc(depth)) + { + return (foundFunc(elems), elems); + } + else + { + DeepSearchUIElements_DepthFirst(rootElement, conditions, depth, walker, firstChildFunc, nextChildFunc, maxSiblingsFunc, maxDepthFunc, maxElementsFunc, timeoutFunc, elems); + return (foundFunc(elems), elems); + } + }), engine); + + if (r is List e) + { + return e; + } + else + { + // not found + return new List(); + } + } + + /// + /// recursive Deep Search UIElements (depth first) + /// + /// root UIElement (this UIElement not check) + /// + /// + /// + /// + /// + /// when Func returns true, max Siblings + /// when Func returns true, max Depth + /// when Func returns true, max Elements + /// + /// + private static void DeepSearchUIElements_DepthFirst(AutomationElement rootElement, List searchConditions, + int currentDepth, + TreeWalker walker, + Func firstChildFunc, Func nextChildFunc, + Func maxSiblingsFunc, Func maxDepthFunc, + Func, bool> maxElementsFunc, + Func timeoutFunc, List matchedElements) + { + var node = firstChildFunc(rootElement, walker); + int sibCount = 0; + while (node != null) + { + // DBG + //Console.WriteLine(node.Current.AutomationId); + + EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.CheckAndAddProcess(node, searchConditions, matchedElements); + if (timeoutFunc() || maxElementsFunc(matchedElements)) + { + return; + } + + // check UIElement has child elements + if (walker.GetFirstChild(node) != null) + { + // has child UIElement + currentDepth++; + if (maxDepthFunc(currentDepth)) + { + return; + } + else + { + DeepSearchUIElements_DepthFirst(node, searchConditions, currentDepth, walker, firstChildFunc, nextChildFunc, maxSiblingsFunc, maxDepthFunc, maxElementsFunc, timeoutFunc, matchedElements); + } + } + if (timeoutFunc() || maxElementsFunc(matchedElements)) + { + return; + } + + // next sibling + node = nextChildFunc(node, walker); + sibCount++; + if (maxSiblingsFunc(sibCount)) + { + return; + } + } + } + + /// + /// deep search UIElements Action + /// + /// + /// + /// + /// + /// + public static void DeepSearchUIElementsAction(this IUIElementDescendantsSearchParametersProperties command, AutomationElement rootElement, Engine.AutomationEngineInstance engine, Action> actionFunc, Action errorFunc = null) + { + try + { + var elems = DeepSearchUIElements(command, rootElement, engine); + actionFunc(elems); + + command.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(rootElement, engine); + } + catch (Exception ex) + { + { + if (errorFunc != null) + { + errorFunc(ex); + } + else + { + throw ex; + } + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchSomewayPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchSomewayPropertiesExtensionMethods.cs new file mode 100644 index 000000000..fe296f6e7 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchSomewayPropertiesExtensionMethods.cs @@ -0,0 +1,42 @@ +using System; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementDescendantsSearchSomewayPropertiesExtensionMethods + { + + /// + /// expand value or user variable as Max Depth + /// + /// + /// + /// + public static int ExpandValueOrUserVariableAsMaxDepth(this IUIElementDescendantsSearchSomewayProperties command, Engine.AutomationEngineInstance engine) + { + if (string.IsNullOrEmpty(command.v_MaxDepth)) + { + command.v_MaxDepth = "32"; + } + return command.ToScriptCommand().ExpandValueOrUserVariableAsInteger(nameof(command.v_MaxDepth), engine); + } + + /// + /// get check Max Depth func + /// + /// + /// + /// when Func returns true, max depth + public static Func GetMaxDepthFunc(this IUIElementDescendantsSearchSomewayProperties command, Engine.AutomationEngineInstance engine) + { + var maxDepth = command.ExpandValueOrUserVariableAsMaxDepth(engine); + if (maxDepth == 0) + { + return new Func((d) => false); + } + else + { + return new Func((d) => (d > maxDepth)); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchXPathPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchXPathPropertiesExtensionMethods.cs new file mode 100644 index 000000000..0404c6e9d --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementDescendantsSearchXPathPropertiesExtensionMethods.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Windows.Automation; +using System.Xml.Linq; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementDescendantsSearchXPathPropertiesExtensionMethods + { + /// + /// Deep Search UIElement Action + /// + /// + /// + /// + /// + /// + public static void DeepSearchUIElementAction(this IUIElementDescendantsSearchXPathProperties command, Engine.AutomationEngineInstance engine, AutomationElement targetElement, Action actionFunc, Action errorFunc = null) + { + //try + //{ + // var elem = command.DeepSearchUIElementByXPath(targetElement, engine); + // actionFunc(elem); + // command.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(elem, engine); + //} + //catch (Exception ex) + //{ + // if (errorFunc != null) + // { + // errorFunc(ex); + // } + // else + // { + // throw ex; + // } + //} + + command.SearchAnyUIElementActionCore(engine, + new Func(() => command.DeepSearchUIElementByXPath(targetElement, engine)), + actionFunc, errorFunc); + } + + /// + /// deep search UIElement by XPath + /// + /// + /// + /// + /// + /// + public static AutomationElement DeepSearchUIElementByXPath(this IUIElementDescendantsSearchXPathProperties command, AutomationElement rootElement, Engine.AutomationEngineInstance engine) + { + var waitTime = command.ExpandValueOrUserVariableAsWaitTimeForUIElement(engine); + + var xpath = command.ExpandValueOrUserVariableAsXPath(engine); + + var r = WaitControls.WaitProcess(waitTime, "UIElement", new Func, (bool, object)>(waitFunc => + { + (var xml, var dic) = command.DeepCreateUIElementXMLCore(rootElement, waitFunc, engine); + var elem = EM_UIElementChildrenSearchXPathPropertiesExtentionMethods.SearchUIElementByXPath(xpath, xml, dic); + if (elem != null) + { + return (true, elem); + } + else + { + return (false, null); + } + }), engine); + if (r is AutomationElement e) + { + return e; + } + else + { + throw new Exception($"AutomationElement not Found. XPath: '{command.v_SearchXPath}', Expand Value: '{xpath}'"); + } + } + + /// + /// deep create UIElement xml + /// + /// + /// + /// + /// + public static (XElement, Dictionary) DeepCreateUIElementXMLCore(this IUIElementDescendantsSearchXPathProperties command, AutomationElement targetElement, Func timeFunc, Engine.AutomationEngineInstance engine) + { + var siblingFunc = command.GetMaxSiblingsFunc(engine); + var depthFunc = command.GetMaxDepthFunc(engine); + + var rootXML = EM_CanHandleUIElementXMLExtentionMethods.CreateXmlElement(targetElement); + + var hashDic = new Dictionary() + { + { rootXML.GetHashCode().ToString(), targetElement } + }; + + var walker = TreeWalker.RawViewWalker; + DeepCreateUIElementXML_DepthFirst(rootXML, targetElement, hashDic, walker, 1, siblingFunc, depthFunc, timeFunc); + + // DBG + //Console.WriteLine("!!XML Tree"); + //foreach(var item in hashDic) + //{ + // var k = item.Key; + // var v = item.Value; + // Console.WriteLine($"{k} {v.Current.Name} {v.Current.GetHashCode()}"); + //} + + return (rootXML, hashDic); + } + + /// + /// deep create UIElement XML depth first + /// + /// + /// + /// + /// + /// + /// when Func returns true, max siblings + /// when Func returns true, max depth + /// when Func returns true, time out + private static void DeepCreateUIElementXML_DepthFirst(XElement parentXMLNode, AutomationElement rootElement, Dictionary elemsDic, + TreeWalker walker, int depth, Func siblingFunc, Func depthFunc, Func timeFunc) + { + var targetElement = walker.GetFirstChild(rootElement); + int sibCnt = 0; + while (targetElement != null) + { + // check hash dup + string hash = targetElement.GetHashCode().ToString(); + if (elemsDic.ContainsKey(hash)) + { + int i = 1; + while (elemsDic.ContainsKey($"{hash}-{i}")) + { + i++; + } + hash += $"-{i}"; + } + + var childNode = EM_CanHandleUIElementXMLExtentionMethods.CreateXmlElement(targetElement, hash); + parentXMLNode.Add(childNode); + elemsDic.Add(hash, targetElement); + + sibCnt++; + if (siblingFunc(sibCnt) || timeFunc()) + { + return; + } + + if (walker.GetFirstChild(targetElement) != null) + { + depth++; + if (depthFunc(depth)) + { + return; + } + else + { + DeepCreateUIElementXML_DepthFirst(childNode, targetElement, elemsDic, walker, depth, siblingFunc, depthFunc, timeFunc); + } + } + if (timeFunc()) + { + return; + } + + targetElement = walker.GetNextSibling(targetElement); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementIndexPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementIndexPropertiesExtensionMethods.cs new file mode 100644 index 000000000..d6314221c --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementIndexPropertiesExtensionMethods.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Windows.Automation; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementIndexPropertiesExtensionMethods + { + /// + /// Expand value or user variable as UIElement Index + /// + /// + /// + /// + public static int ExpandValueOrUserVariableAsUIElementIndex(this IUIElementIndexProperties command, Engine.AutomationEngineInstance engine) + { + if (string.IsNullOrEmpty(command.v_TargetUIElementIndex)) + { + command.v_TargetUIElementIndex = "0"; + } + return command.ToScriptCommand().ExpandValueOrUserVariableAsInteger(nameof(command.v_TargetUIElementIndex), "UIElement Index", engine); + } + + /// + /// get UIElement from List-UIElement + /// + /// + /// + /// + /// + /// + public static AutomationElement GetUIElementFromList(this IUIElementIndexProperties command, List elems, Engine.AutomationEngineInstance engine) + { + var index = command.ExpandValueOrUserVariableAsUIElementIndex(engine); + if (index < 0) + { + index += elems.Count; + } + if (index >= 0 && index < elems.Count) + { + return elems[index]; + } + else + { + throw new System.Exception($"UIElement does not Exists. Index: {command.v_TargetUIElementIndex}, Expand Value: {index}"); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementSearchUIElementFromWindowSomethingByAnywayPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementSearchUIElementFromWindowSomethingByAnywayPropertiesExtensionMethods.cs new file mode 100644 index 000000000..8998c6735 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementSearchUIElementFromWindowSomethingByAnywayPropertiesExtensionMethods.cs @@ -0,0 +1,30 @@ +using System; +using System.Windows.Automation; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementSearchUIElementFromWindowSomethingByAnywayPropertiesExtensionMethods + { + /// + /// Search Window after Action command core + /// + /// + /// + /// search window process, InnerScriptVariable is variable to store Window UIElement + /// action process, InnerScriptVariable is Window UIElement + public static void SearchWindowAfterActionCore(this IUIElementSearchUIElementFromWindowSomethingByAnywayProperties command, Engine.AutomationEngineInstance engine, Func searchFunc, Func actionFunc) + { + using (var winElem = new InnerScriptVariable(engine)) + { + var winSearch = searchFunc(winElem); + winSearch.RunCommand(engine); + + var actionCmd = actionFunc(winElem); + actionCmd.RunCommand(engine); + + command.StoreWindowUIElementInUserVariable((AutomationElement)winElem.VariableValue, engine); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementSelectionItemsPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementSelectionItemsPropertiesExtensionMethods.cs new file mode 100644 index 000000000..61aabdb1c --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementSelectionItemsPropertiesExtensionMethods.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Windows.Automation; +using taskt.Core.Automation.Engine; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementSelectionItemsPropertiesExtensionMethods + { + public static void SelectionItemsAction(this IUIElementSelectionItemsProperties command, AutomationEngineInstance engine, Action> actionFunc, Action errorFunc) + { + List GetListItems(AutomationElement element) + { + var elems = element.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.IsSelectionItemPatternAvailableProperty, true)); + var ret = new List(); + foreach (AutomationElement elem in elems) + { + ret.Add(elem); + } + return ret; + } + + command.UIElementAction(engine, + new Action(targetElement => + { + List items; + ExpandCollapsePattern ecPtn = null; + + if ((bool)targetElement.GetCurrentPropertyValue(AutomationElement.IsGridPatternAvailableProperty) || + (bool)targetElement.GetCurrentPropertyValue(AutomationElement.IsSelectionPatternAvailableProperty)) + { + // DataGridView-ComboBox, ListBox + items = GetListItems(targetElement); + } + else + { + // ComboBox, TreeView + AutomationElement curElement = targetElement; + bool isCmb = (bool)curElement.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty); + + if (!isCmb) + { + curElement = EM_CanHandleUIElementExtentionMethods.GetParentUIElement(curElement); + isCmb = (bool)curElement.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty); + } + + if (isCmb) + { + if (curElement.TryGetCurrentPattern(ExpandCollapsePattern.Pattern, out object selPtn)) + { + ecPtn = (ExpandCollapsePattern)selPtn; + + command.ExpandAndActivateWindowProcess(curElement, ecPtn, engine); + + items = GetListItems(curElement); + + if (items.Count == 0) + { + // selection window is other window + var pid = targetElement.Current.ProcessId; + var con = new AndCondition( + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.List), + new PropertyCondition(AutomationElement.ProcessIdProperty, pid) + ); + var popupListElem = AutomationElement.RootElement.FindFirst(TreeScope.Children, con); + if (popupListElem != null) + { + // DBG + //Console.WriteLine($"#!# {popupListElem.Current.Name}"); + + items = GetListItems(popupListElem); + } + } + } + else + { + errorFunc(); + return; + } + } + else + { + //throw new Exception("This UIElement does not have Selection Items"); + errorFunc(); + return; + } + } + + actionFunc(items); + + // collapse after action (when targetElement is expanded) + if (ecPtn != null) + { + ecPtn.Collapse(); + } + }) + ); + } + + /// + /// expand selection items and activate window process + /// + /// + /// + private static void ExpandAndActivateWindowProcess(this IUIElementSelectionItemsProperties command, AutomationElement targetElement, ExpandCollapsePattern expandPattern, AutomationEngineInstance engine) + { + var cmd = command.ToScriptCommand(); + if (cmd.ExpandValueOrUserVariableAsYesNo(nameof(command.v_ExpandWhenItemsNotFound), engine)) + { + using (var elemVar = new InnerScriptVariable(engine)) + { + elemVar.VariableValue = targetElement; + using (var winVar = new InnerScriptVariable(engine)) + { + // get window handle + var getHandle = new UIAutomationGetWindowHandleFromUIElementCommand() + { + v_TargetElement = elemVar.VariableName, + v_WindowHandleResult = winVar.VariableName, + }; + getHandle.RunCommand(engine); + + var activateWin = new ActivateWindowByWindowHandleCommand() + { + v_WindowHandle = VariableNameControls.GetWrappedVariableName(winVar.VariableName, engine), + }; + activateWin.RunCommand(engine); + + // expand and wait + if (string.IsNullOrEmpty(command.v_WaitTimeAfterExpand)) + { + command.v_WaitTimeAfterExpand = "1000"; + } + var waitTime = cmd.ExpandValueOrUserVariableAsInteger(nameof(command.v_WaitTimeAfterExpand), engine); + expandPattern.Expand(); + System.Threading.Thread.Sleep(waitTime); + } + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementTableUIElement.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementTableUIElement.cs new file mode 100644 index 000000000..6d48b7512 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementTableUIElement.cs @@ -0,0 +1,162 @@ +using System.Windows.Automation; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementTableUIElement + { + /// + /// row search condition to DataGridView(.net) + /// + /// + public static PropertyCondition GetRowSearchConditionToDataGridView() + { + return new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom); + } + + /// + /// get row UIElements from DataGridView(.net) + /// + /// + /// + public static AutomationElementCollection GetRowsFromDataGridView(AutomationElement targetElement) + { + return FindAllFromChildren(targetElement, GetRowSearchConditionToDataGridView()); + } + + /// + /// column search condition to DataGridView(.net) + /// + /// + public static OrCondition GetColumnSearchConditionToDataGridView() + { + return new OrCondition( + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Header), + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit) + ); + } + + /// + /// get column UIElements from DataGridView(.net) + /// + /// + /// + public static AutomationElementCollection GetColumnsFromDataGridView(AutomationElement targetElement) + { + return FindAllFromChildren(targetElement, GetColumnSearchConditionToDataGridView()); + } + + /// + /// get row search condition to GridPattern UIElement + /// + /// + public static OrCondition GetRowSearchConditionToGridPattern() + { + return new OrCondition( + new Condition[] + { + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Header), + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem), + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ListItem), + } + ); + } + + /// + /// get rows UIElements from GridPattern + /// + /// + /// + public static AutomationElementCollection GetRowsFromGridPattern(AutomationElement targetElement) + { + return FindAllFromChildren(targetElement, GetRowSearchConditionToGridPattern()); + } + + /// + /// get column search condition to GridPattern UIElement + /// + /// + public static OrCondition GetColumnSearchConditionToGridPattern() + { + return new OrCondition( + new Condition[] + { + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.HeaderItem), + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text), + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit), + } + ); + } + + /// + /// get column UIElements from GridPattern + /// + /// + /// + public static AutomationElementCollection GetColumnsFromGridPattern(AutomationElement targetElement) + { + return FindAllFromChildren(targetElement, GetColumnSearchConditionToGridPattern()); + } + + /// + /// get row search condition to SelectionPattarn table + /// + /// + public static OrCondition GetRowSearchConditionToSelectionTable() + { + return new OrCondition( + new Condition[] + { + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Header), + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ListItem), + } + ); + } + + /// + /// get rows UIElement from SelectionPattern table + /// + /// + /// + public static AutomationElementCollection GetRowsFromSelectionTable(AutomationElement targetElement) + { + return FindAllFromChildren(targetElement, GetRowSearchConditionToSelectionTable()); + } + + /// + /// get column search condition to SelectionPattern table + /// + /// + public static OrCondition GetColumnSearchConditionToSelectionTable() + { + return new OrCondition( + new Condition[] + { + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.HeaderItem), + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text), + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit), + } + ); + } + + /// + /// get column UIElements from SelectionPattern table + /// + /// + /// + public static AutomationElementCollection GetColumnsFromSelectionTable(AutomationElement targetElement) + { + return FindAllFromChildren(targetElement, GetColumnSearchConditionToSelectionTable()); + } + + /// + /// general find all + /// + /// + /// + /// + private static AutomationElementCollection FindAllFromChildren(AutomationElement targetElement, Condition condition) + { + return targetElement.FindAll(TreeScope.Children, condition); + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementWindowNameResultsFromUIElementPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementWindowNameResultsFromUIElementPropertiesExtensionMethods.cs new file mode 100644 index 000000000..678521bc7 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_UIElementWindowNameResultsFromUIElementPropertiesExtensionMethods.cs @@ -0,0 +1,24 @@ +using System; +using System.Windows.Automation; +using taskt.Core.Automation.Commands.WindowGroup; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_UIElementWindowNameResultsFromUIElementPropertiesExtensionMethods + { + /// + /// store window name and window handle in User variables from UIElement + /// + /// + /// + /// + public static void StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(this IUIElementWindowResultsFromUIElementProperties command, AutomationElement targetElement, Engine.AutomationEngineInstance engine) + { + if (command.IsWindowNameOrWindowHandleResultsSpecified()) + { + (var name, var whnd) = EM_CanHandleUIElementExtentionMethods.GetWindowNameAndHandle(targetElement); + command.StoreWindowNameAndWindowHandleResultsInUserVariables(name, whnd, engine); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/EM_WindowUIElementResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_WindowUIElementResultPropertiesExtensionMethods.cs new file mode 100644 index 000000000..be4916ce9 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/EM_WindowUIElementResultPropertiesExtensionMethods.cs @@ -0,0 +1,21 @@ +using System.Windows.Automation; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class EM_WindowUIElementResultPropertiesExtensionMethods + { + /// + /// Store Window UIElement In User varialbe + /// + /// + /// + /// + public static void StoreWindowUIElementInUserVariable(this IWindowUIElementResultProperties command, AutomationElement elem, Engine.AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(command.v_WindowUIElement)) + { + elem.StoreInUserVariable(engine, command.v_WindowUIElement); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ICanHandleUIElement.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ICanHandleUIElement.cs new file mode 100644 index 000000000..53fa3e242 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ICanHandleUIElement.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// this interface can handle UIElement + /// + public interface ICanHandleUIElement + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ICanHandleUIElementScrollBar.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ICanHandleUIElementScrollBar.cs new file mode 100644 index 000000000..89844e78f --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ICanHandleUIElementScrollBar.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for handle UIElement ScrollBar + /// + public interface ICanHandleUIElementScrollBar + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/ICanHandleUIElementXML.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/ICanHandleUIElementXML.cs new file mode 100644 index 000000000..5221e6db2 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/ICanHandleUIElementXML.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for handle UIElement-XML + /// + public interface ICanHandleUIElementXML : ICanHandleUIElement + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IDoSomethingUIElementProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IDoSomethingUIElementProperties.cs new file mode 100644 index 000000000..8ec0d2016 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IDoSomethingUIElementProperties.cs @@ -0,0 +1,18 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// Get from UIElement or UIElement Action commands properties + /// + public interface IDoSomethingUIElementProperties : IUIElementCoreProperties, IUIElementWindowResultsFromUIElementProperties + { + ///// + ///// variable name to store Window Name + ///// + //string v_WindowNameResult { get; set; } + + ///// + ///// variable name to store Window Handle + ///// + //string v_WindowHandleResult { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IGetFromUIElementProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IGetFromUIElementProperties.cs new file mode 100644 index 000000000..c69542938 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IGetFromUIElementProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// get something from UIElement properties + /// + public interface IGetFromUIElementProperties : IDoSomethingUIElementProperties + { + /// + /// when Value(s) can not retrieved + /// + string v_WhenValueCanNotRetrieved { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IGetUIElementsInformationProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IGetUIElementsInformationProperties.cs new file mode 100644 index 000000000..4ebbed04f --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IGetUIElementsInformationProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for Get UIElements Information properties + /// + public interface IGetUIElementsInformationProperties : IResultProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IGetUIElementsXMLTreeFromSomethingProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IGetUIElementsXMLTreeFromSomethingProperties.cs new file mode 100644 index 000000000..c44840264 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IGetUIElementsXMLTreeFromSomethingProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for Get UIElements XML Tree commands + /// + public interface IGetUIElementsXMLTreeFromSomethingProperties : IUIElementChildrenSearchSomewayProperties, IUIElementDescendantsSearchSomewayProperties, IResultProperties, IUIElementWindowResultsFromUIElementProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementActionProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementActionProperties.cs new file mode 100644 index 000000000..e2734de19 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementActionProperties.cs @@ -0,0 +1,25 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public interface IUIElementActionProperties : IDoSomethingUIElementProperties + { + /// + /// wait time before action + /// + string v_WaitTimeBeforeAction { get; set; } + + /// + /// wait time after action + /// + string v_WaitTimeAfterAction { get; set; } + + /// + /// activate window before action + /// + string v_ActivateWindowBeforeAction { get; set; } + + /// + /// when UIElement is not supprted this action + /// + string v_WhenActionIsNotSupported { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementChildrenSearchParametersProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementChildrenSearchParametersProperties.cs new file mode 100644 index 000000000..837a605bb --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementChildrenSearchParametersProperties.cs @@ -0,0 +1,35 @@ +using System.Data; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// UIElement children search parameters + /// + public interface IUIElementChildrenSearchParametersProperties : IUIElementChildrenSearchSomewayProperties, IHaveDataTableElements + { + /// + /// UIElement search parameters + /// + DataTable v_SearchParameters { get; set; } + + ///// + ///// wait time for UIElement + ///// + //string v_WaitTimeForUIElement { get; set; } + + ///// + ///// maximum number of sibling nodes to search + ///// + //string v_MaxSiblings { get; set; } + + /// + /// Maxinum Number of UIElements to Search + /// + string v_MaxNumberUIElements { get; set; } + + /// + /// Siblings search Dicretion + /// + string v_SiblingsDirection { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementChildrenSearchSomewayProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementChildrenSearchSomewayProperties.cs new file mode 100644 index 000000000..ed11f1497 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementChildrenSearchSomewayProperties.cs @@ -0,0 +1,18 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for UIElement children search by someway properites + /// + public interface IUIElementChildrenSearchSomewayProperties : IUIElementWindowResultsFromUIElementProperties + { + /// + /// wait time for UIElement + /// + string v_WaitTimeForUIElement { get; set; } + + /// + /// maximum number of sibling nodes to search + /// + string v_MaxSiblings { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementChildrenSearchXPathProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementChildrenSearchXPathProperties.cs new file mode 100644 index 000000000..21a632f6a --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementChildrenSearchXPathProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// UIElement children search XPath properties + /// + public interface IUIElementChildrenSearchXPathProperties : IUIElementChildrenSearchSomewayProperties + { + /// + /// UIElement search XPath + /// + string v_SearchXPath { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementCoreProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementCoreProperties.cs new file mode 100644 index 000000000..f5ee86b20 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementCoreProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for UIElement action or get from UIElement properties + /// + public interface IUIElementCoreProperties : ICanHandleUIElement, IExpandableProperties + { + /// + /// target UIElement variable name + /// + string v_TargetElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchAnyUIElementProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchAnyUIElementProperties.cs new file mode 100644 index 000000000..ade24d0f4 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchAnyUIElementProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// descendants search UIElements and Get any-one UIElement properties + /// + public interface IUIElementDescendantsSearchAnyUIElementProperties : IUIElementDescendantsSearchParametersProperties, IUIElementIndexProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchParametersProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchParametersProperties.cs new file mode 100644 index 000000000..f426f0274 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchParametersProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// descendants search UIElement search parameters + /// + public interface IUIElementDescendantsSearchParametersProperties : IUIElementChildrenSearchParametersProperties, IUIElementDescendantsSearchSomewayProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchSomewayProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchSomewayProperties.cs new file mode 100644 index 000000000..6ee081c79 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchSomewayProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// UIElement descendants search (someway) parameters + /// + public interface IUIElementDescendantsSearchSomewayProperties : IExpandableProperties + { + /// + /// Max depth to Search UIElements + /// + string v_MaxDepth { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchXPathProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchXPathProperties.cs new file mode 100644 index 000000000..a7e1c6cd4 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementDescendantsSearchXPathProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// UIElement descendants search XPath properties + /// + public interface IUIElementDescendantsSearchXPathProperties : IUIElementChildrenSearchXPathProperties, IUIElementDescendantsSearchSomewayProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementIndexProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementIndexProperties.cs new file mode 100644 index 000000000..8ecda6567 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementIndexProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// UIElement Index properties + /// + public interface IUIElementIndexProperties : IExpandableProperties + { + /// + /// UIElement Index + /// + string v_TargetUIElementIndex { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementSearchUIElementFromWindowSomethingByAnywayProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementSearchUIElementFromWindowSomethingByAnywayProperties.cs new file mode 100644 index 000000000..111a9fc46 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementSearchUIElementFromWindowSomethingByAnywayProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for Search UIElement from Window something by Anyway properties + /// + public interface IUIElementSearchUIElementFromWindowSomethingByAnywayProperties : IWindowUIElementResultProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementSelectionItemsProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementSelectionItemsProperties.cs new file mode 100644 index 000000000..842e3533a --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementSelectionItemsProperties.cs @@ -0,0 +1,18 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for UIElement Selection Items + /// + public interface IUIElementSelectionItemsProperties : IDoSomethingUIElementProperties + { + /// + /// try expand combobox when selection items not found + /// + string v_ExpandWhenItemsNotFound { get; set; } + + /// + /// wait time after expand selection items + /// + string v_WaitTimeAfterExpand { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementUIElementActionSomewayProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementUIElementActionSomewayProperties.cs new file mode 100644 index 000000000..0bbd0b3b6 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementUIElementActionSomewayProperties.cs @@ -0,0 +1,20 @@ +using System.Data; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for UIElement Action By/From someway properties + /// + public interface IUIElementUIElementActionSomewayProperties : IExpandableProperties, IHaveDataTableElements + { + /// + /// UIElement Action type + /// + string v_AutomationType { get; set; } + + /// + /// UIElement Action Parameters + /// + DataTable v_UIAActionParameters { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementWindowResultsFromUIElementProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementWindowResultsFromUIElementProperties.cs new file mode 100644 index 000000000..9e90390f2 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IUIElementWindowResultsFromUIElementProperties.cs @@ -0,0 +1,12 @@ +using taskt.Core.Automation.Commands.WindowGroup; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// for to get window name and handle from UIElement properties + /// + public interface IUIElementWindowResultsFromUIElementProperties : IFromWindowNameResultsProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/IWindowUIElementResultProperties.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/IWindowUIElementResultProperties.cs new file mode 100644 index 000000000..dd23eff16 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/IWindowUIElementResultProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + /// + /// window UIElement results + /// + public interface IWindowUIElementResultProperties : ICanHandleUIElement + { + /// + /// Variable Name to Store Window UIElement + /// + string v_WindowUIElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationCheckUIElementExistsByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationCheckUIElementExistsByXPathCommand.cs new file mode 100644 index 000000000..468939cbc --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationCheckUIElementExistsByXPathCommand.cs @@ -0,0 +1,69 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement By XPath")] + [Attributes.ClassAttributes.CommandSettings("Check UIElement Exists By XPath")] + [Attributes.ClassAttributes.Description("This command allows you to check UIElement existence.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to check UIElement existence.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationCheckUIElementExistsByXPathCommand : ADescendantsSearchUIElementsFromUIElementByXPathCommands, IResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] + //public string v_SearchXPath { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] + [Remarks("When the UIElement exists, Result value is **True**")] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //[PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + //[PropertyIsOptional(true, "0")] + //[PropertyFirstValue("0")] + //public string v_WaitTimeForUIElement { get; set; } + + public UIAutomationCheckUIElementExistsByXPathCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //try + //{ + // UIElementControls.SearchGUIElementByXPath(this, engine); + // true.StoreInUserVariable(engine, v_Result); + //} + //catch + //{ + // false.StoreInUserVariable(engine, v_Result); + //} + + var targetElement = this.ExpandUserVariableAsUIElement(engine); + this.DeepSearchUIElementAction(engine, targetElement, + new Action(elem => + { + true.StoreInUserVariable(engine, v_Result); + }), + new Action(ex => + { + false.StoreInUserVariable(engine, v_Result); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationCheckUIElementExistsCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationCheckUIElementExistsCommand.cs new file mode 100644 index 000000000..b883f2429 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationCheckUIElementExistsCommand.cs @@ -0,0 +1,99 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement")] + [Attributes.ClassAttributes.CommandSettings("Check UIElement Exists")] + [Attributes.ClassAttributes.Description("This command allows you to to check UIElement existence.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to check UIElement existence")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationCheckUIElementExistsCommand : ADescendantsSearchAnyUIElementFromUIElementByTreeWalkerCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] + //public DataTable v_SearchParameters { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] + [Remarks("When the UIElement exists, Result value is **True**")] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //[PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + //[PropertyIsOptional(true, "0")] + //[PropertyFirstValue("0")] + //public string v_WaitTimeForUIElement { get; set; } + + //[XmlAttribute] + //[PropertyIsOptional(true, "1")] + //public override string v_MaxNumberUIElements { get; set; } + + public UIAutomationCheckUIElementExistsCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //try + //{ + // UIElementControls.SearchGUIElement(this, engine); + // true.StoreInUserVariable(engine, v_Result); + //} + //catch + //{ + // false.StoreInUserVariable(engine, v_Result); + //} + //try + //{ + // var targetElement = this.ExpandUserVariableAsUIElement(engine); + // var index = this.ExpandValueOrUserVariableAsUIElementIndex(engine); + // var elems = this.DeepSearchUIElements(targetElement, engine); + // (elems.Count >= index).StoreInUserVariable(engine, v_Result); + //} + //catch + //{ + // false.StoreInUserVariable(engine, v_Result); + //} + + var targetElement = this.ExpandUserVariableAsUIElement(engine); + this.DeepSearchUIElementsAction(targetElement, engine, + new Action>(elems => + { + var index = this.ExpandValueOrUserVariableAsUIElementIndex(engine); + (elems.Count >= index).StoreInUserVariable(engine, v_Result); + }), + new Action(ex => + { + false.StoreInUserVariable(engine, v_Result); + }) + ); + } + + //public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + //{ + // //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); + // UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); + //} + + //public override void BeforeValidate() + //{ + // base.BeforeValidate(); + + // var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); + // DataTableControls.BeforeValidate_NoRowAdding(dgv, v_SearchParameters); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationClickUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationClickUIElementCommand.cs new file mode 100644 index 000000000..1909463dc --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationClickUIElementCommand.cs @@ -0,0 +1,257 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("UIElement Action")] + [Attributes.ClassAttributes.CommandSettings("Click UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to Click UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Click UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationClickUIElementCommand : AUIElementActionCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + // TODO: add click parameters interface + [XmlAttribute] + [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_MouseClickType))] + [PropertyParameterOrder(6000)] + public string v_ClickType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_XOffsetAdjustment))] + [PropertyParameterOrder(6100)] + public string v_XOffset { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_YOffsetAdjustment))] + [PropertyParameterOrder(6200)] + public string v_YOffset { get; set; } + + [XmlAttribute] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Activate Window before Click")] + [PropertyIsOptional(true, "Yes")] + //[PropertyParameterOrder(8000)] + public override string v_ActivateWindowBeforeAction { get; set; } + + public UIAutomationClickUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //if (!string.IsNullOrEmpty(v_WaitTimeBeforeAction)) + //{ + // var wt = this.ExpandValueOrUserVariableAsDecimal(nameof(v_WaitTimeBeforeAction), engine); + // if (wt > 0) + // { + // int waitTime = (int)(wt * 1000); + // System.Threading.Thread.Sleep(waitTime); + // } + //} + + //var targetElement = this.ExpandUserVariableAsUIElement(engine); + + //(var windowName, var wHnd) = EM_CanHandleUIElementExtentionMethods.GetWindowNameAndHandle(targetElement); + + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ActivateWindowBeforeAction), engine)) + //{ + // var activateWindow = new ActivateWindowByWindowHandleCommand() + // { + // v_WindowHandle = wHnd.ToString(), + // }; + // activateWindow.RunCommand(engine); + //} + + //// check empty or zero + //bool IsEmptyOrZero(string txt) + //{ + // txt = txt.Trim(); + // if (string.IsNullOrEmpty(txt) || txt == "0") + // { + // return true; + // } + // else + // { + // var exp = txt.ExpandValueOrUserVariable(engine).Trim(); + // return (string.IsNullOrEmpty(exp) || exp == "0"); + // } + //} + + //// check available invoke + //var canInvoke = (bool)targetElement.GetCurrentPropertyValue(AutomationElement.IsInvokePatternAvailableProperty); + + //if (canInvoke && IsEmptyOrZero(v_XOffset) && IsEmptyOrZero(v_YOffset)) + //{ + // // try button + // var btn = (InvokePattern)targetElement.GetCurrentPattern(InvokePattern.Pattern); + // btn.Invoke(); + //} + //else + //{ + // // try mouse click + + // // move window to left-top + // void MoveWindowToLeftTop() + // { + // var moveWindow = new MoveWindowByWindowHandleCommand() + // { + // v_WindowHandle = wHnd.ToString(), + // v_XPosition = "0", + // v_YPosition = "0", + // }; + // moveWindow.RunCommand(engine); + // } + + // System.Windows.Point point; + // try + // { + // if (!targetElement.TryGetClickablePoint(out point)) + // { + // MoveWindowToLeftTop(); + // targetElement.TryGetClickablePoint(out point); + // } + // if ((point.X < 0.0) || (point.Y < 0.0)) + // { + // MoveWindowToLeftTop(); + + // if (!targetElement.TryGetClickablePoint(out point)) + // { + // throw new Exception($"No Clickable Point in UIElement '{v_TargetElement}'"); + // } + // } + // } + // catch (Exception) + // { + // throw new Exception($"No Clickable Point in UIElement '{v_TargetElement}'"); + // } + + // var click = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ClickType), engine); + // var xAd = this.ExpandValueOrUserVariableAsInteger(nameof(v_XOffset), engine); + // var yAd = this.ExpandValueOrUserVariableAsInteger(nameof(v_YOffset), engine); + + // var mouseClick = new MoveMouseCommand() + // { + // v_MouseClick = click, + // v_XMousePosition = (point.X + xAd).ToString(), + // v_YMousePosition = (point.Y + yAd).ToString() + // }; + // mouseClick.RunCommand(engine); + //} + + //if (!string.IsNullOrEmpty(v_WaitTimeAfterAction)) + //{ + // var wt = this.ExpandValueOrUserVariableAsDecimal(nameof(v_WaitTimeAfterAction), engine); + // if (wt > 0) + // { + // int waitTime = (int)(wt * 1000); + // System.Threading.Thread.Sleep(waitTime); + // } + //} + + //if (!string.IsNullOrEmpty(v_WindowNameResult)) + //{ + // windowName.StoreInUserVariable(engine, v_WindowNameResult); + //} + //if (!string.IsNullOrEmpty(v_WindowHandleResult)) + //{ + // wHnd.StoreInUserVariable(engine, v_WindowHandleResult); + //} + + this.UIElementActionAndWait(engine, + new Action((targetElement, whnd) => + { + // check empty or zero + bool IsEmptyOrZero(string txt) + { + txt = txt.Trim(); + if (string.IsNullOrEmpty(txt) || txt == "0") + { + return true; + } + else + { + var exp = txt.ExpandValueOrUserVariable(engine).Trim(); + return (string.IsNullOrEmpty(exp) || exp == "0"); + } + } + + // check available invoke + var canInvoke = (bool)targetElement.GetCurrentPropertyValue(AutomationElement.IsInvokePatternAvailableProperty); + + if (canInvoke && IsEmptyOrZero(v_XOffset) && IsEmptyOrZero(v_YOffset)) + { + // try button + var btn = (InvokePattern)targetElement.GetCurrentPattern(InvokePattern.Pattern); + btn.Invoke(); + } + else + { + // try mouse click + + // move window to left-top + void MoveWindowToLeftTop() + { + var moveWindow = new MoveWindowByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_XPosition = "0", + v_YPosition = "0", + }; + moveWindow.RunCommand(engine); + } + + System.Windows.Point point; + try + { + if (!targetElement.TryGetClickablePoint(out point)) + { + MoveWindowToLeftTop(); + targetElement.TryGetClickablePoint(out point); + } + if ((point.X < 0.0) || (point.Y < 0.0)) + { + MoveWindowToLeftTop(); + + if (!targetElement.TryGetClickablePoint(out point)) + { + //throw new Exception($"No Clickable Point in UIElement '{v_TargetElement}'"); + this.ActionNotSupportedProcess("Click", engine); + return; + } + } + } + catch (Exception) + { + //throw new Exception($"No Clickable Point in UIElement '{v_TargetElement}'"); + this.ActionNotSupportedProcess("Click", engine); + return; + } + + var click = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ClickType), engine); + var xAd = this.ExpandValueOrUserVariableAsInteger(nameof(v_XOffset), engine); + var yAd = this.ExpandValueOrUserVariableAsInteger(nameof(v_YOffset), engine); + + var mouseClick = new MoveMouseCommand() + { + v_MouseClick = click, + v_XMousePosition = (point.X + xAd).ToString(), + v_YMousePosition = (point.Y + yAd).ToString() + }; + mouseClick.RunCommand(engine); + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationExpandCollapseItemsInUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationExpandCollapseItemsInUIElementCommand.cs new file mode 100644 index 000000000..325fc006c --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationExpandCollapseItemsInUIElementCommand.cs @@ -0,0 +1,89 @@ +using System; +using System.Xml.Serialization; +using System.Windows.Automation; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("UIElement Action")] + [Attributes.ClassAttributes.CommandSettings("Expand Collapse Items In UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to Expand or Collapse Items in UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Expand or Collapse Items in UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationExpandCollapseItemsInUIElementCommand : AUIElementActionCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Items State")] + //[PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)] + //[InputSpecification("", true)] + [PropertyUISelectionOption("Expand")] + [PropertyUISelectionOption("Collapse")] + //[Remarks("")] + //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] + [PropertyValidationRule("Items State", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "State")] + [PropertyParameterOrder(6000)] + public string v_ItemsState { get; set; } + + public UIAutomationExpandCollapseItemsInUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + //var state = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ItemsState), engine); + + //if (targetElement.TryGetCurrentPattern(ExpandCollapsePattern.Pattern, out object exColPtn)) + //{ + // switch (state) + // { + // case "expand": + // ((ExpandCollapsePattern)exColPtn).Expand(); + // break; + // case "collapse": + // ((ExpandCollapsePattern)exColPtn).Collapse(); + // break; + // } + //} + //else + //{ + // throw new Exception($"UIElement '{v_TargetElement}' does not support Expand/Collapse"); + //} + + this.UIElementActionAndWait(engine, + new Action((targetElement, whnd) => + { + var state = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ItemsState), engine); + if (targetElement.TryGetCurrentPattern(ExpandCollapsePattern.Pattern, out object exColPtn)) + { + switch (state) + { + case "expand": + ((ExpandCollapsePattern)exColPtn).Expand(); + break; + case "collapse": + ((ExpandCollapsePattern)exColPtn).Collapse(); + break; + } + } + else + { + //throw new Exception($"UIElement '{v_TargetElement}' does not support Expand/Collapse"); + this.ActionNotSupportedProcess("Expand/Collapse", engine); + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetParentUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetParentUIElementCommand.cs new file mode 100644 index 000000000..06c6285e0 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetParentUIElementCommand.cs @@ -0,0 +1,85 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Parent UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Parent UIElement from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Parent UIElement from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetParentUIElementCommand : AGetFromUIElementCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_NewOutputUIElementName))] + [PropertyDescription("Variable Name to Store Parent UIElement")] + [PropertyParameterOrder(6000)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //public string v_WaitTime { get; set; } + + public UIAutomationGetParentUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var rootElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + + //var waitTime = this.ExpandValueOrUserVariableAsInteger(nameof(v_WaitTime), engine); + //object ret = WaitControls.WaitProcess(waitTime, "Parent Element", + // new Func<(bool, object)>(() => + // { + // try + // { + // var root = UIElementControls.GetParentUIElement(rootElement); + // return (true, root); + // } + // catch + // { + // return (false, null); + // } + // }), engine + //); + //if (ret is AutomationElement parent) + //{ + // parent.StoreInUserVariable(engine, v_AutomationElementVariable); + //} + //else + //{ + // throw new Exception("Parent UIElement not Found"); + //} + + this.UIElementAction(engine, + new Action((targetElement) => + { + try + { + var p = EM_CanHandleUIElementExtentionMethods.GetParentUIElement(targetElement); + p.StoreInUserVariable(engine, v_Result); + } + catch + { + this.ValueCanNotRetrievedProcess("Parent Element", new Action(() => + { + "".StoreInUserVariable(engine, v_Result); + }), engine); + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetPropertyValueFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetPropertyValueFromUIElementCommand.cs new file mode 100644 index 000000000..4ab5b328f --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetPropertyValueFromUIElementCommand.cs @@ -0,0 +1,249 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Property Value From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Property Value from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Property Value from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetPropertyValueFromUIElementCommand : AGetFromUIElementCommands, IResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Property Name")] + [PropertyUISelectionOption("Name")] + [PropertyUISelectionOption("ControlType")] + [PropertyUISelectionOption("LocalizedControlType")] + [PropertyUISelectionOption("IsEnabled")] + [PropertyUISelectionOption("IsOffscreen")] + [PropertyUISelectionOption("IsKeyboardFocusable")] + [PropertyUISelectionOption("HasKeyboardFocusable")] + [PropertyUISelectionOption("AccessKey")] + [PropertyUISelectionOption("ProcessId")] + [PropertyUISelectionOption("AutomationId")] + [PropertyUISelectionOption("FrameworkId")] + [PropertyUISelectionOption("ClassName")] + [PropertyUISelectionOption("IsContentElement")] + [PropertyUISelectionOption("IsPassword")] + [PropertyUISelectionOption("AcceleratorKey")] + [PropertyUISelectionOption("HelpText")] + [PropertyUISelectionOption("IsControlElement")] + [PropertyUISelectionOption("IsRequiredForForm")] + [PropertyUISelectionOption("ItemStatus")] + [PropertyUISelectionOption("ItemType")] + [PropertyUISelectionOption("NativeWindowHandle")] + [PropertyValidationRule("Property", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Property")] + [PropertyParameterOrder(6000)] + public string v_PropertyName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + [XmlAttribute] + [PropertyIsOptional(true, "Set Empty")] + public override string v_WhenValueCanNotRetrieved { get; set; } + + public UIAutomationGetPropertyValueFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + + //var propName = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PropertyName), engine); + //switch (propName) + //{ + // case "name": + // propName = "Name"; + // break; + // case "controltype": + // propName = "ControlType"; + // break; + // case "localizedcontroltype": + // propName = "LocalizedControlType"; + // break; + // case "isenabled": + // propName = "IsEnabled"; + // break; + // case "isoffscreen": + // propName = "IsOffscreen"; + // break; + // case "iskeyboardfocusable": + // propName = "IsKeyboardFocusable"; + // break; + // case "haskeyboardfocusable": + // propName = "HasKeyboardFocusable"; + // break; + // case "accesskey": + // propName = "AccessKey"; + // break; + // case "processid": + // propName = "ProcessId"; + // break; + // case "automationid": + // propName = "AutomationId"; + // break; + // case "frameworkid": + // propName = "FrameworkId"; + // break; + // case "classname": + // propName = "ClassName"; + // break; + // case "iscontentelement": + // propName = "IsContentElement"; + // break; + // case "ispassword": + // propName = "IsPassword"; + // break; + // case "acceleratorkey": + // propName = "AcceleratorKey"; + // break; + // case "helptext": + // propName = "HelpText"; + // break; + // case "iscontrolelement": + // propName = "IsControlElement"; + // break; + // case "isrequiredforform": + // propName = "IsRequiredForForm"; + // break; + // case "itemstatus": + // propName = "ItemStatus"; + // break; + // case "itemtype": + // propName = "ItemType"; + // break; + // case "nativewindowhandle": + // propName = "NativeWindowHandle"; + // break; + //} + + //string v; + //if (propName == "ControlType") + //{ + // var c = (ControlType)targetElement.Current.GetType().GetProperty(propName).GetValue(targetElement.Current); + // v = UIElementControls.GetControlTypeText(c); + //} + //else + //{ + // v = targetElement.Current.GetType().GetProperty(propName)?.GetValue(targetElement.Current)?.ToString() ?? ""; + //} + + //v.StoreInUserVariable(engine, v_Result); + + this.UIElementAction(engine, + new Action((targetElement) => + { + var propName = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PropertyName), engine); + switch (propName) + { + case "name": + propName = "Name"; + break; + case "controltype": + propName = "ControlType"; + break; + case "localizedcontroltype": + propName = "LocalizedControlType"; + break; + case "isenabled": + propName = "IsEnabled"; + break; + case "isoffscreen": + propName = "IsOffscreen"; + break; + case "iskeyboardfocusable": + propName = "IsKeyboardFocusable"; + break; + case "haskeyboardfocusable": + propName = "HasKeyboardFocusable"; + break; + case "accesskey": + propName = "AccessKey"; + break; + case "processid": + propName = "ProcessId"; + break; + case "automationid": + propName = "AutomationId"; + break; + case "frameworkid": + propName = "FrameworkId"; + break; + case "classname": + propName = "ClassName"; + break; + case "iscontentelement": + propName = "IsContentElement"; + break; + case "ispassword": + propName = "IsPassword"; + break; + case "acceleratorkey": + propName = "AcceleratorKey"; + break; + case "helptext": + propName = "HelpText"; + break; + case "iscontrolelement": + propName = "IsControlElement"; + break; + case "isrequiredforform": + propName = "IsRequiredForForm"; + break; + case "itemstatus": + propName = "ItemStatus"; + break; + case "itemtype": + propName = "ItemType"; + break; + case "nativewindowhandle": + propName = "NativeWindowHandle"; + break; + } + + string v; + if (propName == "ControlType") + { + //var c = (ControlType)targetElement.Current.GetType().GetProperty(propName).GetValue(targetElement.Current); + //v = UIElementControls.GetControlTypeText(c); + v = EM_CanHandleUIElementExtentionMethods.GetControlTypeText(targetElement); + } + else + { + try + { + v = targetElement.Current.GetType().GetProperty(propName)?.GetValue(targetElement.Current)?.ToString(); + } + catch + { + this.ValueCanNotRetrievedProcess($"{propName} Property", new Action(() => + { + "".StoreInUserVariable(engine, v_Result); + }), engine); + return; + } + } + v.StoreInUserVariable(engine, v_Result); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetScrollBarInformationFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetScrollBarInformationFromUIElementCommand.cs new file mode 100644 index 000000000..031539f06 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetScrollBarInformationFromUIElementCommand.cs @@ -0,0 +1,105 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get ScrollBar Information From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get ScrollBar Information from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get ScrollBar Information from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetScrollBarInformationFromUIElementCommand : AGetFromUIElementCommands, IResultProperties, ICanHandleUIElementScrollBar + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Information Type")] + [PropertyUISelectionOption("Horizontally Scrollable")] + [PropertyUISelectionOption("Horizontal Scroll Percent")] + [PropertyUISelectionOption("Vertically Scrollable")] + [PropertyUISelectionOption("Vertical Scroll Percent")] + [PropertyValidationRule("Information", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Information")] + [PropertyParameterOrder(6000)] + public string v_InformationType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + public UIAutomationGetScrollBarInformationFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementAction(engine, + new Action((targetElement) => + { + //if (!targetElement.TryGetCurrentPattern(ScrollPattern.Pattern, out object scrollPtn)) + //{ + // if (targetElement.Current.ControlType == ControlType.ScrollBar) + // { + // var parentElement = EM_CanHandleUIElementExtentionMethods.GetParentUIElement(targetElement); + // if (!parentElement.TryGetCurrentPattern(ScrollPattern.Pattern, out scrollPtn)) + // { + // this.ValueCanNotRetrievedProcess($"ScrollBar Value", new Action(() => + // { + // "".StoreInUserVariable(engine, v_Result); + // }), engine); + // return; + // } + // } + // else + // { + // this.ValueCanNotRetrievedProcess($"ScrollBar Value", new Action(() => + // { + // "".StoreInUserVariable(engine, v_Result); + // }), engine); + // return; + // } + //} + var sp = EM_CanHandleUIElementScrollBarExtensionMethods.GetScrollPattern(targetElement, new Action(() => + { + this.ValueCanNotRetrievedProcess($"ScrollBar Information", new Action(() => + { + "".StoreInUserVariable(engine, v_Result); + }), engine); + })); + if (sp == null) + { + return; + } + + //var sp = (ScrollPattern)scrollPtn; + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_InformationType), engine)) + { + case "horizontally scrollable": + sp.Current.HorizontallyScrollable.StoreInUserVariable(engine, v_Result); + break; + case "horizontal scroll percent": + sp.Current.HorizontalScrollPercent.StoreInUserVariable(engine, v_Result); + break; + case "vertically scrollable": + sp.Current.VerticallyScrollable.StoreInUserVariable(engine, v_Result); + break; + case "vertical scroll percent": + sp.Current.VerticalScrollPercent.StoreInUserVariable(engine, v_Result); + break; + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetSelectedStateFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetSelectedStateFromUIElementCommand.cs new file mode 100644 index 000000000..81b60598e --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetSelectedStateFromUIElementCommand.cs @@ -0,0 +1,79 @@ +using System; +using System.Xml.Serialization; +using System.Windows.Automation; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Selected State From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Selected State from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Selected State from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetSelectedStateFromUIElementCommand : AGetFromUIElementCommands, IResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] + [Remarks("When UIElement is Selected, Result is **True**")] + [PropertyParameterOrder(6000)] + public string v_Result { get; set; } + + public UIAutomationGetSelectedStateFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + + //bool checkState; + //if (targetElement.TryGetCurrentPattern(TogglePattern.Pattern, out object patternObj)) + //{ + // checkState = (((TogglePattern)patternObj).Current.ToggleState == ToggleState.On); + //} + //else if (targetElement.TryGetCurrentPattern(SelectionItemPattern.Pattern, out patternObj)) + //{ + // checkState = ((SelectionItemPattern)patternObj).Current.IsSelected; + //} + //else + //{ + // throw new Exception("Thie UIElement does not have Selected State"); + //} + //checkState.StoreInUserVariable(engine, v_ResultVariable); + + this.UIElementAction(engine, + new Action((targetElement) => + { + bool checkState; + if (targetElement.TryGetCurrentPattern(TogglePattern.Pattern, out object patternObj)) + { + checkState = (((TogglePattern)patternObj).Current.ToggleState == ToggleState.On); + } + else if (targetElement.TryGetCurrentPattern(SelectionItemPattern.Pattern, out patternObj)) + { + checkState = ((SelectionItemPattern)patternObj).Current.IsSelected; + } + else + { + //throw new Exception("Thie UIElement does not have Selected State"); + this.ValueCanNotRetrievedProcess("Selected State", new Action(() => + { + "".StoreInUserVariable(engine, v_Result); + }), engine); + return; + } + checkState.StoreInUserVariable(engine, v_Result); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetSelectionItemsValueFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetSelectionItemsValueFromUIElementCommand.cs new file mode 100644 index 000000000..99e6f3c7a --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetSelectionItemsValueFromUIElementCommand.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Selection Items Value From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Selection Items Name from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Selection Items Name from UIElement. Search for only Child Elements.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetSelectionItemsValueFromUIElementCommand : AGetFromUIElementCommands, IUIElementSelectionItemsProperties, IListResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] + [PropertyParameterOrder(6000)] + public string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_ExpandWhenItemsNotFound))] + [PropertyParameterOrder(7000)] + public string v_ExpandWhenItemsNotFound { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeAfterExpand))] + [PropertyParameterOrder(7100)] + public string v_WaitTimeAfterExpand { get; set; } + + public UIAutomationGetSelectionItemsValueFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.SelectionItemsAction(engine, + new Action>((items) => + { + var res = new List(); + foreach (var item in items) + { + res.Add(item.Current.Name); + } + //this.StoreListInUserVariable(res, nameof(v_Result), engine); + this.StoreListInUserVariable(res, engine); + }), + new Action(()=> + { + this.ValueCanNotRetrievedProcess("Selection Items", new Action(() => + { + (new List()).StoreInUserVariable(engine, v_Result); + }), engine); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTableInformationFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTableInformationFromUIElementCommand.cs new file mode 100644 index 000000000..da88814c6 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTableInformationFromUIElementCommand.cs @@ -0,0 +1,132 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Table Information From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Table Information from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Table Information from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetTableInformationFromUIElementCommand : AGetFromUIElementCommands, IResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Information Type")] + [PropertyUISelectionOption("Column Count")] + [PropertyUISelectionOption("Row Count")] + [PropertyValidationRule("Information Type", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Information")] + [PropertyParameterOrder(6000)] + public string v_InformationType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Contains Header Row, Column")] + [PropertyIsOptional(true, "No")] + [PropertyValidationRule("Contains Header", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Contains Header")] + [PropertyParameterOrder(8000)] + public string v_ContainsHeader { get; set; } + + public UIAutomationGetTableInformationFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + var containsHeader = this.ExpandValueOrUserVariableAsYesNo(nameof(v_ContainsHeader), engine); + var infoType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_InformationType), engine); + + this.UIElementAction(engine, + new Action((targetElement) => + { + if (targetElement.TryGetCurrentPattern(GridPattern.Pattern, out object gridObj)) + { + var grid = (GridPattern)gridObj; + if (containsHeader) + { + var customRows = EM_UIElementTableUIElement.GetRowsFromDataGridView(targetElement); + if (customRows.Count > 0) + { + // DataGridView(.net) + switch (infoType) + { + case "column count": + var cols = EM_UIElementTableUIElement.GetColumnsFromDataGridView(customRows[0]); + cols.Count.StoreInUserVariable(engine, v_Result); + break; + case "row count": + customRows.Count.StoreInUserVariable(engine, v_Result); + break; + } + } + else + { + // GridPattern + var rows = EM_UIElementTableUIElement.GetRowsFromGridPattern(targetElement); + switch (infoType) + { + case "column count": + var cols = EM_UIElementTableUIElement.GetColumnsFromGridPattern(rows[0]); + cols.Count.StoreInUserVariable(engine, v_Result); + break; + case "row count": + rows.Count.StoreInUserVariable(engine, v_Result); + break; + } + } + } + else + { + switch (infoType) + { + case "column count": + grid.Current.ColumnCount.StoreInUserVariable(engine, v_Result); + break; + case "row count": + grid.Current.RowCount.StoreInUserVariable(engine, v_Result); + break; + } + } + } + else if (targetElement.TryGetCurrentPattern(SelectionPattern.Pattern, out object selPattern)) + { + var selPtn = (SelectionPattern)selPattern; + var rows = EM_UIElementTableUIElement.GetRowsFromSelectionTable(targetElement); + switch(infoType) + { + case "column count": + var cols = EM_UIElementTableUIElement.GetColumnsFromSelectionTable(rows[0]); + cols.Count.StoreInUserVariable(engine, v_Result); + break; + case "row count": + rows.Count.StoreInUserVariable(engine, v_Result); + break; + } + } + else + { + this.ValueCanNotRetrievedProcess("Table Information", new Action(() => + { + "".StoreInUserVariable(engine, v_Result); + }), engine); + return; + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetTextFromTableUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTextFromTableUIElementCommand.cs similarity index 60% rename from taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetTextFromTableUIElementCommand.cs rename to taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTextFromTableUIElementCommand.cs index 2b6f28ce7..bce72c0b3 100644 --- a/taskt/Core/Automation/Commands/UIAutomation/UIAutomationGetTextFromTableUIElementCommand.cs +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTextFromTableUIElementCommand.cs @@ -1,11 +1,11 @@ using System; using System.Xml.Serialization; -using System.Windows.Automation; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; namespace taskt.Core.Automation.Commands { - [Serializable] [Attributes.ClassAttributes.Group("UIAutomation")] [Attributes.ClassAttributes.SubGruop("Get From UIElement")] @@ -15,12 +15,13 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class UIAutomationGetTextFromTableUIElementCommand : ScriptCommand + public sealed class UIAutomationGetTextFromTableUIElementCommand : AGetFromUIElementCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] - public string v_TargetElement { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + // todo: create table row&column interface [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] [PropertyDetailSampleUsage("**0**", "Specify the First Row Index")] @@ -30,6 +31,7 @@ public sealed class UIAutomationGetTextFromTableUIElementCommand : ScriptCommand [InputSpecification("Row Index", true)] [PropertyValidationRule("Row", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "Row")] + [PropertyParameterOrder(6000)] public string v_Row { get; set; } [XmlAttribute] @@ -41,30 +43,47 @@ public sealed class UIAutomationGetTextFromTableUIElementCommand : ScriptCommand [InputSpecification("Column Index", true)] [PropertyValidationRule("Column", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "Column")] + [PropertyParameterOrder(6100)] public string v_Column { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_TextVariable { get; set; } + [PropertyParameterOrder(6200)] + public string v_Result { get; set; } public UIAutomationGetTextFromTableUIElementCommand() { - //this.CommandName = "UIAutomationGetTextFromTableElementCommand"; - //this.SelectionName = "Get Text From Table Element"; - //this.CommandEnabled = true; - //this.CustomRendering = true; } public override void RunCommand(Engine.AutomationEngineInstance engine) { - var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); - int row = v_Row.ExpandValueOrUserVariableAsInteger("v_Row", engine); - int column = v_Column.ExpandValueOrUserVariableAsInteger("v_Column", engine); + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + //int row = v_Row.ExpandValueOrUserVariableAsInteger("v_Row", engine); + //int column = v_Column.ExpandValueOrUserVariableAsInteger("v_Column", engine); + + //AutomationElement cellElem = UIElementControls.GetTableUIElement(targetElement, row, column); + + //string res = UIElementControls.GetTextValue(cellElem); + //res.StoreInUserVariable(engine, v_Result); - AutomationElement cellElem = UIElementControls.GetTableUIElement(targetElement, row, column); + using (var cellVar = new InnerScriptVariable(engine)) + { + var getCell = new UIAutomationGetUIElementFromTableUIElementCommand() + { + v_TargetElement = this.v_TargetElement, + v_Row = this.v_Row, + v_Column = this.v_Column, + v_Result = cellVar.VariableName, + }; + getCell.RunCommand(engine); - string res = UIElementControls.GetTextValue(cellElem); - res.StoreInUserVariable(engine, v_TextVariable); + var getText = new UIAutomationGetTextFromUIElementCommand() + { + v_TargetElement = cellVar.VariableName, + v_Result = this.v_Result, + }; + getText.RunCommand(engine); + } } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTextFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTextFromUIElementCommand.cs new file mode 100644 index 000000000..d77293274 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTextFromUIElementCommand.cs @@ -0,0 +1,77 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Text From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Text Value from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Text Value from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetTextFromUIElementCommand : AGetFromUIElementCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(6000)] + public string v_Result { get; set; } + + public UIAutomationGetTextFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + + //string res = UIElementControls.GetTextValue(targetElement); + //res.StoreInUserVariable(engine, v_Result); + + this.UIElementAction(engine, + new Action(targetElement => + { + string text; + //object patternObj; + if (targetElement.TryGetCurrentPattern(RangeValuePattern.Pattern, out object rPtn)) + { + // bar + text = ((RangeValuePattern)rPtn).Current.Value.ToString(); + } + else if (targetElement.TryGetCurrentPattern(ValuePattern.Pattern, out object vPtn)) + { + // TextBox + text = ((ValuePattern)vPtn).Current.Value; + } + else if (targetElement.TryGetCurrentPattern(TextPattern.Pattern, out object tPtn)) + { + // TextBox Multilune + text = ((TextPattern)tPtn).DocumentRange.GetText(-1); + } + else if (targetElement.TryGetCurrentPattern(SelectionPattern.Pattern, out object sPtn)) + { + // combobox + AutomationElement selElem = ((SelectionPattern)sPtn).Current.GetSelection()[0]; + text = selElem.Current.Name; + } + else + { + // others + text = targetElement.Current.Name; + } + + text.StoreInUserVariable(engine, v_Result); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTextsFromTableUIElementAsDataTableCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTextsFromTableUIElementAsDataTableCommand.cs new file mode 100644 index 000000000..d3064d27e --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetTextsFromTableUIElementAsDataTableCommand.cs @@ -0,0 +1,88 @@ +using System; +using System.Data; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Texts From Table UIElement As DataTable")] + [Attributes.ClassAttributes.Description("This command allows you to get Texts from Table UIElement as DataTable.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Texts from Table UIElement as DataTable.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetTextsFromTableUIElementAsDataTableCommand : AGetFromUIElementCommands, IDataTableResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] + [PropertyParameterOrder(6000)] + public string v_Result { get; set; } + + public UIAutomationGetTextsFromTableUIElementAsDataTableCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + int GetTableInfo(string elementVarName, string infoType) + { + using (var v = new InnerScriptVariable(engine)) + { + var getFromTable = new UIAutomationGetTableInformationFromUIElementCommand() + { + v_TargetElement = elementVarName, + v_InformationType = infoType, + v_ContainsHeader = "Yes", + v_Result = v.VariableName, + }; + getFromTable.RunCommand(engine); + return int.Parse(v.VariableValue.ToString()); + } + } + + string GetTableText(string elementVarName, int row, int col) + { + using (var v = new InnerScriptVariable(engine)) + { + var getFromTable = new UIAutomationGetTextFromTableUIElementCommand() + { + v_TargetElement = elementVarName, + v_Row = row.ToString(), + v_Column = col.ToString(), + v_Result = v.VariableName, + }; + getFromTable.RunCommand(engine); + return v.VariableValue.ToString(); + } + } + + int rows = GetTableInfo(v_TargetElement, "Row Count"); + int cols = GetTableInfo(v_TargetElement, "Column Count"); + + var dt = new DataTable(); + for (int i = 0; i < cols; i++) + { + dt.Columns.Add(); + } + + dt.BeginLoadData(); + for (int i = 0; i < rows; i++) + { + var row = dt.NewRow(); + for (int j = 0; j < cols; j++) + { + row[j] = GetTableText(v_TargetElement, i, j); + } + dt.Rows.Add(row); + } + dt.EndLoadData(); + + this.StoreDataTableInUserVariable(dt, engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetUIElementFromTableUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetUIElementFromTableUIElementCommand.cs new file mode 100644 index 000000000..2a63f1a56 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetUIElementFromTableUIElementCommand.cs @@ -0,0 +1,201 @@ +using System; +using System.Xml.Serialization; +using System.Windows.Automation; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get UIElement From Table UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Table UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Table UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetUIElementFromTableUIElementCommand : AGetFromUIElementCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + // TODO: table row/col interface + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDetailSampleUsage("**0**", "Specify the First Row Index")] + [PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "Row Index")] + [PropertyDetailSampleUsage("**{{{vRow}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Row Index")] + [PropertyDescription("Row Index")] + [InputSpecification("Row Index", true)] + [PropertyValidationRule("Row", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Row")] + [PropertyParameterOrder(6000)] + public string v_Row { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDetailSampleUsage("**0**", "Specify the First Column Index")] + [PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "Column Index")] + [PropertyDetailSampleUsage("**{{{vColumn}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Column Index")] + [PropertyDescription("Column Index")] + [InputSpecification("Column Index", true)] + [PropertyValidationRule("Column", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Column")] + [PropertyParameterOrder(6100)] + public string v_Column { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_NewOutputUIElementName))] + [PropertyParameterOrder(6200)] + public string v_Result { get; set; } + + public UIAutomationGetUIElementFromTableUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + void ErrorAction() + { + this.ValueCanNotRetrievedProcess("Table UIElement", new Action(() => + { + "".StoreInUserVariable(engine, v_Result); + }), engine); + } + + this.UIElementAction(engine, + new Action(targetElement => + { + int rowIndex = v_Row.ExpandValueOrUserVariableAsInteger("v_Row", engine); + int columnIndex = v_Column.ExpandValueOrUserVariableAsInteger("v_Column", engine); + + AutomationElement ret = null; + if (targetElement.TryGetCurrentPattern(GridPattern.Pattern, out object gridObj)) + { + var grid = (GridPattern)gridObj; + //var customRows = targetElement.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom)); + //var customRows = targetElement.FindAll(TreeScope.Children, EM_UIElementTableUIElement.GetRowSearchConditionToDataGridView()); + var customRows = EM_UIElementTableUIElement.GetRowsFromDataGridView(targetElement); + if (customRows.Count > 0) + { + // DataGridView (.net) + try + { + var row = GetInRangeUIElement(customRows, rowIndex, v_Row, "Row"); + //var cols = row.FindAll(TreeScope.Children, new OrCondition( + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Header), + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit) + // ) + // ); + //var cols = row.FindAll(TreeScope.Children, EM_UIElementTableUIElement.GetColumnSearchConditionToDataGridView()); + var cols = EM_UIElementTableUIElement.GetColumnsFromDataGridView(row); + ret = GetInRangeUIElement(cols, columnIndex, v_Column, "Column"); + } + catch + { + ErrorAction(); + return; + } + } + else + { + // listView + try + { + //var rows = targetElement.FindAll(TreeScope.Children, + // new OrCondition( + // new Condition[] + // { + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Header), + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem), + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ListItem), + // } + // ) + // ); + //var rows = targetElement.FindAll(TreeScope.Children, EM_UIElementTableUIElement.GetRowSearchConditionToGridPattern()); + var rows = EM_UIElementTableUIElement.GetRowsFromGridPattern(targetElement); + var row = GetInRangeUIElement(rows, rowIndex, v_Row, "Row"); + //var cols = row.FindAll(TreeScope.Children, new OrCondition( + // new Condition[] + // { + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.HeaderItem), + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text), + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit), + // } + // ) + // ); + //var cols = row.FindAll(TreeScope.Children, EM_UIElementTableUIElement.GetColumnSearchConditionToGridPattern()); + var cols = EM_UIElementTableUIElement.GetColumnsFromGridPattern(row); + ret = GetInRangeUIElement(cols, columnIndex, v_Column, "Column"); + } + catch + { + ErrorAction(); + return; + } + } + } + else if (targetElement.TryGetCurrentPattern(SelectionPattern.Pattern, out object selectObj)) + { + var selPattern = (SelectionPattern)selectObj; + // foobar2000 like table + try + { + //var rows = targetElement.FindAll(TreeScope.Children, EM_UIElementTableUIElement.GetRowSearchConditionToSelectionTable()); + var rows = EM_UIElementTableUIElement.GetRowsFromSelectionTable(targetElement); + var row = GetInRangeUIElement(rows, rowIndex, v_Row, "Row"); + //var cols = row.FindAll(TreeScope.Children, EM_UIElementTableUIElement.GetColumnSearchConditionToSelectionTable()); + var cols = EM_UIElementTableUIElement.GetColumnsFromSelectionTable(row); + if ((cols.Count == 0) && (columnIndex == 0)) + { + ret = row; + } + else + { + ret = GetInRangeUIElement(cols, columnIndex, v_Column, "Column"); + } + } + catch + { + ErrorAction(); + return; + } + } + else + { + ErrorAction(); + return; + } + ret.StoreInUserVariable(engine, v_Result); + }) + ); + } + + /// + /// get in range UIElement + /// + /// + /// + /// + /// + /// + /// + private static AutomationElement GetInRangeUIElement(AutomationElementCollection elems, int index, string rawValue, string elementType) + { + if (index < 0) + { + index += elems.Count; + } + if (index < 0 || index >= elems.Count) + { + throw new Exception($"Error. Table {elementType} is Out of Range. Value: '{rawValue}', Expand Value: {index}"); + } + else + { + return elems[index]; + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetUIElementPositionCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetUIElementPositionCommand.cs new file mode 100644 index 000000000..d7ed84654 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetUIElementPositionCommand.cs @@ -0,0 +1,159 @@ +using System; +using System.Windows; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get UIElement Position")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement Position.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement Position.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetUIElementPositionCommand : AGetFromUIElementCommands, IPositionProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store X Position")] + [PropertyIsOptional(true)] + [PropertyValidationRule("X Position", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "X")] + [PropertyParameterOrder(6000)] + public string v_XPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Y Position")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Y Position", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Y Position")] + [PropertyParameterOrder(6100)] + public string v_YPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Base position")] + [PropertyUISelectionOption("Top Left")] + [PropertyUISelectionOption("Bottom Right")] + [PropertyUISelectionOption("Top Right")] + [PropertyUISelectionOption("Bottom Left")] + [PropertyUISelectionOption("Center")] + [PropertyIsOptional(true, "Top Left")] + [PropertyParameterOrder(6300)] + public string v_PositionBase { get; set; } + + public UIAutomationGetUIElementPositionCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + + //var rct = targetElement.Current.BoundingRectangle; + + //double x = 0.0, y = 0.0; + //switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) + //{ + // case "top left": + // x = rct.Left; + // y = rct.Top; + // break; + // case "bottom right": + // x = rct.Right; + // y = rct.Bottom; + // break; + // case "top right": + // x = rct.Right; + // y = rct.Top; + // break; + // case "bottom left": + // x = rct.Left; + // y = rct.Bottom; + // break; + // case "center": + // x = (rct.Right - rct.Left) / 2.0; + // y = (rct.Bottom - rct.Top) / 2.0; + // break; + //} + + //if (!string.IsNullOrEmpty(v_XPosition)) + //{ + // x.StoreInUserVariable(engine, v_XPosition); + //} + //if (!string.IsNullOrEmpty(v_YPosition)) + //{ + // y.StoreInUserVariable(engine, v_YPosition); + //} + + this.UIElementAction(engine, + new Action((targetElement) => { + Rect rct; + try + { + rct = targetElement.Current.BoundingRectangle; + } + catch + { + this.ValueCanNotRetrievedProcess("Position", new Action(() => + { + if (!string.IsNullOrEmpty(v_XPosition)) + { + "".StoreInUserVariable(engine, v_XPosition); + } + if (!string.IsNullOrEmpty(v_YPosition)) + { + "".StoreInUserVariable(engine, v_YPosition); + } + }), engine); + return; + } + + double x = 0.0, y = 0.0; + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) + { + case "top left": + x = rct.Left; + y = rct.Top; + break; + case "bottom right": + x = rct.Right; + y = rct.Bottom; + break; + case "top right": + x = rct.Right; + y = rct.Top; + break; + case "bottom left": + x = rct.Left; + y = rct.Bottom; + break; + case "center": + x = (rct.Right - rct.Left) / 2.0; + y = (rct.Bottom - rct.Top) / 2.0; + break; + } + + if (!string.IsNullOrEmpty(v_XPosition)) + { + x.StoreInUserVariable(engine, v_XPosition); + } + if (!string.IsNullOrEmpty(v_YPosition)) + { + y.StoreInUserVariable(engine, v_YPosition); + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetUIElementSizeCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetUIElementSizeCommand.cs new file mode 100644 index 000000000..9810b4f93 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetUIElementSizeCommand.cs @@ -0,0 +1,97 @@ +using System; +using System.Windows; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get UIElement Size")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement Size.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement Size.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetUIElementSizeCommand : AGetFromUIElementCommands, ISizeProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Width")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Width")] + [PropertyParameterOrder(6000)] + public string v_Width { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Height")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Height", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Height")] + [PropertyParameterOrder(6100)] + public string v_Height { get; set; } + + public UIAutomationGetUIElementSizeCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + + //var rct = targetElement.Current.BoundingRectangle; + //if (!string.IsNullOrEmpty(v_Width)) + //{ + // rct.Width.StoreInUserVariable(engine, v_Width); + //} + //if (!string.IsNullOrEmpty(v_Height)) + //{ + // rct.Height.StoreInUserVariable(engine, v_Height); + //} + + this.UIElementAction(engine, + new Action((targetElement) => + { + Rect rct; + try + { + rct = targetElement.Current.BoundingRectangle; + } + catch + { + this.ValueCanNotRetrievedProcess("Size", new Action(() => + { + if (!string.IsNullOrEmpty(v_Width)) + { + "".StoreInUserVariable(engine, v_Width); + } + if (!string.IsNullOrEmpty(v_Height)) + { + "".StoreInUserVariable(engine, v_Height); + } + }) , engine); + return; + } + + if (!string.IsNullOrEmpty(v_Width)) + { + rct.Width.StoreInUserVariable(engine, v_Width); + } + if (!string.IsNullOrEmpty(v_Height)) + { + rct.Height.StoreInUserVariable(engine, v_Height); + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowHandleFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowHandleFromUIElementCommand.cs new file mode 100644 index 000000000..a8dad2d5b --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowHandleFromUIElementCommand.cs @@ -0,0 +1,40 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Window Handle From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Window Handle from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Window Handle from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetWindowHandleFromUIElementCommand : AGetFromUIElementCommands + { + [XmlAttribute] + [PropertyIsOptional(false)] + [PropertyValidationRule("Window Handle", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyParameterOrder(6000)] + public override string v_WindowHandleResult { get; set; } + + public UIAutomationGetWindowHandleFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementAction(engine, + new Action((targetElement) => + { + // nothing + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowNameFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowNameFromUIElementCommand.cs new file mode 100644 index 000000000..e2ff7d123 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowNameFromUIElementCommand.cs @@ -0,0 +1,41 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Get From UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Window Name From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Window Name from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Window Name from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetWindowNameFromUIElementCommand : AGetFromUIElementCommands + { + + [XmlAttribute] + [PropertyIsOptional(false)] + [PropertyValidationRule("Window Name", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyParameterOrder(6000)] + public override string v_WindowNameResult { get; set; } + + public UIAutomationGetWindowNameFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementAction(engine, + new Action((targetElement) => + { + // nothing + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowUIElementFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowUIElementFromUIElementCommand.cs new file mode 100644 index 000000000..098cce8ed --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowUIElementFromUIElementCommand.cs @@ -0,0 +1,54 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Window UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Window UIElement From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Window UIElement from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Window UIElement from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetWindowUIElementFromUIElementCommand : AGetFromUIElementCommands, IResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + public UIAutomationGetWindowUIElementFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using (var whnd = new InnerScriptVariable(engine)) + { + var getWinHandle = new UIAutomationGetWindowHandleFromUIElementCommand() + { + v_TargetElement = this.v_TargetElement, + v_WindowHandleResult = whnd.VariableName, + v_WindowNameResult = this.v_WindowNameResult, + }; + getWinHandle.RunCommand(engine); + + var getWinElem = new UIAutomationGetWindowUIElementFromWindowHandleCommand() + { + v_WindowHandle = whnd.VariableValue.ToString(), + v_Result = this.v_Result, + }; + getWinElem.RunCommand(engine); + if (!string.IsNullOrEmpty(this.v_WindowHandleResult)) + { + whnd.VariableValue.ToString().StoreInUserVariable(engine, v_WindowHandleResult); + } + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowUIElementFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowUIElementFromWindowHandleCommand.cs new file mode 100644 index 000000000..4d754f40e --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowUIElementFromWindowHandleCommand.cs @@ -0,0 +1,38 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Window UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Window UIElement From Window Handle")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Window Handle")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Window Handle")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetWindowUIElementFromWindowHandleCommand : AWindowHandleCommands + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyParameterOrder(5100)] + public string v_Result { get; set; } + + public UIAutomationGetWindowUIElementFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowHandleAction(engine, new Action(whnd => + { + var ele = AutomationElement.FromHandle(whnd); + ele.StoreInUserVariable(engine, v_Result); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowUIElementFromWindowNameCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowUIElementFromWindowNameCommand.cs new file mode 100644 index 000000000..bf5a63fbf --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationGetWindowUIElementFromWindowNameCommand.cs @@ -0,0 +1,87 @@ +using System; +using System.Windows.Automation; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.UI.CustomControls; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Window UIElement")] + [Attributes.ClassAttributes.CommandSettings("Get Window UIElement From Window Name")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Window Name")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Window Name.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationGetWindowUIElementFromWindowNameCommand : AOneWindowNameCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + //public string v_WindowName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyParameterOrder(5100)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] + //public string v_CompareMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] + //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + //public string v_MatchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + //public string v_TargetWindowIndex { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + //public string v_WaitTimeForWindow { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + //public string v_NameResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_HandleResult { get; set; } + + public UIAutomationGetWindowUIElementFromWindowNameCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //UIElementControls.GetWindowUIElement(this, engine); + + this.WindowNameAction(engine, new Action((whnd, name) => + { + var ret = AutomationElement.FromHandle(whnd); + + if (!string.IsNullOrEmpty(v_Result)) + { + ret.StoreInUserVariable(engine, v_Result); + } + })); + } + + //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + //} + + public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + //var cmb = (ComboBox)ControlsList[nameof(v_WindowName)]; + //cmb.AddWindowNames(); + ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationScrollPercentUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationScrollPercentUIElementCommand.cs new file mode 100644 index 000000000..7c8b75606 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationScrollPercentUIElementCommand.cs @@ -0,0 +1,94 @@ +using System; +using System.Xml.Serialization; +using System.Windows.Automation; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("UIElement Action")] + [Attributes.ClassAttributes.CommandSettings("Scroll Percent UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to Scroll UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Scroll UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationScrollPercentUIElementCommand : AUIElementActionCommands, ICanHandleUIElementScrollBar + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("ScrollBar Type")] + [PropertyUISelectionOption("Vertical")] + [PropertyUISelectionOption("Horizonal")] + [PropertyValidationRule("ScrollBar Type", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Type")] + [PropertyParameterOrder(6000)] + public string v_ScrollBarType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Scroll Value")] + [PropertyDetailSampleUsage("**0**", PropertyDetailSampleUsage.ValueType.Value, "Scroll")] + [PropertyDetailSampleUsage("**{{vScroll}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Scroll")] + [PropertyValueRange(0, 100)] + [PropertyValidationRule("Scroll Method", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + [PropertyDisplayText(true, "Scroll Value")] + [PropertyParameterOrder(6100)] + public string v_ScrollValue{ get; set; } + + public UIAutomationScrollPercentUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementActionAndWait(engine, + new Action((targetElement, whnd) => + { + //if (!targetElement.TryGetCurrentPattern(ScrollPattern.Pattern, out object scrollPtn)) + //{ + // if (targetElement.Current.ControlType == ControlType.ScrollBar) + // { + // var parentElement = EM_CanHandleUIElementExtentionMethods.GetParentUIElement(targetElement); + // if (!parentElement.TryGetCurrentPattern(ScrollPattern.Pattern, out scrollPtn)) + // { + // this.ActionNotSupportedProcess("Scroll", engine); + // return; + // } + // } + // else + // { + // this.ActionNotSupportedProcess("Scroll", engine); + // return; + // } + //} + + var sp = EM_CanHandleUIElementScrollBarExtensionMethods.GetScrollPattern(targetElement, new Action(() => + { + this.ActionNotSupportedProcess("Scroll", engine); + })); + if (sp == null) + { + return; + } + + var scrollValue = (double)this.ExpandValueOrUserVariableAsDecimal(nameof(v_ScrollValue), engine); + + //var sp = (ScrollPattern)scrollPtn; + var scrollbarType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ScrollBarType), engine); + switch (scrollbarType) + { + case "horizonal": + sp.SetScrollPercent(scrollValue, ScrollPattern.NoScroll); + break; + case "vertical": + sp.SetScrollPercent(ScrollPattern.NoScroll, scrollValue); + break; + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationScrollUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationScrollUIElementCommand.cs new file mode 100644 index 000000000..b8ef0760e --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationScrollUIElementCommand.cs @@ -0,0 +1,165 @@ +using System; +using System.Xml.Serialization; +using System.Windows.Automation; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("UIElement Action")] + [Attributes.ClassAttributes.CommandSettings("Scroll UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to Scroll UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Scroll UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationScrollUIElementCommand : AUIElementActionCommands, ICanHandleUIElementScrollBar + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("ScrollBar Type")] + [PropertyUISelectionOption("Vertical")] + [PropertyUISelectionOption("Horizonal")] + [PropertyValidationRule("ScrollBar Type", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Type")] + [PropertyParameterOrder(6000)] + public string v_ScrollBarType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Scroll Method")] + [PropertyUISelectionOption("Scroll Small Down or Right")] + [PropertyUISelectionOption("Scroll Large Down or Right")] + [PropertyUISelectionOption("Scroll Small Up or Left")] + [PropertyUISelectionOption("Scroll Large Up or Left")] + [PropertyValidationRule("Scroll Method", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Method")] + [PropertyParameterOrder(6100)] + public string v_DirectionAndAmount{ get; set; } + + public UIAutomationScrollUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + //var scrollbarType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ScrollBarType), engine); + + //var dirAndAmo = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_DirectionAndAmount), engine); + //var amount = ScrollAmount.NoAmount; + //switch (dirAndAmo) + //{ + // case "scroll small down or right": + // amount = ScrollAmount.SmallIncrement; + // break; + // case "scroll large down or right": + // amount = ScrollAmount.LargeIncrement; + // break; + // case "scroll small up or left": + // amount = ScrollAmount.SmallDecrement; + // break; + // case "scroll large up or left": + // amount = ScrollAmount.LargeDecrement; + // break; + //} + + //if (!targetElement.TryGetCurrentPattern(ScrollPattern.Pattern, out object scrollPtn)) + //{ + // if (targetElement.Current.ControlType == ControlType.ScrollBar) + // { + // var parentElement = UIElementControls.GetParentUIElement(targetElement); + // if (!parentElement.TryGetCurrentPattern(ScrollPattern.Pattern, out scrollPtn)) + // { + // throw new Exception($"UIElement '{v_TargetElement}' does not have ScrollBar"); + // } + // } + // else + // { + // throw new Exception($"UIElement '{v_TargetElement}' is not ScrollBar and does not have ScrollBar"); + // } + //} + //var sp = (ScrollPattern)scrollPtn; + //switch (scrollbarType) + //{ + // case "horizonal": + // sp.ScrollHorizontal(amount); + // break; + // case "vertical": + // sp.ScrollVertical(amount); + // break; + //} + + this.UIElementActionAndWait(engine, + new Action((targetElement, whnd) => + { + var dirAndAmo = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_DirectionAndAmount), engine); + var amount = ScrollAmount.NoAmount; + switch (dirAndAmo) + { + case "scroll small down or right": + amount = ScrollAmount.SmallIncrement; + break; + case "scroll large down or right": + amount = ScrollAmount.LargeIncrement; + break; + case "scroll small up or left": + amount = ScrollAmount.SmallDecrement; + break; + case "scroll large up or left": + amount = ScrollAmount.LargeDecrement; + break; + } + + //if (!targetElement.TryGetCurrentPattern(ScrollPattern.Pattern, out object scrollPtn)) + //{ + // if (targetElement.Current.ControlType == ControlType.ScrollBar) + // { + // //var parentElement = UIElementControls.GetParentUIElement(targetElement); + // var parentElement = EM_CanHandleUIElementExtentionMethods.GetParentUIElement(targetElement); + // if (!parentElement.TryGetCurrentPattern(ScrollPattern.Pattern, out scrollPtn)) + // { + // //throw new Exception($"UIElement '{v_TargetElement}' does not have ScrollBar"); + // this.ActionNotSupportedProcess("Scroll", engine); + // return; + // } + // } + // else + // { + // //throw new Exception($"UIElement '{v_TargetElement}' is not ScrollBar and does not have ScrollBar"); + // this.ActionNotSupportedProcess("Scroll", engine); + // return; + // } + //} + + var sp = EM_CanHandleUIElementScrollBarExtensionMethods.GetScrollPattern(targetElement, new Action(()=> + { + this.ActionNotSupportedProcess("Scroll", engine); + })); + if (sp == null) + { + return; + } + + //var sp = (ScrollPattern)scrollPtn; + var scrollbarType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ScrollBarType), engine); + switch (scrollbarType) + { + case "horizonal": + sp.ScrollHorizontal(amount); + break; + case "vertical": + sp.ScrollVertical(amount); + break; + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildUIElementCommand.cs new file mode 100644 index 000000000..65fb53a95 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildUIElementCommand.cs @@ -0,0 +1,86 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement")] + [Attributes.ClassAttributes.CommandSettings("Search Child UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get Child Element from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Child UIElement from UIElement. Search only for Child UIElements.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchChildUIElementCommand : AChildrenSearchUIElementsFromUIElementByTreeWalkerCommands, IUIElementIndexProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //[PropertyDescription("Search Start UIElement Variable")] + //public string v_TargetElement { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_SearchParameters))] + //[PropertyParameterOrder(6000)] + //public DataTable v_SearchParameters { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_TargetUIElementIndex))] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Child UIElement Index")] + //[InputSpecification("Number", true)] + //[PropertyDetailSampleUsage("**0**", "Specfity the First UIElement")] + //[PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "Index")] + //[PropertyDetailSampleUsage("**{{{vIndex}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Index")] + //[Remarks("")] + //[PropertyShowSampleUsageInDescription(true)] + //[PropertyValidationRule("Index", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + //[PropertyDisplayText(true, "Index")] + [PropertyParameterOrder(6100)] + public string v_TargetUIElementIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_NewOutputUIElementName))] + [PropertyDescription("UIElement Variable Name to Store Child UIElement")] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeForUIElement))] + //[PropertyParameterOrder(7100)] + //public string v_WaitTimeForUIElement { get; set; } + + public UIAutomationSearchChildUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementAction(engine, new Action((elem) => + { + var children = this.SearchChildrenUIElements(elem, engine); + + //var index = v_TargetUIElementIndex.ExpandValueOrUserVariableAsInteger("v_Index", engine); + //var index = this.ExpandValueOrUserVariableAsUIElementIndex(engine); + //if (index < 0) + //{ + // index += children.Count; + //} + //if (index >= 0 && index < children.Count) + //{ + // children[index].StoreInUserVariable(engine, v_Result); + //} + //else + //{ + // throw new Exception($"UIElement not found. Index: '{v_TargetUIElementIndex}', Expand Value: '{index}'"); + //} + + var e = this.GetUIElementFromList(children, engine); + e.StoreInUserVariable(engine, v_Result); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildUIElementFromUIElementByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildUIElementFromUIElementByXPathCommand.cs new file mode 100644 index 000000000..22cfdf351 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildUIElementFromUIElementByXPathCommand.cs @@ -0,0 +1,37 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement By XPath")] + [Attributes.ClassAttributes.CommandSettings("Search Child UIElement From UIElement By XPath")] + [Attributes.ClassAttributes.Description("This command allows you to get Child UIElement from UIElement using by XPath.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Child UIElement from UIElement. XPath does not support to use parent and sibling for root element.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchChildUIElementFromUIElementByXPathCommand : AChildrenSearchUIElementsFromUIElementByXPathCommands, IResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_NewOutputUIElementName))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + public UIAutomationSearchChildUIElementFromUIElementByXPathCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + var targetElement = this.ExpandUserVariableAsUIElement(engine); + this.SearchChildrenUIElementAction(engine, targetElement, new Action(elem => + { + elem.StoreInUserVariable(engine, v_Result); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildrenUIElementsInformationCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildrenUIElementsInformationCommand.cs new file mode 100644 index 000000000..abb4b8e82 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildrenUIElementsInformationCommand.cs @@ -0,0 +1,63 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement")] + [Attributes.ClassAttributes.CommandSettings("Search Children UIElements Information")] + [Attributes.ClassAttributes.Description("This command allows you to get Children UIElements Information from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get Children UIElements Information from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchChildrenUIElementsInformationCommand : AChildrenSearchUIElementsFromUIElementByTreeWalkerCommands, IGetUIElementsInformationProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_SearchParameters))] + //[PropertyParameterOrder(6000)] + //public DataTable v_SearchParameters { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(6100)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeForUIElement))] + //[PropertyParameterOrder(7100)] + //public string v_WaitTimeForUIElement { get; set; } + + public UIAutomationSearchChildrenUIElementsInformationCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementAction(engine, new Action((targetElement) => + { + var elems = this.SearchChildrenUIElements(targetElement, engine); + + //string result = ""; + + //int counts = elems.Count; + //for (int i = 0; i < counts; i++) + //{ + // var elem = elems[i]; + // result += $"Index: {i}, Name: {elem.Current.Name}, LocalizedControlType: {elem.Current.LocalizedControlType}, ControlType: {EM_CanHandleUIElementExtentionMethods.GetControlTypeText(elem)}\n"; + //} + //result.Trim().StoreInUserVariable(engine, v_Result); + + this.StoreUIElementsInformationInUserVariable(elems, engine); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildrenUIElementsTreeXMLFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildrenUIElementsTreeXMLFromUIElementCommand.cs new file mode 100644 index 000000000..cf0b17481 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchChildrenUIElementsTreeXMLFromUIElementCommand.cs @@ -0,0 +1,72 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement By XPath")] + [Attributes.ClassAttributes.CommandSettings("Search Children UIElements Tree XML From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to Search Children UIElements Tree XML from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Search Children UIElements Tree XML from UIElement. XML content is based on WinAppDriver UI Recorder.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchChildrenUIElementsTreeXMLFromUIElementCommand : ADoSomethingUIElementCommands, IUIElementChildrenSearchSomewayProperties, IResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to store XML")] + [PropertyDetailSampleUsage("**vXML**", PropertyDetailSampleUsage.ValueType.VariableName)] + [PropertyDetailSampleUsage("**{{{vXML}}}**", PropertyDetailSampleUsage.ValueType.VariableName)] + [Remarks("XML content is based on WinAppDriver UI Recorder.")] + [PropertyParameterOrder(6000)] + public string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeForUIElement))] + [PropertyParameterOrder(7990)] + public string v_WaitTimeForUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxSiblings))] + [PropertyParameterOrder(7991)] + public string v_MaxSiblings { get; set; } + + public UIAutomationSearchChildrenUIElementsTreeXMLFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + var maxTime = this.ExpandValueOrUserVariableAsWaitTimeForUIElement(engine); + var finishTime = (maxTime > 0) ? DateTime.Now.AddSeconds(maxTime) : DateTime.Now; + Func timeFunc = (maxTime <= 0) ? + new Func(() => false) : + new Func(() => + { + return (DateTime.Now >= finishTime); + }); + + var targetElement = this.ExpandUserVariableAsUIElement(engine); + var cmd = new UIAutomationSearchChildUIElementFromUIElementByXPathCommand() + { + v_MaxSiblings = this.v_MaxSiblings, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + }; + (var xml, _) = cmd.CreateChildrenXMLCore(targetElement, timeFunc, engine); + + using(var sw = new System.IO.StringWriter()) + { + xml.Save(sw); + sw.ToString().StoreInUserVariable(engine, v_Result); + } + + cmd.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(targetElement, engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromUIElementByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromUIElementByXPathCommand.cs new file mode 100644 index 000000000..0574d97ca --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromUIElementByXPathCommand.cs @@ -0,0 +1,57 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement By XPath")] + [Attributes.ClassAttributes.CommandSettings("Search UIElement From UIElement By XPath")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement from UIElement using by XPath.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from UIElement. XPath does not support to use parent and sibling for root element.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementFromUIElementByXPathCommand : ADescendantsSearchUIElementsFromUIElementByXPathCommands, IResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //[PropertyDescription("UIElement Variable Name to Search")] + //public string v_TargetElement { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] + //public string v_SearchXPath { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_NewOutputUIElementName))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //public string v_WaitTimeForUIElement { get; set; } + + //[XmlIgnore] + //[NonSerialized] + //private TextBox XPathTextBox; + + public UIAutomationSearchUIElementFromUIElementByXPathCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var elem = UIElementControls.SearchGUIElementByXPath(this, engine); + //elem.StoreInUserVariable(engine, v_Result); + + var targetElement = this.ExpandUserVariableAsUIElement(engine); + this.DeepSearchUIElementAction(engine, targetElement, new Action(elem => + { + elem.StoreInUserVariable(engine, v_Result); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromUIElementCommand.cs new file mode 100644 index 000000000..6b2cdec55 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromUIElementCommand.cs @@ -0,0 +1,71 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement")] + [Attributes.ClassAttributes.CommandSettings("Search UIElement From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from UIElement. Search for Descendants Elements.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementFromUIElementCommand : ADescendantsSearchAnyUIElementFromUIElementByTreeWalkerCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //[PropertyDescription("UIElement Variable Name to Search")] + //public string v_TargetElement { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] + //public DataTable v_SearchParameters { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_NewOutputUIElementName))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //public string v_WaitTimeForUIElement { get; set; } + + public UIAutomationSearchUIElementFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var elem = UIElementControls.SearchGUIElement(this, engine); + //elem.StoreInUserVariable(engine, v_Result); + + var targetElement = this.ExpandUserVariableAsUIElement(engine); + + this.DeepSearchAnyUIElementAction(targetElement, engine, new Action(elem => + { + elem.StoreInUserVariable(engine, v_Result); + })); + + //var ret = this.GetUIElementFromDeepSearchUIElements(targetElement, engine); + //ret.StoreInUserVariable(engine, v_Result); + } + + //public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + //{ + // //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); + // UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); + //} + + //public override void BeforeValidate() + //{ + // base.BeforeValidate(); + + // var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); + // DataTableControls.BeforeValidate_NoRowAdding(dgv, v_SearchParameters); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowHandleByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowHandleByXPathCommand.cs new file mode 100644 index 000000000..18405e7da --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowHandleByXPathCommand.cs @@ -0,0 +1,59 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement From Window")] + [Attributes.ClassAttributes.CommandSettings("Search UIElement From Window Handle By XPath")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Window Handle using by XPath.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Window Handle. XPath does not support to use parent and sibling for root element.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementFromWindowHandleByXPathCommand : ADescendantsSearchUIElementsFromWindowHandleByXPathCommands, IResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + + public UIAutomationSearchUIElementFromWindowHandleByXPathCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using(var winElem = new InnerScriptVariable(engine)) + { + var winSearch = new UIAutomationGetWindowUIElementFromWindowHandleCommand() + { + v_WindowHandle = this.v_WindowHandle, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = winElem.VariableName, + v_WindowNameResult = this.v_WindowNameResult, + }; + winSearch.RunCommand(engine); + + var searchElem = new UIAutomationSearchUIElementFromUIElementByXPathCommand() + { + v_TargetElement = winElem.VariableName, + v_SearchXPath = this.v_SearchXPath, + v_Result = this.v_Result, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_MaxDepth = this.v_MaxDepth, + v_MaxSiblings = this.v_MaxSiblings, + }; + searchElem.RunCommand(engine); + + this.StoreWindowUIElementInUserVariable((AutomationElement)winElem.VariableValue, engine); + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowHandleCommand.cs new file mode 100644 index 000000000..eb86a5bb3 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowHandleCommand.cs @@ -0,0 +1,61 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement From Window")] + [Attributes.ClassAttributes.CommandSettings("Search UIElement From Window Handle")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Window Handle.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Window Handle.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementFromWindowHandleCommand : ADescendantsSearchAnyUIElementFromWindowHandleByTreeWalkerCommands, IResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyParameterOrder(6200)] + public string v_Result { get; set; } + + public UIAutomationSearchUIElementFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using (var winElem = new InnerScriptVariable(engine)) + { + var winSearch = new UIAutomationGetWindowUIElementFromWindowHandleCommand() + { + v_WindowHandle = this.v_WindowHandle, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = winElem.VariableName, + v_WindowNameResult = this.v_WindowNameResult, + }; + winSearch.RunCommand(engine); + + var searchElem = new UIAutomationSearchUIElementFromUIElementCommand() + { + v_TargetElement = winElem.VariableName, + v_SearchParameters = this.v_SearchParameters, + v_TargetUIElementIndex = this.v_TargetUIElementIndex, + v_Result = this.v_Result, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_MaxSiblings = this.v_MaxSiblings, + v_MaxDepth = this.v_MaxDepth, + v_MaxNumberUIElements = this.v_MaxNumberUIElements, + v_SiblingsDirection = this.v_SiblingsDirection, + }; + searchElem.RunCommand(engine); + + this.StoreWindowUIElementInUserVariable((AutomationElement)winElem.VariableValue, engine); + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowNameByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowNameByXPathCommand.cs new file mode 100644 index 000000000..b1f27b619 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowNameByXPathCommand.cs @@ -0,0 +1,115 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement From Window")] + [Attributes.ClassAttributes.CommandSettings("Search UIElement From Window Name By XPath")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Window Name using by XPath.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Window Name. XPath does not support to use parent and sibling for root element.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementFromWindowNameByXPathCommand : ADescendantsSearchUIElementsFromWindowNameByXPathCommands, IResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + //public string v_WindowName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] + //public string v_SearchXPath { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CheckMethod))] + //public string v_CheckMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_SelectionMethod_Single))] + //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + //public string v_SelectionMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + //public string v_TargetWindowIndex { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + //public string v_WaitTimeForWindow { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //public string v_WaitTimeForUIElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + //public string v_WindowNameResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_WindowHandleResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WindowUIElementName))] + //public string v_WindowUIElement { get;set; } + + public UIAutomationSearchUIElementFromWindowNameByXPathCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using(var winElem = new InnerScriptVariable(engine)) + { + var winSearch = new UIAutomationGetWindowUIElementFromWindowNameCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_SelectionMethod = this.v_SelectionMethod, + v_TargetWindowIndex = this.v_TargetWindowIndex, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = winElem.VariableName, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + v_CaseSensitive = this.v_CaseSensitive, + v_TrimBeforeCheck = this.v_TrimBeforeCheck, + }; + winSearch.RunCommand(engine); + + var searchElem = new UIAutomationSearchUIElementFromUIElementByXPathCommand() + { + v_TargetElement = winElem.VariableName, + v_SearchXPath = this.v_SearchXPath, + v_Result = this.v_Result, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_MaxDepth = this.v_MaxDepth, + v_MaxSiblings = this.v_MaxSiblings, + }; + searchElem.RunCommand(engine); + + this.StoreWindowUIElementInUserVariable((AutomationElement)winElem.VariableValue, engine); + } + } + + //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + //} + + //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + //{ + // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowNameCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowNameCommand.cs new file mode 100644 index 000000000..b6ddb3469 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementFromWindowNameCommand.cs @@ -0,0 +1,164 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement From Window")] + [Attributes.ClassAttributes.CommandSettings("Search UIElement From Window Name")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElement from Window Name.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElement from Window Name.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementFromWindowNameCommand : ADescendantsSearchAnyUIElementFromWindowNameByTreeWalkerCommands, IResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + //[PropertyParameterOrder(5000)] + //public string v_WindowName { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] + //public DataTable v_SearchParameters { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyParameterOrder(6200)] + public string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CheckMethod))] + //[PropertyParameterOrder(8100)] + //public string v_CheckMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_SelectionMethod_Single))] + //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + //[PropertyParameterOrder(8200)] + //public string v_SelectionMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + //[PropertyParameterOrder(8300)] + //public string v_TargetWindowIndex { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + //[PropertyParameterOrder(8300)] + //public string v_WaitTimeForWindow { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //public string v_WaitTimeForUIElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + //public string v_WindowNameResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_WindowHandleResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WindowUIElementName))] + //[PropertyParameterOrder(10200)] + //public string v_WindowUIElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CaseSensitive))] + //[PropertyParameterOrder(11000)] + //public string v_CaseSensitive { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TrimBeforeCheck))] + //[PropertyParameterOrder(11100)] + //public string v_TrimBeforeCheck { get; set; } + + public UIAutomationSearchUIElementFromWindowNameCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //using (var winElem = new InnerScriptVariable(engine)) + //{ + // var winSearch = new UIAutomationGetWindowUIElementCommand() + // { + // v_WindowName = this.v_WindowName, + // v_CheckMethod = this.v_CheckMethod, + // v_SelectionMethod = this.v_SelectionMethod, + // v_TargetWindowIndex = this.v_TargetWindowIndex, + // v_WaitTimeForWindow = this.v_WaitTimeForWindow, + // v_Result = winElem.VariableName, + // v_WindowNameResult = this.v_WindowNameResult, + // v_WindowHandleResult = this.v_WindowHandleResult, + // v_CaseSensitive = this.v_CaseSensitive, + // v_TrimBeforeCheck = this.v_TrimBeforeCheck, + // }; + // winSearch.RunCommand(engine); + + // var searchElem = new UIAutomationSearchUIElementFromUIElementCommand() + // { + // v_TargetElement = winElem.VariableName, + // v_SearchParameters = this.v_SearchParameters, + // v_TargetUIElementIndex = this.v_TargetUIElementIndex, + // v_Result = this.v_Result, + // v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + // v_MaxSiblings = this.v_MaxSiblings, + // v_MaxDepth = this.v_MaxDepth, + // v_MaxNumberUIElements = this.v_MaxNumberUIElements, + // v_SiblingsDirection = this.v_SiblingsDirection, + // }; + // searchElem.RunCommand(engine); + + // this.StoreWindowUIElementInUserVariable((AutomationElement)winElem.VariableValue, engine); + //} + + this.SearchWindowAfterAction(engine, + new Func(winElem => + { + return new UIAutomationSearchUIElementFromUIElementCommand() + { + v_TargetElement = winElem.VariableName, + v_SearchParameters = this.v_SearchParameters, + v_TargetUIElementIndex = this.v_TargetUIElementIndex, + v_Result = this.v_Result, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_MaxSiblings = this.v_MaxSiblings, + v_MaxDepth = this.v_MaxDepth, + v_MaxNumberUIElements = this.v_MaxNumberUIElements, + v_SiblingsDirection = this.v_SiblingsDirection, + }; + }) + ); + } + + //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + //} + + //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + //{ + // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); + //} + + //public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + //{ + // //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); + // UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); + //} + + //public override void BeforeValidate() + //{ + // var dgvSearch = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); + // DataTableControls.BeforeValidate(dgvSearch, v_SearchParameters); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsInformationFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsInformationFromUIElementCommand.cs new file mode 100644 index 000000000..c94eeae87 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsInformationFromUIElementCommand.cs @@ -0,0 +1,45 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement")] + [Attributes.ClassAttributes.CommandSettings("Search UIElements Information From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElements Information from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElements Information from UIElement. Search for Descendants Elements.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementsInformationFromUIElementCommand : ADescendantsSearchUIElementsFromSomethingByTreeWalkerCommands, IUIElementCoreProperties, IGetUIElementsInformationProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_InputUIElementName))] + [PropertyParameterOrder(5000)] + public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + public UIAutomationSearchUIElementsInformationFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + var targetElement = this.ExpandUserVariableAsUIElement(engine); + //var elems = this.DeepSearchUIElements(targetElement, engine); + //this.StoreUIElementsInformationInUserVariable(elems, engine); + + this.DeepSearchUIElementsAction(targetElement, engine, new Action>(elems => + { + this.StoreUIElementsInformationInUserVariable(elems, engine); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsInformationFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsInformationFromWindowHandleCommand.cs new file mode 100644 index 000000000..4e08e59ec --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsInformationFromWindowHandleCommand.cs @@ -0,0 +1,60 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement From Window")] + [Attributes.ClassAttributes.CommandSettings("Search UIElements Information From Window Handle")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElements Information from Window Handle.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElements Information from Window Handle.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementsInformationFromWindowHandleCommand : ADescendantsSearchUIElementsFromWindowHandleByTreeWalkerCommands, IResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(6200)] + public string v_Result { get; set; } + + public UIAutomationSearchUIElementsInformationFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using (var winElem = new InnerScriptVariable(engine)) + { + var winSearch = new UIAutomationGetWindowUIElementFromWindowHandleCommand() + { + v_WindowHandle = this.v_WindowHandle, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = winElem.VariableName, + v_WindowNameResult = this.v_WindowNameResult, + }; + winSearch.RunCommand(engine); + + var searchInfo = new UIAutomationSearchUIElementsInformationFromUIElementCommand() + { + v_TargetElement = winElem.VariableName, + v_SearchParameters = this.v_SearchParameters, + v_Result = this.v_Result, + v_MaxSiblings = this.v_MaxSiblings, + v_MaxDepth = this.v_MaxDepth, + v_MaxNumberUIElements = this.v_MaxNumberUIElements, + v_SiblingsDirection = this.v_SiblingsDirection, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + }; + searchInfo.RunCommand(engine); + + this.StoreWindowUIElementInUserVariable((AutomationElement)winElem.VariableValue, engine); + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsInformationFromWindowNameCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsInformationFromWindowNameCommand.cs new file mode 100644 index 000000000..8de22e1af --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsInformationFromWindowNameCommand.cs @@ -0,0 +1,83 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement From Window")] + [Attributes.ClassAttributes.CommandSettings("Search UIElements Information From Window Name")] + [Attributes.ClassAttributes.Description("This command allows you to get UIElements Information from Window Name.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to get UIElements Information from Window Name.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementsInformationFromWindowNameCommand : ADescendantsSearchUIElementsFromWindowNameByTreeWalkerCommands, IResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(6200)] + public string v_Result { get; set; } + + public UIAutomationSearchUIElementsInformationFromWindowNameCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //using (var winElem = new InnerScriptVariable(engine)) + //{ + // var winSearch = new UIAutomationGetWindowUIElementCommand() + // { + // v_WindowName = this.v_WindowName, + // v_CheckMethod = this.v_CheckMethod, + // v_SelectionMethod = this.v_SelectionMethod, + // v_TargetWindowIndex = this.v_TargetWindowIndex, + // v_WaitTimeForWindow = this.v_WaitTimeForWindow, + // v_Result = winElem.VariableName, + // v_WindowNameResult = this.v_WindowNameResult, + // v_WindowHandleResult = this.v_WindowHandleResult, + // v_CaseSensitive = this.v_CaseSensitive, + // v_TrimBeforeCheck = this.v_TrimBeforeCheck, + // }; + // winSearch.RunCommand(engine); + + // var searchInfo = new UIAutomationSearchUIElementsInformationFromUIElementCommand() + // { + // v_TargetElement = winElem.VariableName, + // v_SearchParameters = this.v_SearchParameters, + // v_Result = this.v_Result, + // v_MaxSiblings =this.v_MaxSiblings, + // v_MaxDepth = this.v_MaxDepth, + // v_MaxNumberUIElements = this.v_MaxNumberUIElements, + // v_SiblingsDirection = this.v_SiblingsDirection, + // v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + // }; + // searchInfo.RunCommand(engine); + + // this.StoreWindowUIElementInUserVariable((AutomationElement)winElem.VariableValue, engine); + //} + + this.SearchWindowAfterAction(engine, + new Func(winElem => + { + return new UIAutomationSearchUIElementsInformationFromUIElementCommand() + { + v_TargetElement = winElem.VariableName, + v_SearchParameters = this.v_SearchParameters, + v_Result = this.v_Result, + v_MaxSiblings = this.v_MaxSiblings, + v_MaxDepth = this.v_MaxDepth, + v_MaxNumberUIElements = this.v_MaxNumberUIElements, + v_SiblingsDirection = this.v_SiblingsDirection, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + }; + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsTreeXMLFromUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsTreeXMLFromUIElementCommand.cs new file mode 100644 index 000000000..def07e5eb --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsTreeXMLFromUIElementCommand.cs @@ -0,0 +1,85 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement By XPath")] + [Attributes.ClassAttributes.CommandSettings("Search UIElements Tree XML From UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to Search UIElements Tree XML from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Search UIElements Tree XML from UIElement. XML content is based on WinAppDriver UI Recorder.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementsTreeXMLFromUIElementCommand : ADoSomethingUIElementCommands, IGetUIElementsXMLTreeFromSomethingProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to store XML")] + [PropertyDetailSampleUsage("**vXML**", PropertyDetailSampleUsage.ValueType.VariableName)] + [PropertyDetailSampleUsage("**{{{vXML}}}**", PropertyDetailSampleUsage.ValueType.VariableName)] + [Remarks("XML content is based on WinAppDriver UI Recorder.")] + [PropertyParameterOrder(6000)] + public string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeForUIElement))] + [PropertyParameterOrder(7990)] + public string v_WaitTimeForUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxSiblings))] + [PropertyParameterOrder(7991)] + public string v_MaxSiblings { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxDepth))] + [PropertyParameterOrder(7992)] + public string v_MaxDepth { get; set; } + + public UIAutomationSearchUIElementsTreeXMLFromUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var maxTime = this.ExpandValueOrUserVariableAsWaitTimeForUIElement(engine); + //var finishTime = (maxTime > 0) ? DateTime.Now.AddSeconds(maxTime) : DateTime.Now; + //Func timeFunc = (maxTime <= 0) ? + // new Func(() => false) : + // new Func(() => + // { + // return (DateTime.Now >= finishTime); + // }); + + //var targetElement = this.ExpandUserVariableAsUIElement(engine); + //var cmd = new UIAutomationSearchUIElementFromUIElementByXPathCommand() + //{ + // v_MaxDepth = this.v_MaxDepth, + // v_MaxSiblings = this.v_MaxSiblings, + // v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + // v_WindowNameResult = this.v_WindowNameResult, + // v_WindowHandleResult = this.v_WindowHandleResult, + //}; + //(var xml, _) = cmd.DeepCreateUIElementXMLCore(targetElement, timeFunc, engine); + + //using(var sw = new System.IO.StringWriter()) + //{ + // xml.Save(sw); + // sw.ToString().StoreInUserVariable(engine, v_Result); + //} + + //cmd.StoreWindowNameAndWindowHandleInUserVariablesFromUIElement(targetElement, engine); + + var targetElement = this.ExpandUserVariableAsUIElement(engine); + this.StoreUIElementsTreeXMLInUserVariableFromUIElement(targetElement, engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsTreeXMLFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsTreeXMLFromWindowHandleCommand.cs new file mode 100644 index 000000000..a49953860 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsTreeXMLFromWindowHandleCommand.cs @@ -0,0 +1,70 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement From Window")] + [Attributes.ClassAttributes.CommandSettings("Search UIElements Tree XML From Window Handle")] + [Attributes.ClassAttributes.Description("This command allows you to Search UIElements Tree XML from Window Handle.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Search UIElements Tree XML from Window Handle. XML content is based on WinAppDriver UI Recorder.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementsTreeXMLFromWindowHandleCommand : AWindowHandleCommands, IGetUIElementsXMLTreeFromSomethingProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to store XML")] + [PropertyDetailSampleUsage("**vXML**", PropertyDetailSampleUsage.ValueType.VariableName)] + [PropertyDetailSampleUsage("**{{{vXML}}}**", PropertyDetailSampleUsage.ValueType.VariableName)] + [Remarks("XML content is based on WinAppDriver UI Recorder.")] + [PropertyParameterOrder(6000)] + public string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeForUIElement))] + [PropertyParameterOrder(7990)] + public string v_WaitTimeForUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxSiblings))] + [PropertyParameterOrder(7991)] + public string v_MaxSiblings { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxDepth))] + [PropertyParameterOrder(7992)] + public string v_MaxDepth { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + [PropertyParameterOrder(8200)] + public string v_WindowHandleResult { get; set; } + + public UIAutomationSearchUIElementsTreeXMLFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using (var winElem = new InnerScriptVariable(engine)) + { + var getWin = new UIAutomationGetWindowUIElementFromWindowHandleCommand() + { + v_WindowHandle = this.v_WindowHandle, + v_Result = winElem.VariableName, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + }; + getWin.RunCommand(engine); + + this.StoreUIElementsTreeXMLInUserVariableFromUIElement((AutomationElement)winElem.VariableValue, engine); + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsTreeXMLFromWindowNameCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsTreeXMLFromWindowNameCommand.cs new file mode 100644 index 000000000..e1b683424 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSearchUIElementsTreeXMLFromWindowNameCommand.cs @@ -0,0 +1,70 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement From Window")] + [Attributes.ClassAttributes.CommandSettings("Search UIElements Tree XML From Window Name")] + [Attributes.ClassAttributes.Description("This command allows you to Search UIElements Tree XML from Window Name.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Search UIElements Tree XML from Window Name. XML content is based on WinAppDriver UI Recorder.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSearchUIElementsTreeXMLFromWindowNameCommand : AOneWindowNameCommands, IGetUIElementsXMLTreeFromSomethingProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to store XML")] + [PropertyDetailSampleUsage("**vXML**", PropertyDetailSampleUsage.ValueType.VariableName)] + [PropertyDetailSampleUsage("**{{{vXML}}}**", PropertyDetailSampleUsage.ValueType.VariableName)] + [Remarks("XML content is based on WinAppDriver UI Recorder.")] + [PropertyParameterOrder(6500)] + public string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeForUIElement))] + [PropertyParameterOrder(7990)] + public string v_WaitTimeForUIElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxSiblings))] + [PropertyParameterOrder(7991)] + public string v_MaxSiblings { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_MaxDepth))] + [PropertyParameterOrder(7992)] + public string v_MaxDepth { get; set; } + + public UIAutomationSearchUIElementsTreeXMLFromWindowNameCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using (var winElem = new InnerScriptVariable(engine)) + { + var getWin = new UIAutomationGetWindowUIElementFromWindowNameCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_SelectionMethod = this.v_SelectionMethod, + v_Result = winElem.VariableName, + v_TargetWindowIndex =this.v_TargetWindowIndex, + v_CaseSensitive = this.v_CaseSensitive, + v_TrimBeforeCheck = this.v_TrimBeforeCheck, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + }; + getWin.RunCommand(engine); + + this.StoreUIElementsTreeXMLInUserVariableFromUIElement((AutomationElement)winElem.VariableValue, engine); + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSelectItemInUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSelectItemInUIElementCommand.cs new file mode 100644 index 000000000..c8b027d30 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSelectItemInUIElementCommand.cs @@ -0,0 +1,117 @@ +using System; +using System.Xml.Serialization; +using System.Windows.Automation; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using System.Collections.Generic; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("UIElement Action")] + [Attributes.ClassAttributes.CommandSettings("Select Item In UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to Select a Item in UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Select a Item in UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSelectItemInUIElementCommand : AUIElementActionCommands, IUIElementSelectionItemsProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Item Value to Select")] + [InputSpecification("Item Value", true)] + [PropertyDetailSampleUsage("**Yes**", PropertyDetailSampleUsage.ValueType.Value)] + [PropertyDetailSampleUsage("**Hello**", PropertyDetailSampleUsage.ValueType.Value)] + [PropertyDetailSampleUsage("**{{{vItem}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value)] + [PropertyDisplayText(true, "Item")] + [PropertyParameterOrder(6000)] + public string v_Item { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Item Value Type")] + [PropertyUISelectionOption("Text Value")] + [PropertyUISelectionOption("Index")] + [PropertyIsOptional(true, "Text Value")] + [PropertyValidationRule("Value Type", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Value Type")] + [PropertyParameterOrder(6100)] + public string v_ItemValueType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_ExpandWhenItemsNotFound))] + [PropertyParameterOrder(7000)] + public string v_ExpandWhenItemsNotFound { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_WaitTimeAfterExpand))] + [PropertyParameterOrder(7100)] + public string v_WaitTimeAfterExpand { get; set; } + + public UIAutomationSelectItemInUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.SelectionItemsAction(engine, + new Action>((items) => + { + bool isSelected = false; + + AutomationElement targetItem = null; + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ItemValueType), engine)) + { + case "text value": + var itemName = v_Item.ExpandValueOrUserVariable(engine); + foreach (var item in items) + { + if (item.Current.Name == itemName) + { + targetItem = item; + break; + } + } + break; + case "index": + var itemIndex = this.ExpandValueOrUserVariableAsInteger(nameof(v_Item), engine); + if (itemIndex < 0) + { + itemIndex += items.Count; + } + if (itemIndex >= 0 && itemIndex < items.Count) + { + targetItem = items[itemIndex]; + } + break; + } + + if (targetItem != null) + { + if (targetItem.TryGetCurrentPattern(SelectionItemPattern.Pattern, out object siPtn)) + { + ((SelectionItemPattern)siPtn).Select(); + isSelected = true; + } + } + + if (!isSelected) + { + this.ActionNotSupportedProcess("Select Item", engine); + } + }), + new Action(() => + { + this.ActionNotSupportedProcess("Select Item", engine); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSelectUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSelectUIElementCommand.cs new file mode 100644 index 000000000..647305313 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSelectUIElementCommand.cs @@ -0,0 +1,78 @@ +using System; +using System.Windows.Automation; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("UIElement Action")] + [Attributes.ClassAttributes.CommandSettings("Select UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to Select UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Select UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSelectUIElementCommand : AUIElementActionCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + public UIAutomationSelectUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + + //if (targetElement.TryGetCurrentPattern(TogglePattern.Pattern, out object checkPtn)) + //{ + // TogglePattern ptn = (TogglePattern)checkPtn; + // switch (ptn.Current.ToggleState) + // { + // case ToggleState.Off: + // case ToggleState.Indeterminate: + // do + // { + // ptn.Toggle(); + // } while (ptn.Current.ToggleState != ToggleState.On); + // break; + // } + //} + //else if (targetElement.TryGetCurrentPattern(SelectionItemPattern.Pattern, out checkPtn)) + //{ + // ((SelectionItemPattern)checkPtn).Select(); + //} + + this.UIElementActionAndWait(engine, + new Action((targetElement, whnd) => + { + if (targetElement.TryGetCurrentPattern(TogglePattern.Pattern, out object checkPtn)) + { + TogglePattern ptn = (TogglePattern)checkPtn; + switch (ptn.Current.ToggleState) + { + case ToggleState.Off: + case ToggleState.Indeterminate: + do + { + ptn.Toggle(); + } while (ptn.Current.ToggleState != ToggleState.On); + break; + } + } + else if (targetElement.TryGetCurrentPattern(SelectionItemPattern.Pattern, out checkPtn)) + { + ((SelectionItemPattern)checkPtn).Select(); + } + else + { + this.ActionNotSupportedProcess("Select", engine); + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSetSelectedStateToUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSetSelectedStateToUIElementCommand.cs new file mode 100644 index 000000000..6de8e1553 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSetSelectedStateToUIElementCommand.cs @@ -0,0 +1,81 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("UIElement Action")] + [Attributes.ClassAttributes.CommandSettings("Set Selected State To UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to set Selected State from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to set Selected State from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSetSelectedStateToUIElementCommand : AUIElementActionCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Selected State")] + [PropertyUISelectionOption("Selected")] + [PropertyUISelectionOption("Unselected")] + [PropertyDisplayText(true, "State")] + [PropertyParameterOrder(6000)] + public string v_State { get; set; } + + public UIAutomationSetSelectedStateToUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementActionAndWait(engine, + new Action((targetElement, whnd) => + { + bool newState = false; + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_State), engine)) + { + case "selected": + newState = true; + break; + } + + using(var state = new InnerScriptVariable(engine)) + { + var getSelect = new UIAutomationGetSelectedStateFromUIElementCommand() + { + v_TargetElement = this.v_TargetElement, + v_Result = state.VariableName, + }; + getSelect.RunCommand(engine); + if (bool.Parse(state.VariableValue.ToString()) != newState) + { + if (targetElement.TryGetCurrentPattern(TogglePattern.Pattern, out object tgl)) + { + var tglPtn = (TogglePattern)tgl; + tglPtn.Toggle(); + } + else if (targetElement.TryGetCurrentPattern(SelectionItemPattern.Pattern, out object sel)) + { + var selPtn = (SelectionItemPattern)sel; + selPtn.Select(); + } + else + { + this.ActionNotSupportedProcess("Set Selected State", engine); + } + } + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSetTextToUIElementCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSetTextToUIElementCommand.cs new file mode 100644 index 000000000..47a210bc6 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationSetTextToUIElementCommand.cs @@ -0,0 +1,116 @@ +using System; +using System.Windows.Automation; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("UIElement Action")] + [Attributes.ClassAttributes.CommandSettings("Set Text To UIElement")] + [Attributes.ClassAttributes.Description("This command allows you to set Text Value from UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to set Text Value from UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationSetTextToUIElementCommand : AUIElementActionCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_OneLineTextBox))] + [PropertyDescription("Text to Set")] + [InputSpecification("Text", true)] + [PropertyDetailSampleUsage("**Hello**", PropertyDetailSampleUsage.ValueType.Value)] + [PropertyDetailSampleUsage("**{{{vText}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyDisplayText(true, "Text")] + [PropertyParameterOrder(6000)] + public string v_TextToSet { get; set; } + + public UIAutomationSetTextToUIElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_TargetElement.ExpandUserVariableAsUIElement(engine); + + //var ct = targetElement.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty) as ControlType; + //if (ct == ControlType.Spinner) + //{ + // targetElement = UIElementControls.SearchGUIElementByXPath(targetElement, "/Edit[1]", 10, engine); + // targetElement = targetElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit)); + //} + + //string textValue = v_TextVariable.ExpandValueOrUserVariable(engine); + + //if (targetElement.TryGetCurrentPattern(ValuePattern.Pattern, out object valPtn)) + //{ + // ((ValuePattern)valPtn).SetValue(textValue); + //} + //else if (targetElement.TryGetCurrentPattern(TextPattern.Pattern, out _)) + //{ + // targetElement.SetFocus(); + // System.Threading.Thread.Sleep(100); + // SendKeys.SendWait("^{HOME}"); + // SendKeys.SendWait("^+{END}"); + // SendKeys.SendWait("{DEL}"); + // SendKeys.SendWait(textValue); + //} + //else + //{ + // throw new Exception("UIElement '" + v_TargetElement + "' can not set Text"); + //} + + this.UIElementActionAndWait(engine, + new Action((targetElement, whnd) => + { + var ct = targetElement.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty) as ControlType; + if (ct == ControlType.Spinner) + { + targetElement = targetElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit)); + } + + string textValue = v_TextToSet.ExpandValueOrUserVariable(engine); + + if (targetElement.TryGetCurrentPattern(ValuePattern.Pattern, out object valPtn)) + { + ((ValuePattern)valPtn).SetValue(textValue); + } + else if (targetElement.TryGetCurrentPattern(TextPattern.Pattern, out _)) + { + targetElement.SetFocus(); + System.Threading.Thread.Sleep(100); + //SendKeys.SendWait("^{HOME}"); + //SendKeys.SendWait("^+{END}"); + //SendKeys.SendWait("{DEL}"); + //SendKeys.SendWait(textValue); + + var sendKey = new EnterKeysFromWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_TextToSend = "^{HOME}", + v_WaitTimeAfterKeyEnter = "0", + }; + sendKey.RunCommand(engine); + sendKey.v_TextToSend = "^+{END}"; + sendKey.RunCommand(engine); + sendKey.v_TextToSend = "{DEL}"; + sendKey.RunCommand(engine); + sendKey.v_TextToSend = textValue; + sendKey.RunCommand(engine); + } + else + { + //throw new Exception("UIElement '" + v_TargetElement + "' can not set Text"); + this.ActionNotSupportedProcess("Set Text", engine); + } + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowHandleCommand.cs new file mode 100644 index 000000000..5730d4755 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowHandleCommand.cs @@ -0,0 +1,72 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search And Action")] + [Attributes.ClassAttributes.CommandSettings("UIElement Action After Search UIElement By XPath From Window Handle")] + [Attributes.ClassAttributes.Description("This command searches for the UIElement in the specified Window Handle and then takes action on that UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("This command is used when you want to Search an UIElement by its Window Handle and perform an action on that UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowHandleCommand : AUIElementActionFromWindowSomethingByXPathCommands, IWindowHandleProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWindowHandle))] + [PropertyParameterOrder(5000)] + public string v_WindowHandle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + [PropertyParameterOrder(6000)] + public string v_WaitTimeForWindow { get; set; } + + public UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementActionProcess(engine, + new Action(v => + { + var winElem = new UIAutomationGetWindowUIElementFromWindowHandleCommand() + { + v_WindowHandle = this.v_WindowHandle, + v_Result = v.VariableName, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + }; + winElem.RunCommand(engine); + }), + new Action((v, r) => + { + var chkElem = new UIAutomationCheckUIElementExistsByXPathCommand() + { + v_TargetElement = v.VariableName, + v_SearchXPath = this.v_SearchXPath, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_Result = r, + }; + chkElem.RunCommand(engine); + }), + new Action((v, r) => + { + var trgElem = new UIAutomationSearchUIElementFromUIElementByXPathCommand() + { + v_TargetElement = v.VariableName, + v_SearchXPath = this.v_SearchXPath, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_Result = r.VariableName, + }; + trgElem.RunCommand(engine); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowNameCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowNameCommand.cs new file mode 100644 index 000000000..8071f8a82 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowNameCommand.cs @@ -0,0 +1,525 @@ +using System; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; +using taskt.UI.CustomControls; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search And Action")] + [Attributes.ClassAttributes.CommandSettings("UIElement Action After Search UIElement By XPath From Window Name")] + [Attributes.ClassAttributes.Description("This command searches for the UIElement in the specified Window Name and then takes action on that UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("This command is used when you want to Search an UIElement by its Window Name and perform an action on that UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowNameCommand : AUIElementActionFromWindowSomethingByXPathCommands, IOneWindowNameProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + //public string v_WindowName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyParameterOrder(5500)] + //[PropertyDescription("UIElement Action")] + //[PropertyUISelectionOption("Click UIElement")] + //[PropertyUISelectionOption("Expand Collapse Items In UIElement")] + //[PropertyUISelectionOption("Scroll UIElement")] + //[PropertyUISelectionOption("Select UIElement")] + //[PropertyUISelectionOption("Select Item In UIElement")] + //[PropertyUISelectionOption("Set Text To UIElement")] + //[PropertyUISelectionOption("Get Property Value From UIElement")] + //[PropertyUISelectionOption("Check UIElement Exists")] + //[PropertyUISelectionOption("Get Text From UIElement")] + //[PropertyUISelectionOption("Get Selected State From UIElement")] + //[PropertyUISelectionOption("Get Text From Table UIElement")] + //[PropertyUISelectionOption("Get UIElement Position")] + //[PropertyUISelectionOption("Get UIElement Size")] + //[PropertyUISelectionOption("Wait For UIElement To Exists")] + //[PropertySelectionChangeEvent(nameof(cmbActionType_SelectedItemChange))] + //[PropertyDisplayText(true, "Action")] + //public string v_AutomationType { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] + //public string v_SearchXPath { get; set; } + + //[XmlElement] + //[PropertyDescription("Action Parameters")] + //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + //[PropertyDataGridViewSetting(false, false, true, 400, 250)] + //[PropertyDataGridViewColumnSettings("Parameter Name", "Parameter Name", true)] + //[PropertyDataGridViewColumnSettings("Parameter Value", "Parameter Value", false)] + //[PropertyParameterOrder(6500)] + //public DataTable v_UIAActionParameters { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CheckMethod))] + //public string v_CheckMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_SelectionMethod_Single))] + //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + //public string v_SelectionMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + //public string v_TargetWindowIndex { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + //public string v_WaitTimeForWindow { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //public string v_WaitTimeForUIElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + //public string v_WindowNameResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_WindowHandleResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + [PropertyParameterOrder(5000)] + public string v_WindowName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CheckMethod))] + [PropertyParameterOrder(8100)] + public string v_CheckMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_SelectionMethod_Single))] + [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + [PropertyParameterOrder(8200)] + public string v_SelectionMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + [PropertyParameterOrder(8300)] + public string v_TargetWindowIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + [PropertyParameterOrder(8300)] + public string v_WaitTimeForWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CaseSensitive))] + [PropertyParameterOrder(11000)] + public string v_CaseSensitive { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TrimBeforeCheck))] + [PropertyParameterOrder(11100)] + public string v_TrimBeforeCheck { get; set; } + + public UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowNameCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementActionProcess(engine, + new Action(v => + { + var winElem = new UIAutomationGetWindowUIElementFromWindowNameCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_SelectionMethod = this.v_SelectionMethod, + v_TargetWindowIndex = this.v_TargetWindowIndex, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = v.VariableName, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + v_CaseSensitive = this.v_CaseSensitive, + v_TrimBeforeCheck = this.v_TrimBeforeCheck, + }; + winElem.RunCommand(engine); + }), + new Action((v, r) => + { + var chkElem = new UIAutomationCheckUIElementExistsByXPathCommand() + { + v_TargetElement = v.VariableName, + v_SearchXPath = this.v_SearchXPath, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_Result = r, + }; + chkElem.RunCommand(engine); + }), + new Action((v, r) => + { + var trgElem = new UIAutomationSearchUIElementFromUIElementByXPathCommand() + { + v_TargetElement = v.VariableName, + v_SearchXPath = this.v_SearchXPath, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_Result = r.VariableName, + }; + trgElem.RunCommand(engine); + }) + ); + + //var elemAction = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_AutomationType), engine); + + //using(var myWinElem = new InnerScriptVariable(engine)) + //{ + // var winElem = new UIAutomationGetWindowUIElementCommand() + // { + // v_WindowName = this.v_WindowName, + // v_CheckMethod = this.v_CheckMethod, + // v_SelectionMethod = this.v_SelectionMethod, + // v_TargetWindowIndex = this.v_TargetWindowIndex, + // v_WaitTimeForWindow = this.v_WaitTimeForWindow, + // v_Result = myWinElem.VariableName, + // v_WindowNameResult = this.v_WindowNameResult, + // v_WindowHandleResult = this.v_WindowHandleResult, + // v_CaseSensitive = this.v_CaseSensitive, + // v_TrimBeforeCheck = this.v_TrimBeforeCheck, + // }; + // winElem.RunCommand(engine); + + // var p = DataTableControls.GetFieldValues(v_UIAActionParameters, "Parameter Name", "Parameter Value", false, engine); + + // using (var myTrgElem = new InnerScriptVariable(engine)) + // { + // switch (elemAction) + // { + // case "check uielement exists": + // var chkElem = new UIAutomationCheckUIElementExistsByXPathCommand() + // { + // v_TargetElement = myWinElem.VariableName, + // v_SearchXPath = this.v_SearchXPath, + // v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + // v_Result = p["Apply To Variable"], + // }; + // chkElem.RunCommand(engine); + // return; + + // default: + // var trgElem = new UIAutomationSearchUIElementFromUIElementByXPathCommand() + // { + // v_TargetElement = myWinElem.VariableName, + // v_SearchXPath = this.v_SearchXPath, + // v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + // v_Result = myTrgElem.VariableName, + // }; + // trgElem.RunCommand(engine); + // break; + // } + + // switch (elemAction) + // { + // case "click uielement": + // var clickCmd = new UIAutomationClickUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_ClickType = p["Click Type"], + // v_XOffset = p["X Offset"], + // v_YOffset = p["Y Offset"], + // }; + // clickCmd.RunCommand(engine); + // break; + // case "expand collapse items in uielement": + // var expandCmd = new UIAutomationExpandCollapseItemsInUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_ItemsState = p["Items State"], + // }; + // expandCmd.RunCommand(engine); + // break; + // case "scroll uielement": + // var scrollCmd = new UIAutomationScrollUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_ScrollBarType = p["ScrollBar Type"], + // v_DirectionAndAmount = p["Scroll Method"], + // }; + // scrollCmd.RunCommand(engine); + // break; + // case "select uielement": + // var selectCmd = new UIAutomationSelectUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // }; + // selectCmd.RunCommand(engine); + // break; + // case "select item in uielement": + // var selectItemCmd = new UIAutomationSelectItemInUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Item = p["Item Value"], + // }; + // selectItemCmd.RunCommand(engine); + // break; + // case "set text to uielement": + // var setTextCmd = new UIAutomationSetTextToUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_TextToSet = p["Text To Set"], + // }; + // setTextCmd.RunCommand(engine); + // break; + // case "get property value from uielement": + // var propValueCmd = new UIAutomationGetPropertyValueFromUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_PropertyName = p["Property Name"], + // v_Result = p["Apply To Variable"], + // }; + // propValueCmd.RunCommand(engine); + // break; + // case "check uielement exists": + // true.StoreInUserVariable(engine, p["Apply To Variable"]); + // break; + // case "get text from uielement": + // var getTextCmd = new UIAutomationGetTextFromUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Result = p["Apply To Variable"], + // }; + // getTextCmd.RunCommand(engine); + // break; + // case "get selected state from uielement": + // var getSelectedCmd = new UIAutomationGetSelectedStateFromUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Result = p["Apply To Variable"], + // }; + // getSelectedCmd.RunCommand(engine); + // break; + // case "get text from table uielement": + // var getTableCmd = new UIAutomationGetTextFromTableUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Row = p["Row"], + // v_Column = p["Column"], + // v_Result = p["Apply To Variable"], + // }; + // getTableCmd.RunCommand(engine); + // break; + // case "get uielement position": + // var getElemPosCmd = new UIAutomationGetUIElementPositionCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_XPosition = p["X Variable"], + // v_YPosition = p["Y Variable"], + // v_PositionBase = p["Base Position"], + // }; + // getElemPosCmd.RunCommand(engine); + // break; + // case "get uielement size": + // var getElemSizeCmd = new UIAutomationGetUIElementSizeCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Width = p["Width Variable"], + // v_Height = p["Height Variable"], + // }; + // getElemSizeCmd.RunCommand(engine); + // break; + // } + // } + //} + } + + private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + { + WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + } + + public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); + } + + //public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + //{ + // var cmb = FormUIControls.GetPropertyControl(ControlsList, nameof(v_AutomationType)); + // var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); + // actionParameterProcess(dgv, cmb.SelectedItem?.ToString() ?? ""); + //} + + //private void cmbActionType_SelectedItemChange(object sender, EventArgs e) + //{ + // var a = ((ComboBox)sender).SelectedItem?.ToString() ?? ""; + + // var dgv = FormUIControls.GetPropertyControl(this.ControlsList, nameof(v_UIAActionParameters)); + // var table = v_UIAActionParameters; + // table.Rows.Clear(); + // switch (a.ToLower()) + // { + // case "click uielement": + // table.Rows.Add(new string[] { "Click Type", "" }); + // table.Rows.Add(new string[] { "X Offset", "" }); + // table.Rows.Add(new string[] { "Y Offset", "" }); + // break; + + // case "expand collapse items in uielement": + // table.Rows.Add(new string[] { "Items State", "" }); + // break; + + // case "scroll uielement": + // table.Rows.Add(new string[] { "ScrollBar Type", "" }); + // table.Rows.Add(new string[] { "Scroll Method", "" }); + // break; + + // case "select item in uielement": + // table.Rows.Add(new string[] { "Item Value", "" }); + // break; + + // case "set text to uielement": + // table.Rows.Add(new string[] { "Text To Set", "" }); + // break; + + // case "get property value from uielement": + // table.Rows.Add(new string[] { "Property Name", "" }); + // table.Rows.Add(new string[] { "Apply To Variable", "" }); + // break; + + // case "get text from table uielement": + // table.Rows.Add(new string[] { "Row", "" }); + // table.Rows.Add(new string[] { "Column", "" }); + // table.Rows.Add(new string[] { "Apply To Variable", "" }); + // break; + + // case "get uielement position": + // table.Rows.Add(new string[] { "X Variable", "" }); + // table.Rows.Add(new string[] { "Y Variable", "" }); + // table.Rows.Add(new string[] { "Base Position", "" }); + // break; + + // case "get uielement size": + // table.Rows.Add(new string[] { "Width Variable", "" }); + // table.Rows.Add(new string[] { "Height Variable", "" }); + // break; + + // case "check uielement exists": + // case "get text from uielement": + // case "get selected state from uielement": + // table.Rows.Add(new string[] { "Apply To Variable", "" }); + // break; + + // case "select uielement": + // case "wait for uielement to exists": + // // nothing + // break; + // } + + // actionParameterProcess(dgv, a); + //} + + //private static void actionParameterProcess(DataGridView dgv, string actionType) + //{ + // switch (actionType.ToLower()) + // { + // case "click uielement": + // var clickType = new DataGridViewComboBoxCell(); + // clickType.Items.AddRange(new string[] + // { + // "Left Click", + // "Middle Click", + // "Right Click", + // "Left Down", + // "Middle Down", + // "Right Down", + // "Left Up", + // "Middle Up", + // "Right Up", + // "Double Left Click", + // "None", + // }); + // dgv.Rows[0].Cells[1] = clickType; + // break; + // case "expand collapse items in uielement": + // var itemState = new DataGridViewComboBoxCell(); + // itemState.Items.AddRange(new string[] + // { + // "Expand", + // "Collapse" + // }); + // dgv.Rows[0].Cells[1] = itemState; + // break; + // case "scroll uielement": + // var barType = new DataGridViewComboBoxCell(); + // barType.Items.AddRange(new string[] + // { + // "Vertical", + // "Horizonal", + // }); + // var scrollMethod = new DataGridViewComboBoxCell(); + // scrollMethod.Items.AddRange(new string[] + // { + // "Scroll Small Down or Right", + // "Scroll Large Down or Right", + // "Scroll Small Up or Left", + // "Scroll Large Up or Left", + // }); + // dgv.Rows[0].Cells[1] = barType; + // dgv.Rows[1].Cells[1] = scrollMethod; + // break; + // case "get property value from uielement": + // var propNames = new DataGridViewComboBoxCell(); + // propNames.Items.AddRange(new string[] + // { + // "Name", + // "ControlType", + // "LocalizedControlType", + // "IsEnabled", + // "IsOffscreen", + // "IsKeyboardFocusable", + // "HasKeyboardFocusable", + // "AccessKey", + // "ProcessId", + // "AutomationId", + // "FrameworkId", + // "ClassName", + // "IsContentElement", + // "IsPassword", + // "AcceleratorKey", + // "HelpText", + // "IsControlElement", + // "IsRequiredForForm", + // "ItemStatus", + // "ItemType", + // "NativeWindowHandle", + // }); + // dgv.Rows[0].Cells[1] = propNames; + // break; + // case "get uielement position": + // var positionName = new DataGridViewComboBoxCell(); + // positionName.Items.AddRange(new string[] + // { + // "Top Left", + // "Bottom Right", + // "Top Right", + // "Bottom Left", + // "Center", + // }); + // dgv.Rows[2].Cells[1] = positionName; + // break; + // } + //} + + //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + //} + + //public override void BeforeValidate() + //{ + // var dgvAction = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); + // DataTableControls.BeforeValidate(dgvAction, v_UIAActionParameters); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementFromWindowHandleCommand.cs new file mode 100644 index 000000000..9c4145698 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementFromWindowHandleCommand.cs @@ -0,0 +1,86 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search And Action")] + [Attributes.ClassAttributes.CommandSettings("UIElement Action After Search UIElement From Window Handle")] + [Attributes.ClassAttributes.Description("This command searches for the UIElement in the specified Window Handle and then takes action on that UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("This command is used when you want to Search an UIElement by its Window Handle and perform an action on that UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationUIElementActionAfterSearchUIElementFromWindowHandleCommand : AUIElementActionFromWindowSomethingByTreeWalkerCommands, IWindowHandleProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWindowHandle))] + [PropertyParameterOrder(5000)] + public string v_WindowHandle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + [PropertyParameterOrder(6000)] + public string v_WaitTimeForWindow { get; set; } + + public UIAutomationUIElementActionAfterSearchUIElementFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementActionProcess(engine, + new Action(v => + { + var winElem = new UIAutomationGetWindowUIElementFromWindowHandleCommand() + { + v_WindowHandle = this.v_WindowHandle, + v_Result = v.VariableName, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + }; + winElem.RunCommand(engine); + }), + new Action((v, r) => + { + var chkElem = new UIAutomationCheckUIElementExistsCommand() + { + v_TargetElement = v.VariableName, + v_SearchParameters = this.v_SearchParameters, + v_TargetUIElementIndex = this.v_TargetUIElementIndex, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_Result = r, + v_MaxSiblings = this.v_MaxSiblings, + v_SiblingsDirection = this.v_SiblingsDirection, + v_MaxDepth = this.v_MaxDepth, + v_MaxNumberUIElements = this.v_MaxNumberUIElements, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + }; + chkElem.RunCommand(engine); + }), + new Action((v, r) => + { + var trgElem = new UIAutomationSearchUIElementFromUIElementCommand() + { + v_TargetElement = v.VariableName, + v_SearchParameters = this.v_SearchParameters, + v_TargetUIElementIndex = this.v_TargetUIElementIndex, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_Result = r.VariableName, + v_MaxSiblings = this.v_MaxSiblings, + v_SiblingsDirection = this.v_SiblingsDirection, + v_MaxDepth = this.v_MaxDepth, + v_MaxNumberUIElements = this.v_MaxNumberUIElements, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + }; + trgElem.RunCommand(engine); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementFromWindowNameCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementFromWindowNameCommand.cs new file mode 100644 index 000000000..45e983636 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationUIElementActionAfterSearchUIElementFromWindowNameCommand.cs @@ -0,0 +1,760 @@ +using System; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.UIAutomationGroup; +using taskt.Core.Script; +using taskt.UI.CustomControls; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search And Action")] + [Attributes.ClassAttributes.CommandSettings("UIElement Action After Search UIElement From Window Name")] + [Attributes.ClassAttributes.Description("This command searches for the UIElement in the specified Window Name and then takes action on that UIElement.")] + [Attributes.ClassAttributes.ImplementationDescription("This command is used when you want to Search an UIElement by its Window Name and perform an action on that UIElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationUIElementActionAfterSearchUIElementFromWindowNameCommand : AUIElementActionFromWindowSomethingByTreeWalkerCommands, IOneWindowNameProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + //public string v_WindowName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("UIElement Action")] + //[PropertyUISelectionOption("Click UIElement")] + //[PropertyUISelectionOption("Expand Collapse Items In UIElement")] + //[PropertyUISelectionOption("Scroll UIElement")] + //[PropertyUISelectionOption("Select UIElement")] + //[PropertyUISelectionOption("Select Item In UIElement")] + //[PropertyUISelectionOption("Set Text To UIElement")] + //[PropertyUISelectionOption("Get Property Value From UIElement")] + //[PropertyUISelectionOption("Check UIElement Exists")] + //[PropertyUISelectionOption("Get Text From UIElement")] + //[PropertyUISelectionOption("Get Selected State From UIElement")] + //[PropertyUISelectionOption("Get Text From Table UIElement")] + //[PropertyUISelectionOption("Get UIElement Position")] + //[PropertyUISelectionOption("Get UIElement Size")] + //[PropertyUISelectionOption("Wait For UIElement To Exists")] + //[PropertySelectionChangeEvent(nameof(cmbActionType_SelectedItemChange))] + //[PropertyDisplayText(true, "Action")] + //[PropertyParameterOrder(6200)] + //public string v_AutomationType { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] + //public DataTable v_SearchParameters { get; set; } + + //[XmlElement] + //[PropertyDescription("Action Parameters")] + //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + //[PropertyDataGridViewSetting(false, false, true, 400, 250)] + //[PropertyDataGridViewColumnSettings("Parameter Name", "Parameter Name", true)] + //[PropertyDataGridViewColumnSettings("Parameter Value", "Parameter Value", false)] + //[PropertyParameterOrder(7900)] + //public DataTable v_UIAActionParameters { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CheckMethod))] + //public string v_CheckMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_SelectionMethod_Single))] + //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + //public string v_SelectionMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + //public string v_TargetWindowIndex { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + //public string v_WaitTimeForWindow { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //public string v_WaitTimeForUIElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] + //public string v_WindowNameResult { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_WindowHandleResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] + [PropertyParameterOrder(5000)] + public string v_WindowName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CheckMethod))] + [PropertyParameterOrder(8100)] + public string v_CheckMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_SelectionMethod_Single))] + [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] + [PropertyParameterOrder(8200)] + public string v_SelectionMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] + [PropertyParameterOrder(8300)] + public string v_TargetWindowIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + [PropertyParameterOrder(8300)] + public string v_WaitTimeForWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CaseSensitive))] + [PropertyParameterOrder(11000)] + public string v_CaseSensitive { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TrimBeforeCheck))] + [PropertyParameterOrder(11100)] + public string v_TrimBeforeCheck { get; set; } + + public UIAutomationUIElementActionAfterSearchUIElementFromWindowNameCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.UIElementActionProcess(engine, + new Action(v => + { + var winElem = new UIAutomationGetWindowUIElementFromWindowNameCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_SelectionMethod = this.v_SelectionMethod, + v_TargetWindowIndex = this.v_TargetWindowIndex, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = v.VariableName, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + v_CaseSensitive = this.v_CaseSensitive, + v_TrimBeforeCheck = this.v_TrimBeforeCheck, + }; + winElem.RunCommand(engine); + }), + new Action((v, r) => + { + var chkElem = new UIAutomationCheckUIElementExistsCommand() + { + v_TargetElement = v.VariableName, + v_SearchParameters = this.v_SearchParameters, + v_TargetUIElementIndex = this.v_TargetUIElementIndex, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_Result = r, + v_MaxSiblings = this.v_MaxSiblings, + v_SiblingsDirection = this.v_SiblingsDirection, + v_MaxDepth = this.v_MaxDepth, + v_MaxNumberUIElements = this.v_MaxNumberUIElements, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + }; + chkElem.RunCommand(engine); + }), + new Action((v, r) => + { + var trgElem = new UIAutomationSearchUIElementFromUIElementCommand() + { + v_TargetElement = v.VariableName, + v_SearchParameters = this.v_SearchParameters, + v_TargetUIElementIndex = this.v_TargetUIElementIndex, + v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + v_Result = r.VariableName, + v_MaxSiblings = this.v_MaxSiblings, + v_SiblingsDirection = this.v_SiblingsDirection, + v_MaxDepth = this.v_MaxDepth, + v_MaxNumberUIElements = this.v_MaxNumberUIElements, + v_WindowNameResult = this.v_WindowNameResult, + v_WindowHandleResult = this.v_WindowHandleResult, + }; + trgElem.RunCommand(engine); + }) + ); + + //var elemAction = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_AutomationType), engine); + + //using(var myWinElem = new InnerScriptVariable(engine)) + //{ + // var winElem = new UIAutomationGetWindowUIElementCommand() + // { + // v_WindowName = this.v_WindowName, + // v_CheckMethod = this.v_CheckMethod, + // v_SelectionMethod = this.v_SelectionMethod, + // v_TargetWindowIndex = this.v_TargetWindowIndex, + // v_WaitTimeForWindow = this.v_WaitTimeForWindow, + // v_Result = myWinElem.VariableName, + // v_WindowNameResult = this.v_WindowNameResult, + // v_WindowHandleResult = this.v_WindowHandleResult, + // v_CaseSensitive = this.v_CaseSensitive, + // v_TrimBeforeCheck = this.v_TrimBeforeCheck, + // }; + // winElem.RunCommand(engine); + + // var p = DataTableControls.GetFieldValues(v_UIAActionParameters, "Parameter Name", "Parameter Value", false, engine); + + // using (var myTrgElem = new InnerScriptVariable(engine)) + // { + // switch (elemAction) + // { + // case "check uielement exists": + // var chkElem = new UIAutomationCheckUIElementExistsCommand() + // { + // v_TargetElement = myWinElem.VariableName, + // v_SearchParameters = this.v_SearchParameters, + // v_TargetUIElementIndex = this.v_TargetUIElementIndex, + // v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + // v_Result = p["Apply To Variable"], + // v_MaxSiblings = this.v_MaxSiblings, + // v_SiblingsDirection = this.v_SiblingsDirection, + // v_MaxDepth = this.v_MaxDepth, + // v_MaxNumberUIElements = this.v_MaxNumberUIElements, + // v_WindowNameResult = this.v_WindowNameResult, + // v_WindowHandleResult = this.v_WindowHandleResult, + // }; + // chkElem.RunCommand(engine); + // return; + + // default: + // var trgElem = new UIAutomationSearchUIElementFromUIElementCommand() + // { + // v_TargetElement = myWinElem.VariableName, + // v_SearchParameters = this.v_SearchParameters, + // v_TargetUIElementIndex = this.v_TargetUIElementIndex, + // v_WaitTimeForUIElement = this.v_WaitTimeForUIElement, + // v_Result = myTrgElem.VariableName, + // v_MaxSiblings = this.v_MaxSiblings, + // v_SiblingsDirection = this.v_SiblingsDirection, + // v_MaxDepth = this.v_MaxDepth, + // v_MaxNumberUIElements = this.v_MaxNumberUIElements, + // v_WindowNameResult = this.v_WindowNameResult, + // v_WindowHandleResult = this.v_WindowHandleResult, + // }; + // trgElem.RunCommand(engine); + // break; + // } + + // // todo: use same method + // switch (elemAction) + // { + // case "click uielement": + // var clickCmd = new UIAutomationClickUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_ClickType = p["Click Type"], + // v_XOffset = p["X Offset"], + // v_YOffset = p["Y Offset"], + // }; + // clickCmd.RunCommand(engine); + // break; + // case "expand collapse items in uielement": + // var expandCmd = new UIAutomationExpandCollapseItemsInUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_ItemsState = p["Items State"], + // }; + // expandCmd.RunCommand(engine); + // break; + // case "scroll uielement": + // var scrollCmd = new UIAutomationScrollUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_ScrollBarType = p["ScrollBar Type"], + // v_DirectionAndAmount = p["Scroll Method"], + // }; + // scrollCmd.RunCommand(engine); + // break; + // case "select uielement": + // var selectCmd = new UIAutomationSelectUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // }; + // selectCmd.RunCommand(engine); + // break; + // case "select item in uielement": + // var selectItemCmd = new UIAutomationSelectItemInUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Item = p["Item Value"], + // }; + // selectItemCmd.RunCommand(engine); + // break; + // case "set text to uielement": + // var setTextCmd = new UIAutomationSetTextToUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_TextToSet = p["Text To Set"], + // }; + // setTextCmd.RunCommand(engine); + // break; + // case "get property value from uielement": + // var propValueCmd = new UIAutomationGetPropertyValueFromUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_PropertyName = p["Property Name"], + // v_Result = p["Apply To Variable"], + // }; + // propValueCmd.RunCommand(engine); + // break; + // case "check uielement exists": + // true.StoreInUserVariable(engine, p["Apply To Variable"]); + // break; + // case "get text from uielement": + // var getTextCmd = new UIAutomationGetTextFromUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Result = p["Apply To Variable"], + // }; + // getTextCmd.RunCommand(engine); + // break; + // case "get selected state from uielement": + // var getSelectedCmd = new UIAutomationGetSelectedStateFromUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Result = p["Apply To Variable"], + // }; + // getSelectedCmd.RunCommand(engine); + // break; + // case "get text from table uielement": + // var getTableCmd = new UIAutomationGetTextFromTableUIElementCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Row = p["Row"], + // v_Column = p["Column"], + // v_Result = p["Apply To Variable"], + // }; + // getTableCmd.RunCommand(engine); + // break; + // case "get uielement position": + // var getElemPosCmd = new UIAutomationGetUIElementPositionCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_XPosition = p["X Variable"], + // v_YPosition = p["Y Variable"], + // v_PositionBase = p["Base Position"], + // }; + // getElemPosCmd.RunCommand(engine); + // break; + // case "get uielement size": + // var getElemSizeCmd = new UIAutomationGetUIElementSizeCommand() + // { + // v_TargetElement = myTrgElem.VariableName, + // v_Width = p["Width Variable"], + // v_Height = p["Height Variable"], + // }; + // getElemSizeCmd.RunCommand(engine); + // break; + // } + // } + //} + } + + private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + { + WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + } + + public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); + } + + //public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + //{ + // var cmb = FormUIControls.GetPropertyControl(ControlsList, nameof(v_AutomationType)); + // var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); + // actionParameterProcess(dgv, cmb.SelectedItem?.ToString() ?? ""); + //} + + //private void cmbActionType_SelectedItemChange(object sender, EventArgs e) + //{ + // var a = ((ComboBox)sender).SelectedItem?.ToString() ?? ""; + + // var dgv = FormUIControls.GetPropertyControl(this.ControlsList, nameof(v_UIAActionParameters)); + // var table = v_UIAActionParameters; + // table.Rows.Clear(); + // switch (a.ToLower()) + // { + // case "click uielement": + // table.Rows.Add(new string[] { "Click Type", "" }); + // table.Rows.Add(new string[] { "X Offset", "" }); + // table.Rows.Add(new string[] { "Y Offset", "" }); + // break; + + // case "expand collapse items in uielement": + // table.Rows.Add(new string[] { "Items State", "" }); + // break; + // case "scroll uielement": + // table.Rows.Add(new string[] { "ScrollBar Type", "" }); + // table.Rows.Add(new string[] { "Scroll Method", "" }); + // break; + + // case "select item in uielement": + // table.Rows.Add(new string[] { "Item Value", "" }); + // break; + + // case "set text to uielement": + // table.Rows.Add(new string[] { "Text To Set", "" }); + // break; + + // case "get property value from uielement": + // table.Rows.Add(new string[] { "Property Name", "" }); + // table.Rows.Add(new string[] { "Apply To Variable", "" }); + // break; + + // case "get text from table uielement": + // table.Rows.Add(new string[] { "Row", "" }); + // table.Rows.Add(new string[] { "Column", "" }); + // table.Rows.Add(new string[] { "Apply To Variable", "" }); + // break; + + // case "get uielement position": + // table.Rows.Add(new string[] { "X Variable", "" }); + // table.Rows.Add(new string[] { "Y Variable", "" }); + // table.Rows.Add(new string[] { "Base Position", ""}); + // break; + + // case "get uielement size": + // table.Rows.Add(new string[] { "Width Variable", "" }); + // table.Rows.Add(new string[] { "Height Variable", "" }); + // break; + + // case "check uielement exists": + // case "get text from uielement": + // case "get selected state from uielement": + // table.Rows.Add(new string[] { "Apply To Variable", "" }); + // break; + + // case "select uielement": + // case "wait for uielement to exists": + // // nothing + // break; + // } + + // actionParameterProcess(dgv, a); + //} + + //private static void actionParameterProcess(DataGridView dgv, string actionType) + //{ + // switch (actionType.ToLower()) + // { + // case "click uielement": + // var clickType = new DataGridViewComboBoxCell(); + // clickType.Items.AddRange(new string[] + // { + // "Left Click", + // "Middle Click", + // "Right Click", + // "Left Down", + // "Middle Down", + // "Right Down", + // "Left Up", + // "Middle Up", + // "Right Up", + // "Double Left Click", + // "None", + // }); + // dgv.Rows[0].Cells[1] = clickType; + // break; + // case "expand collapse items in uielement": + // var itemState = new DataGridViewComboBoxCell(); + // itemState.Items.AddRange(new string[] + // { + // "Expand", + // "Collapse" + // }); + // dgv.Rows[0].Cells[1] = itemState; + // break; + // case "scroll uielement": + // var barType = new DataGridViewComboBoxCell(); + // barType.Items.AddRange(new string[] + // { + // "Vertical", + // "Horizonal", + // }); + // var scrollMethod = new DataGridViewComboBoxCell(); + // scrollMethod.Items.AddRange(new string[] + // { + // "Scroll Small Down or Right", + // "Scroll Large Down or Right", + // "Scroll Small Up or Left", + // "Scroll Large Up or Left", + // }); + // dgv.Rows[0].Cells[1] = barType; + // dgv.Rows[1].Cells[1] = scrollMethod; + // break; + // case "get property value from uielement": + // var propNames = new DataGridViewComboBoxCell(); + // propNames.Items.AddRange(new string[] + // { + // "Name", + // "ControlType", + // "LocalizedControlType", + // "IsEnabled", + // "IsOffscreen", + // "IsKeyboardFocusable", + // "HasKeyboardFocusable", + // "AccessKey", + // "ProcessId", + // "AutomationId", + // "FrameworkId", + // "ClassName", + // "IsContentElement", + // "IsPassword", + // "AcceleratorKey", + // "HelpText", + // "IsControlElement", + // "IsRequiredForForm", + // "ItemStatus", + // "ItemType", + // "NativeWindowHandle", + // }); + // dgv.Rows[0].Cells[1] = propNames; + // break; + // case "get uielement position": + // var positionName = new DataGridViewComboBoxCell(); + // positionName.Items.AddRange(new string[] + // { + // "Top Left", + // "Bottom Right", + // "Top Right", + // "Bottom Left", + // "Center", + // }); + // dgv.Rows[2].Cells[1] = positionName; + // break; + // } + //} + + //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // WindowControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); + //} + + //public override void BeforeValidate() + //{ + // var dgvAction = FormUIControls.GetPropertyControl(ControlsList, nameof(v_UIAActionParameters)); + // DataTableControls.BeforeValidate(dgvAction, v_UIAActionParameters); + + // var dgvSearch = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); + // DataTableControls.BeforeValidate(dgvSearch, v_SearchParameters); + //} + + //public override string GetDisplayValue() + //{ + // if (v_AutomationType == "Click Element") + // { + // //create search params + // var clickType = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Click Type" + // select rw.Field("Parameter Value")).FirstOrDefault(); + + + // return base.GetDisplayValue() + " [" + clickType + " element in window '" + v_WindowName + "']"; + // } + // else if(v_AutomationType == "Check If Element Exists") + // { + + // //apply to variable + // var applyToVariable = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Apply To Variable" + // select rw.Field("Parameter Value")).FirstOrDefault(); + + // return base.GetDisplayValue() + " [Check for element in window '" + v_WindowName + "' and apply to '" + applyToVariable + "']"; + // } + // else if (v_AutomationType == "Get Text Value From Element") + // { + // //apply to variable + // var applyToVariable = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Apply To Variable" + // select rw.Field("Parameter Value")).FirstOrDefault(); + + // return base.GetDisplayValue() + " [Text Value for element in window '" + v_WindowName + "' and apply to '" + applyToVariable + "']"; + // } + // else if (v_AutomationType == "Get Selected State From Element") + // { + // //apply to variable + // var applyToVariable = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Apply To Variable" + // select rw.Field("Parameter Value")).FirstOrDefault(); + + // return base.GetDisplayValue() + " [Selected State for element in window '" + v_WindowName + "' and apply to '" + applyToVariable + "']"; + // } + // else + // { + // //get value from property + // var propertyName = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Get Value From" + // select rw.Field("Parameter Value")).FirstOrDefault(); + + // //apply to variable + // var applyToVariable = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Apply To Variable" + // select rw.Field("Parameter Value")).FirstOrDefault(); + + // return base.GetDisplayValue() + " [Get value from '" + propertyName + "' in window '" + v_WindowName + "' and apply to '" + applyToVariable + "']"; + // } + //} + + //public override bool IsValidate(frmCommandEditor editor) + //{ + // base.IsValidate(editor); + + // if (String.IsNullOrEmpty(this.v_WindowName)) + // { + // this.validationResult += "Window Name is empty.\n"; + // this.IsValid = false; + // } + // if (String.IsNullOrEmpty(this.v_AutomationType)) + // { + // this.validationResult += "Action is empty.\n"; + // this.IsValid = false; + // } + // else + // { + // switch (this.v_AutomationType) + // { + // case "Click Element": + // ClickElementValidate(); + // break; + // case "Get Value From Element": + // GetValueFromElementValidate(); + // break; + // case "Check If Element Exists": + // case "Get Text Value From Element": + // case "Get Selected State From Element": + // CheckIfElementExistsValidate(); + // break; + + // case "Get Value From Table Element": + // GetValueFromTableElement(); + // break; + + // default: + // break; + // } + // } + + // return this.IsValid; + //} + + //private void ClickElementValidate() + //{ + // var clickType = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Click Type" + // select rw.Field("Parameter Value")).FirstOrDefault(); + // if (String.IsNullOrEmpty(clickType)) + // { + // this.validationResult += "Click Type is empty.\n"; + // this.IsValid = false; + // } + + // var x = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "X Adjustment" + // select rw.Field("Parameter Value")).FirstOrDefault(); + // var y = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Y Adjustment" + // select rw.Field("Parameter Value")).FirstOrDefault(); + + // if (String.IsNullOrEmpty(x)) + // { + // this.validationResult += "X Adjustment is empty.\n"; + // this.IsValid = false; + // } + // if (String.IsNullOrEmpty(y)) + // { + // this.validationResult += "Y Adjustment is empty.\n"; + // this.IsValid = false; + // } + //} + + //private void GetValueFromElementValidate() + //{ + // var valueFrom = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Get Value From" + // select rw.Field("Parameter Value")).FirstOrDefault(); + // var variable = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Apply To Variable" + // select rw.Field("Parameter Value")).FirstOrDefault(); + + // if (String.IsNullOrEmpty(valueFrom)) + // { + // this.validationResult += "Get Value From is empty.\n"; + // this.IsValid = false; + // } + // if (String.IsNullOrEmpty(variable)) + // { + // this.validationResult += "Variable is empty.\n"; + // this.IsValid = false; + // } + //} + + //private void CheckIfElementExistsValidate() + //{ + // var variable = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Apply To Variable" + // select rw.Field("Parameter Value")).FirstOrDefault(); + // if (String.IsNullOrEmpty(variable)) + // { + // this.validationResult += "Variable is empty.\n"; + // this.IsValid = false; + // } + //} + + //private void GetValueFromTableElement() + //{ + // var row = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Row" + // select rw.Field("Parameter Value")).FirstOrDefault(); + // var column = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Column" + // select rw.Field("Parameter Value")).FirstOrDefault(); + // var variable = (from rw in v_UIAActionParameters.AsEnumerable() + // where rw.Field("Parameter Name") == "Apply To Variable" + // select rw.Field("Parameter Value")).FirstOrDefault(); + + // if (String.IsNullOrEmpty(row)) + // { + // this.validationResult += "Row is empty.\n"; + // this.IsValid = false; + // } + // if (String.IsNullOrEmpty(column)) + // { + // this.validationResult += "Column is empty.\n"; + // this.IsValid = false; + // } + // if (String.IsNullOrEmpty(variable)) + // { + // this.validationResult += "Variable is empty.\n"; + // this.IsValid = false; + // } + //} + + //public override void ConvertToIntermediate(EngineSettings settings, List variables) + //{ + // var cnv = new Dictionary(); + // cnv.Add("v_WindowName", "convertToIntermediateWindowName"); + // ConvertToIntermediate(settings, cnv, variables); + //} + + //public override void ConvertToRaw(EngineSettings settings) + //{ + // var cnv = new Dictionary(); + // cnv.Add("v_WindowName", "convertToRawWindowName"); + // ConvertToRaw(settings, cnv); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationWaitForUIElementToExistsByXPathCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationWaitForUIElementToExistsByXPathCommand.cs new file mode 100644 index 000000000..605dbbc97 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationWaitForUIElementToExistsByXPathCommand.cs @@ -0,0 +1,45 @@ +using System; +using System.Windows.Automation; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement By XPath")] + [Attributes.ClassAttributes.CommandSettings("Wait For UIElement To Exists By XPath")] + [Attributes.ClassAttributes.Description("This command allows you to Wait until the UIElement exists using by XPath.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Wait until the UIElement exists using by XPath.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationWaitForUIElementToExistsByXPathCommand : ADescendantsSearchUIElementsFromUIElementByXPathCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_XPath))] + //public string v_SearchXPath { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //public string v_WaitTimeForUIElement { get; set; } + + public UIAutomationWaitForUIElementToExistsByXPathCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //UIElementControls.SearchGUIElementByXPath(this, engine); + var targetElement = this.ExpandUserVariableAsUIElement(engine); + + this.DeepSearchUIElementAction(engine, targetElement, new Action(elem => + { + // nothing + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationWaitForUIElementToExistsCommand.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationWaitForUIElementToExistsCommand.cs new file mode 100644 index 000000000..10ee8dece --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/UIAutomationWaitForUIElementToExistsCommand.cs @@ -0,0 +1,59 @@ +using System; +using taskt.Core.Automation.Commands.UIAutomationGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("UIAutomation")] + [Attributes.ClassAttributes.SubGruop("Search UIElement")] + [Attributes.ClassAttributes.CommandSettings("Wait For UIElement To Exists")] + [Attributes.ClassAttributes.Description("This command allows you to Wait until the UIElement exists.")] + [Attributes.ClassAttributes.ImplementationDescription("Use this command when you want to Wait until the UIElement exists.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class UIAutomationWaitForUIElementToExistsCommand : ADescendantsSearchAnyUIElementFromUIElementByTreeWalkerCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_InputUIElementName))] + //public string v_TargetElement { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_SearchParameters))] + //public DataTable v_SearchParameters { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_WaitTime))] + //public string v_WaitTimeForUIElement { get; set; } + + public UIAutomationWaitForUIElementToExistsCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //UIElementControls.SearchGUIElement(this, engine); + + var targetElement = this.ExpandUserVariableAsUIElement(engine); + //this.DeepSearchUIElements(targetElement, engine); + this.DeepSearchUIElementsAction(targetElement, engine, new Action>(elems => + { + // nothing + })); + } + + //public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + //{ + // //AutomationElementControls.RenderSearchParameterDataGridView((DataGridView)ControlsList[nameof(v_SearchParameters)]); + // UIElementControls.RenderSearchParameterDataGridView(ControlsList.GetPropertyControl(nameof(v_SearchParameters))); + //} + + //public override void BeforeValidate() + //{ + // base.BeforeValidate(); + + // var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SearchParameters)); + // DataTableControls.BeforeValidate_NoRowAdding(dgv, v_SearchParameters); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/UIAutomationGroup/VP_UIElementControls.cs b/taskt/Core/Automation/Commands/UIAutomationGroup/VP_UIElementControls.cs new file mode 100644 index 000000000..94d5f4376 --- /dev/null +++ b/taskt/Core/Automation/Commands/UIAutomationGroup/VP_UIElementControls.cs @@ -0,0 +1,551 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Windows.Forms; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.UIAutomationGroup +{ + public static class VP_UIElementControls + { + /// + /// input UIElement + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_InputInstanceName))] + [PropertyDescription("UIElement Variable Name")] + [InputSpecification("UIElement Variable Name", true)] + [PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyInstanceType(PropertyInstanceType.InstanceType.UIElement, true)] + [PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Input)] + [PropertyValidationRule("UIElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "UIElement")] + public static string v_InputUIElementName { get; } + + /// + /// output UIElement property + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store UIElement")] + [InputSpecification("UIElement Variable Name", true)] + [PropertyInstanceType(PropertyInstanceType.InstanceType.UIElement, true)] + [PropertyValidationRule("UIElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "UIElement")] + public static string v_OutputUIElementName { get; } + + /// + /// window UIElement variable name + /// + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyDescription("Variable Name to Store Window UIElement")] + [InputSpecification("Window UIElement Variable Name", true)] + [PropertyIsOptional(true, "")] + [PropertyValidationRule("Window UIElement", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Window UIElement")] + public static string v_WindowUIElementName { get; } + + /// + /// New output UIElement name + /// + [PropertyVirtualProperty(nameof(VP_UIElementControls), nameof(VP_UIElementControls.v_OutputUIElementName))] + [PropertyDescription("UIElement Variable Name")] + [PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] + [PropertyDetailSampleUsage("**vNewElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyDetailSampleUsage("**{{{vNewElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyValidationRule("New UIElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "New UIElement")] + public static string v_NewOutputUIElementName { get; } + + /// + /// wait time before action + /// + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time before Action (sec)")] + [PropertyIsOptional(true, "0")] + [PropertyFirstValue("0")] + [PropertyDisplayText(false, "Wait Time Before", "s")] + public static string v_WaitTimeBeforeAction { get; } + + /// + /// wait time after action + /// + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time after Action (sec)")] + [PropertyIsOptional(true, "0")] + [PropertyFirstValue("0")] + [PropertyDisplayText(false, "Wait Time Before", "s")] + public static string v_WaitTimeAfterAction { get; } + + /// + /// activate window before action + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Activate Window before Action")] + [PropertyIsOptional(true, "No")] + public static string v_ActivateWindow { get; } + + /// + /// when this action is not supported + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnore))] + [PropertyDescription("When Action Is Not Supported")] + [PropertyIsOptional(true, "Error")] + public static string v_WhenActionIsNotSupported { get; } + + /// + /// wait time for UIElement + /// + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time for the UIElement to Exist (sec)")] + [Remarks("Specify how long to Wait before an Error will occur because the UIElement is Not Found.")] + [PropertyIsOptional(true, "10")] + [PropertyFirstValue("10")] + public static string v_WaitTimeForUIElement { get; } + + /// + /// Search paramters property (DataTable) + /// + [PropertyDescription("Search Parameters")] + [PropertyCustomUIHelper("GUI Inspect Tool", nameof(VP_UIElementControls) + "+" + nameof(lnkGUIInspectTool_UsedByInspectResult_Click))] + [PropertyCustomUIHelper("Inspect Tool Parser", nameof(VP_UIElementControls) + "+" + nameof(lnkInspectToolParser_Click))] + [PropertyCustomUIHelper("Add Empty Parameters", nameof(VP_UIElementControls) + "+" + nameof(lnkAddEmptyParameter_Click))] + [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)] + [InputSpecification("Search Paramters", true)] + [Remarks("")] + [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + [PropertyDataGridViewSetting(false, false, true)] + [PropertyDataGridViewColumnSettings("Enabled", "Enabled", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.CheckBox)] + [PropertyDataGridViewColumnSettings("ParameterName", "Parameter Name", true, PropertyDataGridViewColumnSettings.DataGridViewColumnType.TextBox)] + [PropertyDataGridViewColumnSettings("ParameterValue", "Parameter Value", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.TextBox)] + [PropertyDataGridViewCellEditEvent(nameof(VP_UIElementControls) + "+" + nameof(UIElementSearchDGV_CellBeginEdit), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellBeginEdit)] + [PropertyDataGridViewCellEditEvent(nameof(VP_UIElementControls) + "+" + nameof(UIElementSearchDGV_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] + [PropertyDataGridViewInitMethod(nameof(VP_UIElementControls) + "+" + nameof(CreateEmptySearchParamters))] + [PropertyParameterOrder(5000)] + public static string v_SearchParameters { get; } + + /// + /// Maxinum number of Sibling Node for Search UIElements + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Maxinum number of Sibling Nodes for Search UIElements")] + [InputSpecification("Number Greater than or Equal 0")] + [PropertyDetailSampleUsage("**10**", PropertyDetailSampleUsage.ValueType.Value, "Max Siblings")] + [PropertyDetailSampleUsage("**{{{vMax}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Max Siblings")] + [PropertyDetailSampleUsage("**0**", "Search All Sibling")] + [PropertyIsOptional(true, "64")] + [PropertyDisplayText(false, "Max Siblings")] + [PropertyValidationRule("Max Siblings", PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + public static string v_MaxSiblings { get; } + + /// + /// Maxinum Depth for Search UIElements + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Maxinum Depth for Search UIElements")] + [InputSpecification("Number Greater than or Equal 0")] + [PropertyDetailSampleUsage("**10**", PropertyDetailSampleUsage.ValueType.Value, "Max Depth")] + [PropertyDetailSampleUsage("**{{{vMax}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Max Depth")] + [PropertyDetailSampleUsage("**0**", "Search to All Depth")] + [PropertyIsOptional(true, "32")] + [PropertyDisplayText(false, "Max Depth")] + [PropertyValidationRule("Max Depth", PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + public static string v_MaxDepth { get; } + + /// + /// Maxinum Number of UIElements to Search + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Maxinum Number of UIElements to Search")] + [InputSpecification("Number Greater than or Equal 0")] + [PropertyDetailSampleUsage("**10**", PropertyDetailSampleUsage.ValueType.Value, "Max UIElements")] + [PropertyDetailSampleUsage("**{{{vMax}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Max UIElements")] + [PropertyDetailSampleUsage("**0**", "After checking all UIElements, return the result")] + [PropertyIsOptional(true, "0")] + [PropertyDisplayText(false, "Max UIElements")] + [PropertyValidationRule("Max UIElements", PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + public static string v_MaxNumberUIElements { get; } + + /// + /// Search Siblings Direction + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Search Siblings Direction")] + [PropertyUISelectionOption("First to Last")] + [PropertyUISelectionOption("Last to First")] + [PropertyIsOptional(true, "First to Last")] + [PropertyDisplayText(false, "Direction")] + public static string v_SiblingsDirection { get; } + + /// + /// window index for match + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("UIElement Index")] + [InputSpecification("UIElement Index", true)] + [PropertyDetailSampleUsage("**0**", "Specify the First Window")] + [PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "UIElement Index")] + [PropertyDetailSampleUsage("**{{{vIndex}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "UIElement Index")] + [PropertyIsOptional(true, "0")] + [PropertyFirstValue("0")] + [PropertyDisplayText(true, "UIElement Index")] + public static string v_TargetUIElementIndex { get; } + + /// + /// xpath property + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Search XPath")] + [InputSpecification("Search XPath", true)] + [PropertyDetailSampleUsage("**//Button[@Name=\"OK\"]**", "Specify a Button whose **Name** Attribute is **OK** in descendant node of the criteria AutomationElement")] + [PropertyDetailSampleUsage("**/Pane[1]/Button[2]**", "Specify the **second** Button of the **first** Pane child node of the child node of the criteria AutomationElement")] + [PropertyDetailSampleUsage("**{{{vXPath}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "XPath")] + [Remarks("XPath does not support to use parent, following-sibling, and preceding-sibling for root element.")] + [PropertyValidationRule("XPath", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "XPath")] + [PropertyCustomUIHelper("GUI Inspect Tool", nameof(VP_UIElementControls) + "+" + nameof(lnkGUIInspectTool_UsedByXPath_Click))] + public static string v_SearchXPath { get; } + + /// + /// UIElement Action + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("UIElement Action")] + [PropertyUISelectionOption("Click UIElement")] + [PropertyUISelectionOption("Expand Collapse Items In UIElement")] + [PropertyUISelectionOption("Scroll UIElement")] + [PropertyUISelectionOption("Scroll Percent UIElement")] + [PropertyUISelectionOption("Select Item In UIElement")] + [PropertyUISelectionOption("Select UIElement")] + [PropertyUISelectionOption("Set Selected State To UIElement")] + [PropertyUISelectionOption("Set Text To UIElement")] + [PropertyUISelectionOption("Get Parent UIElement")] + [PropertyUISelectionOption("Get Property Value From UIElement")] + [PropertyUISelectionOption("Get ScrollBar Information From UIElement")] + [PropertyUISelectionOption("Get Selected State From UIElement")] + [PropertyUISelectionOption("Get Selection Items Value From UIElement")] + [PropertyUISelectionOption("Get Table Information From UIElement")] + [PropertyUISelectionOption("Get Text From Table UIElement")] + [PropertyUISelectionOption("Get Text From UIElement")] + [PropertyUISelectionOption("Get UIElement From Table UIElement")] + [PropertyUISelectionOption("Get UIElement Position")] + [PropertyUISelectionOption("Get UIElement Size")] + [PropertyUISelectionOption("Get Window Handle From UIElement")] + [PropertyUISelectionOption("Get Window Name From UIElement")] + [PropertyUISelectionOption("Check UIElement Exists")] + [PropertyUISelectionOption("Wait For UIElement To Exists")] + //[PropertySelectionChangeEvent(nameof(cmbActionType_SelectedItemChange))] + [PropertyDisplayText(true, "Action")] + public static string v_AutomationType { get; } + + /// + /// UIElement Action Parameters (actually data type is DataTable) + /// + [PropertyDescription("Action Parameters")] + [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + [PropertyDataGridViewSetting(false, false, true, 400, 250)] + [PropertyDataGridViewColumnSettings("Parameter Name", "Parameter Name", true)] + [PropertyDataGridViewColumnSettings("Parameter Value", "Parameter Value", false)] + public static string v_UIAActionParameters { get; } + + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Expand And Activate Window When Selection Items Not Found")] + [PropertyIsOptional(true, "Yes")] + [PropertyValidationRule("Expand", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Expand")] + public static string v_ExpandWhenItemsNotFound { get; set; } + + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time After Expand Selection Items")] + [PropertyIsOptional(true, "1000")] + [PropertyFirstValue("1000")] + [PropertyValidationRule("Wait Time After Expand", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Wait Time After Expand")] + public static string v_WaitTimeAfterExpand { get; set; } + + /// + /// show GUI InspectTool and get InspectTool like result + /// + /// + /// + public static void lnkGUIInspectTool_UsedByInspectResult_Click(object sender, EventArgs e) + { + using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmGUIInspectTool()) + { + if (fm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) + { + (var command, var dgv) = EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.GetCommandAndSearchDataGridView((Control)sender); + command.SearchParametersUpdateProcess(dgv, new Action((tbl) => + { + ParseInspectToolResult(fm.InspectResult, tbl); + })); + } + } + } + + /// + /// set Empty Paramter in DGV + /// + /// + /// + public static void lnkAddEmptyParameter_Click(object sender, EventArgs e) + { + (var command, var dgv) = EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.GetCommandAndSearchDataGridView((Control)sender); + command.SearchParametersUpdateProcess(dgv, new Action((tbl) => + { + CreateEmptySearchParamters(tbl); + })); + } + + /// + /// show InspectTool Parser and set result + /// + /// + /// + public static void lnkInspectToolParser_Click(object sender, EventArgs e) + { + using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmInspectToolParser()) + { + if (fm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) + { + (var command, var dgv) = EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.GetCommandAndSearchDataGridView((Control)sender); + command.SearchParametersUpdateProcess(dgv, new Action((tbl) => + { + ParseInspectToolResult(fm.InspectResult, tbl); + })); + } + } + } + + /// + /// UIElement search DGV cell click event + /// + /// + /// + public static void UIElementSearchDGV_CellClick(object sender, DataGridViewCellEventArgs e) + { + var myDGV = (DataGridView)sender; + + if (e.RowIndex < 0) + { + return; + } + + if (e.ColumnIndex >= 0) + { + if (e.ColumnIndex != 1) + { + var targetCell = myDGV.Rows[e.RowIndex].Cells[1]; + if (targetCell is DataGridViewTextBoxCell) + { + myDGV.BeginEdit(false); + } + else if (targetCell is DataGridViewComboBoxCell) + { + SendKeys.Send("{F4}"); + } + } + } + else + { + myDGV.EndEdit(); + } + } + + /// + /// UIElement search DGV cell begin edit + /// + /// + /// + public static void UIElementSearchDGV_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) + { + if (e.ColumnIndex == 1) + { + e.Cancel = true; + } + } + + + /// + /// create empty UIElement search parameters + /// + /// + public static void CreateEmptySearchParamters(DataTable table) + { + table.Rows.Clear(); + foreach (var n in EM_UIElementChildrenSearchParametersPropertiesExtensionMethods.TargetControlProperties) + { + table.Rows.Add(false, n, ""); + } + } + + /// + /// parse inspect tool result for UIElement Search DGV + /// + /// + /// + /// + private static void ParseInspectToolResult(string result, DataTable table, ComboBox windowNames = null) + { + var results = result.Split(new[] { "\r\n" }, StringSplitOptions.None); + + if ((results.Length >= 1) && (result != "")) + { + CreateEmptySearchParamters(table); + + var ancestors = new List(); + string currentParam = ""; + foreach (string res in results) + { + var spt = res.Split('\t'); + string value = (spt.Length >= 2) ? spt[1] : ""; + if (value.StartsWith("\"") && value.EndsWith("\"")) + { + value = value.Substring(1, value.Length - 2); + } + if (spt[0] != "") + { + string name = spt[0].Substring(0, spt[0].Length - 1); + currentParam = name; + + switch (name) + { + case "AcceleratorKey": + case "AccessKey": + case "AutomationId": + case "ClassName": + case "FrameworkId": + case "HasKeyboardFocus": + case "HelpText": + case "IsContentElement": + case "IsControlElement": + case "IsEnabled": + case "IsKeyboardFocusable": + case "IsOffscreen": + case "IsPassword": + case "IsRequiredForForm": + case "ItemStatus": + case "ItemType": + case "LocalizedControlType": + case "Name": + case "NativeWindowHandle": + case "ProcessId": + DataTableControls.SetParameterValue(table, value, name, "ParameterName", "ParameterValue"); + break; + + case "ControlType": + DataTableControls.SetParameterValue(table, ParseControlTypeInspectToolResult(value), name, "ParameterName", "ParameterValue"); + break; + + case "Ancestors": + ancestors.Add(value); + break; + } + } + else + { + if (currentParam == "Ancestors") + { + ancestors.Add(value); + } + } + if (windowNames != null) + { + SetComboBoxWindowNameFromInspectAncestors(ancestors, windowNames); + } + } + } + else + { + var f = new UI.Forms.General.frmDialog("No Inspect Tool Results", "Fail Parse", UI.Forms.General.frmDialog.DialogType.OkOnly, 0); + f.ShowDialog(); + } + } + + /// + /// parse ControlType in InspectTool result + /// + /// + /// + private static string ParseControlTypeInspectToolResult(string value) + { + var spt = value.Split(' '); + return spt[0].Replace("UIA_", "").Replace("ControlTypeId", ""); + } + + /// + /// set combobox window name from Inspect Tool result Ancenstors value + /// + /// + /// + private static void SetComboBoxWindowNameFromInspectAncestors(List ancestors, ComboBox cmb) + { + if (ancestors.Count > 0) + { + var windows = new string[cmb.Items.Count]; + cmb.Items.CopyTo(windows, 0); + + bool isFound = false; + foreach (string ancestor in ancestors) + { + // get quoted " " text + int pos = ancestor.IndexOf("\""); + if (pos < 0) + { + continue; + } + + string winName = ancestor.Substring(pos + 1); + pos = winName.IndexOf("\""); + if (pos < 0) + { + continue; + } + winName = winName.Substring(0, pos); + + foreach (string win in windows) + { + if (winName == win) + { + cmb.Text = winName; + isFound = true; + break; + } + } + if (isFound) + { + break; + } + } + } + } + + /// + /// show GUI Inspect Tool and get XPath + /// + /// + /// + public static void lnkGUIInspectTool_UsedByXPath_Click(object sender, EventArgs e) + { + using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmGUIInspectTool()) + { + var trgCtrl = (Control)sender; + if (fm.ShowDialog(trgCtrl.FindForm()) == DialogResult.OK) + { + object ctrl = trgCtrl.Tag; + if (ctrl is TextBox txt) + { + txt.Text = fm.XPath; + } + else if (ctrl is ComboBox cmb) + { + cmb.Text = fm.XPath; + } + else if (ctrl is DataGridView dgv) + { + dgv.CurrentCell.Value = fm.XPath; + } + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/UIElementControls.cs b/taskt/Core/Automation/Commands/UIElementControls.cs index 4aedc022f..16f08e76e 100644 --- a/taskt/Core/Automation/Commands/UIElementControls.cs +++ b/taskt/Core/Automation/Commands/UIElementControls.cs @@ -1,13 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Security; -using System.Windows.Automation; -using System.Windows.Forms; -using System.Xml.Linq; -using System.Xml.XPath; -using taskt.Core.Automation.Attributes.PropertyAttributes; +using System.Windows.Automation; namespace taskt.Core.Automation.Commands { @@ -18,205 +9,205 @@ internal static class UIElementControls { #region fields - /// - /// UIElement type for Reflection - /// - private static readonly Type TypeOfAutomationElement = typeof(AutomationElement); - - /// - /// ControlType type for Reflection - /// - private static readonly Type TypeOfControlType = typeof(ControlType); - - private static readonly string[] TargetControlTypes = new string[] - { - "AcceleratorKey", "AccessKey", "AutomationId", "ClassName", "ControlType", - "FrameworkId", "HasKeyboardFocus", "HelpText", "IsContentElement", - "IsControlElement", "IsEnabled", "IsKeyboardFocusable", "IsOffscreen", - "IsPassword", "IsRequiredForForm", "ItemStatus", "ItemType", - "LocalizedControlType", "Name", "NativeWindowHandle", "ProcessId", - }; + ///// + ///// UIElement type for Reflection + ///// + //private static readonly Type TypeOfAutomationElement = typeof(AutomationElement); + + ///// + ///// ControlType type for Reflection + ///// + //private static readonly Type TypeOfControlType = typeof(ControlType); + + //private static readonly string[] TargetControlTypes = new string[] + //{ + // "AcceleratorKey", "AccessKey", "AutomationId", "ClassName", "ControlType", + // "FrameworkId", "HasKeyboardFocus", "HelpText", "IsContentElement", + // "IsControlElement", "IsEnabled", "IsKeyboardFocusable", "IsOffscreen", + // "IsPassword", "IsRequiredForForm", "ItemStatus", "ItemType", + // "LocalizedControlType", "Name", "NativeWindowHandle", "ProcessId", + //}; #endregion #region VirtualProperties - /// - /// input UIElement property - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_InputInstanceName))] - [PropertyDescription("UIElement Variable Name")] - [InputSpecification("UIElement Variable Name", true)] - [PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyInstanceType(PropertyInstanceType.InstanceType.UIElement, true)] - [PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Input)] - [PropertyValidationRule("UIElement", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Element")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterOrder(5000)] - public static string v_InputUIElementName { get; } - - /// - /// output UIElement property - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Store UIElement")] - [InputSpecification("UIElement Variable Name", true)] - [PropertyInstanceType(PropertyInstanceType.InstanceType.UIElement, true)] - [PropertyValidationRule("UIElement", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Element")] + ///// + ///// input UIElement property + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_InputInstanceName))] + //[PropertyDescription("UIElement Variable Name")] + //[InputSpecification("UIElement Variable Name", true)] //[PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] //[PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyIsVariablesList(true)] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] - //[PropertyParameterOrder(5000)] - public static string v_OutputUIElementName { get; } - - /// - /// New output UIElement name - /// - [PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_OutputUIElementName))] - [PropertyDescription("UIElement Variable Name")] - [PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] - [PropertyDetailSampleUsage("**vNewElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyDetailSampleUsage("**{{{vNewElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] - [PropertyValidationRule("New UIElement", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "New UIElement")] + //[PropertyInstanceType(PropertyInstanceType.InstanceType.UIElement, true)] + //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Input)] + //[PropertyValidationRule("UIElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "Element")] + ////[Remarks("")] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] + ////[PropertyParameterOrder(5000)] + //public static string v_InputUIElementName { get; } + + ///// + ///// output UIElement property + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyDescription("Variable Name to Store UIElement")] //[InputSpecification("UIElement Variable Name", true)] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyIsVariablesList(true)] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] //[PropertyInstanceType(PropertyInstanceType.InstanceType.UIElement, true)] - //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] - //[PropertyParameterOrder(5000)] - public static string v_NewOutputUIElementName { get; } - - /// - /// xpath property - /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Search XPath")] - [InputSpecification("Search XPath", true)] - [PropertyDetailSampleUsage("**//Button[@Name=\"OK\"]**", "Specify a Button whose **Name** Attribute is **OK** in descendant node of the criteria AutomationElement")] - [PropertyDetailSampleUsage("**/Pane[1]/Button[2]**", "Specify the **second** Button of the **first** Pane child node of the child node of the criteria AutomationElement")] - [PropertyDetailSampleUsage("**{{{vXPath}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "XPath")] - [Remarks("XPath does not support to use parent, following-sibling, and preceding-sibling for root element.")] - [PropertyValidationRule("XPath", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "XPath")] - [PropertyCustomUIHelper("GUI Inspect Tool", nameof(UIElementControls) + "+" + nameof(lnkGUIInspectTool_UsedByXPath_Click))] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.TextBox)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] - public static string v_XPath { get; } - - /// - /// Search paramters property - /// - [PropertyDescription("Search Parameters")] - [PropertyCustomUIHelper("GUI Inspect Tool", nameof(UIElementControls) + "+" + nameof(lnkGUIInspectTool_UsedByInspectResult_Click))] - [PropertyCustomUIHelper("Inspect Tool Parser", nameof(UIElementControls) + "+" + nameof(lnkInspectToolParser_Click))] - [PropertyCustomUIHelper("Add Empty Parameters", nameof(UIElementControls) + "+" + nameof(lnkAddEmptyParameter_Click))] - [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)] - [InputSpecification("Search Paramters", true)] - [Remarks("")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] - [PropertyDataGridViewSetting(false, false, true)] - [PropertyDataGridViewColumnSettings("Enabled", "Enabled", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.CheckBox)] - [PropertyDataGridViewColumnSettings("ParameterName", "Parameter Name", true, PropertyDataGridViewColumnSettings.DataGridViewColumnType.TextBox)] - [PropertyDataGridViewColumnSettings("ParameterValue", "Parameter Value", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.TextBox)] - [PropertyDataGridViewCellEditEvent(nameof(UIElementControls) + "+" + nameof(UIAutomationDataGridView_CellBeginEdit), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellBeginEdit)] - [PropertyDataGridViewCellEditEvent(nameof(UIElementControls) + "+" + nameof(UIAutomationDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] - [PropertyDataGridViewInitMethod(nameof(UIElementControls) + "+" + nameof(CreateEmptyParamters))] - [PropertyParameterOrder(5000)] - public static string v_SearchParameters { get; } - - /// - /// AutomationElement wait time - /// - [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] - [PropertyDescription("Wait Time for the UIElement to Exist (sec)")] - [Remarks("Specify how long to Wait before an Error will occur because the UIElement is Not Found.")] - [PropertyIsOptional(true, "10")] - [PropertyFirstValue("10")] - //[InputSpecification("Wait Time", true)] - //[PropertyDetailSampleUsage("**10**", PropertyDetailSampleUsage.ValueType.Value, "Wait Time")] - //[PropertyDetailSampleUsage("**{{{vTime}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Wait Time")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] + //[PropertyValidationRule("UIElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "Element")] + ////[PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] + ////[PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + ////[Remarks("")] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyIsVariablesList(true)] + ////[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] + ////[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] + ////[PropertyParameterOrder(5000)] + //public static string v_OutputUIElementName { get; } + + ///// + ///// New output UIElement name + ///// + //[PropertyVirtualProperty(nameof(UIElementControls), nameof(UIElementControls.v_OutputUIElementName))] + //[PropertyDescription("UIElement Variable Name")] + //[PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] + //[PropertyDetailSampleUsage("**vNewElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] + //[PropertyDetailSampleUsage("**{{{vNewElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + //[PropertyValidationRule("New UIElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "New UIElement")] + ////[InputSpecification("UIElement Variable Name", true)] + ////[Remarks("")] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyIsVariablesList(true)] + ////[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] + ////[PropertyInstanceType(PropertyInstanceType.InstanceType.UIElement, true)] + ////[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] + ////[PropertyParameterOrder(5000)] + //public static string v_NewOutputUIElementName { get; } + + ///// + ///// xpath property + ///// + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Search XPath")] + //[InputSpecification("Search XPath", true)] + //[PropertyDetailSampleUsage("**//Button[@Name=\"OK\"]**", "Specify a Button whose **Name** Attribute is **OK** in descendant node of the criteria AutomationElement")] + //[PropertyDetailSampleUsage("**/Pane[1]/Button[2]**", "Specify the **second** Button of the **first** Pane child node of the child node of the criteria AutomationElement")] + //[PropertyDetailSampleUsage("**{{{vXPath}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "XPath")] + //[Remarks("XPath does not support to use parent, following-sibling, and preceding-sibling for root element.")] + //[PropertyValidationRule("XPath", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "XPath")] + //[PropertyCustomUIHelper("GUI Inspect Tool", nameof(UIElementControls) + "+" + nameof(lnkGUIInspectTool_UsedByXPath_Click))] + ////[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.TextBox)] + ////[PropertyTextBoxSetting(1, false)] + ////[PropertyParameterOrder(5000)] + //public static string v_XPath { get; } + + ///// + ///// Search paramters property + ///// + //[PropertyDescription("Search Parameters")] + //[PropertyCustomUIHelper("GUI Inspect Tool", nameof(UIElementControls) + "+" + nameof(lnkGUIInspectTool_UsedByInspectResult_Click))] + //[PropertyCustomUIHelper("Inspect Tool Parser", nameof(UIElementControls) + "+" + nameof(lnkInspectToolParser_Click))] + //[PropertyCustomUIHelper("Add Empty Parameters", nameof(UIElementControls) + "+" + nameof(lnkAddEmptyParameter_Click))] + //[PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)] + //[InputSpecification("Search Paramters", true)] + //[Remarks("")] + //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + //[PropertyDataGridViewSetting(false, false, true)] + //[PropertyDataGridViewColumnSettings("Enabled", "Enabled", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.CheckBox)] + //[PropertyDataGridViewColumnSettings("ParameterName", "Parameter Name", true, PropertyDataGridViewColumnSettings.DataGridViewColumnType.TextBox)] + //[PropertyDataGridViewColumnSettings("ParameterValue", "Parameter Value", false, PropertyDataGridViewColumnSettings.DataGridViewColumnType.TextBox)] + //[PropertyDataGridViewCellEditEvent(nameof(UIElementControls) + "+" + nameof(UIAutomationDataGridView_CellBeginEdit), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellBeginEdit)] + //[PropertyDataGridViewCellEditEvent(nameof(UIElementControls) + "+" + nameof(UIAutomationDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] + //[PropertyDataGridViewInitMethod(nameof(UIElementControls) + "+" + nameof(CreateEmptyParamters))] //[PropertyParameterOrder(5000)] - public static string v_WaitTime { get; } + //public static string v_SearchParameters { get; } + + ///// + ///// AutomationElement wait time + ///// + //[PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + //[PropertyDescription("Wait Time for the UIElement to Exist (sec)")] + //[Remarks("Specify how long to Wait before an Error will occur because the UIElement is Not Found.")] + //[PropertyIsOptional(true, "10")] + //[PropertyFirstValue("10")] + ////[InputSpecification("Wait Time", true)] + ////[PropertyDetailSampleUsage("**10**", PropertyDetailSampleUsage.ValueType.Value, "Wait Time")] + ////[PropertyDetailSampleUsage("**{{{vTime}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Wait Time")] + ////[PropertyShowSampleUsageInDescription(true)] + ////[PropertyTextBoxSetting(1, false)] + ////[PropertyParameterOrder(5000)] + //public static string v_WaitTime { get; } #endregion #region variable methods - /// - /// expand user variable as UIElement - /// - /// - /// - /// - /// - public static AutomationElement ExpandUserVariableAsUIElement(this string variableName, Engine.AutomationEngineInstance engine) - { - Script.ScriptVariable v = variableName.GetRawVariable(engine); - if (v.VariableValue is AutomationElement e) - { - return e; - } - else - { - throw new Exception("Variable " + variableName + " is not UIElement"); - } - } - - /// - /// expand user variable as UIElement - /// - /// - /// - /// - /// - public static AutomationElement ExpandUserVariableAsUIElement(this ScriptCommand command, string parameterName, Engine.AutomationEngineInstance engine) - { - var prop = command.GetProperty(parameterName); - var value = prop?.GetValue(command)?.ToString() ?? ""; - return ExpandUserVariableAsUIElement(value, engine); - } - - /// - /// expand user variable string as XPath - /// - /// - /// - /// - public static string ExpandUserVariableAsXPath(this string value, Engine.AutomationEngineInstance engine) - { - var p = value.ExpandValueOrUserVariable(engine); - if (!p.StartsWith(".")) - { - p = "." + p; - } - return p; - } - - /// - /// expand variable string as XPath - /// - /// - /// - /// - /// - public static string ExpandUserVariableAsXPath(this ScriptCommand command, string parameterName, Engine.AutomationEngineInstance engine) - { - var prop = command.GetProperty(parameterName); - var value = prop?.GetValue(command)?.ToString() ?? ""; - return ExpandUserVariableAsXPath(value, engine); - } + ///// + ///// expand user variable as UIElement + ///// + ///// + ///// + ///// + ///// + //public static AutomationElement ExpandUserVariableAsUIElement(this string variableName, Engine.AutomationEngineInstance engine) + //{ + // Script.ScriptVariable v = variableName.GetRawVariable(engine); + // if (v.VariableValue is AutomationElement e) + // { + // return e; + // } + // else + // { + // throw new Exception($"Variable '{variableName}' is not UIElement"); + // } + //} + + ///// + ///// expand user variable as UIElement + ///// + ///// + ///// + ///// + ///// + //public static AutomationElement ExpandUserVariableAsUIElement(this ScriptCommand command, string parameterName, Engine.AutomationEngineInstance engine) + //{ + // var prop = command.GetProperty(parameterName); + // var value = prop?.GetValue(command)?.ToString() ?? ""; + // return ExpandUserVariableAsUIElement(value, engine); + //} + + ///// + ///// expand user variable string as XPath + ///// + ///// + ///// + ///// + //public static string ExpandUserVariableAsXPath(this string value, Engine.AutomationEngineInstance engine) + //{ + // var p = value.ExpandValueOrUserVariable(engine); + // if (!p.StartsWith(".")) + // { + // p = "." + p; + // } + // return p; + //} + + ///// + ///// expand variable string as XPath + ///// + ///// + ///// + ///// + ///// + //public static string ExpandUserVariableAsXPath(this ScriptCommand command, string parameterName, Engine.AutomationEngineInstance engine) + //{ + // var prop = command.GetProperty(parameterName); + // var value = prop?.GetValue(command)?.ToString() ?? ""; + // return ExpandUserVariableAsXPath(value, engine); + //} /// /// store AutomationElement @@ -231,1428 +222,1385 @@ public static void StoreInUserVariable(this AutomationElement value, Engine.Auto #endregion - public static AutomationElement GetFromWindowName(string windowName, Engine.AutomationEngineInstance engine) - { - var windowSearchConditions = new AndCondition( - new PropertyCondition(AutomationElement.NameProperty, windowName), - new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window) - ); - - var paneSearchConditions = new AndCondition( - new PropertyCondition(AutomationElement.NameProperty, windowName), - new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Pane) - ); - - var windowElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, windowSearchConditions); - if (windowElement == null) - { - // Pane search - windowElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, paneSearchConditions); - } - if (windowElement == null) - { - // try window handle - try - { - IntPtr wHnd = WindowControls.FindWindowHandle(windowName, "exact match", engine); - windowElement = AutomationElement.FromHandle(wHnd); - } - catch - { - // nothing to do - } - } - if (windowElement == null) - { - // more deep search window - windowElement = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, windowSearchConditions); - } - if (windowElement == null) - { - // more deep search pane - windowElement = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, paneSearchConditions); - } - - if (windowElement == null) - { - throw new Exception("Window Name '" + windowName + "' not found AutomationElement"); - } - else - { - return windowElement; - } - } - - public static void CreateEmptyParamters(DataTable table) - { - table.Rows.Clear(); - foreach(var n in TargetControlTypes) - { - table.Rows.Add(false, n, ""); - } - } - - private static void parseInspectToolResult(string result, DataTable table, ComboBox windowNames = null) - { - string[] results = result.Split(new[] { "\r\n" }, StringSplitOptions.None); - - if ((results.Length >= 1) && (result != "")) - { - CreateEmptyParamters(table); - - List ancestors = new List(); - string currentParam = ""; - foreach (string res in results) - { - string[] spt = res.Split('\t'); - string value = (spt.Length >= 2) ? spt[1] : ""; - if (value.StartsWith("\"") && value.EndsWith("\"")) - { - value = value.Substring(1, value.Length - 2); - } - if (spt[0] != "") - { - string name = spt[0].Substring(0, spt[0].Length - 1); - currentParam = name; - - switch (name) - { - case "AcceleratorKey": - case "AccessKey": - case "AutomationId": - case "ClassName": - case "FrameworkId": - case "HasKeyboardFocus": - case "HelpText": - case "IsContentElement": - case "IsControlElement": - case "IsEnabled": - case "IsKeyboardFocusable": - case "IsOffscreen": - case "IsPassword": - case "IsRequiredForForm": - case "ItemStatus": - case "ItemType": - case "LocalizedControlType": - case "Name": - case "NativeWindowHandle": - case "ProcessId": - DataTableControls.SetParameterValue(table, value, name, "ParameterName", "ParameterValue"); - break; - - case "ControlType": - DataTableControls.SetParameterValue(table, parseControlTypeInspectToolResult(value), name, "ParameterName", "ParameterValue"); - break; - - case "Ancestors": - ancestors.Add(value); - break; - } - } - else - { - if (currentParam == "Ancestors") - { - ancestors.Add(value); - } - } - if (windowNames != null) - { - setComboBoxWindowNameFromInspectAncestors(ancestors, windowNames); - } - } - } - else - { - var f = new UI.Forms.General.frmDialog("No Inspect Tool Results", "Fail Parse", UI.Forms.General.frmDialog.DialogType.OkOnly, 0); - f.ShowDialog(); - } - } - - private static string parseControlTypeInspectToolResult(string value) - { - var spt = value.Split(' '); - return spt[0].Replace("UIA_", "").Replace("ControlTypeId", ""); - } - - private static void setComboBoxWindowNameFromInspectAncestors(List ancestors, ComboBox cmb) - { - if (ancestors.Count > 0) - { - string[] windows = new string[cmb.Items.Count]; - cmb.Items.CopyTo(windows, 0); - - bool isFound = false; - foreach (string ancestor in ancestors) - { - // get quoted " " text - int pos = ancestor.IndexOf("\""); - if (pos < 0) - { - continue; - } - - string winName = ancestor.Substring(pos + 1); - pos = winName.IndexOf("\""); - if (pos < 0) - { - continue; - } - winName = winName.Substring(0, pos); - - foreach (string win in windows) - { - if (winName == win) - { - cmb.Text = winName; - isFound = true; - break; - } - } - if (isFound) - { - break; - } - } - } - } - - public static string GetControlTypeText(ControlType control) - { - var fullName = control.ProgrammaticName; - return fullName.Substring(fullName.LastIndexOf('.') + 1); - } + //public static AutomationElement GetFromWindowName(string windowName, Engine.AutomationEngineInstance engine) + //{ + // var windowSearchConditions = new AndCondition( + // new PropertyCondition(AutomationElement.NameProperty, windowName), + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window) + // ); + + // var paneSearchConditions = new AndCondition( + // new PropertyCondition(AutomationElement.NameProperty, windowName), + // new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Pane) + // ); + + // var windowElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, windowSearchConditions); + // if (windowElement == null) + // { + // // Pane search + // windowElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, paneSearchConditions); + // } + // if (windowElement == null) + // { + // // try window handle + // try + // { + // using (var whnd = new InnerScriptVariable(engine)) + // { + // //IntPtr wHnd = WindowControls.FindWindowHandle(windowName, "exact match", engine); + // var getWinHnd = new GetOneWindowHandleFromOneWindowNameCommand() + // { + // v_WindowName = windowName, + // v_CheckMethod = "Exact Match", + // v_WindowHandleResult = whnd.VariableName, + // }; + // getWinHnd.RunCommand(engine); + + // windowElement = AutomationElement.FromHandle((IntPtr)whnd.VariableValue); + // } + + // } + // catch + // { + // // nothing to do + // } + // } + // if (windowElement == null) + // { + // // more deep search window + // windowElement = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, windowSearchConditions); + // } + // if (windowElement == null) + // { + // // more deep search pane + // windowElement = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, paneSearchConditions); + // } + + // if (windowElement == null) + // { + // throw new Exception("Window Name '" + windowName + "' not found AutomationElement"); + // } + // else + // { + // return windowElement; + // } + //} + + //public static void CreateEmptyParamters(DataTable table) + //{ + // table.Rows.Clear(); + // foreach(var n in TargetControlTypes) + // { + // table.Rows.Add(false, n, ""); + // } + //} + + //private static void parseInspectToolResult(string result, DataTable table, ComboBox windowNames = null) + //{ + // string[] results = result.Split(new[] { "\r\n" }, StringSplitOptions.None); + + // if ((results.Length >= 1) && (result != "")) + // { + // CreateEmptyParamters(table); + + // List ancestors = new List(); + // string currentParam = ""; + // foreach (string res in results) + // { + // string[] spt = res.Split('\t'); + // string value = (spt.Length >= 2) ? spt[1] : ""; + // if (value.StartsWith("\"") && value.EndsWith("\"")) + // { + // value = value.Substring(1, value.Length - 2); + // } + // if (spt[0] != "") + // { + // string name = spt[0].Substring(0, spt[0].Length - 1); + // currentParam = name; + + // switch (name) + // { + // case "AcceleratorKey": + // case "AccessKey": + // case "AutomationId": + // case "ClassName": + // case "FrameworkId": + // case "HasKeyboardFocus": + // case "HelpText": + // case "IsContentElement": + // case "IsControlElement": + // case "IsEnabled": + // case "IsKeyboardFocusable": + // case "IsOffscreen": + // case "IsPassword": + // case "IsRequiredForForm": + // case "ItemStatus": + // case "ItemType": + // case "LocalizedControlType": + // case "Name": + // case "NativeWindowHandle": + // case "ProcessId": + // DataTableControls.SetParameterValue(table, value, name, "ParameterName", "ParameterValue"); + // break; + + // case "ControlType": + // DataTableControls.SetParameterValue(table, parseControlTypeInspectToolResult(value), name, "ParameterName", "ParameterValue"); + // break; + + // case "Ancestors": + // ancestors.Add(value); + // break; + // } + // } + // else + // { + // if (currentParam == "Ancestors") + // { + // ancestors.Add(value); + // } + // } + // if (windowNames != null) + // { + // setComboBoxWindowNameFromInspectAncestors(ancestors, windowNames); + // } + // } + // } + // else + // { + // var f = new UI.Forms.General.frmDialog("No Inspect Tool Results", "Fail Parse", UI.Forms.General.frmDialog.DialogType.OkOnly, 0); + // f.ShowDialog(); + // } + //} + + //private static string parseControlTypeInspectToolResult(string value) + //{ + // var spt = value.Split(' '); + // return spt[0].Replace("UIA_", "").Replace("ControlTypeId", ""); + //} + + //private static void setComboBoxWindowNameFromInspectAncestors(List ancestors, ComboBox cmb) + //{ + // if (ancestors.Count > 0) + // { + // string[] windows = new string[cmb.Items.Count]; + // cmb.Items.CopyTo(windows, 0); + + // bool isFound = false; + // foreach (string ancestor in ancestors) + // { + // // get quoted " " text + // int pos = ancestor.IndexOf("\""); + // if (pos < 0) + // { + // continue; + // } + + // string winName = ancestor.Substring(pos + 1); + // pos = winName.IndexOf("\""); + // if (pos < 0) + // { + // continue; + // } + // winName = winName.Substring(0, pos); + + // foreach (string win in windows) + // { + // if (winName == win) + // { + // cmb.Text = winName; + // isFound = true; + // break; + // } + // } + // if (isFound) + // { + // break; + // } + // } + // } + //} + + //public static string GetControlTypeText(ControlType control) + //{ + // var fullName = control.ProgrammaticName; + // return fullName.Substring(fullName.LastIndexOf('.') + 1); + //} #region GUI Search by conditions - /// - /// create AutomationElement search condition - /// - /// - /// - /// - /// - private static PropertyCondition CreatePropertyCondition(string propertyName, object propertyValue) - { - var conditionProp = (AutomationProperty)TypeOfAutomationElement.GetField(propertyName + "Property")?.GetValue(null) ?? - throw new Exception("Property '" + propertyName + "' does not Exists"); - - switch (propertyName) - { - case "ControlType": - var controlValue = TypeOfControlType.GetField(propertyValue.ToString())?.GetValue(null) ?? throw new Exception("ControlType '" + propertyValue.ToString() + "' does not Exists"); - return new PropertyCondition(conditionProp, controlValue); - - default: - return new PropertyCondition(conditionProp, propertyValue); - } - } - - /// - /// create AutomationElement search condition from DataTable - /// - /// - /// - /// - private static Condition CreateSearchCondition(DataTable table, Engine.AutomationEngineInstance engine) - { - //create and populate condition list - var conditionList = new List(); - foreach(DataRow row in table.Rows) - { - var isEnabled = row.Field("Enabled") ?? "false"; - if (bool.TryParse(isEnabled, out bool res)) - { - if (!res) - { - continue; - } - } - else - { - continue; - } - - var parameterName = row.Field("ParameterName") ?? ""; - var parameterValue = (row.Field("ParameterValue") ?? "").ExpandValueOrUserVariable(engine); - - // value correction - switch (parameterName) - { - case "HasKeyboardFocus": - case "IsContentElement": - case "IsControlElement": - case "IsEnabled": - case "IsKeyboardFocusable": - case "IsOffscreen": - case "IsPassword": - case "IsRequiredForForm": - if (string.IsNullOrEmpty(parameterValue)) - { - parameterValue = "False"; - } - else - { - switch (parameterValue.ToLower()) - { - case "yes": - parameterValue = "True"; - break; - case "no": - parameterValue = "False"; - break; - } - } - if (!bool.TryParse(parameterValue, out _)) - { - throw new Exception($"Invalid ParamterValue. Value must be 'True' or 'False'. ParameterName: '{parameterName}', ParameteValue: '{parameterValue}'"); - } - break; - - case "NativeWindowHandle": - case "ProcessId": - if (string.IsNullOrEmpty(parameterValue)) - { - parameterValue = "0"; - } - if (!Int32.TryParse(parameterValue, out _)) - { - throw new Exception($"Invalid ParamterValue. Value must be Int32 value. ParameterName: '{parameterName}', ParameteValue: '{parameterValue}'"); - } - break; - } - - // DBG - //Debug.WriteLine($"Name: '{parameterName}', Value: '{parameterValue}'"); - - PropertyCondition propCondition = null; - - switch (parameterName) - { - case "HasKeyboardFocus": - case "IsContentElement": - case "IsControlElement": - case "IsEnabled": - case "IsKeyboardFocusable": - case "IsOffscreen": - case "IsPassword": - case "IsRequiredForForm": - propCondition = CreatePropertyCondition(parameterName, bool.Parse(parameterValue)); - break; - - case "NativeWindowHandle": - case "ProcessId": - propCondition = CreatePropertyCondition(parameterName, Int32.Parse(parameterValue)); - break; - - case "AcceleratorKey": - case "AccessKey": - case "AutomationId": - case "ClassName": - case "ControlType": - case "FrameworkId": - case "HelpText": - case "ItemStatus": - case "ItemType": - case "LocalizedControlType": - case "Name": - propCondition = CreatePropertyCondition(parameterName, parameterValue); - break; - } - - conditionList.Add(propCondition); - } - - switch (conditionList.Count) - { - case 0: - return null; // no conditions + ///// + ///// create AutomationElement search condition + ///// + ///// + ///// + ///// + ///// + //private static PropertyCondition CreatePropertyCondition(string propertyName, object propertyValue) + //{ + // var conditionProp = (AutomationProperty)TypeOfAutomationElement.GetField(propertyName + "Property")?.GetValue(null) ?? + // throw new Exception("Property '" + propertyName + "' does not Exists"); + + // switch (propertyName) + // { + // case "ControlType": + // var controlValue = TypeOfControlType.GetField(propertyValue.ToString())?.GetValue(null) ?? throw new Exception("ControlType '" + propertyValue.ToString() + "' does not Exists"); + // return new PropertyCondition(conditionProp, controlValue); + + // default: + // return new PropertyCondition(conditionProp, propertyValue); + // } + //} + + ///// + ///// create AutomationElement search condition from DataTable + ///// + ///// + ///// + ///// + //private static Condition CreateSearchCondition(DataTable table, Engine.AutomationEngineInstance engine) + //{ + // //create and populate condition list + // var conditionList = new List(); + // foreach(DataRow row in table.Rows) + // { + // var isEnabled = row.Field("Enabled") ?? "false"; + // if (bool.TryParse(isEnabled, out bool res)) + // { + // if (!res) + // { + // continue; + // } + // } + // else + // { + // continue; + // } + + // var parameterName = row.Field("ParameterName") ?? ""; + // var parameterValue = (row.Field("ParameterValue") ?? "").ExpandValueOrUserVariable(engine); + + // // value correction + // switch (parameterName) + // { + // case "HasKeyboardFocus": + // case "IsContentElement": + // case "IsControlElement": + // case "IsEnabled": + // case "IsKeyboardFocusable": + // case "IsOffscreen": + // case "IsPassword": + // case "IsRequiredForForm": + // if (string.IsNullOrEmpty(parameterValue)) + // { + // parameterValue = "False"; + // } + // else + // { + // switch (parameterValue.ToLower()) + // { + // case "yes": + // parameterValue = "True"; + // break; + // case "no": + // parameterValue = "False"; + // break; + // } + // } + // if (!bool.TryParse(parameterValue, out _)) + // { + // throw new Exception($"Invalid ParamterValue. Value must be 'True' or 'False'. ParameterName: '{parameterName}', ParameteValue: '{parameterValue}'"); + // } + // break; + + // case "NativeWindowHandle": + // case "ProcessId": + // if (string.IsNullOrEmpty(parameterValue)) + // { + // parameterValue = "0"; + // } + // if (!Int32.TryParse(parameterValue, out _)) + // { + // throw new Exception($"Invalid ParamterValue. Value must be Int32 value. ParameterName: '{parameterName}', ParameteValue: '{parameterValue}'"); + // } + // break; + // } + + // // DBG + // //Debug.WriteLine($"Name: '{parameterName}', Value: '{parameterValue}'"); + + // PropertyCondition propCondition = null; + + // switch (parameterName) + // { + // case "HasKeyboardFocus": + // case "IsContentElement": + // case "IsControlElement": + // case "IsEnabled": + // case "IsKeyboardFocusable": + // case "IsOffscreen": + // case "IsPassword": + // case "IsRequiredForForm": + // propCondition = CreatePropertyCondition(parameterName, bool.Parse(parameterValue)); + // break; + + // case "NativeWindowHandle": + // case "ProcessId": + // propCondition = CreatePropertyCondition(parameterName, Int32.Parse(parameterValue)); + // break; + + // case "AcceleratorKey": + // case "AccessKey": + // case "AutomationId": + // case "ClassName": + // case "ControlType": + // case "FrameworkId": + // case "HelpText": + // case "ItemStatus": + // case "ItemType": + // case "LocalizedControlType": + // case "Name": + // propCondition = CreatePropertyCondition(parameterName, parameterValue); + // break; + // } + + // conditionList.Add(propCondition); + // } + + // switch (conditionList.Count) + // { + // case 0: + // return null; // no conditions - case 1: - return conditionList[0]; // 1 condition + // case 1: + // return conditionList[0]; // 1 condition - default: - return new AndCondition(conditionList.ToArray()); // 2+ conditions - } - } - - /// - /// Deep Search GUI Element by Specified Condition - /// - /// - /// - /// - private static AutomationElement DeepSearchGUIElement(AutomationElement rootElement, Condition searchCondition, DateTime endTime) - { - TreeWalker walker = TreeWalker.RawViewWalker; - - // format conditions - PropertyCondition[] conditions; - if (searchCondition is AndCondition andConds) - { - conditions = andConds.GetConditions().Cast().ToArray(); - } - else - { - conditions = new PropertyCondition[1] - { - (PropertyCondition)searchCondition - }; - } - - var ret = WalkerSearch_DepthFirst(rootElement, conditions, walker, endTime); - //var ret = WalkerSearch_WidthFirst_Reverse(rootElement, conditions, walker, endTime); - return ret; - } - - /// - /// Search GUI Element used by TreeWalker (Depth First) - /// - /// - /// - /// - /// - private static AutomationElement WalkerSearch_DepthFirst(AutomationElement rootElement, PropertyCondition[] searchConditions, TreeWalker walker, DateTime endTime) - { - AutomationElement node = walker.GetFirstChild(rootElement); - AutomationElement ret = null; - - while (node != null) - { - // DBG - //Console.WriteLine($"# Node: {node.Current.Name}"); - - bool result = true; - foreach (var c in searchConditions) - { - object p = node.GetCurrentPropertyValue(c.Property); - - switch (c.Property.ProgrammaticName) - { - case "AutomationElementIdentifiers.ControlTypeProperty": - // ControlType compare - result &= (c.Value.ToString() == ((ControlType)p).Id.ToString()); - // DBG - //Console.WriteLine($"Property: '{c.Property.ProgrammaticName}', Value Cond: '{c.Value.ToString()}', Value Node: '{((ControlType)p).Id.ToString()}'"); - break; - - default: - // normal compare - result &= (c.Value.ToString() == p.ToString()); - // DBG - //Console.WriteLine($"Property: '{c.Property.ProgrammaticName}', Value Cond: '{c.Value.ToString()}', Value Node: '{p.ToString()}'"); - break; - } - - if (!result) - { - break; - } - } - - if (result) - { - ret = node; - break; - } - // Time up! not found. - if (DateTime.Now > endTime) - { - break; - } - - // search child node - if (walker.GetFirstChild(node) != null) - { - ret = WalkerSearch_DepthFirst(node, searchConditions, walker, endTime); - if (ret != null) - { - break; - } - } - - // next sibling - node = walker.GetNextSibling(node); - } - - return ret; - } - - /// - /// Search GUI Element used by TreeWalker (Depth First, Reverse) - /// - /// - /// - /// - /// - /// - private static AutomationElement WalkerSearch_DepthFirst_Reverse(AutomationElement rootElement, PropertyCondition[] searchConditions, TreeWalker walker, DateTime endTime) - { - AutomationElement node = walker.GetLastChild(rootElement); - AutomationElement ret = null; - - while (node != null) - { - // DBG - //Console.WriteLine($"# Node: {node.Current.Name}"); - - bool result = true; - foreach (var c in searchConditions) - { - object p = node.GetCurrentPropertyValue(c.Property); - - switch (c.Property.ProgrammaticName) - { - case "AutomationElementIdentifiers.ControlTypeProperty": - // ControlType compare - result &= (c.Value.ToString() == ((ControlType)p).Id.ToString()); - // DBG - //Console.WriteLine($"Property: '{c.Property.ProgrammaticName}', Value Cond: '{c.Value.ToString()}', Value Node: '{((ControlType)p).Id.ToString()}'"); - break; - - default: - // normal compare - result &= (c.Value.ToString() == p.ToString()); - // DBG - //Console.WriteLine($"Property: '{c.Property.ProgrammaticName}', Value Cond: '{c.Value.ToString()}', Value Node: '{p.ToString()}'"); - break; - } - - if (!result) - { - break; - } - } - - if (result) - { - ret = node; - break; - } - // Time up! not found. - if (DateTime.Now > endTime) - { - break; - } - - // search child node - if (walker.GetLastChild(node) != null) - { - ret = WalkerSearch_DepthFirst_Reverse(node, searchConditions, walker, endTime); - if (ret != null) - { - break; - } - } - - // previous sibling - node = walker.GetPreviousSibling(node); - } - - return ret; - } - - /// - /// Search GUI Element by specified conditions DataTable - /// - /// - /// - /// - /// - private static AutomationElement SearchGUIElement(AutomationElement rootElement, DataTable conditionTable, Engine.AutomationEngineInstance engine, DateTime endTime) - { - Condition searchConditions = CreateSearchCondition(conditionTable, engine); - - // NOTE: stop hung up - //var element = rootElement.FindFirst(TreeScope.Descendants, searchConditions) ?? - // rootElement.FindFirst(TreeScope.Subtree, searchConditions) ?? - // DeepSearchGUIElement(rootElement, searchConditions); - - var element = DeepSearchGUIElement(rootElement, searchConditions, endTime); - - // if element not found, don't throw exception here - return element; - } - - /// - /// Search GUI Element from specified arguments - /// - /// - /// - /// - /// - /// - /// - public static AutomationElement SearchGUIElement(AutomationElement elem, DataTable conditionTable, int waitTime, Engine.AutomationEngineInstance engine) - { - var ret = WaitControls.WaitProcess(waitTime, "AutomationElement", - new Func<(bool, object)>(() => - { - var endTime = DateTime.Now.AddSeconds(waitTime); - var e = SearchGUIElement(elem, conditionTable, engine, endTime); - if (e != null) - { - return (true, e); - } - else - { - return (false, null); - } - }), engine - ); - if (ret is AutomationElement foundElem) - { - return foundElem; - } - else - { - throw new Exception("AutomationElement Not Found"); - } - } - - /// - /// Search GUI Element from specified parameter names - /// - /// - /// - /// - /// - /// - /// - /// - public static AutomationElement SearchGUIElement(ScriptCommand command, string elementName, string conditionName, string waitTimeName, Engine.AutomationEngineInstance engine) - { - var elem = command.ExpandUserVariableAsUIElement(elementName, engine); - var table = command.ConvertParameterToDataTable(conditionName, engine); - var waitTime = command.ExpandValueOrUserVariableAsInteger(waitTimeName, engine); - - return SearchGUIElement(elem, table, waitTime, engine); - } - - /// - /// Search GUI Element. this method use VirtualProperty to get parameter names - /// - /// - /// - /// - public static AutomationElement SearchGUIElement(ScriptCommand command, Engine.AutomationEngineInstance engine) - { - var elementName = PropertyControls.GetProperty(command, new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_InputUIElementName)))?.Name ?? ""; - var conditionName = PropertyControls.GetProperty(command, new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_SearchParameters)))?.Name ?? ""; - var waitTimeName = PropertyControls.GetProperty(command, new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_WaitTime))).Name ?? ""; - - return SearchGUIElement(command, elementName, conditionName, waitTimeName, engine); - } + // default: + // return new AndCondition(conditionList.ToArray()); // 2+ conditions + // } + //} + + ///// + ///// Deep Search GUI Element by Specified Condition + ///// + ///// + ///// + ///// + //private static AutomationElement DeepSearchGUIElement(AutomationElement rootElement, Condition searchCondition, DateTime endTime) + //{ + // TreeWalker walker = TreeWalker.RawViewWalker; + + // // format conditions + // PropertyCondition[] conditions; + // if (searchCondition is AndCondition andConds) + // { + // conditions = andConds.GetConditions().Cast().ToArray(); + // } + // else + // { + // conditions = new PropertyCondition[1] + // { + // (PropertyCondition)searchCondition + // }; + // } + + // var ret = WalkerSearch_DepthFirst(rootElement, conditions, walker, endTime); + // //var ret = WalkerSearch_WidthFirst_Reverse(rootElement, conditions, walker, endTime); + // return ret; + //} + + ///// + ///// Search GUI Element used by TreeWalker (Depth First) + ///// + ///// + ///// + ///// + ///// + //private static AutomationElement WalkerSearch_DepthFirst(AutomationElement rootElement, PropertyCondition[] searchConditions, TreeWalker walker, DateTime endTime) + //{ + // AutomationElement node = walker.GetFirstChild(rootElement); + // AutomationElement ret = null; + + // while (node != null) + // { + // // DBG + // //Console.WriteLine($"# Node: {node.Current.Name}"); + + // bool result = true; + // foreach (var c in searchConditions) + // { + // object p = node.GetCurrentPropertyValue(c.Property); + + // switch (c.Property.ProgrammaticName) + // { + // case "AutomationElementIdentifiers.ControlTypeProperty": + // // ControlType compare + // result &= (c.Value.ToString() == ((ControlType)p).Id.ToString()); + // // DBG + // //Console.WriteLine($"Property: '{c.Property.ProgrammaticName}', Value Cond: '{c.Value.ToString()}', Value Node: '{((ControlType)p).Id.ToString()}'"); + // break; + + // default: + // // normal compare + // result &= (c.Value.ToString() == p.ToString()); + // // DBG + // //Console.WriteLine($"Property: '{c.Property.ProgrammaticName}', Value Cond: '{c.Value.ToString()}', Value Node: '{p.ToString()}'"); + // break; + // } + + // if (!result) + // { + // break; + // } + // } + + // if (result) + // { + // ret = node; + // break; + // } + // // Time up! not found. + // if (DateTime.Now > endTime) + // { + // break; + // } + + // // search child node + // if (walker.GetFirstChild(node) != null) + // { + // ret = WalkerSearch_DepthFirst(node, searchConditions, walker, endTime); + // if (ret != null) + // { + // break; + // } + // } + + // // next sibling + // node = walker.GetNextSibling(node); + // } + + // return ret; + //} + + ///// + ///// Search GUI Element used by TreeWalker (Depth First, Reverse) + ///// + ///// + ///// + ///// + ///// + ///// + //private static AutomationElement WalkerSearch_DepthFirst_Reverse(AutomationElement rootElement, PropertyCondition[] searchConditions, TreeWalker walker, DateTime endTime) + //{ + // AutomationElement node = walker.GetLastChild(rootElement); + // AutomationElement ret = null; + + // while (node != null) + // { + // // DBG + // //Console.WriteLine($"# Node: {node.Current.Name}"); + + // bool result = true; + // foreach (var c in searchConditions) + // { + // object p = node.GetCurrentPropertyValue(c.Property); + + // switch (c.Property.ProgrammaticName) + // { + // case "AutomationElementIdentifiers.ControlTypeProperty": + // // ControlType compare + // result &= (c.Value.ToString() == ((ControlType)p).Id.ToString()); + // // DBG + // //Console.WriteLine($"Property: '{c.Property.ProgrammaticName}', Value Cond: '{c.Value.ToString()}', Value Node: '{((ControlType)p).Id.ToString()}'"); + // break; + + // default: + // // normal compare + // result &= (c.Value.ToString() == p.ToString()); + // // DBG + // //Console.WriteLine($"Property: '{c.Property.ProgrammaticName}', Value Cond: '{c.Value.ToString()}', Value Node: '{p.ToString()}'"); + // break; + // } + + // if (!result) + // { + // break; + // } + // } + + // if (result) + // { + // ret = node; + // break; + // } + // // Time up! not found. + // if (DateTime.Now > endTime) + // { + // break; + // } + + // // search child node + // if (walker.GetLastChild(node) != null) + // { + // ret = WalkerSearch_DepthFirst_Reverse(node, searchConditions, walker, endTime); + // if (ret != null) + // { + // break; + // } + // } + + // // previous sibling + // node = walker.GetPreviousSibling(node); + // } + + // return ret; + //} + + ///// + ///// Search GUI Element by specified conditions DataTable + ///// + ///// + ///// + ///// + ///// + //private static AutomationElement SearchGUIElement(AutomationElement rootElement, DataTable conditionTable, Engine.AutomationEngineInstance engine, DateTime endTime) + //{ + // Condition searchConditions = CreateSearchCondition(conditionTable, engine); + + // // NOTE: stop hung up + // //var element = rootElement.FindFirst(TreeScope.Descendants, searchConditions) ?? + // // rootElement.FindFirst(TreeScope.Subtree, searchConditions) ?? + // // DeepSearchGUIElement(rootElement, searchConditions); + + // var element = DeepSearchGUIElement(rootElement, searchConditions, endTime); + + // // if element not found, don't throw exception here + // return element; + //} + + ///// + ///// Search GUI Element from specified arguments + ///// + ///// + ///// + ///// + ///// + ///// + ///// + //public static AutomationElement SearchGUIElement(AutomationElement elem, DataTable conditionTable, int waitTime, Engine.AutomationEngineInstance engine) + //{ + // var ret = WaitControls.WaitProcess(waitTime, "AutomationElement", + // new Func<(bool, object)>(() => + // { + // var endTime = DateTime.Now.AddSeconds(waitTime); + // var e = SearchGUIElement(elem, conditionTable, engine, endTime); + // if (e != null) + // { + // return (true, e); + // } + // else + // { + // return (false, null); + // } + // }), engine + // ); + // if (ret is AutomationElement foundElem) + // { + // return foundElem; + // } + // else + // { + // throw new Exception("AutomationElement Not Found"); + // } + //} + + ///// + ///// Search GUI Element from specified parameter names + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + //public static AutomationElement SearchGUIElement(ScriptCommand command, string elementName, string conditionName, string waitTimeName, Engine.AutomationEngineInstance engine) + //{ + // var elem = command.ExpandUserVariableAsUIElement(elementName, engine); + // var table = command.ConvertParameterToDataTable(conditionName, engine); + // var waitTime = command.ExpandValueOrUserVariableAsInteger(waitTimeName, engine); + + // return SearchGUIElement(elem, table, waitTime, engine); + //} + + ///// + ///// Search GUI Element. this method use VirtualProperty to get parameter names + ///// + ///// + ///// + ///// + //public static AutomationElement SearchGUIElement(ScriptCommand command, Engine.AutomationEngineInstance engine) + //{ + // var elementName = PropertyControls.GetProperty(command, new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_InputUIElementName)))?.Name ?? ""; + // var conditionName = PropertyControls.GetProperty(command, new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_SearchParameters)))?.Name ?? ""; + // var waitTimeName = PropertyControls.GetProperty(command, new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_WaitTime))).Name ?? ""; + + // return SearchGUIElement(command, elementName, conditionName, waitTimeName, engine); + //} #endregion - #region Winodow Search Methods - - /// - /// get window UIElement. this method use PropertyVirtualProperty - /// - /// - /// - /// - /// - public static AutomationElement GetWindowUIElement(ScriptCommand command, Engine.AutomationEngineInstance engine, string resultName = "") - { - AutomationElement ret = null; - - WindowControls.WindowAction(command, engine, - new Action>(wins => - { - ret = AutomationElement.FromHandle(wins[0].Item1); - - if (!string.IsNullOrEmpty(resultName)) - { - //var resultValue = command.ConvertToUserVariable(resultName, "Result", engine); - var resultValue = command.GetRawPropertyValueAsString(resultName, "Result"); - - ret.StoreInUserVariable(engine, resultValue); - } - }) - ); - - return ret; - } - - /// - /// get window UIElement - /// - /// - /// - /// - public static AutomationElement GetWindowUIElement(ScriptCommand command, Engine.AutomationEngineInstance engine) - { - var resultName = command.GetProperty(new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_OutputUIElementName)))?.Name ?? ""; - - return GetWindowUIElement(command, engine, resultName); - } - #endregion - #region search element node - public static List GetChildrenUIElements(AutomationElement rootElement, DataTable conditionTable, Engine.AutomationEngineInstance engine) - { - Condition searchConditions = CreateSearchCondition(conditionTable, engine); - - if (searchConditions != null) - { - AutomationElementCollection elements = rootElement.FindAll(TreeScope.Children, searchConditions); - - // if element not found, don't throw exception here - List ret = new List(); - foreach (AutomationElement element in elements) - { - ret.Add(element); - } - return ret; - } - else - { - return GetAllChildrenUIElements(rootElement); - } - } - - private static List GetAllChildrenUIElements(AutomationElement rootElement) - { - TreeWalker walker = TreeWalker.RawViewWalker; - - var elems = new List(); - - var node = walker.GetFirstChild(rootElement); - while (node != null) - { - elems.Add(node); - node = walker.GetNextSibling(node); - } - - return elems; - } - - /// - /// get parent element - /// - /// - /// - /// - public static AutomationElement GetParentUIElement(AutomationElement targetElement) - { - TreeWalker walker = TreeWalker.RawViewWalker; - - var parent = walker.GetParent(targetElement); - if (parent != null) - { - return parent; - } - else - { - throw new Exception("Parent UIElement not exists"); - } - } - - /// - /// get window name from UIElement - /// - /// - /// - public static string GetWindowName(AutomationElement targetElement) - { - TreeWalker walker = TreeWalker.RawViewWalker; - - if (targetElement.Current.ControlType == ControlType.Window) - { - return targetElement.Current.Name; - } - - try - { - var parent = walker.GetParent(targetElement); - while (parent.Current.ControlType != ControlType.Window) - { - parent = walker.GetParent(parent); - } - return parent.Current.Name; - } - catch - { - // try other method - var windowNames = WindowControls.GetAllWindowTitles(); - if ((targetElement.Current.NativeWindowHandle != 0) && (windowNames.Contains(targetElement.Current.Name))) - { - return targetElement.Current.Name; - } - - try - { - var parent = walker.GetParent(targetElement); - while((parent.Current.NativeWindowHandle == 0) || (!windowNames.Contains(parent.Current.Name))) - { - parent = walker.GetParent(parent); - } - return parent.Current.Name; - } - catch - { - throw new Exception("Fail Get Window Name from UIElement"); - } - } - } - - /// - /// get window handle from UIElement - /// - /// - /// - public static int GetWindowHandle(AutomationElement targetElement) - { - TreeWalker walker = TreeWalker.RawViewWalker; - - var hnd = targetElement.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty); - if(hnd != AutomationElement.NotSupported) - { - return (int)hnd; - } - - var parent = walker.GetParent(targetElement); - while (true) - { - hnd = parent.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty); - if (hnd != AutomationElement.NotSupported) - { - return (int)hnd; - } - parent = walker.GetParent(parent); - } - } + //public static List GetChildrenUIElements(AutomationElement rootElement, DataTable conditionTable, Engine.AutomationEngineInstance engine) + //{ + // Condition searchConditions = CreateSearchCondition(conditionTable, engine); + + // if (searchConditions != null) + // { + // AutomationElementCollection elements = rootElement.FindAll(TreeScope.Children, searchConditions); + + // // if element not found, don't throw exception here + // List ret = new List(); + // foreach (AutomationElement element in elements) + // { + // ret.Add(element); + // } + // return ret; + // } + // else + // { + // return GetAllChildrenUIElements(rootElement); + // } + //} + + //private static List GetAllChildrenUIElements(AutomationElement rootElement) + //{ + // TreeWalker walker = TreeWalker.RawViewWalker; + + // var elems = new List(); + + // var node = walker.GetFirstChild(rootElement); + // while (node != null) + // { + // elems.Add(node); + // node = walker.GetNextSibling(node); + // } + + // return elems; + //} + + ///// + ///// get parent element + ///// + ///// + ///// + ///// + //public static AutomationElement GetParentUIElement(AutomationElement targetElement) + //{ + // TreeWalker walker = TreeWalker.RawViewWalker; + + // var parent = walker.GetParent(targetElement); + // if (parent != null) + // { + // return parent; + // } + // else + // { + // throw new Exception("Parent UIElement not exists"); + // } + //} + + ///// + ///// get window name from UIElement + ///// + ///// + ///// + //public static string GetWindowName(AutomationElement targetElement) + //{ + // TreeWalker walker = TreeWalker.RawViewWalker; + + // if (targetElement.Current.ControlType == ControlType.Window) + // { + // return targetElement.Current.Name; + // } + + // try + // { + // var parent = walker.GetParent(targetElement); + // while (parent.Current.ControlType != ControlType.Window) + // { + // parent = walker.GetParent(parent); + // } + // return parent.Current.Name; + // } + // catch + // { + // // try other method + // var windowNames = WindowControls.GetAllWindowTitles(); + // if ((targetElement.Current.NativeWindowHandle != 0) && (windowNames.Contains(targetElement.Current.Name))) + // { + // return targetElement.Current.Name; + // } + + // try + // { + // var parent = walker.GetParent(targetElement); + // while((parent.Current.NativeWindowHandle == 0) || (!windowNames.Contains(parent.Current.Name))) + // { + // parent = walker.GetParent(parent); + // } + // return parent.Current.Name; + // } + // catch + // { + // throw new Exception("Fail Get Window Name from UIElement"); + // } + // } + //} #endregion - public static string GetTextValue(AutomationElement targetElement) - { - //object patternObj; - if (targetElement.TryGetCurrentPattern(RangeValuePattern.Pattern, out object rPtn)) - { - // bar - return ((RangeValuePattern)rPtn).Current.Value.ToString(); - } - else if (targetElement.TryGetCurrentPattern(ValuePattern.Pattern, out object vPtn)) - { - // TextBox - return ((ValuePattern)vPtn).Current.Value; - } - else if (targetElement.TryGetCurrentPattern(TextPattern.Pattern, out object tPtn)) - { - // TextBox Multilune - return ((TextPattern)tPtn).DocumentRange.GetText(-1); - } - else if (targetElement.TryGetCurrentPattern(SelectionPattern.Pattern, out object sPtn)) - { - // combobox - AutomationElement selElem = ((SelectionPattern)sPtn).Current.GetSelection()[0]; - return selElem.Current.Name; - } - else - { - // others - return targetElement.Current.Name; - } - } - - public static AutomationElement GetTableUIElement(AutomationElement targetElement, int row, int column) - { - if (targetElement.TryGetCurrentPattern(GridPattern.Pattern, out object gridObj)) - { - var cosutomRows = targetElement.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom)); - if (cosutomRows.Count > 0) - { - // DataGridView (.net) - if (cosutomRows.Count > row) - { - var r = cosutomRows[row + 1]; - var cols = r.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit)); - if (cols.Count > column) - { - return cols[column]; - } - } - - throw new Exception("Table Row: '" + row + "', Column: '" + column + "' does not exists"); - } - else - { - // listView - AutomationElement cellElem = ((GridPattern)gridObj).GetItem(row, column); - if (cellElem == null) - { - throw new Exception("Table Row: '" + row + "', Column: '" + column + "' does not exists"); - } - return cellElem; - } - } - else - { - throw new Exception("UIElement is not Table Element"); - } - } - - public static List GetSelectionItems(AutomationElement targetElement) - { - var getListItemFunc = new Func>( el => { - var elems = el.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.IsSelectionItemPatternAvailableProperty, true)); - List ret = new List(); - foreach (AutomationElement elem in elems) - { - ret.Add(elem); - } - return ret; - }); - - AutomationElement rootElement = targetElement; - - if ((bool)rootElement.GetCurrentPropertyValue(AutomationElement.IsGridPatternAvailableProperty) || - (bool)rootElement.GetCurrentPropertyValue(AutomationElement.IsSelectionPatternAvailableProperty)) - { - // DataGridView-ComboBox, ListBox - return getListItemFunc(rootElement); - } - else - { - // ComboBox, TreeView - bool isCmb = (bool)rootElement.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty); - - if (!isCmb) - { - rootElement = GetParentUIElement(rootElement); - isCmb = (bool)rootElement.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty); - } - - if ((bool)isCmb) - { - object selPtn = rootElement.GetCurrentPattern(ExpandCollapsePattern.Pattern); - - ExpandCollapsePattern ecPtn = (ExpandCollapsePattern)selPtn; - ecPtn.Expand(); - System.Threading.Thread.Sleep(500); - - // dbg - //System.Threading.Thread.Sleep(1000); - //Console.WriteLine("Expanded"); - - var ret = getListItemFunc(rootElement); - - //if (collapseAfter) - //{ - // ecPtn.Collapse(); - //} - return ret; - } - else - { - throw new Exception("This UIElement does not have Selection Items"); - } - } - } + //public static string GetTextValue(AutomationElement targetElement) + //{ + // //object patternObj; + // if (targetElement.TryGetCurrentPattern(RangeValuePattern.Pattern, out object rPtn)) + // { + // // bar + // return ((RangeValuePattern)rPtn).Current.Value.ToString(); + // } + // else if (targetElement.TryGetCurrentPattern(ValuePattern.Pattern, out object vPtn)) + // { + // // TextBox + // return ((ValuePattern)vPtn).Current.Value; + // } + // else if (targetElement.TryGetCurrentPattern(TextPattern.Pattern, out object tPtn)) + // { + // // TextBox Multilune + // return ((TextPattern)tPtn).DocumentRange.GetText(-1); + // } + // else if (targetElement.TryGetCurrentPattern(SelectionPattern.Pattern, out object sPtn)) + // { + // // combobox + // AutomationElement selElem = ((SelectionPattern)sPtn).Current.GetSelection()[0]; + // return selElem.Current.Name; + // } + // else + // { + // // others + // return targetElement.Current.Name; + // } + //} + + //public static AutomationElement GetTableUIElement(AutomationElement targetElement, int row, int column) + //{ + // if (targetElement.TryGetCurrentPattern(GridPattern.Pattern, out object gridObj)) + // { + // var cosutomRows = targetElement.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom)); + // if (cosutomRows.Count > 0) + // { + // // DataGridView (.net) + // if (cosutomRows.Count > row) + // { + // var r = cosutomRows[row + 1]; + // var cols = r.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit)); + // if (cols.Count > column) + // { + // return cols[column]; + // } + // } + + // throw new Exception($"Table Row: '{row}', Column: '{column}' does not exists"); + // } + // else + // { + // // listView + // AutomationElement cellElem = ((GridPattern)gridObj).GetItem(row, column); + // if (cellElem == null) + // { + // throw new Exception($"Table Row: '{row}', Column: '{column}' does not exists"); + // } + // return cellElem; + // } + // } + // else + // { + // throw new Exception("UIElement is not Table Element"); + // } + //} + + //public static List GetSelectionItems(AutomationElement targetElement) + //{ + // var getListItemFunc = new Func>( el => { + // var elems = el.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.IsSelectionItemPatternAvailableProperty, true)); + // List ret = new List(); + // foreach (AutomationElement elem in elems) + // { + // ret.Add(elem); + // } + // return ret; + // }); + + // AutomationElement rootElement = targetElement; + + // if ((bool)rootElement.GetCurrentPropertyValue(AutomationElement.IsGridPatternAvailableProperty) || + // (bool)rootElement.GetCurrentPropertyValue(AutomationElement.IsSelectionPatternAvailableProperty)) + // { + // // DataGridView-ComboBox, ListBox + // return getListItemFunc(rootElement); + // } + // else + // { + // // ComboBox, TreeView + // bool isCmb = (bool)rootElement.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty); + + // if (!isCmb) + // { + // rootElement = GetParentUIElement(rootElement); + // isCmb = (bool)rootElement.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty); + // } + + // if ((bool)isCmb) + // { + // object selPtn = rootElement.GetCurrentPattern(ExpandCollapsePattern.Pattern); + + // ExpandCollapsePattern ecPtn = (ExpandCollapsePattern)selPtn; + // ecPtn.Expand(); + // System.Threading.Thread.Sleep(500); + + // // dbg + // //System.Threading.Thread.Sleep(1000); + // //Console.WriteLine("Expanded"); + + // var ret = getListItemFunc(rootElement); + + // //if (collapseAfter) + // //{ + // // ecPtn.Collapse(); + // //} + // return ret; + // } + // else + // { + // throw new Exception("This UIElement does not have Selection Items"); + // } + // } + //} #region create XElement methods - public static (XElement, Dictionary) GetElementXml(AutomationElement targetElement) - { - XElement root = CreateXmlElement(targetElement); - - var dic = new Dictionary() - { - { root.GetHashCode().ToString(), targetElement } - }; - - TreeWalker walker = TreeWalker.RawViewWalker; - - GetChildNodeFromElement(root, targetElement, dic, walker); - - return (root, dic); - } - - private static XElement GetChildNodeFromElement(XElement rootNode, AutomationElement rootElement, Dictionary elemsDic, TreeWalker walker) - { - var node = walker.GetFirstChild(rootElement); - while (node != null) - { - string hash = node.GetHashCode().ToString(); - if (elemsDic.ContainsKey(hash)) - { - int i = 1; - while(elemsDic.ContainsKey(hash + "-" + i)) - { - i++; - } - hash += "-" + i; - } - - var childNode = CreateXmlElement(node, hash); - rootNode.Add(childNode); - elemsDic.Add(hash, node); - - if (walker.GetFirstChild(node) != null) - { - GetChildNodeFromElement(childNode, node, elemsDic, walker); - } - - node = walker.GetNextSibling(node); - } - - return rootNode; - } - - private static XElement CreateXmlElement(AutomationElement targetElement, string hash = "") - { - XElement node = new XElement(GetControlTypeText(targetElement.Current.ControlType)); - - var tp = targetElement.Current.GetType(); - - foreach(var t in TargetControlTypes) - { - node.SetAttributeValue(t, tp.GetProperty(t)?.GetValue(targetElement.Current)?.ToString() ?? ""); - } - - node.SetAttributeValue("Hash", (hash == "") ? targetElement.GetHashCode().ToString() : hash); + //public static (XElement, Dictionary) GetElementXml(AutomationElement targetElement) + //{ + // XElement root = CreateXmlElement(targetElement); + + // var dic = new Dictionary() + // { + // { root.GetHashCode().ToString(), targetElement } + // }; + + // TreeWalker walker = TreeWalker.RawViewWalker; + + // GetChildNodeFromElement(root, targetElement, dic, walker); + + // return (root, dic); + //} + + //private static XElement GetChildNodeFromElement(XElement rootNode, AutomationElement rootElement, Dictionary elemsDic, TreeWalker walker) + //{ + // var node = walker.GetFirstChild(rootElement); + // while (node != null) + // { + // string hash = node.GetHashCode().ToString(); + // if (elemsDic.ContainsKey(hash)) + // { + // int i = 1; + // while(elemsDic.ContainsKey(hash + "-" + i)) + // { + // i++; + // } + // hash += "-" + i; + // } + + // var childNode = CreateXmlElement(node, hash); + // rootNode.Add(childNode); + // elemsDic.Add(hash, node); + + // if (walker.GetFirstChild(node) != null) + // { + // GetChildNodeFromElement(childNode, node, elemsDic, walker); + // } + + // node = walker.GetNextSibling(node); + // } + + // return rootNode; + //} + + //private static XElement CreateXmlElement(AutomationElement targetElement, string hash = "") + //{ + // XElement node = new XElement(GetControlTypeText(targetElement.Current.ControlType)); + + // var tp = targetElement.Current.GetType(); + + // foreach (var t in TargetControlTypes) + // { + // node.SetAttributeValue(t, tp.GetProperty(t)?.GetValue(targetElement.Current)?.ToString() ?? ""); + // } + + // node.SetAttributeValue("Hash", (hash == "") ? targetElement.GetHashCode().ToString() : hash); - return node; - } + // return node; + //} #endregion #region AutomationElement XPath search methods - public static AutomationElement SearchGUIElementByXPath(AutomationElement rootElement, string xpath, int waitTime, Engine.AutomationEngineInstance engine) - { - object ret; - ret = WaitControls.WaitProcess(waitTime, "AutomationElement", - new Func<(bool, object)>(() => - { - (var xml, var dic) = GetElementXml(rootElement); + //public static AutomationElement SearchGUIElementByXPath(AutomationElement rootElement, string xpath, int waitTime, Engine.AutomationEngineInstance engine) + //{ + // object ret; + // ret = WaitControls.WaitProcess(waitTime, "AutomationElement", + // new Func<(bool, object)>(() => + // { + // (var xml, var dic) = GetElementXml(rootElement); - var e = xml.XPathSelectElement(xpath) ?? null; + // var e = xml.XPathSelectElement(xpath) ?? null; - if (e != null) - { - return (true, dic[e.Attribute("Hash").Value]); - } - else - { - return (false, null); - } - }), engine - ); - - if (ret is AutomationElement elem) - { - return elem; - } - else - { - throw new Exception("UIElement not Found"); - } - } + // if (e != null) + // { + // return (true, dic[e.Attribute("Hash").Value]); + // } + // else + // { + // return (false, null); + // } + // }), engine + // ); + + // if (ret is AutomationElement elem) + // { + // return elem; + // } + // else + // { + // throw new Exception("UIElement not Found"); + // } + //} + + //public static AutomationElement SearchGUIElementByXPath(ScriptCommand command, string rootElementName, string xpathName, string waitTimeName, Engine.AutomationEngineInstance engine) + //{ + // var element = command.ExpandUserVariableAsUIElement(rootElementName, engine); + // var xpath = command.ExpandUserVariableAsXPath(xpathName, engine); + // var wait = command.ExpandValueOrUserVariableAsInteger(waitTimeName, engine); + + // return SearchGUIElementByXPath(element, xpath, wait, engine); + //} + + //public static AutomationElement SearchGUIElementByXPath(ScriptCommand command, Engine.AutomationEngineInstance engine) + //{ + // var elemName = command.GetProperty(new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_InputUIElementName)))?.Name ?? ""; + // var xpathName = command.GetProperty(new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_XPath)))?.Name ?? ""; + // var waitTimeName = command.GetProperty(new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_WaitTime)))?.Name ?? ""; + + // return SearchGUIElementByXPath(command, elemName, xpathName, waitTimeName, engine); + //} - public static AutomationElement SearchGUIElementByXPath(ScriptCommand command, string rootElementName, string xpathName, string waitTimeName, Engine.AutomationEngineInstance engine) - { - var element = command.ExpandUserVariableAsUIElement(rootElementName, engine); - var xpath = command.ExpandUserVariableAsXPath(xpathName, engine); - var wait = command.ExpandValueOrUserVariableAsInteger(waitTimeName, engine); + #endregion - return SearchGUIElementByXPath(element, xpath, wait, engine); - } + //public static TreeNode GetElementTreeNode(string windowName, Engine.AutomationEngineInstance engine, out XElement xml) + //{ + // // cache request + // var cacheReq = new CacheRequest(); + // cacheReq.Add(AutomationElement.NameProperty); + // cacheReq.Add(AutomationElement.ControlTypeProperty); + // cacheReq.Add(AutomationElement.LocalizedControlTypeProperty); + // cacheReq.TreeScope = TreeScope.Element | TreeScope.Children; - public static AutomationElement SearchGUIElementByXPath(ScriptCommand command, Engine.AutomationEngineInstance engine) - { - var elemName = command.GetProperty(new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_InputUIElementName)))?.Name ?? ""; - var xpathName = command.GetProperty(new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_XPath)))?.Name ?? ""; - var waitTimeName = command.GetProperty(new PropertyVirtualProperty(nameof(UIElementControls), nameof(v_WaitTime)))?.Name ?? ""; + // var root = GetFromWindowName(windowName, engine); - return SearchGUIElementByXPath(command, elemName, xpathName, waitTimeName, engine); - } + // cacheReq.Push(); - #endregion + // var walker = TreeWalker.RawViewWalker; - public static TreeNode GetElementTreeNode(string windowName, Engine.AutomationEngineInstance engine, out XElement xml) - { - AutomationElement root = GetFromWindowName(windowName, engine); + // var tree = CreateTreeNodeFromAutomationElement(root); + // xml = CreateXmlElement(root); - TreeWalker walker = TreeWalker.RawViewWalker; + // GetChildElementTreeNode(tree, xml, root, walker, cacheReq, 1, engine); - var tree = CreateTreeNodeFromAutomationElement(root); - xml = CreateXmlElement(root); + // cacheReq.Pop(); - GetChildElementTreeNode(tree, xml, root, walker, 1, engine); + // return tree; + //} - return tree; - } + //private static void GetChildElementTreeNode(TreeNode tree, XElement xml, AutomationElement rootElement, TreeWalker walker, CacheRequest cacheRequest, int depth, Engine.AutomationEngineInstance engine) + //{ + // var node = walker.GetFirstChild(rootElement, cacheRequest); + // //var node = walker.GetLastChild(rootElement); - private static void GetChildElementTreeNode(TreeNode tree, XElement xml, AutomationElement rootElement, TreeWalker walker, int depth, Engine.AutomationEngineInstance engine) - { - AutomationElement node = walker.GetFirstChild(rootElement); - - int siblingCount = 0; - while(node != null) - { - var item = CreateTreeNodeFromAutomationElement(node); - tree.Nodes.Add(item); - - var childXml = CreateXmlElement(node); - xml.Add(childXml); - - if ((walker.GetFirstChild(node) != null) && (depth < engine.engineSettings.MaxUIElementInpectDepth)) - { - GetChildElementTreeNode(item, childXml, node, walker, (depth + 1), engine); - } - - siblingCount++; - if (siblingCount >= engine.engineSettings.MaxUIElementInspectSiblingNodes) - { - break; - } - - node = walker.GetNextSibling(node); - } - } - + // int siblingCount = 0; + // while(node != null) + // { + // var item = CreateTreeNodeFromAutomationElement(node); + // tree.Nodes.Add(item); - private static TreeNode CreateTreeNodeFromAutomationElement(AutomationElement element) - { - TreeNode node = new TreeNode(); - node.Text = "\"" + element.Current.Name + "\" " + element.Current.LocalizedControlType; - node.Tag = element; - return node; - } + // var childXml = CreateXmlElement(node); + // xml.Add(childXml); - public static string GetInspectResultFromAutomationElement(AutomationElement elem) - { - string res = ""; - - try - { - res += "Name:\t\"" + elem.Current.Name + "\"\r\n"; - res += "ControlType:\t" + GetControlTypeText(elem.Current.ControlType) + "\r\n"; - res += "LocalizedControlType:\t\"" + elem.Current.LocalizedControlType + "\"\r\n"; - res += "IsEnabled:\t" + elem.Current.IsEnabled.ToString() + "\r\n"; - res += "IsOffscreen:\t" + elem.Current.IsOffscreen.ToString() + "\r\n"; - res += "IsKeyboardFocusable:\t" + elem.Current.IsKeyboardFocusable.ToString() + "\r\n"; - res += "HasKeyboardFocusable:\t" + elem.Current.HasKeyboardFocus.ToString() + "\r\n"; - res += "AccessKey:\t\"" + elem.Current.AccessKey + "\"\r\n"; - res += "ProcessId:\t" + elem.Current.ProcessId.ToString() + "\r\n"; - res += "AutomationId:\t\"" + elem.Current.AutomationId + "\"\r\n"; - res += "FrameworkId:\t\"" + elem.Current.FrameworkId + "\"\r\n"; - res += "ClassName:\t\"" + elem.Current.ClassName + "\"\r\n"; - res += "IsContentElement:\t" + elem.Current.IsContentElement.ToString() + "\r\n"; - res += "IsPassword:\t" + elem.Current.IsPassword.ToString() + "\r\n"; - - res += "AcceleratorKey:\t\"" + elem.Current.AcceleratorKey + "\"\r\n"; - res += "HelpText:\t\"" + elem.Current.HelpText + "\"\r\n"; - res += "IsControlElement:\t" + elem.Current.IsControlElement.ToString() + "\r\n"; - res += "IsRequiredForForm:\t" + elem.Current.IsRequiredForForm.ToString() + "\r\n"; - res += "ItemStatus:\t\"" + elem.Current.ItemStatus + "\"\r\n"; - res += "ItemType:\t\"" + elem.Current.ItemType + "\"\r\n"; - res += "NativeWindowHandle:\t" + elem.Current.NativeWindowHandle.ToString() + "\r\n"; - - res += "IsDockPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsDockPatternAvailableProperty) + "\r\n"; - res += "IsExpandCollapsePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty) + "\r\n"; - res += "IsGridPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsGridPatternAvailableProperty) + "\r\n"; - res += "IsGridItemPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsGridItemPatternAvailableProperty) + "\r\n"; - res += "IsInvokePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsInvokePatternAvailableProperty) + "\r\n"; - res += "IsMultipleViewPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsMultipleViewPatternAvailableProperty) + "\r\n"; - res += "IsRangeValuePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsRangeValuePatternAvailableProperty) + "\r\n"; - res += "IsScrollPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsScrollPatternAvailableProperty) + "\r\n"; - res += "IsScrollItemPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsScrollItemPatternAvailableProperty) + "\r\n"; - res += "IsSelectionPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsSelectionPatternAvailableProperty) + "\r\n"; - res += "IsSelectionItemPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsSelectionItemPatternAvailableProperty) + "\r\n"; - res += "IsTablePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTablePatternAvailableProperty) + "\r\n"; - res += "IsTableItemPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTableItemPatternAvailableProperty) + "\r\n"; - res += "IsTextPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTextPatternAvailableProperty) + "\r\n"; - res += "IsTogglePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTogglePatternAvailableProperty) + "\r\n"; - res += "IsTransformPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTransformPatternAvailableProperty) + "\r\n"; - res += "IsValuePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsValuePatternAvailableProperty) + "\r\n"; - res += "IsWindowPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsWindowPatternAvailableProperty) + "\r\n"; - } - catch(Exception ex) - { - res += "Error: " + ex.Message; - } - - return res; - } + // if ((walker.GetFirstChild(node, cacheRequest) != null) && (depth < engine.engineSettings.MaxUIElementInpectDepth)) + // //if ((walker.GetLastChild(node) != null) && (depth < engine.engineSettings.MaxUIElementInpectDepth)) + // { + // GetChildElementTreeNode(item, childXml, node, walker, cacheRequest, (depth + 1), engine); + // } - public static string GetXPath(XElement xml, AutomationElement elem, bool useNameAttribute = true, bool useAutomationIdAttribute = false) - { - string searchPath = "//" + GetControlTypeText(elem.Current.ControlType) + "[@Hash=\"" + elem.GetHashCode() + "\"]"; - XElement trgElement = xml.XPathSelectElement(searchPath); - - if (trgElement == null) - { - return ""; - } - - string xpath = ""; - while (trgElement.Parent != null) - { - xpath = CreateXPath(trgElement, useNameAttribute, useAutomationIdAttribute) + xpath; - trgElement = trgElement.Parent; - } - - return xpath; - } + // siblingCount++; + // if (siblingCount >= engine.engineSettings.MaxUIElementInspectSiblingNodes) + // { + // break; + // } - public static string GetXPath(XElement xml, AutomationElement trgElem, AutomationElement curElem, bool useNameAttribute = true, bool useAutomationIdAttribute = false) - { - string searchPath = "//" + GetControlTypeText(trgElem.Current.ControlType) + "[@Hash=\"" + trgElem.GetHashCode() + "\"]"; - XElement trgElement = xml.XPathSelectElement(searchPath); - - searchPath = GetControlTypeText(curElem.Current.ControlType) + "[@Hash=\"" + curElem.GetHashCode() + "\"]"; - XElement curElement = xml.XPathSelectElement("//" + searchPath); - if (curElement == null) - { - // curElem is root-window-node ? - if (xml.Attribute("Hash").Value == curElem.GetHashCode().ToString()) - { - curElement = xml; - } - } - - if ((trgElement == null) || (curElement == null)) - { - return ""; - } - - string xpath = ""; - while (trgElement.Parent != null) - { - xpath = CreateXPath(trgElement, useNameAttribute, useAutomationIdAttribute) + xpath; - trgElement = trgElement.Parent; - - if (trgElement == curElement) - { - break; - } - } - - if (trgElement == curElement) - { - return "/" + xpath; - } - else - { - return ""; - } - } - - private static string CreateXPath(XElement elemNode, bool useNameAttribute = true, bool useAutomationIdAttribute = false) - { - XElement parentNode = elemNode.Parent; + // node = walker.GetNextSibling(node, cacheRequest); + // //node = walker.GetPreviousSibling(node); + // } + //} + - string elemType = elemNode.Name.ToString(); - string elemHash = elemNode.Attribute("Hash").Value; - string xpath; + //private static TreeNode CreateTreeNodeFromAutomationElement(AutomationElement element) + //{ + // var node = new TreeNode + // { + // Text = "\"" + (element.Current.Name) + "\" " + (element.Current.LocalizedControlType), + // Tag = element + // }; + // return node; + //} + + //public static string GetInspectResultFromAutomationElement(AutomationElement elem) + //{ + // string res = ""; + + // try + // { + // res += "Name:\t\"" + elem.Current.Name + "\"\r\n"; + // res += "ControlType:\t" + GetControlTypeText(elem.Current.ControlType) + "\r\n"; + // res += "LocalizedControlType:\t\"" + elem.Current.LocalizedControlType + "\"\r\n"; + // res += "IsEnabled:\t" + elem.Current.IsEnabled.ToString() + "\r\n"; + // res += "IsOffscreen:\t" + elem.Current.IsOffscreen.ToString() + "\r\n"; + // res += "IsKeyboardFocusable:\t" + elem.Current.IsKeyboardFocusable.ToString() + "\r\n"; + // res += "HasKeyboardFocusable:\t" + elem.Current.HasKeyboardFocus.ToString() + "\r\n"; + // res += "AccessKey:\t\"" + elem.Current.AccessKey + "\"\r\n"; + // res += "ProcessId:\t" + elem.Current.ProcessId.ToString() + "\r\n"; + // res += "AutomationId:\t\"" + elem.Current.AutomationId + "\"\r\n"; + // res += "FrameworkId:\t\"" + elem.Current.FrameworkId + "\"\r\n"; + // res += "ClassName:\t\"" + elem.Current.ClassName + "\"\r\n"; + // res += "IsContentElement:\t" + elem.Current.IsContentElement.ToString() + "\r\n"; + // res += "IsPassword:\t" + elem.Current.IsPassword.ToString() + "\r\n"; + + // res += "AcceleratorKey:\t\"" + elem.Current.AcceleratorKey + "\"\r\n"; + // res += "HelpText:\t\"" + elem.Current.HelpText + "\"\r\n"; + // res += "IsControlElement:\t" + elem.Current.IsControlElement.ToString() + "\r\n"; + // res += "IsRequiredForForm:\t" + elem.Current.IsRequiredForForm.ToString() + "\r\n"; + // res += "ItemStatus:\t\"" + elem.Current.ItemStatus + "\"\r\n"; + // res += "ItemType:\t\"" + elem.Current.ItemType + "\"\r\n"; + // res += "NativeWindowHandle:\t" + elem.Current.NativeWindowHandle.ToString() + "\r\n"; + + // res += "IsDockPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsDockPatternAvailableProperty) + "\r\n"; + // res += "IsExpandCollapsePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty) + "\r\n"; + // res += "IsGridPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsGridPatternAvailableProperty) + "\r\n"; + // res += "IsGridItemPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsGridItemPatternAvailableProperty) + "\r\n"; + // res += "IsInvokePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsInvokePatternAvailableProperty) + "\r\n"; + // res += "IsMultipleViewPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsMultipleViewPatternAvailableProperty) + "\r\n"; + // res += "IsRangeValuePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsRangeValuePatternAvailableProperty) + "\r\n"; + // res += "IsScrollPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsScrollPatternAvailableProperty) + "\r\n"; + // res += "IsScrollItemPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsScrollItemPatternAvailableProperty) + "\r\n"; + // res += "IsSelectionPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsSelectionPatternAvailableProperty) + "\r\n"; + // res += "IsSelectionItemPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsSelectionItemPatternAvailableProperty) + "\r\n"; + // res += "IsTablePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTablePatternAvailableProperty) + "\r\n"; + // res += "IsTableItemPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTableItemPatternAvailableProperty) + "\r\n"; + // res += "IsTextPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTextPatternAvailableProperty) + "\r\n"; + // res += "IsTogglePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTogglePatternAvailableProperty) + "\r\n"; + // res += "IsTransformPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsTransformPatternAvailableProperty) + "\r\n"; + // res += "IsValuePatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsValuePatternAvailableProperty) + "\r\n"; + // res += "IsWindowPatternAvailableProperty:\t" + (bool)elem.GetCurrentPropertyValue(AutomationElement.IsWindowPatternAvailableProperty) + "\r\n"; + // } + // catch(Exception ex) + // { + // res += $"Error: {ex.Message}"; + // } + + // return res; + //} + + //public static string GetXPath(XElement xml, AutomationElement elem, bool useNameAttribute = true, bool useAutomationIdAttribute = false) + //{ + // string searchPath = "//" + GetControlTypeText(elem.Current.ControlType) + "[@Hash=\"" + elem.GetHashCode() + "\"]"; + // XElement trgElement = xml.XPathSelectElement(searchPath); + + // if (trgElement == null) + // { + // return ""; + // } + + // string xpath = ""; + // while (trgElement.Parent != null) + // { + // xpath = CreateXPath(trgElement, useNameAttribute, useAutomationIdAttribute) + xpath; + // trgElement = trgElement.Parent; + // } + + // return xpath; + //} + + //public static string GetXPath(XElement xml, AutomationElement trgElem, AutomationElement curElem, bool useNameAttribute = true, bool useAutomationIdAttribute = false) + //{ + // string searchPath = "//" + GetControlTypeText(trgElem.Current.ControlType) + "[@Hash=\"" + trgElem.GetHashCode() + "\"]"; + // XElement trgElement = xml.XPathSelectElement(searchPath); + + // searchPath = GetControlTypeText(curElem.Current.ControlType) + "[@Hash=\"" + curElem.GetHashCode() + "\"]"; + // XElement curElement = xml.XPathSelectElement("//" + searchPath); + // if (curElement == null) + // { + // // curElem is root-window-node ? + // if (xml.Attribute("Hash").Value == curElem.GetHashCode().ToString()) + // { + // curElement = xml; + // } + // } + + // if ((trgElement == null) || (curElement == null)) + // { + // return ""; + // } + + // string xpath = ""; + // while (trgElement.Parent != null) + // { + // xpath = CreateXPath(trgElement, useNameAttribute, useAutomationIdAttribute) + xpath; + // trgElement = trgElement.Parent; + + // if (trgElement == curElement) + // { + // break; + // } + // } + + // if (trgElement == curElement) + // { + // return "/" + xpath; + // } + // else + // { + // return ""; + // } + //} + + //private static string CreateXPath(XElement elemNode, bool useNameAttribute = true, bool useAutomationIdAttribute = false) + //{ + // XElement parentNode = elemNode.Parent; + + // string elemType = elemNode.Name.ToString(); + // string elemHash = elemNode.Attribute("Hash").Value; + // string xpath; - if (useAutomationIdAttribute && (elemNode.Attribute("AutomationId").Value != "")) - { - xpath = "/" + elemType + "[@AutomationId=\"" + SecurityElement.Escape(elemNode.Attribute("AutomationId").Value) + "\"]"; - XElement idNode = parentNode.XPathSelectElement("." + xpath); - if (idNode != null) - { - if (idNode.Attribute("Hash").Value == elemHash) - { - return xpath; - } - } - } - - if (useNameAttribute && (elemNode.Attribute("Name").Value != "")) - { - xpath = "/" + elemType + "[@Name=\"" + SecurityElement.Escape(elemNode.Attribute("Name").Value) + "\"]"; - XElement nameNode = parentNode.XPathSelectElement("." + xpath); - if (nameNode != null) - { - if (nameNode.Attribute("Hash").Value == elemHash) - { - return xpath; - } - } - } - - xpath = "/" + elemType; - IEnumerable typeNodes = parentNode.XPathSelectElements("." + xpath); - int idx = 1; - foreach(XElement nd in typeNodes) - { - if (nd.Attribute("Hash").Value == elemHash) - { - return xpath + "[" + idx + "]"; - } - idx++; - } - - throw new Exception("Fail Create UIElement XPath"); - } + // if (useAutomationIdAttribute && (elemNode.Attribute("AutomationId").Value != "")) + // { + // xpath = "/" + elemType + "[@AutomationId=\"" + SecurityElement.Escape(elemNode.Attribute("AutomationId").Value) + "\"]"; + // XElement idNode = parentNode.XPathSelectElement("." + xpath); + // if (idNode != null) + // { + // if (idNode.Attribute("Hash").Value == elemHash) + // { + // return xpath; + // } + // } + // } + + // if (useNameAttribute && (elemNode.Attribute("Name").Value != "")) + // { + // xpath = "/" + elemType + "[@Name=\"" + SecurityElement.Escape(elemNode.Attribute("Name").Value) + "\"]"; + // XElement nameNode = parentNode.XPathSelectElement("." + xpath); + // if (nameNode != null) + // { + // if (nameNode.Attribute("Hash").Value == elemHash) + // { + // return xpath; + // } + // } + // } + + // xpath = "/" + elemType; + // IEnumerable typeNodes = parentNode.XPathSelectElements("." + xpath); + // int idx = 1; + // foreach(XElement nd in typeNodes) + // { + // if (nd.Attribute("Hash").Value == elemHash) + // { + // return xpath + "[" + idx + "]"; + // } + // idx++; + // } + + // throw new Exception("Fail Create UIElement XPath"); + //} #region events - /// - /// show GUI Inspect Tool and get XPath - /// - /// - /// - public static void lnkGUIInspectTool_UsedByXPath_Click(object sender, EventArgs e) - { - using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmGUIInspect()) - { - var trgCtrl = (Control)sender; - if (fm.ShowDialog(trgCtrl.FindForm()) == DialogResult.OK) - { - object ctrl = trgCtrl.Tag; - if (ctrl is TextBox txt) - { - txt.Text = fm.XPath; - } - else if (ctrl is ComboBox cmb) - { - cmb.Text = fm.XPath; - } - else if (ctrl is DataGridView dgv) - { - dgv.CurrentCell.Value = fm.XPath; - } - } - } - } - - private static void dgvUpdateProcess(object sender, Action updateFunc) - { - var ctrl = ((Control)sender).Tag; - if (ctrl is DataGridView dgv) - { - var propName = dgv.DataBindings[0].BindingMemberInfo.BindingField; - var command = (ScriptCommand)dgv.DataBindings[0].DataSource; - var propInfo = command.GetType().GetProperty(propName); - var source = propInfo.GetValue(command); - if (source is DataTable tbl) - { - updateFunc(tbl); - RenderSearchParameterDataGridView(dgv); - } - } - } - - /// - /// show GUI InspectTool and get InspectTool like result - /// - /// - /// - public static void lnkGUIInspectTool_UsedByInspectResult_Click(object sender, EventArgs e) - { - using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmGUIInspect()) - { - if (fm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) - { - dgvUpdateProcess(sender, new Action((tbl) => - { - parseInspectToolResult(fm.InspectResult, tbl); - })); - } - } - } - - /// - /// set Empty Paramter in DGV - /// - /// - /// - public static void lnkAddEmptyParameter_Click(object sender, EventArgs e) - { - dgvUpdateProcess(sender, new Action((tbl) => - { - CreateEmptyParamters(tbl); - })); - } - - /// - /// show InspectTool Parser and set result - /// - /// - /// - public static void lnkInspectToolParser_Click(object sender, EventArgs e) - { - using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmInspectParser()) - { - if (fm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) - { - dgvUpdateProcess(sender, new Action((tbl) => - { - parseInspectToolResult(fm.inspectResult, tbl); - })); - } - } - } - - public static void UIAutomationDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) - { - var myDGV = (DataGridView)sender; - - if (e.RowIndex < 0) - { - return; - } - - if (e.ColumnIndex >= 0) - { - if (e.ColumnIndex != 1) - { - var targetCell = myDGV.Rows[e.RowIndex].Cells[1]; - if (targetCell is DataGridViewTextBoxCell) - { - myDGV.BeginEdit(false); - } - else if (targetCell is DataGridViewComboBoxCell) - { - SendKeys.Send("{F4}"); - } - } - } - else - { - myDGV.EndEdit(); - } - } - public static void UIAutomationDataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) - { - if (e.ColumnIndex == 1) - { - e.Cancel = true; - } - } + ///// + ///// show GUI Inspect Tool and get XPath + ///// + ///// + ///// + //public static void lnkGUIInspectTool_UsedByXPath_Click(object sender, EventArgs e) + //{ + // using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmGUIInspect()) + // { + // var trgCtrl = (Control)sender; + // if (fm.ShowDialog(trgCtrl.FindForm()) == DialogResult.OK) + // { + // object ctrl = trgCtrl.Tag; + // if (ctrl is TextBox txt) + // { + // txt.Text = fm.XPath; + // } + // else if (ctrl is ComboBox cmb) + // { + // cmb.Text = fm.XPath; + // } + // else if (ctrl is DataGridView dgv) + // { + // dgv.CurrentCell.Value = fm.XPath; + // } + // } + // } + //} + + //private static void dgvUpdateProcess(object sender, Action updateFunc) + //{ + // var ctrl = ((Control)sender).Tag; + // if (ctrl is DataGridView dgv) + // { + // var propName = dgv.DataBindings[0].BindingMemberInfo.BindingField; + // var command = (ScriptCommand)dgv.DataBindings[0].DataSource; + // var propInfo = command.GetType().GetProperty(propName); + // var source = propInfo.GetValue(command); + // if (source is DataTable tbl) + // { + // updateFunc(tbl); + // RenderSearchParameterDataGridView(dgv); + // } + // } + //} + + ///// + ///// show GUI InspectTool and get InspectTool like result + ///// + ///// + ///// + //public static void lnkGUIInspectTool_UsedByInspectResult_Click(object sender, EventArgs e) + //{ + // using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmGUIInspect()) + // { + // if (fm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) + // { + // dgvUpdateProcess(sender, new Action((tbl) => + // { + // parseInspectToolResult(fm.InspectResult, tbl); + // })); + // } + // } + //} + + ///// + ///// set Empty Paramter in DGV + ///// + ///// + ///// + //public static void lnkAddEmptyParameter_Click(object sender, EventArgs e) + //{ + // dgvUpdateProcess(sender, new Action((tbl) => + // { + // CreateEmptyParamters(tbl); + // })); + //} + + ///// + ///// show InspectTool Parser and set result + ///// + ///// + ///// + //public static void lnkInspectToolParser_Click(object sender, EventArgs e) + //{ + // using (var fm = new UI.Forms.ScriptBuilder.CommandEditor.Supplemental.frmInspectParser()) + // { + // if (fm.ShowDialog(((Control)sender).FindForm()) == DialogResult.OK) + // { + // dgvUpdateProcess(sender, new Action((tbl) => + // { + // parseInspectToolResult(fm.inspectResult, tbl); + // })); + // } + // } + //} + + //public static void UIAutomationDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) + //{ + // var myDGV = (DataGridView)sender; + + // if (e.RowIndex < 0) + // { + // return; + // } + + // if (e.ColumnIndex >= 0) + // { + // if (e.ColumnIndex != 1) + // { + // var targetCell = myDGV.Rows[e.RowIndex].Cells[1]; + // if (targetCell is DataGridViewTextBoxCell) + // { + // myDGV.BeginEdit(false); + // } + // else if (targetCell is DataGridViewComboBoxCell) + // { + // SendKeys.Send("{F4}"); + // } + // } + // } + // else + // { + // myDGV.EndEdit(); + // } + //} + + //public static void UIAutomationDataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) + //{ + // if (e.ColumnIndex == 1) + // { + // e.Cancel = true; + // } + //} #endregion - public static void RenderSearchParameterDataGridView(DataGridView dgv) - { - DataGridViewRow r = null; - foreach(DataGridViewRow row in dgv.Rows) - { - if ((row.Cells[1].Value?.ToString() ?? "") == "ControlType") - { - r = row; - break; - } - } - - if (r != null) - { - var cmb = new DataGridViewComboBoxCell(); - - var fields = typeof(ControlType).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static).Select(f => f.Name).ToList(); - - cmb.Items.Add(""); - cmb.Items.AddRange(fields.ToArray()); - - r.Cells[2] = cmb; - } - } + //public static void RenderSearchParameterDataGridView(DataGridView dgv) + //{ + // DataGridViewRow r = null; + // foreach(DataGridViewRow row in dgv.Rows) + // { + // if ((row.Cells[1].Value?.ToString() ?? "") == "ControlType") + // { + // r = row; + // break; + // } + // } + + // if (r != null) + // { + // var cmb = new DataGridViewComboBoxCell(); + + // var fields = typeof(ControlType).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static).Select(f => f.Name).ToList(); + + // cmb.Items.Add(""); + // cmb.Items.AddRange(fields.ToArray()); + + // r.Cells[2] = cmb; + // } + //} } } diff --git a/taskt/Core/Automation/Commands/Variable/CheckVariableExistsCommand.cs b/taskt/Core/Automation/Commands/VariableGroup/CheckVariableExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Variable/CheckVariableExistsCommand.cs rename to taskt/Core/Automation/Commands/VariableGroup/CheckVariableExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/Variable/GetVariableIndexCommand.cs b/taskt/Core/Automation/Commands/VariableGroup/GetVariableIndexCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Variable/GetVariableIndexCommand.cs rename to taskt/Core/Automation/Commands/VariableGroup/GetVariableIndexCommand.cs diff --git a/taskt/Core/Automation/Commands/Variable/GetVariableTypeCommand.cs b/taskt/Core/Automation/Commands/VariableGroup/GetVariableTypeCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Variable/GetVariableTypeCommand.cs rename to taskt/Core/Automation/Commands/VariableGroup/GetVariableTypeCommand.cs diff --git a/taskt/Core/Automation/Commands/Variable/NewVariableCommand.cs b/taskt/Core/Automation/Commands/VariableGroup/NewVariableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Variable/NewVariableCommand.cs rename to taskt/Core/Automation/Commands/VariableGroup/NewVariableCommand.cs diff --git a/taskt/Core/Automation/Commands/Variable/SetVariableIndexCommand.cs b/taskt/Core/Automation/Commands/VariableGroup/SetVariableIndexCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Variable/SetVariableIndexCommand.cs rename to taskt/Core/Automation/Commands/VariableGroup/SetVariableIndexCommand.cs diff --git a/taskt/Core/Automation/Commands/Variable/SetVariableValueCommand.cs b/taskt/Core/Automation/Commands/VariableGroup/SetVariableValueCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Variable/SetVariableValueCommand.cs rename to taskt/Core/Automation/Commands/VariableGroup/SetVariableValueCommand.cs diff --git a/taskt/Core/Automation/Commands/WaitControls.cs b/taskt/Core/Automation/Commands/WaitControls.cs index fbdeac728..44e09c4a4 100644 --- a/taskt/Core/Automation/Commands/WaitControls.cs +++ b/taskt/Core/Automation/Commands/WaitControls.cs @@ -13,13 +13,13 @@ internal static class WaitControls /// /// Wait Time for something /// - /// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] [PropertyDescription("Wait Time for *** (sec)")] [InputSpecification("Number Greater than or Equal 0")] [PropertyDetailSampleUsage("**10**", PropertyDetailSampleUsage.ValueType.Value, "Wait Time")] [PropertyDetailSampleUsage("**{{{vWaitTime}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Wait Time")] [PropertyDisplayText(true, "Wait", "s")] - [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.LessThanZero | PropertyValidationRule.ValidationRuleFlags.EqualsZero)] + [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.LessThanZero)] public static string v_WaitTime { get; } #endregion @@ -57,22 +57,68 @@ public static object WaitProcess(int pauseTime, string targetName, Func<(bool, o object ret = null; var isFound = false; - //while target not been found + // while target not been found while (!isFound) { (isFound, ret) = waitFunc(); if (!isFound) { - //test if we should exit and throw exception + // test if we should exit and throw exception if (DateTime.Now > stopWaiting) { - throw new Exception(targetName + " was not found in time!"); + throw new Exception($"{targetName} was not found in time!"); } else { - //put thread to sleep before iterating - engine.ReportProgress(targetName + " Not Yet Found... " + (int)((stopWaiting - DateTime.Now).TotalSeconds) + "s remain"); + // put thread to sleep before iterating + engine.ReportProgress($"{targetName} Not Yet Found... {(int)((stopWaiting - DateTime.Now).TotalSeconds)}s remain"); + System.Threading.Thread.Sleep(1000); + } + } + } + + return ret; + } + + /// + /// wait process, this method can check timeout in callback Func + /// + /// + /// + /// 1st arg Func is check timeout method + /// + /// + /// + public static object WaitProcess(int pauseTime, string targetName, Func, (bool, object)> waitFunc, Engine.AutomationEngineInstance engine) + { + var stopWaiting = DateTime.Now.AddSeconds(pauseTime); + + // check timeout + bool CheckTimeout() + { + return (DateTime.Now > stopWaiting); + } + + object ret = null; + var isFound = false; + + // while target not been found + while (!isFound) + { + (isFound, ret) = waitFunc(CheckTimeout); + + if (!isFound) + { + // test if we should exit and throw exception + if (CheckTimeout()) + { + throw new Exception($"{targetName} was not found in time!"); + } + else + { + // put thread to sleep before iterating + engine.ReportProgress($"{targetName} Not Yet Found... {(int)((stopWaiting - DateTime.Now).TotalSeconds)}s remain"); System.Threading.Thread.Sleep(1000); } } diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCheckWebElementExistsCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCheckWebElementExistsCommand.cs deleted file mode 100644 index d023d48b6..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCheckWebElementExistsCommand.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Search WebElement")] - [Attributes.ClassAttributes.CommandSettings("Check WebElement Exists")] - [Attributes.ClassAttributes.Description("This command allows you to check WebElement existance.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to check WebElement existance.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserCheckWebElementExistsCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] - public string v_ElementIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] - [Remarks("When WebElement exists, Result is **True**")] - public string v_Result { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] - [PropertyIsOptional(true, "0")] - [PropertyFirstValue("0")] - public string v_WaitTime { get; set; } - - public SeleniumBrowserCheckWebElementExistsCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - try - { - SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), nameof(v_WaitTime), engine); - true.StoreInUserVariable(engine, v_Result); - } - catch - { - false.StoreInUserVariable(engine, v_Result); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserClearTextInWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserClearTextInWebElementCommand.cs deleted file mode 100644 index 8efef3509..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserClearTextInWebElementCommand.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("WebElement Action")] - [Attributes.ClassAttributes.CommandSettings("Clear Text In WebElement")] - [Attributes.ClassAttributes.Description("This command allows you to Clear Text in WebElement.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Clear Text in WebElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserClearTextInWebElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("When the WebElement does not support Clear Text")] - [PropertyUISelectionOption("Error")] - [PropertyUISelectionOption("Ignore")] - [PropertyIsOptional(true, "Error")] - [PropertyDisplayText(false, "")] - public string v_WhenClearNotSupported { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - [PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] - public string v_ScrollToElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyIsOptional(true)] - public string v_InstanceName { get; set; } - - public SeleniumBrowserClearTextInWebElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToElement), engine)) - { - var scroll = new SeleniumBrowserScrollToWebElementCommand - { - v_InstanceName = this.v_InstanceName, - v_WebElement = this.v_WebElement, - v_WhenFailScroll = "ignore" - }; - scroll.RunCommand(engine); - } - - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - - switch (elem.TagName.ToLower()) - { - case "input": - case "textarea": - elem.Clear(); - break; - default: - if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenClearNotSupported), engine) == "error") - { - throw new Exception("Specified WebElement does not support Clear Text. TagName: '" + elem.TagName + "'"); - } - break; - } - } - - private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) - { - SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserClickWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserClickWebElementCommand.cs deleted file mode 100644 index ee0d1434c..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserClickWebElementCommand.cs +++ /dev/null @@ -1,173 +0,0 @@ -using Newtonsoft.Json.Linq; -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("WebElement Action")] - [Attributes.ClassAttributes.CommandSettings("Click WebElement")] - [Attributes.ClassAttributes.Description("This command allows you to Click to WebElement.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Click to WebElement.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserClickWebElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_MouseClickType))] - [PropertyUISelectionOption("Invoke Click")] - [PropertyFirstValue("Invoke Click")] - [PropertySelectionChangeEvent(nameof(cmdClickType_SelectinChange))] - public string v_ClickType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyIsOptional(true)] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_XOffsetAdjustment))] - [PropertyFirstValue("10")] - [Remarks("It is strongly recommended to Enter a value between **10** and **20** depending on your WebBrowser.")] - public string v_XOffset { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_YOffsetAdjustment))] - [PropertyFirstValue("136")] - [Remarks("It is strongly recommended to Enter a value between **100** and **200** depending on your WebBrowser.")] - public string v_YOffset { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("When Fail Click")] - [PropertyUISelectionOption("Error")] - [PropertyUISelectionOption("Ignore")] - [PropertyIsOptional(true, "Error")] - [PropertyDisplayText(false, "")] - public string v_WhenFailClick { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - [PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] - public string v_ScrollToElement { get; set; } - - public SeleniumBrowserClickWebElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToElement), engine)) - { - var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() - { - v_InstanceName = this.v_InstanceName, - v_WebElement = this.v_WebElement, - v_WhenFailScroll = "ignore" - }; - scrollCommand.RunCommand(engine); - } - - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - var clickType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ClickType), engine); - - Action clickAction; - switch (clickType) - { - case "invoke click": - clickAction = new Action(() => - { - elem.Click(); - }); - break; - default: - clickAction = new Action(() => - { - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - - var scrollJson = JObject.Parse(SeleniumBrowserControls.ExcecuteScript(seleniumInstance, - "return JSON.stringify({x: window.scrollX, y: window.scrollY})").ToString()); - var scrollX = scrollJson.Value("x"); - var scrollY = scrollJson.Value("y"); - - var screenJson = JObject.Parse(SeleniumBrowserControls.ExcecuteScript(seleniumInstance, - "return JSON.stringify({x: window.screenX, y: window.screenY})").ToString()); - var screenX = screenJson.Value("x"); - var screenY = screenJson.Value("y"); - - var elementLocation = elem.Location; - - //var html = seleniumInstance.FindElement(By.TagName("html")); - //var clientX = html.GetAttribute("clientWidth"); - //var clientY = html.GetAttribute("clientHeight"); - - // DBG - //Console.WriteLine($"Elem x:{elementLocation.X}, y:{elementLocation.Y}"); - //Console.WriteLine($"Brow x:{screenX}, y:{screenY}"); - //Console.WriteLine($"Scroll x:{scrollX}, y:{scrollY}"); - - var offsetX = this.ExpandValueOrUserVariableAsInteger(nameof(v_XOffset), engine); - var offsetY = this.ExpandValueOrUserVariableAsInteger(nameof(v_YOffset), engine); - - var clickX = elementLocation.X - scrollX + screenX + offsetX; - var clickY = elementLocation.Y - scrollY + screenY + offsetY; - - // DBG - //Console.WriteLine($"Click x:{clickX}, y:{clickY}"); - - var clickCommand = new MoveMouseCommand() - { - v_MouseClick = this.v_ClickType, - v_XMousePosition = clickX.ToString(), - v_YMousePosition = clickY.ToString(), - }; - clickCommand.RunCommand(engine); - }); - break; - } - - try - { - clickAction(); - } - catch - { - if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailClick), engine) == "error") - { - throw new Exception("Fail Click WebElement. Click Type: '" + clickType + "', Location: (" + elem.Location.X + ", " + elem.Location.Y + ")"); - } - } - } - - private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) - { - //SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); - var useInstance = (((ComboBox)sender).SelectedItem?.ToString().ToLower() ?? "") != "no"; - - var inst = ControlsList.GetPropertyControl(nameof(v_InstanceName)); - useInstance = useInstance && ((inst.SelectedItem?.ToString().ToLower() ?? "") != "invoke click"); - - FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_InstanceName), useInstance); - } - - private void cmdClickType_SelectinChange(object sender, EventArgs e) - { - var useOffset = (((ComboBox)sender).SelectedItem?.ToString().ToLower() ?? "") != "invoke click"; - FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_XOffset), useOffset); ; - FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_YOffset), useOffset); ; - - var scroll = ControlsList.GetPropertyControl(nameof(v_ScrollToElement)); - var useInstance = useOffset || ((scroll.SelectedItem?.ToString().ToLower() ?? "") != "no"); - FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_InstanceName), useInstance); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCloseWebBrowserInstanceCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCloseWebBrowserInstanceCommand.cs deleted file mode 100644 index 42a2da3ff..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCloseWebBrowserInstanceCommand.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Instance")] - [Attributes.ClassAttributes.CommandSettings("Close Web Browser Instance")] - [Attributes.ClassAttributes.Description("This command allows you to close a Selenium web browser session.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to close and end a web browser session.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserCloseWebBrowserInstanceCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - public SeleniumBrowserCloseWebBrowserInstanceCommand() - { - //this.CommandName = "SeleniumBrowserCloseCommand"; - //this.SelectionName = "Close Browser"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var vInstance = v_InstanceName.ExpandValueOrUserVariable(engine); - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - - seleniumInstance.Quit(); - seleniumInstance.Dispose(); - - engine.RemoveAppInstance(vInstance); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCreateWebBrowserInstanceCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCreateWebBrowserInstanceCommand.cs deleted file mode 100644 index 961b26516..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCreateWebBrowserInstanceCommand.cs +++ /dev/null @@ -1,284 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Instance")] - [Attributes.ClassAttributes.CommandSettings("Create Web Browser Instance")] - [Attributes.ClassAttributes.Description("This command allows you to create a new Selenium web browser session which enables automation for websites.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to create a browser that will eventually perform web automation such as checking an internal company intranet site to retrieve data.\nIf this command does not work, please check your browser version, and WebDriver version.\nYou can check the WebDriver version with \"foo.exe -v\" in command prompt.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserCreateWebBrowserInstanceCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.TextBox)] - [PropertyTextBoxSetting(1, false)] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Web Browser Type")] - [PropertyUISelectionOption("Edge")] - [PropertyUISelectionOption("Chrome")] - [PropertyUISelectionOption("Firefox")] - [PropertyUISelectionOption("IE")] - [InputSpecification("", true)] - [Remarks("")] - [PropertyIsOptional(true, "Chrome")] - [PropertyFirstValue("Chrome")] - [PropertyDisplayText(true, "Web Browser Type")] - public string v_EngineType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Instance Tracking (After task ends)")] - [PropertyUISelectionOption("Forget Instance")] - [PropertyUISelectionOption("Keep Instance Alive")] - [InputSpecification("Specify if taskt should remember this instance name after the script has finished executing.")] - //[SampleUsage("Select **Forget Instance** to or **Keep Instance Alive** to allow subsequent tasks to call the instance by name.")] - [PropertyDetailSampleUsage("**Forget Instance**", "Forget the instance After tasks ends")] - [PropertyDetailSampleUsage("**Keep Instance Alive**", "Allow subsequent tasks to call the instance by name")] - [Remarks("Calling the **Close Browser** command or ending the browser session will end the instance. This command only works during the lifetime of the application. If the application is closed, the references will be forgetten automatically.")] - [PropertyIsOptional(true, "Forget Instance")] - [PropertyDisplayText(false, "")] - public string v_InstanceTracking { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Window State")] - [PropertyUISelectionOption("Normal")] - [PropertyUISelectionOption("Maximize")] - [InputSpecification("Select the window state that the browser should start up with.")] - //[SampleUsage("Select **Normal** to start the browser in normal mode or **Maximize** to start the browser in maximized mode.")] - [PropertyDetailSampleUsage("**Normal**", "Start the WebBrowser in Normal mode")] - [PropertyDetailSampleUsage("**Maximize**", "Start the WebBrowser in maximized mode")] - [Remarks("")] - [PropertyIsOptional(true, "Normal")] - [PropertyDisplayText(false, "")] - public string v_BrowserWindowOption { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Web Browser Command Line Options")] - [InputSpecification("Command Line Options", true)] - [SampleUsage("user-data-dir=c:\\users\\public\\SeleniumTasktProfile")] - [Remarks("")] - [PropertyIsOptional(true)] - [PropertyDisplayText(false, "")] - public string v_SeleniumOptions { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] - public string v_Handle { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Web Browser Binary Path")] - [InputSpecification("Web Browser Binary Path", true)] - //[SampleUsage("**C:\\temp\\BrowserPath.exe** or **{{{vPath}}}**")] - [PropertyDetailSampleUsage("**C:\\temp\\BrowserPath.exe**", PropertyDetailSampleUsage.ValueType.Value, "WebBrowser Path")] - [PropertyDetailSampleUsage("**{{{vBrowserPath}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebBrowser Path")] - [Remarks("When path is Empty, taskt try open default path.\nEdge and IE is not supported.\nIf you use a fixed web browser version, use this parameter.")] - [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFileSelectionHelper)] - [PropertyIsOptional(true, "Empty")] - [PropertyDisplayText(false, "")] - public string v_BrowserPath { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Web Driver Binary Path")] - [InputSpecification("Web Driver Binary Path", true)] - //[SampleUsage("**C:\\temp\\WebDriverPath.exe** or **{{{vPath}}}**")] - [PropertyDetailSampleUsage("**C:\\temp\\WebDriverPath.exe**", PropertyDetailSampleUsage.ValueType.Value, "WebDriver Path")] - [PropertyDetailSampleUsage("**{{{vBrowserPath}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebDriver Path")] - [Remarks("When path is Empty, taskt uses default WebDriver.\nIE is not supported.\nIf you use a fixed web browser version, use this parameter.")] - [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFileSelectionHelper)] - [PropertyIsOptional(true, "Empty")] - [PropertyDisplayText(false, "")] - public string v_WebDriverPath { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Use Headless")] - [PropertyIsOptional(true, "No")] - [PropertyFirstValue("No")] - [PropertyDisplayText(false, "")] - [Remarks("Headless mode does not show WebBrowser window")] - public string v_HeadlessMode { get; set; } - - public SeleniumBrowserCreateWebBrowserInstanceCommand() - { - //this.CommandName = "SeleniumBrowserCreateCommand"; - //this.SelectionName = "Create Browser"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - //this.v_EngineType = "Chrome"; - //this.v_InstanceName = ""; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var seleniumEngine = SelectionItemsControls.ExpandValueOrUserVariableAsSelectionItem(this, nameof(v_EngineType), engine); - - var driverPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "Resources"); - var browserPath = v_BrowserPath.ExpandValueOrUserVariable(engine); - var webDriverPath = v_WebDriverPath.ExpandValueOrUserVariable(engine); - - OpenQA.Selenium.DriverService driverService; - OpenQA.Selenium.IWebDriver webDriver; - if (seleniumEngine == "chrome") - { - OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions(); - if (!string.IsNullOrEmpty(browserPath)) - { - options.BinaryLocation = browserPath; - } - - if (!string.IsNullOrEmpty(v_SeleniumOptions)) - { - var convertedOptions = v_SeleniumOptions.ExpandValueOrUserVariable(engine); - options.AddArguments(convertedOptions); - } - - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_HeadlessMode), engine)) - { - options.AddArgument("--headless"); - } - - if (!string.IsNullOrEmpty(webDriverPath)) - { - driverService = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(System.IO.Path.GetDirectoryName(webDriverPath), System.IO.Path.GetFileName(webDriverPath)); - } - else - { - driverService = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(driverPath); - } - - webDriver = new OpenQA.Selenium.Chrome.ChromeDriver((OpenQA.Selenium.Chrome.ChromeDriverService)driverService, options); - } - else if (seleniumEngine == "edge") - { - OpenQA.Selenium.Edge.EdgeOptions options = new OpenQA.Selenium.Edge.EdgeOptions(); - - if (!string.IsNullOrEmpty(v_SeleniumOptions)) - { - var convertedOptions = v_SeleniumOptions.ExpandValueOrUserVariable(engine); - options.AddArguments(convertedOptions); - } - - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_HeadlessMode), engine)) - { - options.AddArgument("--headless"); - } - - if (!string.IsNullOrEmpty(webDriverPath)) - { - driverService = OpenQA.Selenium.Edge.EdgeDriverService.CreateDefaultService(System.IO.Path.GetDirectoryName(webDriverPath), System.IO.Path.GetFileName(webDriverPath)); - } - else - { - driverService = OpenQA.Selenium.Edge.EdgeDriverService.CreateDefaultService(driverPath, "msedgedriver.exe"); - } - - webDriver = new OpenQA.Selenium.Edge.EdgeDriver((OpenQA.Selenium.Edge.EdgeDriverService)driverService, options); - } - else if (seleniumEngine == "firefox") - { - OpenQA.Selenium.Firefox.FirefoxOptions options = new OpenQA.Selenium.Firefox.FirefoxOptions(); - if (!string.IsNullOrEmpty(browserPath)) - { - //options.BrowserExecutableLocation = browserPath; - options.BinaryLocation = browserPath; - } - else - { - //options.BrowserExecutableLocation = @"c:\Program Files\Mozilla Firefox\firefox.exe"; - options.BinaryLocation = @"c:\Program Files\Mozilla Firefox\firefox.exe"; - } - - if (!string.IsNullOrEmpty(v_SeleniumOptions)) - { - var convertedOptions = v_SeleniumOptions.ExpandValueOrUserVariable(engine); - options.AddArguments(convertedOptions); - } - - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_HeadlessMode), engine)) - { - options.AddArgument("-headless"); - } - - if (!string.IsNullOrEmpty(webDriverPath)) - { - driverService = OpenQA.Selenium.Firefox.FirefoxDriverService.CreateDefaultService(System.IO.Path.GetDirectoryName(webDriverPath), System.IO.Path.GetFileName(webDriverPath)); - } - else - { - driverService = OpenQA.Selenium.Firefox.FirefoxDriverService.CreateDefaultService(driverPath); - } - - webDriver = new OpenQA.Selenium.Firefox.FirefoxDriver((OpenQA.Selenium.Firefox.FirefoxDriverService)driverService, options); - } - else if (seleniumEngine == "ie") - { - driverService = OpenQA.Selenium.IE.InternetExplorerDriverService.CreateDefaultService(driverPath); - webDriver = new OpenQA.Selenium.IE.InternetExplorerDriver((OpenQA.Selenium.IE.InternetExplorerDriverService)driverService, new OpenQA.Selenium.IE.InternetExplorerOptions()); - } - else - { - throw new Exception("strange Web Browser"); - } - - //add app instance - var instanceName = v_InstanceName.ExpandValueOrUserVariable(engine); - engine.AddAppInstance(instanceName, webDriver); - - var instanceTracking = SelectionItemsControls.ExpandValueOrUserVariableAsSelectionItem(this, nameof(v_InstanceTracking), engine); - if (instanceTracking != "forget instance") - { - GlobalAppInstances.AddInstance(instanceName, webDriver); - } - - var browserWindowOption = SelectionItemsControls.ExpandValueOrUserVariableAsSelectionItem(this, nameof(v_BrowserWindowOption), engine); - if (browserWindowOption == "maximize") - { - webDriver.Manage().Window.Maximize(); - } - - if (!string.IsNullOrEmpty(v_Handle)) - { - var procId = ProcessControls.GetChildProcessId(driverService.ProcessId, 1); - if (seleniumEngine == "firefox") - { - procId = ProcessControls.GetChildProcessId(procId, 0); - } - var whnd = WindowControls.ConvertProcessIdToWindowHandle(procId); - whnd.ToInt32().StoreInUserVariable(engine, v_Handle); - } - } - - public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - { - if (!editor.appSettings.ClientSettings.SupportIECommand) - { - var cmb = ControlsList.GetPropertyControl(nameof(v_EngineType)); - for (int i = cmb.Items.Count - 1; i >= 0; i--) - { - if (cmb.Items[i].ToString() == "IE") - { - cmb.Items.RemoveAt(i); - break; - } - } - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserExecuteScriptCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserExecuteScriptCommand.cs deleted file mode 100644 index d378495b8..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserExecuteScriptCommand.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Web Browser Actions")] - [Attributes.ClassAttributes.CommandSettings("Execute Script")] - [Attributes.ClassAttributes.Description("This command allows you to execute a script in a Selenium web browser session.")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserExecuteScriptCommand : ScriptCommand, ICanHandleFilePath - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("JavaScript Code Type")] - //[SampleUsage("**Code** or **File**")] - [PropertyDetailSampleUsage("**Code**", "Use Specfied JavaScript Code")] - [PropertyDetailSampleUsage("**File**", "Use Specfied JavaScript File")] - [Remarks("")] - [PropertyUISelectionOption("Code")] - [PropertyUISelectionOption("File")] - [PropertyIsOptional(true, "Code")] - [PropertyFirstValue("Code")] - public string v_CodeType { get; set; } - - [XmlAttribute] - [PropertyDescription("JavaScript Code")] - [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)] - [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFileSelectionHelper)] - [InputSpecification("JavaScript", true)] - [PropertyDetailSampleUsage("**return (2);**", "Specify the JavaScript Code")] - [PropertyDetailSampleUsage("**c:\\js\\mycode.js**", "Specify the JavaScript File Path")] - [PropertyDetailSampleUsage("**{{{vCode}}}**", "Specify the Variable Value **vCode** for JavaScript Code or JavaScript File Path")] - [PropertyShowSampleUsageInDescription(true)] - [Remarks("When Selected **Code**, plese Enter the JavaScript Code.\nWhen Selected **File**, please Enter the JavaScript File Path.")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.MultiLineTextBox)] - [PropertyValidationRule("JavaScript Code", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(false, "")] - public string v_ScriptCode { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Timeout in Seconds")] - [InputSpecification("Timeout in Seconds", true)] - //[SampleUsage("**0** or **10** or **{{{vWaitTime}}}**")] - [PropertyDetailSampleUsage("**0**", "Specify **0** for Timeout. This means Waiting until JavaScript is finished.")] - [PropertyDetailSampleUsage("**10**", PropertyDetailSampleUsage.ValueType.Value, "Timeout")] - [PropertyDetailSampleUsage("**{{{vWaitTime}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Timeout")] - [Remarks("When Value is Less Than or Equals to **0**, this means Waiting until JavaScript is finished.")] - [PropertyIsOptional(true, "0")] - [PropertyDisplayText(false, "")] - public string v_TimeOut { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Argument")] - [InputSpecification("Argument", true)] - [PropertyDetailSampleUsage("**0**", PropertyDetailSampleUsage.ValueType.Value, "Argument")] - [PropertyDetailSampleUsage("**{{{vValue}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Argument")] - [Remarks("The value of the argument can be obtained with 'arguments[0]' in code.")] - [PropertyIsOptional(true)] - [PropertyDisplayText(false, "")] - public string v_Args { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Recieve Result Value")] - [PropertyIsOptional(true)] - [PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.None)] - public string v_userVariableName { get; set; } - - public SeleniumBrowserExecuteScriptCommand() - { - //this.CommandName = "SeleniumBrowserExecuteScriptCommand"; - //this.SelectionName = "Execute Script"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - - //this.v_InstanceName = ""; - //this.v_CodeType = "Code"; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var codeType = SelectionItemsControls.ExpandValueOrUserVariableAsSelectionItem(this, nameof(v_CodeType), engine); - - string script = ""; - if (codeType == "code") - { - script = v_ScriptCode.ExpandValueOrUserVariable(engine); - } - else if (codeType == "file") - { - //string scriptFiile = FilePathControls.FormatFilePath_NoFileCounter(v_ScriptCode, engine, "js", true); - //var scriptFile = v_ScriptCode.ExpandValueOrUserVariableAsFilePath(new PropertyFilePathSetting(false, PropertyFilePathSetting.ExtensionBehavior.RequiredExtensionAndExists, PropertyFilePathSetting.FileCounterBehavior.NoSupport, "js"), engine); - var scriptFile = this.ExpandValueOrUserVariableAsFilePath(nameof(v_ScriptCode), new PropertyFilePathSetting(false, PropertyFilePathSetting.ExtensionBehavior.RequiredExtensionAndExists, PropertyFilePathSetting.FileCounterBehavior.NoSupport, "js"), engine); - script = System.IO.File.ReadAllText(scriptFile); - } - - var args = v_Args.ExpandValueOrUserVariable(engine); - - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - - //configure timeout - //var inputTimeout = v_TimeOut.ConvertToUserVariable(sender); - //int timeOut; - //if (!int.TryParse(inputTimeout, out timeOut)) - //{ - // timeOut = -1; - //} - var timeOut = this.ExpandValueOrUserVariableAsInteger(nameof(v_TimeOut), engine); - - //set driver timeout - if (timeOut > 0) - { - seleniumInstance.Manage().Timeouts().AsynchronousJavaScript = new TimeSpan(0, 0, timeOut); - } - - //run script - OpenQA.Selenium.IJavaScriptExecutor js = (OpenQA.Selenium.IJavaScriptExecutor)seleniumInstance; - - object result; - if (string.IsNullOrEmpty(args)) - { - if (timeOut > 1) - { - result = js.ExecuteAsyncScript(script); - } - else - { - result = js.ExecuteScript(script); - } - } - else - { - if (timeOut > 1) - { - result = js.ExecuteAsyncScript(script, args); - } - else - { - result = js.ExecuteScript(script, args); - } - } - - //apply result to variable - if ((result != null) && (!string.IsNullOrEmpty(v_userVariableName))) - { - result.ToString().StoreInUserVariable(engine, v_userVariableName); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAWebElementValuesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAWebElementValuesAsDataTableCommand.cs deleted file mode 100644 index 816fa6a24..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAWebElementValuesAsDataTableCommand.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Data; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Scraping")] - [Attributes.ClassAttributes.CommandSettings("Get A WebElement Values As DataTable")] - [Attributes.ClassAttributes.Description("This command allows you to get Attributes value for a WebElement As DataTable.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Attributes value for a WebElement As DataTable.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetAWebElementValuesAsDataTableCommand : ScriptCommand, ICanHandleDataTable, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - [PropertySelectionChangeEvent(nameof(SearchMethodComboBox_SelectionChangeCommitted))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] - public string v_ElementIndex { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributesName))] - public DataTable v_AttributesName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] - public string v_DataTableVariableName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetAWebElementValuesAsDataTableCommand() - { - //this.CommandName = "SeleniumBrowserGetAnElementValuesAsDataTableCommand"; - //this.SelectionName = "Get An Element Values As DataTable"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //(var _, var trgElem) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), engine); - (var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), nameof(v_WaitTime), engine); - - DataTable newDT = new DataTable(); - - SeleniumBrowserControls.GetElementAttributes(trgElem, v_AttributesName, engine, new Action( (name, value) => - { - if (newDT.Rows.Count == 0) - { - newDT.Rows.Add(); - } - - if (!newDT.Columns.Contains(name)) - { - newDT.Columns.Add(name); - } - newDT.Rows[0][name] = value; - }) - ); - - //newDT.StoreInUserVariable(engine, v_DataTableVariableName); - this.StoreDataTableInUserVariable(newDT, nameof(v_DataTableVariableName), engine); - } - - private void SearchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - SeleniumBrowserControls.SearchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_ElementIndex)); - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - DataTableControls.BeforeValidate((DataGridView)ControlsList[nameof(v_AttributesName)], v_AttributesName); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAWebElementValuesAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAWebElementValuesAsDictionaryCommand.cs deleted file mode 100644 index ad87b5ae1..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAWebElementValuesAsDictionaryCommand.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Scraping")] - [Attributes.ClassAttributes.CommandSettings("Get A WebElement Values As Dictionary")] - [Attributes.ClassAttributes.Description("This command allows you to get Attributes value for a WebElement As Dictionary.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Attributes value for a WebElement As Dictionary.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetAWebElementValuesAsDictionaryCommand : ScriptCommand, ICanHandleDictionary, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - [PropertySelectionChangeEvent(nameof(SearchMethodComboBox_SelectionChangeCommitted))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] - public string v_ElementIndex { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributesName))] - public DataTable v_AttributesName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_OutputDictionaryName))] - public string v_DictionaryVariableName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetAWebElementValuesAsDictionaryCommand() - { - //this.CommandName = "SeleniumBrowserGetAnElementValuesAsDictionaryCommand"; - //this.SelectionName = "Get An Element Values As Dictionary"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //(var _, var trgElem) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), engine); - (var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), nameof(v_WaitTime), engine); - - Dictionary newDic = new Dictionary(); - - SeleniumBrowserControls.GetElementAttributes(trgElem, v_AttributesName, engine, new Action((name, value) => - { - if (newDic.Keys.Contains(name)) - { - newDic[name] = value; - } - else - { - newDic.Add(name, value); - } - }) - ); - - //newDic.StoreInUserVariable(engine, v_DictionaryVariableName); - this.StoreDictionaryInUserVariable(newDic, nameof(v_DictionaryVariableName), engine); - } - - private void SearchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - SeleniumBrowserControls.SearchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_ElementIndex)); - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - DataTableControls.BeforeValidate((DataGridView)ControlsList[nameof(v_AttributesName)], v_AttributesName); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAWebElementValuesAsListCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAWebElementValuesAsListCommand.cs deleted file mode 100644 index 1f00fbc90..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAWebElementValuesAsListCommand.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Scraping")] - [Attributes.ClassAttributes.CommandSettings("Get A WebElement Values As List")] - [Attributes.ClassAttributes.Description("This command allows you to get Attributes value for a WebElement As List.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Attributes value for a WebElement As List.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetAWebElementValuesAsListCommand : ScriptCommand, IHaveDataTableElements, ICanHandleList - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - [PropertySelectionChangeEvent(nameof(SearchMethodComboBox_SelectionChangeCommitted))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] - public string v_ElementIndex { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributesName))] - public DataTable v_AttributesName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] - public string v_ListVariableName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetAWebElementValuesAsListCommand() - { - //this.CommandName = "SeleniumBrowserGetAnElementValuesAsListCommand"; - //this.SelectionName = "Get An Element Values As List"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //(var _, var trgElem) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), engine); - (var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), nameof(v_WaitTime), engine); - - List newList = new List(); - - SeleniumBrowserControls.GetElementAttributes(trgElem, v_AttributesName, engine, new Action((name, value) => - { - newList.Add(value); - }) - ); - - //newList.StoreInUserVariable(engine, v_ListVariableName); - this.StoreListInUserVariable(newList, nameof(v_ListVariableName), engine); - } - - - private void SearchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - SeleniumBrowserControls.SearchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_ElementIndex)); - } - - public override void BeforeValidate() - { - base.BeforeValidate(); - DataTableControls.BeforeValidate((DataGridView)ControlsList[nameof(v_AttributesName)], v_AttributesName); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAttributeFromWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAttributeFromWebElementCommand.cs deleted file mode 100644 index 46f8c4639..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetAttributeFromWebElementCommand.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Get From WebElement")] - [Attributes.ClassAttributes.CommandSettings("Get Attribute From WebElement")] - [Attributes.ClassAttributes.Description("This command allows you to Get Attribute Value from WebElement.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Attribute Value from WebElement.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetAttributeFromWebElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Attribute Name")] - [PropertyDetailSampleUsage("**class**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] - [PropertyDetailSampleUsage("**{{{vAttribute}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Attribute")] - [PropertyValidationRule("Attribute", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Attribute")] - public string v_AttributeName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_Result { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("When the WebElement does not have the Attribute")] - [PropertyUISelectionOption("Error")] - [PropertyUISelectionOption("Ignore")] - [PropertyIsOptional(true, "Error")] - [PropertyDisplayText(false, "")] - public string v_WhenNoAttribute { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - [PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] - public string v_ScrollToElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyIsOptional(true)] - public string v_InstanceName { get; set; } - - public SeleniumBrowserGetAttributeFromWebElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToElement), engine)) - { - var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() - { - v_InstanceName = this.v_InstanceName, - v_WebElement = this.v_WebElement, - v_WhenFailScroll = "ignore" - }; - scrollCommand.RunCommand(engine); - } - - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - - var attributeName = v_AttributeName.ExpandValueOrUserVariable(engine); - - var v = elem.GetAttribute(attributeName); - - if (v != null) - { - v.StoreInUserVariable(engine, v_Result); - } - else - { - if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenNoAttribute), engine) == "error") - { - throw new Exception("Attribute '" + attributeName + "' does not exists."); - } - else - { - "".StoreInUserVariable(engine, v_Result); - } - } - } - - private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) - { - SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetMatchedWebElementsCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetMatchedWebElementsCommand.cs deleted file mode 100644 index d24c49a24..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetMatchedWebElementsCommand.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Search WebElement")] - [Attributes.ClassAttributes.CommandSettings("Get Matched WebElements")] - [Attributes.ClassAttributes.Description("This command allows you to get Matched WebElements HTML.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Matched WebElements HTML.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetMatchedWebElementsCommand : ScriptCommand, IListResultProperties - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] - public string v_Result { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetMatchedWebElementsCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - (var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_WaitTime), engine); - - var lst = new List(); - foreach(var elem in trgElem) - { - lst.Add(elem.GetAttribute("outerHTML")); - } - //lst.StoreInUserVariable(engine, v_Result); - this.StoreListInUserVariable(lst, engine); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetOptionsFromWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetOptionsFromWebElementCommand.cs deleted file mode 100644 index 16fb0797a..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetOptionsFromWebElementCommand.cs +++ /dev/null @@ -1,119 +0,0 @@ -using OpenQA.Selenium.Support.UI; -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Get From WebElement")] - [Attributes.ClassAttributes.CommandSettings("Get Options From WebElement")] - [Attributes.ClassAttributes.Description("This command allows you to Get Options Value from WebElement.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Options Value from WebElement.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetOptionsFromWebElementCommand : ScriptCommand, IListResultProperties - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Attribute Name")] - [PropertyDetailSampleUsage("**textContent**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] - [PropertyDetailSampleUsage("**value**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] - [PropertyDetailSampleUsage("**{{{vAttribute}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Attribute")] - [PropertyValidationRule("Attribute", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Attribute")] - public string v_AttributeName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] - public string v_Result { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("When the WebElement does not have the Attribute")] - [PropertyUISelectionOption("Error")] - [PropertyUISelectionOption("Ignore")] - [PropertyIsOptional(true, "Error")] - [PropertyDisplayText(false, "")] - public string v_WhenNoAttribute { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - [PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] - public string v_ScrollToElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyIsOptional(true)] - public string v_InstanceName { get; set; } - - public SeleniumBrowserGetOptionsFromWebElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToElement), engine)) - { - var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() - { - v_InstanceName = this.v_InstanceName, - v_WebElement = this.v_WebElement, - v_WhenFailScroll = "ignore" - }; - scrollCommand.RunCommand(engine); - } - - if (!elem.CheckTagName("select")) - { - throw new Exception("WebElement is not Select"); - } - - var sel = new SelectElement(elem); - var options = sel.Options; - - var attributeName = v_AttributeName.ExpandValueOrUserVariable(engine); - - var throwError = (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenNoAttribute), engine) == "error"); - - var lst = new List(); - foreach(var opt in options) - { - var a = opt.GetAttribute(attributeName); - if (a == null) - { - if (throwError) - { - throw new Exception("Attribute '" + attributeName + "' does not exists."); - } - else - { - lst.Add(""); - } - } - else - { - lst.Add(a); - } - } - //lst.StoreInUserVariable(engine, v_Result); - this.StoreListInUserVariable(lst, engine); - } - - private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) - { - SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetTableValueAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetTableValueAsDataTableCommand.cs deleted file mode 100644 index 6407847dc..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetTableValueAsDataTableCommand.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Data; -using System.Windows.Forms; -using System.Xml.Serialization; -using OpenQA.Selenium; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Scraping")] - [Attributes.ClassAttributes.CommandSettings("Get Table Value As DataTable")] - [Attributes.ClassAttributes.Description("This command allows you to get a Table Values As DataTable.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a Table Values As DataTable.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetTableValueAsDataTableCommand : ScriptCommand, ICanHandleDataTable - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - [PropertySelectionChangeEvent(nameof(SearchMethodComboBox_SelectionChangeCommitted))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] - public string v_ElementIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributeName))] - [PropertyIsOptional(true, "textContent")] - [PropertyFirstValue("textContent")] - public string v_AttributeName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] - public string v_DataTableVariableName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Method for the First Row")] - [InputSpecification("", true)] - [PropertyDetailSampleUsage("**First Row**", "The First Row is considered the First Row of Data.")] - [PropertyDetailSampleUsage("**Column Name**", "The First Row is considered the Column Name.")] - [PropertyDetailSampleUsage("**Ignore**", "Ignore First Row")] - [Remarks("")] - [PropertyUISelectionOption("First Row")] - [PropertyUISelectionOption("Column Name")] - [PropertyUISelectionOption("Ignore")] - [PropertyIsOptional(true, "First Row")] - [PropertySelectionValueSensitive(false)] - [PropertyDisplayText(false, "")] - public string v_FirstRowMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetTableValueAsDataTableCommand() - { - //this.CommandName = "SeleniumBrowserGetTableValueAsDataTableCommand"; - //this.SelectionName = "Get Table Value As DataTable"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //(var _, var trgElem) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), engine); - (var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), nameof(v_WaitTime), engine); - - if (trgElem.TagName.ToLower() != "table") - { - throw new Exception("Element is not Table"); - } - - var attrName = v_AttributeName.ExpandValueOrUserVariable(engine); - - var firstRowMethod = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_FirstRowMethod), engine); - - var newDT = new DataTable(); - - var trs = trgElem.FindElements(By.XPath("child::tr | child::thead/tr | child::tbody/tr | child::tfoot/tr")); - if (trs.Count > 0) - { - var columns = trs[0].FindElements(By.XPath("child::th | child::td")); - if (columns.Count > 0) - { - int columnSize = columns.Count; - if (firstRowMethod == "column name") - { - for (int i = 0; i < columnSize; i++) - { - newDT.Columns.Add(columns[i].GetAttribute("textContent")); - } - } - else - { - for (int i = 0; i < columnSize; i++) - { - newDT.Columns.Add("Column_" + i.ToString()); - } - } - - int rowBias = 0; - switch (firstRowMethod) - { - case "column name": - case "ignore": - rowBias = 1; - break; - default: - break; - } - - for (int i = rowBias; i < trs.Count; i++) - { - newDT.Rows.Add(); - var row = trs[i].FindElements(By.XPath("child::th | child::td")); - int cols = (row.Count > columnSize) ? columnSize : row.Count; - for (int j = 0; j < cols; j++) - { - newDT.Rows[i - rowBias][j] = SeleniumBrowserControls.GetAttribute(row[j], attrName, engine); - } - for (int j = cols + 1; j < columnSize; j++) - { - newDT.Rows[i - rowBias][j] = ""; - } - } - } - } - - //newDT.StoreInUserVariable(engine, v_DataTableVariableName); - this.StoreDataTableInUserVariable(newDT, nameof(v_DataTableVariableName), engine); - } - - private void SearchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - { - SeleniumBrowserControls.SearchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_ElementIndex)); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetTextFromWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetTextFromWebElementCommand.cs deleted file mode 100644 index de150a740..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetTextFromWebElementCommand.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Get From WebElement")] - [Attributes.ClassAttributes.CommandSettings("Get Text From WebElement")] - [Attributes.ClassAttributes.Description("This command allows you to Get Text Value from WebElement.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Text Value from WebElement.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetTextFromWebElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_Result { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - [PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] - public string v_ScrollToElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyIsOptional(true)] - public string v_InstanceName { get; set; } - - public SeleniumBrowserGetTextFromWebElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToElement), engine)) - { - var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() - { - v_InstanceName = this.v_InstanceName, - v_WebElement = this.v_WebElement, - v_WhenFailScroll = "ignore" - }; - scrollCommand.RunCommand(engine); - } - - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - - var v = elem.Text; - - if (string.IsNullOrEmpty(v)) - { - v = elem.GetAttribute("textContent"); - } - if (string.IsNullOrEmpty(v) && (elem.TagName.ToLower() == "input")) - { - v = elem.GetAttribute("value"); - } - - v.StoreInUserVariable(engine, v_Result); - } - - private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) - { - SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementPositionCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementPositionCommand.cs deleted file mode 100644 index b45472f19..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementPositionCommand.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Get From WebElement")] - [Attributes.ClassAttributes.CommandSettings("Get WebElement Position")] - [Attributes.ClassAttributes.Description("This command allows you to Get WebElement Position.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get WebElement Position.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumWebElementPositionCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Store X Position")] - [InputSpecification("X Position")] - [PropertyIsOptional(true)] - [PropertyValidationRule("X Position", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(true, "X Position")] - public string v_XPosition { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Store Y Position")] - [InputSpecification("Y Position")] - [PropertyIsOptional(true)] - [PropertyValidationRule("Y Position", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(true, "Y Position")] - public string v_YPosition { get; set; } - - [XmlAttribute] - [PropertyDescription("Base position")] - [InputSpecification("", true)] - [SampleUsage("")] - [Remarks("")] - [PropertyUISelectionOption("Top Left")] - [PropertyUISelectionOption("Bottom Right")] - [PropertyUISelectionOption("Top Right")] - [PropertyUISelectionOption("Bottom Left")] - [PropertyUISelectionOption("Center")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - [PropertyIsOptional(true, "Top Left")] - public string v_PositionBase { get; set; } - - public SeleniumWebElementPositionCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - - var loc = elem.Location; - var size = elem.Size; - - int x = 0, y = 0; - switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) - { - case "top left": - x = loc.X; - y = loc.Y; - break; - case "bottom right": - x = loc.X + size.Width; - y = loc.Y + size.Height; - break; - case "top right": - x = loc.X + size.Width; - y = loc.Y; - break; - case "bottom left": - x = loc.X; - y = loc.Y + size.Height; - break; - case "center": - x = (loc.X + size.Width) / 2; - y = (loc.Y + size.Height) / 2; - break; - } - - if (!string.IsNullOrEmpty(v_XPosition)) - { - x.StoreInUserVariable(engine, v_XPosition); - } - if (!string.IsNullOrEmpty(v_YPosition)) - { - y.StoreInUserVariable(engine, v_YPosition); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsCountCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsCountCommand.cs deleted file mode 100644 index 9b4d5f0a7..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsCountCommand.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Search WebElement")] - [Attributes.ClassAttributes.CommandSettings("Get WebElements Count")] - [Attributes.ClassAttributes.Description("This command allows you to count WebElements.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to count WebElements.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWebElementsCountCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_Result { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetWebElementsCountCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - try - { - (var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_WaitTime), engine); - - trgElem.Count.ToString().StoreInUserVariable(engine, v_Result); - } - catch - { - "0".StoreInUserVariable(engine, v_Result); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValueAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValueAsDataTableCommand.cs deleted file mode 100644 index 17d0d2790..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValueAsDataTableCommand.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Data; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Scraping")] - [Attributes.ClassAttributes.CommandSettings("Get WebElements Value As DataTable")] - [Attributes.ClassAttributes.Description("This command allows you to get a Attribute value for WegElements As DataTable.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a Attribute value for WegElements As DataTable.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWebElementsValueAsDataTableCommand : ScriptCommand, ICanHandleDataTable - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributeName))] - public string v_AttributeName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] - public string v_DataTableVariableName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetWebElementsValueAsDataTableCommand() - { - //this.CommandName = "SeleniumBrowserGetElementsValueAsDataTableCommand"; - //this.SelectionName = "Get Elements Value As DataTable"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //(var _, var elems) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), engine); - (var _, var elems) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_WaitTime), engine); - - DataTable newDT = new DataTable(); - - SeleniumBrowserControls.GetElementsAttribute(elems, v_AttributeName, engine, new Action((idx, name, value) => - { - if (!newDT.Columns.Contains(name)) - { - newDT.Columns.Add(name); - } - newDT.Rows.Add(); - newDT.Rows[idx][0] = value; - }) - ); - - //newDT.StoreInUserVariable(engine, v_DataTableVariableName); - this.StoreDataTableInUserVariable(newDT, nameof(v_DataTableVariableName), engine); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValueAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValueAsDictionaryCommand.cs deleted file mode 100644 index c26a3a6e9..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValueAsDictionaryCommand.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Scraping")] - [Attributes.ClassAttributes.CommandSettings("Get WebElements Value As Dictionary")] - [Attributes.ClassAttributes.Description("This command allows you to get a Attribute value for WegElements As Dictionary.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a Attribute value for WegElements As Dictionary.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWebElementsValueAsDictionaryCommand : ScriptCommand,ICanHandleDictionary - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributeName))] - public string v_AttributeName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_OutputDictionaryName))] - public string v_DictionaryVariableName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetWebElementsValueAsDictionaryCommand() - { - //this.CommandName = "SeleniumBrowserGetElementsValueAsDictionaryCommand"; - //this.SelectionName = "Get Elements Value As Dictionary"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //(var _, var elems) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), engine); - (var _, var elems) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_WaitTime), engine); - - var newDic = new Dictionary(); - - SeleniumBrowserControls.GetElementsAttribute(elems, v_AttributeName, engine, new Action((idx, name, value) => - { - newDic.Add("element_" + idx, value); - }) - ); - - //newDic.StoreInUserVariable(engine, v_DictionaryVariableName); - this.StoreDictionaryInUserVariable(newDic, nameof(v_DictionaryVariableName), engine); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValueAsListCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValueAsListCommand.cs deleted file mode 100644 index b872f244e..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValueAsListCommand.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Scraping")] - [Attributes.ClassAttributes.CommandSettings("Get WebElements Value As List")] - [Attributes.ClassAttributes.Description("This command allows you to get a Attribute value for WegElements As List.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a Attribute value for WegElements As List.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWebElementsValueAsListCommand : ScriptCommand, ICanHandleList - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributeName))] - public string v_AttributeName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] - public string v_ListVariableName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetWebElementsValueAsListCommand() - { - //this.CommandName = "SeleniumBrowserGetElementsValueAsListCommand"; - //this.SelectionName = "Get Elements Value As List"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //(var _, var elems) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), engine); - (var _, var elems) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_WaitTime), engine); - - List newList = new List(); - - SeleniumBrowserControls.GetElementsAttribute(elems, v_AttributeName, engine, new Action((idx, name, value) => - { - newList.Add(value); - }) - ); - - //newList.StoreInUserVariable(engine, v_ListVariableName); - this.StoreListInUserVariable(newList, nameof(v_ListVariableName), engine); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValuesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValuesAsDataTableCommand.cs deleted file mode 100644 index 747e0e72d..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementsValuesAsDataTableCommand.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Data; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Scraping")] - [Attributes.ClassAttributes.CommandSettings("Get WebElements Values As DataTable")] - [Attributes.ClassAttributes.Description("This command allows you to get Attributes value for WegElements As DataTable.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Attributes value for WegElements As DataTable.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWebElementsValuesAsDataTableCommand : ScriptCommand, ICanHandleDataTable, IHaveDataTableElements - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlElement] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributesName))] - public DataTable v_AttributesName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] - public string v_DataTableVariableName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserGetWebElementsValuesAsDataTableCommand() - { - //this.CommandName = "SeleniumBrowserGetElementsValuesAsDataTableCommand"; - //this.SelectionName = "Get Elements Values As DataTable"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - //(var _, var elems) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), engine); - (var _, var elems) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_WaitTime), engine); - - var newDT = new DataTable(); - - int attrs = v_AttributesName.Rows.Count; - for (int i = 0; i (() => { - try - { - var t = searchFunc(targetElement, searchParameter); - if (t is IWebElement elem) - { - return (true, elem); - } - else if (t is ReadOnlyCollection elems) - { - if (index < 0) - { - index += elems.Count; - } - if ((index >= 0) && (index < elems.Count)) - { - return (true, elems[index]); - } - else - { - return (false, null); - } - } - else - { - return (false, null); - } - } - catch - { - return (false, null); - } - }), engine); - - if (ret is IWebElement resultElem) - { - resultElem.StoreInUserVariable(engine, v_Result); - } - else - { - throw new Exception("WebElement not found"); - } - } - - private static Func GetWebElementSearchMethod(string searchMethod) - { - switch (searchMethod.ToLower()) - { - case "find element by xpath": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.XPath(parameter)); - }); - - case "find element by id": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.Id(parameter)); - }); - - case "find element by name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.Name(parameter)); - }); - - case "find element by tag name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.TagName(parameter)); - }); - - case "find element by class name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.ClassName(parameter)); - }); - - case "find element by css selector": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.CssSelector(parameter)); - }); - - case "find element by link text": - return new Func((webDriver, parameter) => - { - return webDriver.FindElement(By.LinkText(parameter)); - }); - - case "find elements by xpath": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.XPath(parameter)); - }); - - case "find elements by id": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.Id(parameter)); - }); - - case "find elements by name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.Name(parameter)); - }); - - case "find elements by tag name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.TagName(parameter)); - }); - - case "find elements by class name": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.ClassName(parameter)); - }); - - case "find elements by css selector": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.CssSelector(parameter)); - }); - - case "find elements by link text": - return new Func((webDriver, parameter) => - { - return webDriver.FindElements(By.LinkText(parameter)); - }); - - default: - throw new Exception("Strange Search Method '" + searchMethod + "'"); - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSelectOptionForWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSelectOptionForWebElementCommand.cs deleted file mode 100644 index df9f8cb1f..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSelectOptionForWebElementCommand.cs +++ /dev/null @@ -1,151 +0,0 @@ -using OpenQA.Selenium.Support.UI; -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("WebElement Action")] - [Attributes.ClassAttributes.CommandSettings("Select Option For WebElement")] - [Attributes.ClassAttributes.Description("This command allows you to Select an Option for WebElement.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Select an Option for WebElement.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserSelectOptionForWebElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Selection Type")] - [PropertyUISelectionOption("Select By Index")] - [PropertyUISelectionOption("Select By Text")] - [PropertyUISelectionOption("Select By Value")] - [PropertyUISelectionOption("Deselect By Index")] - [PropertyUISelectionOption("Deselect By Text")] - [PropertyUISelectionOption("Deselect By Value")] - [PropertyUISelectionOption("Deselect All")] - [PropertySelectionChangeEvent(nameof(cmbSelectionType_SelectionChange))] - [PropertyValidationRule("Select Type", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Select Type")] - public string v_SelectionType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Option Value to Select")] - [PropertyDetailSampleUsage("**Hello**", PropertyDetailSampleUsage.ValueType.Value, "Value")] - [PropertyDetailSampleUsage("**{{{vValue}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Value")] - [PropertyValidationRule("Value", PropertyValidationRule.ValidationRuleFlags.None)] - [PropertyDisplayText(true, "Value")] - public string v_SelectionValue { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("When Fail Select Action")] - [PropertyUISelectionOption("Error")] - [PropertyUISelectionOption("Ignore")] - [PropertyIsOptional(true, "Error")] - [PropertyDisplayText(false, "")] - public string v_WhenFailSelectAction { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - [PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] - public string v_ScrollToElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyIsOptional(true)] - public string v_InstanceName { get; set; } - - public SeleniumBrowserSelectOptionForWebElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToElement), engine)) - { - var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() - { - v_InstanceName = this.v_InstanceName, - v_WebElement = this.v_WebElement, - v_WhenFailScroll = "ignore" - }; - scrollCommand.RunCommand(engine); - } - - if (!elem.CheckTagName("select")) - { - throw new Exception("WebElement is not Select"); - } - - var sel = new SelectElement(elem); - var value = v_SelectionValue.ExpandValueOrUserVariable(engine); - var selectType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SelectionType), engine); - try - { - switch (selectType) - { - case "select by index": - case "deselect by index": - if (int.TryParse(value, out int index)) - { - switch (selectType) - { - case "select by index": - sel.SelectByIndex(index); - break; - default: - sel.DeselectByIndex(index); - break; - } - } - break; - case "select by text": - sel.SelectByText(value); - break; - case "select by value": - sel.SelectByValue(value); - break; - case "deselect by text": - sel.DeselectByText(value); - break; - case "deselect by value": - sel.DeselectByValue(value); - break; - case "deselect all": - sel.DeselectAll(); - break; - } - } - catch - { - if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailSelectAction), engine) == "error") - { - throw new Exception($"Fail Select Option. Type:'{selectType}', Value:'{value}'"); - } - } - } - - private void cmbSelectionType_SelectionChange(object sender, EventArgs e) - { - var showFlag = (((ComboBox)sender).SelectedItem?.ToString().ToLower() != "deselect all"); - FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_SelectionValue), showFlag); - } - - private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) - { - SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSendSpecialKeystrokesToWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSendSpecialKeystrokesToWebElementCommand.cs deleted file mode 100644 index a58373fca..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSendSpecialKeystrokesToWebElementCommand.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("WebElement Action")] - [Attributes.ClassAttributes.CommandSettings("Send Special Keystrokes To WebElement")] - [Attributes.ClassAttributes.Description("This command allows you to Send Special Keystrokes in WebElement.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to SendSpecial Keystrokes in WebElement.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserSendSpecialKeystrokesToWebElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Send Key")] - [PropertyValidationRule("Send Key", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Send Key")] - [PropertyComboBoxItemMethod(nameof(CreateSendKeyList))] - public string v_SendKey { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Use Control Key")] - [PropertyIsOptional(true, "No")] - [PropertyFirstValue("No")] - public string v_ControlKey { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Use Shift Key")] - [PropertyIsOptional(true, "No")] - [PropertyFirstValue("No")] - public string v_ShiftKey { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Use Alt Key")] - [PropertyIsOptional(true, "No")] - [PropertyFirstValue("No")] - public string v_AltKey { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("When the WebElement does not support Set Text")] - [PropertyUISelectionOption("Error")] - [PropertyUISelectionOption("Ignore")] - [PropertyIsOptional(true, "Error")] - [PropertyDisplayText(false, "")] - public string v_WhenSetNotSupported { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - [PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] - public string v_ScrollToElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyIsOptional(true)] - public string v_InstanceName { get; set; } - - public SeleniumBrowserSendSpecialKeystrokesToWebElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToElement), engine)) - { - var scroll = new SeleniumBrowserScrollToWebElementCommand - { - v_InstanceName = this.v_InstanceName, - v_WebElement = this.v_WebElement, - v_WhenFailScroll = "ignore" - }; - scroll.RunCommand(engine); - } - - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - - string sendKey = ""; - - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ControlKey), engine)) - { - sendKey += OpenQA.Selenium.Keys.Control; - } - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ShiftKey), engine)) - { - sendKey += OpenQA.Selenium.Keys.Shift; - } - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_AltKey), engine)) - { - sendKey += OpenQA.Selenium.Keys.Alt; - } - - // TODO: not case sensitive - // send key - var key = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SendKey), "Send Key", engine); - //var keys = this.CreateSendKeyList(); - //string fieldKeyName = ""; - //foreach(var k in keys) - //{ - // if (key == k.ToLower()) - // { - // fieldKeyName = k; - // } - //} - - // get key value - var tp = typeof(OpenQA.Selenium.Keys); - var info = tp.GetField(key); - - sendKey += $"{info.GetValue(null)}"; - - try - { - elem.SendKeys(sendKey); - } - catch - { - if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenSetNotSupported), engine) == "error") - { - throw new Exception("Fail Setting Text. TagName: '" + elem.TagName + "'"); - } - } - } - - private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) - { - SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); - } - - /// - /// OpenQAのキー一覧を取得する - /// - /// - private List CreateSendKeyList() - { - var fields = typeof(OpenQA.Selenium.Keys).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); - return fields.Select(f => f.Name).ToList(); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSetTextToWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSetTextToWebElementCommand.cs deleted file mode 100644 index 8a47b9773..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSetTextToWebElementCommand.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("WebElement Action")] - [Attributes.ClassAttributes.CommandSettings("Set Text To WebElement")] - [Attributes.ClassAttributes.Description("This command allows you to Set Text in WebElement.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Set Text in WebElement.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserSetTextToWebElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_MultiLinesTextBox))] - [PropertyDescription("Text To Set")] - public string v_TextToSet { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Clear Text before Setting Text")] - [PropertyIsOptional(true, "No")] - public string v_ClearTextBeforeSetting { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] - [PropertyDescription("Encrypted Text")] - [PropertyIsOptional(true, "No")] - public string v_EncryptedText { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("When the WebElement does not support Set Text")] - [PropertyUISelectionOption("Error")] - [PropertyUISelectionOption("Ignore")] - [PropertyIsOptional(true, "Error")] - [PropertyDisplayText(false, "")] - public string v_WhenSetNotSupported { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - [PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] - public string v_ScrollToElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyIsOptional(true)] - public string v_InstanceName { get; set; } - - public SeleniumBrowserSetTextToWebElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToElement), engine)) - { - var scroll = new SeleniumBrowserScrollToWebElementCommand - { - v_InstanceName = this.v_InstanceName, - v_WebElement = this.v_WebElement, - v_WhenFailScroll = "ignore" - }; - scroll.RunCommand(engine); - } - - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ClearTextBeforeSetting), engine)) - { - var clearText = new SeleniumBrowserClearTextInWebElementCommand - { - v_WebElement = v_WebElement, - v_WhenClearNotSupported = "Ignore" - }; - clearText.RunCommand(engine); - } - - var textToSet = v_TextToSet.ExpandValueOrUserVariable(engine); - - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_EncryptedText), engine)) - { - textToSet = EncryptionServices.DecryptString(textToSet, "TASKT"); - } - - try - { - elem.SendKeys(textToSet); - } - catch - { - if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenSetNotSupported), engine) == "error") - { - throw new Exception("Fail Setting Text. TagName: '" + elem.TagName + "'"); - } - } - } - - private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) - { - SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSwitchFrameToWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSwitchFrameToWebElementCommand.cs deleted file mode 100644 index bcc7c03f2..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSwitchFrameToWebElementCommand.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("WebElement Action")] - [Attributes.ClassAttributes.CommandSettings("Switch Frame To WebElement")] - [Attributes.ClassAttributes.Description("This command allows you to Switch Frame to WebElement.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Switch Frame to WebElement.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserSwitchFrameToWebElementCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("When Fail Switch")] - [PropertyUISelectionOption("Error")] - [PropertyUISelectionOption("Ignore")] - [PropertyIsOptional(true, "Error")] - [PropertyDisplayText(false, "")] - public string v_WhenFailSwitch { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - public string v_ScrollToElement { get; set; } - - public SeleniumBrowserSwitchFrameToWebElementCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToElement), engine)) - { - var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() - { - v_InstanceName = this.v_InstanceName, - v_WebElement = this.v_WebElement, - v_WhenFailScroll = "ignore" - }; - scrollCommand.RunCommand(engine); - } - - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); - switch (elem.TagName.ToLower()) - { - case "frame": - case "iframe": - break; - default: - throw new Exception("WebElement is not frame or iframe"); - } - - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - - try - { - seleniumInstance.SwitchTo().Frame(elem); - } - catch - { - if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailSwitch), engine) == "error") - { - throw new Exception("Fail Switch to Frame."); - } - } - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSwitchWebBrowserWindowAndTabCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSwitchWebBrowserWindowAndTabCommand.cs deleted file mode 100644 index 4fbb553e9..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSwitchWebBrowserWindowAndTabCommand.cs +++ /dev/null @@ -1,181 +0,0 @@ -using System; -using System.Xml.Serialization; -using OpenQA.Selenium; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Web Browser Actions")] - [Attributes.ClassAttributes.CommandSettings("Switch Web Browser Window And Tab")] - [Attributes.ClassAttributes.Description("This command allows you to create a new Selenium web browser session which enables automation for websites.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to create a browser that will eventually perform web automation such as checking an internal company intranet site to retrieve data")] - [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserSwitchWebBrowserWindowAndTabCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Type of Match to Make")] - [PropertyUISelectionOption("Window URL")] - [PropertyUISelectionOption("Window Title")] - [PropertyUISelectionOption("Handle")] - [InputSpecification("", true)] - [PropertyFirstValue("Window URL")] - [PropertyValidationRule("Type", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Type")] - public string v_WindowMatchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Match Specification")] - [PropertyUISelectionOption("Exact Match")] - [PropertyUISelectionOption("Contains Match")] - [InputSpecification("", true)] - [PropertyIsOptional(true, "Exact Match")] - [PropertyDisplayText(false, "")] - public string v_MatchSpecification { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Search is Case-Sensitive")] - [PropertyUISelectionOption("Yes")] - [PropertyUISelectionOption("No")] - [InputSpecification("", true)] - [PropertyIsOptional(true, "No")] - [PropertyDisplayText(false, "")] - public string v_CaseSensitiveMatch { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - [PropertyDescription("Parameter to Match")] - [PropertyDetailSampleUsage("**http://www.mysite.com**", PropertyDetailSampleUsage.ValueType.Value, "Parameter")] - [PropertyDetailSampleUsage("**Welcome to Homepage**", PropertyDetailSampleUsage.ValueType.Value, "Parameter")] - [PropertyDetailSampleUsage("**{{{vTitle}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Parameter")] - [PropertyDetailSampleUsage("**{{{vURL}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Parameter", false)] - [InputSpecification("Parameter to Match", true)] - [Remarks("")] - [PropertyValidationRule("Parameter", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "Parameter")] - public string v_MatchParameter { get; set; } - - public SeleniumBrowserSwitchWebBrowserWindowAndTabCommand() - { - //this.CommandName = "SeleniumBrowserSwitchWindowCommand"; - //this.SelectionName = "Switch Browser Window"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - - //this.v_InstanceName = ""; - - //set defaults - //this.v_WindowMatchType = "Window URL"; - //this.v_MatchSpecification = "Exact Match"; - //this.v_CaseSensitiveMatch = "Yes"; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - - var matchType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WindowMatchType), engine); - - var exactMatchRequired = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_MatchSpecification), engine); - var caseSensitive = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_CaseSensitiveMatch), engine); - - Func matchFunc = getMatchFunc(matchType, exactMatchRequired, caseSensitive); - - var matchParam = v_MatchParameter.ExpandValueOrUserVariable(engine); - var handles = seleniumInstance.WindowHandles; - var currentHandle = seleniumInstance.CurrentWindowHandle; - var matchFound = false; - foreach (var hndl in handles) - { - var tempHandle = seleniumInstance.SwitchTo().Window(hndl); - - //array ordering is not guaranteed so skip if current window - if (tempHandle.CurrentWindowHandle == currentHandle) - { - continue; - } - - matchFound = matchFunc(tempHandle, matchParam); - if (matchFound) - { - break; - } - } - - if (!matchFound) - { - throw new Exception("Unable to find the specified window!"); - } - } - - private static Func getMatchFunc(string targetType, string searchType, string caseSensitive) - { - Func caseFunc; - if (caseSensitive == "yes") - { - caseFunc = new Func((str) => - { - return str; - }); - } - else - { - caseFunc = new Func((str) => - { - return str.ToLower(); - }); - } - - Func compFunc = null; - switch (searchType) - { - case "exact match": - compFunc = new Func( (a, b) => { - return (caseFunc(a) == caseFunc(b)); - }); - break; - case "contains match": - compFunc = new Func((a, b) => - { - return caseFunc(a).Contains(caseFunc(b)); - }); - break; - } - - Func retFunc = null; - switch(targetType) - { - case "window url": - retFunc = new Func((iw, str) => - { - return compFunc(iw.Url, str); - }); - break; - case "window title": - retFunc = new Func((iw, str) => - { - return compFunc(iw.Title, str); - }); - break; - case "handle": - retFunc = new Func((iw, str) => - { - return compFunc(iw.CurrentWindowHandle, str); - }); - break; - } - return retFunc; - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserWaitForWebElementToExistsCommand.cs b/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserWaitForWebElementToExistsCommand.cs deleted file mode 100644 index 75a8eb783..000000000 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserWaitForWebElementToExistsCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Search WebElement")] - [Attributes.ClassAttributes.CommandSettings("Wait For WebElement To Exists")] - [Attributes.ClassAttributes.Description("This command allows you to Wait for WebElement exists.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Wait for WebElement exists.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserWaitForWebElementToExistsCommand : ScriptCommand - { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] - public string v_SeleniumSearchType { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] - public string v_ElementIndex { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } - - public SeleniumBrowserWaitForWebElementToExistsCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), nameof(v_WaitTime), engine); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumCreateWebDriverCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumCreateWebDriverCommands.cs new file mode 100644 index 000000000..09e32ddf4 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumCreateWebDriverCommands.cs @@ -0,0 +1,106 @@ +using OpenQA.Selenium; +using System; +using System.IO; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for create WebDriver (WebBrowser instance) commands + /// + public abstract class ASeleniumCreateWebDriverCommands : ASeleniumDoSomethingToWebDriverCommands, ISeleniumCreateWebDriverProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_OutputInstanceName))] + //[PropertyParameterOrder(5000)] + public override string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Web Browser Type")] + [PropertyUISelectionOption("Edge")] + [PropertyUISelectionOption("Chrome")] + [PropertyUISelectionOption("Firefox")] + [PropertyUISelectionOptionBehavior(MultiAttributesBehavior.Merge)] + [PropertyIsOptional(true, "Chrome")] + [PropertyFirstValue("Chrome")] + [PropertyDisplayText(true, "Web Browser Type")] + [PropertyParameterOrder(6000)] + public virtual string v_BrowserType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Web Driver Binary Path")] + [InputSpecification("Web Driver Binary Path", true)] + [PropertyDetailSampleUsage("**C:\\temp\\WebDriverPath.exe**", PropertyDetailSampleUsage.ValueType.Value, "WebDriver Path")] + [PropertyDetailSampleUsage("**{{{vBrowserPath}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebDriver Path")] + [Remarks("When path is Empty, taskt uses default WebDriver.\nIE is not supported.\nIf you use a fixed web browser version, use this parameter.")] + [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFileSelectionHelper)] + [PropertyIsOptional(true, "Empty")] + [PropertyDisplayText(false, "Web Driver Binary")] + [PropertyParameterOrder(13000)] + public virtual string v_WebDriverPath { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Hide Terminal Window")] + [PropertyIsOptional(true, "No")] + [PropertyFirstValue("No")] + [PropertyDisplayText(false, "Hide Terminal")] + [PropertyParameterOrder(14000)] + public virtual string v_HideTerminalWindow { get; set; } + + /// + /// create WebDriver Searvice + /// + /// + /// + /// + /// + protected DriverService CreateWebDriverService(Func driverFunc, string webDriverName, Engine.AutomationEngineInstance engine) + { + var driverPath = this.ExpandValueOrUserVariable(nameof(v_WebDriverPath), "Web Driver Binary", engine); + DriverService ret; + if (string.IsNullOrEmpty(driverPath)) + { + ret = driverFunc(IO.Folders.GetResourcesFolderPath(), webDriverName); + } + else + { + ret = driverFunc(Path.GetDirectoryName(driverPath), Path.GetFileName(driverPath)); + } + var hideTerminal = this.ExpandValueOrUserVariableAsYesNo(nameof(v_HideTerminalWindow), engine); + ret.HideCommandPromptWindow = hideTerminal; + return ret; + } + + /// + /// create web driver service + /// + /// + /// + /// + /// + protected DriverService CreateWebDriverService(string browserType, Engine.AutomationEngineInstance engine) + { + switch (browserType.ToLower()) + { + case "chrome": + return CreateWebDriverService(OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService, "chromedriver.exe", engine); + + case "edge": + return CreateWebDriverService(OpenQA.Selenium.Edge.EdgeDriverService.CreateDefaultService, "msedgedriver.exe", engine); + + case "firefox": + return CreateWebDriverService(OpenQA.Selenium.Firefox.FirefoxDriverService.CreateDefaultService, "geckodriver.exe", engine); + + case "ie": + return CreateWebDriverService(OpenQA.Selenium.IE.InternetExplorerDriverService.CreateDefaultService, "IEDriverServer.exe", engine); + + default: + throw new Exception($"Strange Web Browser type. Type: '{browserType}'"); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumDoSomethingToWebDriverCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumDoSomethingToWebDriverCommands.cs new file mode 100644 index 000000000..e1620f0d1 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumDoSomethingToWebDriverCommands.cs @@ -0,0 +1,15 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for do something to WebDriver(WebBrowser instance) commands + /// + public abstract class ASeleniumDoSomethingToWebDriverCommands : ScriptCommand, ISeleniumDoSomethingToWebDriverProperties + { + [XmlAttribute] + [PropertyParameterOrder(5000)] + public abstract string v_InstanceName { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumDoSomethingToWebElementCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumDoSomethingToWebElementCommands.cs new file mode 100644 index 000000000..351ff9339 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumDoSomethingToWebElementCommands.cs @@ -0,0 +1,15 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for do something to webelement commands + /// + public abstract class ASeleniumDoSomethingToWebElementCommands : ScriptCommand, ISeleniumDoSomethingToWebElementProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_InputWebElementName))] + public virtual string v_WebElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumExecuteJavaScriptCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumExecuteJavaScriptCommands.cs new file mode 100644 index 000000000..0dcdd8be5 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumExecuteJavaScriptCommands.cs @@ -0,0 +1,69 @@ +using OpenQA.Selenium; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public abstract class ASeleniumExecuteJavaScriptCommands : ASeleniumWebDriverActionCommands, ISeleniumExecuteJavaScriptProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Arguments")] + [InputSpecification("Argument", true)] + [PropertyDetailSampleUsage("**0**", PropertyDetailSampleUsage.ValueType.Value, "Arguments")] + [PropertyDetailSampleUsage("**{{{vValue}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Arguments")] + [Remarks("The value of the argument can be obtained with 'arguments[0]' in code.")] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "Arguments")] + [PropertyParameterOrder(7000)] + public string v_Arguments { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve Result Value")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyParameterOrder(8000)] + public string v_Result { get; set; } + + /// + /// execute JavaScript process + /// + /// + /// + /// + protected void ExecuteJavaScriptProcess(IWebDriver seleniumInstance, string script, Engine.AutomationEngineInstance engine) + { + var args = v_Arguments.ExpandValueOrUserVariable(engine); + + // run script + //var js = (IJavaScriptExecutor)seleniumInstance; + + //object result; + //if (string.IsNullOrEmpty(args)) + //{ + // result = js.ExecuteScript(script); + //} + //else + //{ + // result = js.ExecuteScript(script, args); + //} + + object result; + if (string.IsNullOrEmpty(args)) + { + result = this.ExecuteJavaScript(seleniumInstance, script); + } + else + { + result = this.ExecuteJavaScript(seleniumInstance, script, args); + } + + // apply result to variable + if (!string.IsNullOrEmpty(v_Result)) + { + (result?.ToString() ?? string.Empty).StoreInUserVariable(engine, v_Result); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetFromWebDriverCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetFromWebDriverCommands.cs new file mode 100644 index 000000000..6c1426f3e --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetFromWebDriverCommands.cs @@ -0,0 +1,18 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// get from WebDriver commands + /// + public abstract class ASeleniumGetFromWebDriverCommands : ASeleniumDoSomethingToWebDriverCommands, IResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_InputInstanceName))] + public override string v_InstanceName { get; set; } + + [XmlAttribute] + public abstract string v_Result { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetFromWebElementCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetFromWebElementCommands.cs new file mode 100644 index 000000000..cb5f396eb --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetFromWebElementCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for get value(s) from WebElement commands + /// + public abstract class ASeleniumGetFromWebElementCommands : ASeleniumWebElementActionAndScrollCommands, ISeleniumGetFromWebElementProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WhenValueCanNotRetrieved))] + [PropertyParameterOrder(12000)] + public string v_WhenValueCanNotRetrieved { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetMultiWebElementsValueAsSomethingCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetMultiWebElementsValueAsSomethingCommands.cs new file mode 100644 index 000000000..497408b2c --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetMultiWebElementsValueAsSomethingCommands.cs @@ -0,0 +1,70 @@ +using OpenQA.Selenium; +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for get multi WebElements value as something commands + /// + public abstract class ASeleniumGetMultiWebElementsValueAsSomethingCommands : ASeleniumSearchMultiWebElementsFromWebDriverCommands + { + /// + /// attribute name + /// + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_AttributeName))] + [PropertyParameterOrder(8000)] + public virtual string v_AttributeName { get; set; } + + [XmlAttribute] + [PropertyParameterOrder(8100)] + public override string v_Result { get; set; } + + /// + /// get muti WebElements value action + /// + /// (attribute-name, attribute-value, index) + /// + protected void GetMultiWebElementValueAction(Action storeValueFunc, Engine.AutomationEngineInstance engine) + { + this.SearchMultiWebElementsAction(new Action>(elems => + { + using (var elemVar = new InnerScriptVariable(engine)) + { + using (var resVar = new InnerScriptVariable(engine)) + { + var attrName = this.ExpandValueOrUserVariable(nameof(v_AttributeName), "Attribute", engine); + if (attrName.StartsWith("@")) + { + attrName = attrName.Substring(1); + } + + var getAttr = new SeleniumBrowserGetAttributeFromWebElementCommand() + { + v_WebElement = elemVar.VariableName, + v_AttributeName = this.v_AttributeName, + v_Result = resVar.VariableName, + }; + + int idx = 0; + foreach (var elem in elems) + { + elemVar.VariableValue = new ValueTuple(elem, null); + + getAttr.RunCommand(engine); + + // newDic.Add($"element_{idx}", resVar.VariableValue.ToString()); + storeValueFunc(attrName, resVar.VariableValue.ToString(), idx); + + idx++; + } + } + } + }), engine); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetOneResultFromWebElementCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetOneResultFromWebElementCommands.cs new file mode 100644 index 000000000..913635652 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetOneResultFromWebElementCommands.cs @@ -0,0 +1,26 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for get one result from WebElement commands + /// + public abstract class ASeleniumGetOneResultFromWebElementCommands : ASeleniumGetFromWebElementCommands, IResultProperties + { + /// + /// variable name to store result + /// + [XmlAttribute] + public abstract string v_Result { get; set; } + + /// + /// store empty value to Result varialbe + /// + /// + protected void StoreEmptyValueToResult(AutomationEngineInstance engine) + { + string.Empty.StoreInUserVariable(engine, v_Result); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetOneWebElementValuesAsSomethingCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetOneWebElementValuesAsSomethingCommands.cs new file mode 100644 index 000000000..a9aacd38d --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetOneWebElementValuesAsSomethingCommands.cs @@ -0,0 +1,78 @@ +using OpenQA.Selenium; +using System; +using System.Collections.Generic; +using System.Data; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// get one WebElement values as something commands + /// + public abstract class ASeleniumGetOneWebElementValuesAsSomethingCommands : ASeleniumSearchWebElementFromWebDriverCommands, IHaveDataTableElements + { + /// + /// attribute names + /// + [XmlElement] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_AttributeNames))] + [PropertyParameterOrder(7000)] + public DataTable v_AttributesName { get; set; } + + [XmlAttribute] + [PropertyParameterOrder(8000)] + public override string v_Result { get; set; } + + public override void BeforeValidate() + { + base.BeforeValidate(); + DataTableControls.BeforeValidate((DataGridView)ControlsList[nameof(v_AttributesName)], v_AttributesName); + } + + /// + /// get multi value from one-WebElement action + /// + /// (attribute-name, attribute-value, index) + /// + protected void GetOneWebElementMultiValuesAction(Action storeValueFunc, Engine.AutomationEngineInstance engine) + { + this.SearchWebElementAction(new Action(elem => + { + using (var elemVar = new InnerScriptVariable(engine)) + { + elemVar.VariableValue = new ValueTuple(elem, null); + + using (var resVar = new InnerScriptVariable(engine)) + { + // create attribute names list + var attrs = new List(); + foreach (DataRow row in v_AttributesName.Rows) + { + attrs.Add((row[0]?.ToString() ?? string.Empty).ExpandValueOrUserVariable(engine)); + } + + var getAttr = new SeleniumBrowserGetAttributeFromWebElementCommand() + { + v_WebElement = elemVar.VariableName, + v_Result = resVar.VariableName, + }; + + int idx = 0; + foreach(var attr in attrs) + { + getAttr.v_AttributeName = attr; + getAttr.RunCommand(engine); + + var tellAttributeName = attr.StartsWith("@") ? attr.Substring(1) : attr; + storeValueFunc(tellAttributeName, resVar.VariableValue.ToString(), idx); + idx++; + } + } + } + }), engine); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetWebElementSelectorFromWebElementCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetWebElementSelectorFromWebElementCommands.cs new file mode 100644 index 000000000..f2aaa1135 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetWebElementSelectorFromWebElementCommands.cs @@ -0,0 +1,22 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + public abstract class ASeleniumGetWebElementSelectorFromWebElementCommands : ASeleniumGetOneResultFromWebElementCommands + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(6000)] + public override string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Believe ID Attribute")] + [PropertyIsOptional(true, "No")] + [PropertyDisplayText(false, "Believe ID")] + [PropertyParameterOrder(7000)] + public virtual string v_BeliveIDAttribute { get; set; } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetWindowAndTabInformationCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetWindowAndTabInformationCommands.cs new file mode 100644 index 000000000..1c900154b --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumGetWindowAndTabInformationCommands.cs @@ -0,0 +1,36 @@ +using OpenQA.Selenium; +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for get Window And Tab information commands + /// + public abstract class ASeleniumGetWindowAndTabInformationCommands : ASeleniumGetFromWebDriverCommands + { + [XmlAttribute] + [PropertyParameterOrder(6000)] + public override abstract string v_Result { get; set; } + + /// + /// selenium window and tab action + /// + /// Action(handle) + protected static void SeleniumWindowAndTabAction(IWebDriver driver, Action actionFunc) + { + var currentHandle = driver.CurrentWindowHandle; + + var handles = driver.WindowHandles; + foreach (var handle in handles) + { + driver.SwitchTo().Window(handle); + + actionFunc(handle); + } + + driver.SwitchTo().Window(currentHandle); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumSearchMultiWebElementsFromWebDriverCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumSearchMultiWebElementsFromWebDriverCommands.cs new file mode 100644 index 000000000..84b3077b3 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumSearchMultiWebElementsFromWebDriverCommands.cs @@ -0,0 +1,43 @@ +using OpenQA.Selenium; +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for search multi WebElements commands + /// + public abstract class ASeleniumSearchMultiWebElementsFromWebDriverCommands : ASeleniumGetFromWebDriverCommands, ISeleniumSearchMultiWebElementsParametersProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchMethod))] + [PropertyParameterOrder(6000)] + public virtual string v_SearchMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchParameter))] + [PropertyParameterOrder(6100)] + public virtual string v_SearchParameter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WaitTimeForWebElement))] + [PropertyParameterOrder(10000)] + public virtual string v_WaitTimeForWebElement { get; set; } + + /// + /// search multi WebElements action + /// + /// + /// + protected void SearchMultiWebElementsAction(Action> actionFunc, Engine.AutomationEngineInstance engine) + { + this.WebDriverActionCore(new System.Action(seleniumInsntance => + { + var elems = this.SearchMultiWebElements(seleniumInsntance, engine); + actionFunc(elems); + }), engine); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumSearchWebElementFromWebDriverCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumSearchWebElementFromWebDriverCommands.cs new file mode 100644 index 000000000..784d326d5 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumSearchWebElementFromWebDriverCommands.cs @@ -0,0 +1,32 @@ +using OpenQA.Selenium; +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for search one WebElement from WebDriver commands + /// + public abstract class ASeleniumSearchWebElementFromWebDriverCommands : ASeleniumSearchMultiWebElementsFromWebDriverCommands, ISeleniumSearchWebElementParametersProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WebElementIndex))] + [PropertyParameterOrder(7000)] + public string v_WebElementIndex { get; set; } + + /// + /// search WebElement action + /// + /// + /// + protected void SearchWebElementAction(Action actionFunc, Engine.AutomationEngineInstance engine) + { + this.WebDriverActionCore(new System.Action(seleniumInsntance => + { + var elem = this.SearchWebElement(seleniumInsntance, engine); + actionFunc(elem); + }), engine); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumWebDriverActionCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumWebDriverActionCommands.cs new file mode 100644 index 000000000..554b4dd13 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumWebDriverActionCommands.cs @@ -0,0 +1,24 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for WebDriver action commands + /// + public abstract class ASeleniumWebDriverActionCommands : ASeleniumDoSomethingToWebDriverCommands, ISeleniumWebDriverActionProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_InputInstanceName))] + public override string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnore))] + [PropertyDescription("When Fail Action")] + [PropertyDisplayText(false, "When Fail Action")] + [PropertyValidationRule("When Fail Action", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyIsOptional(true, "Error")] + [PropertyParameterOrder(10000)] + public virtual string v_WhenFailAction { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumWebElementActionAndScrollCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumWebElementActionAndScrollCommands.cs new file mode 100644 index 000000000..50f9fc04d --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumWebElementActionAndScrollCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for WebElement Action supports scroll to WebElement commands + /// + public abstract class ASeleniumWebElementActionAndScrollCommands : ASeleniumWebElementActionCommands, ISeleniumWebElementActionAndScrollProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_ScrollToWebElement))] + [PropertyParameterOrder(11000)] + public virtual string v_ScrollToWebElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumWebElementActionCommands.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumWebElementActionCommands.cs new file mode 100644 index 000000000..10e8973d9 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ASeleniumWebElementActionCommands.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for WebElement action commands + /// + public abstract class ASeleniumWebElementActionCommands : ASeleniumDoSomethingToWebElementCommands, ISeleniumWebElementActionProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WhenFailAction))] + [PropertyParameterOrder(10000)] + public virtual string v_WhenFailAction { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_CanExecuteJavaScriptToWebDriverExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_CanExecuteJavaScriptToWebDriverExtensionMethods.cs new file mode 100644 index 000000000..5c445e655 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_CanExecuteJavaScriptToWebDriverExtensionMethods.cs @@ -0,0 +1,34 @@ +using OpenQA.Selenium; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_CanExecuteJavaScriptToWebDriverExtensionMethods + { + /// + /// execute JavaScript + /// + /// + /// + /// + /// + public static object ExecuteJavaScript(this ICanExecuteJavaScriptToWebDriver command, IWebDriver seleniumInstance, string script) + { + var js = seleniumInstance as IJavaScriptExecutor; + return js.ExecuteScript(script); + } + + /// + /// execute JavaScript send arguments + /// + /// + /// + /// + /// + /// + public static object ExecuteJavaScript(this ICanExecuteJavaScriptToWebDriver command, IWebDriver seleniumInstance, string script, string arguments) + { + var js = seleniumInstance as IJavaScriptExecutor; + return js.ExecuteScript(script, arguments); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_CanHandleWebBrowserExtentionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_CanHandleWebBrowserExtentionMethods.cs new file mode 100644 index 000000000..e707e487a --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_CanHandleWebBrowserExtentionMethods.cs @@ -0,0 +1,143 @@ +using OpenQA.Selenium; +using System; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_CanHandleWebBrowserExtentionMethods + { + /// + /// Create WebBrowser Intance + /// + /// + /// instance name + /// + /// + /// + public static void CreateWebBrowserInstance(this ICanHandleWebDriver command, string instanceName, IWebDriver driver, string profilePath, Engine.AutomationEngineInstance engine) + { + var expandedInstanceName = instanceName.ExpandValueOrUserVariable(engine); + + engine.AddAppInstance(expandedInstanceName, (driver, profilePath)); + } + + /// + /// Get WebBrowser Instance and profile + /// + /// + /// + /// + /// + /// + public static (IWebDriver, string) GetWebBrowserInstanceAndProfilePath(this ICanHandleWebDriver command, string instanceName, AutomationEngineInstance engine) + { + var expandedInstanceName = instanceName.ExpandValueOrUserVariable(engine); + + var obj = engine.GetAppInstance(expandedInstanceName); + + if (IsWebBrowserInstance(obj, out ValueTuple pair)) + { + return pair; + } + else + { + throw new Exception($"Specified Instance is Not WebBrowser Intance. Instance Name: '{instanceName}', Expand: '{expandedInstanceName}'"); + } + } + + /// + /// get WebBrowser Instance + /// + /// + /// + /// + /// + public static IWebDriver GetWebBrowserIntance(this ICanHandleWebDriver command, string instanceName, AutomationEngineInstance engine) + { + (var ins, _) = command.GetWebBrowserInstanceAndProfilePath(instanceName, engine); + return ins; + } + + /// + /// get WebBrowser Profile Path + /// + /// + /// + /// + /// + public static string GetWebBrowserProfilePath(this ICanHandleWebDriver command, string instanceName, AutomationEngineInstance engine) + { + (_, var prof) = command.GetWebBrowserInstanceAndProfilePath(instanceName, engine); + return prof; + } + + /// + /// get instance name from WebBrowser + /// + /// + /// + /// + /// + public static string GetInstanceNameFromWebBrowserInstance(this ICanHandleWebDriver command, IWebDriver driver, AutomationEngineInstance engine) + { + (var name, _) = GetInstanceNameAndProfilePathFromWebDriver(driver, engine); + return name; + } + + /// + /// get Profile path from WebBroswer Instance + /// + /// + /// + /// + /// + public static string GetProfilePathFromWebBroswerInstance(this ICanHandleWebDriver command, IWebDriver driver, AutomationEngineInstance engine) + { + (_, var prof) = GetInstanceNameAndProfilePathFromWebDriver(driver, engine); + return prof; + } + + /// + /// get WebBrowser instance name and profile path from WebDriver + /// + /// + /// + /// (instance name, profile path) + private static (string, string) GetInstanceNameAndProfilePathFromWebDriver(IWebDriver driver, AutomationEngineInstance engine) + { + var instances = engine.AppInstances; + foreach (var kv in instances) + { + if (IsWebBrowserInstance(kv.Value, out ValueTuple pair)) + { + if (pair.Item1 == driver) + { + return (kv.Key, pair.Item2); + } + } + } + return (string.Empty, string.Empty); + } + + /// + /// check object is WebBrowser instance + /// + /// + /// + /// + private static bool IsWebBrowserInstance(object obj, out ValueTuple ret) + { + ret = (null, null); + if (obj is ValueTuple pair) + { + ret = pair; + return true; + } + else + { + return false; + } + } + + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_CanHandleWebElementExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_CanHandleWebElementExtensionMethods.cs new file mode 100644 index 000000000..0bb382d8c --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_CanHandleWebElementExtensionMethods.cs @@ -0,0 +1,99 @@ +using OpenQA.Selenium; +using System; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_CanHandleWebElementExtensionMethods + { + /// + /// expand user variable as WebElement and WebDriver + /// + /// + /// + /// + /// + /// + public static (IWebElement, IWebDriver) ExpandUserVariableAsWebElementAndWebDriver(this ICanHandleWebElement command, string str, string parameterName, Engine.AutomationEngineInstance engine) + { + var v = str.GetRawVariable(engine); + + if (IsWebElementAndWebDriverTuple(v.VariableValue, out (IWebElement, IWebDriver) webs)) + { + return webs; + } + else + { + throw new Exception($"{parameterName} '{str}' is not a WebElement-WebDriver tuple."); + } + } + + /// + /// expand user variable as WebElement + /// + /// + /// + /// + /// + /// + public static IWebElement ExpandUserVariableAsWebElement(this ICanHandleWebElement command, string str, string parameterName, Engine.AutomationEngineInstance engine) + { + (var e, _) = command.ExpandUserVariableAsWebElementAndWebDriver(str, parameterName, engine); + return e; + } + + /// + /// expand user variable as webDriver from WebElement + /// + /// + /// + /// + /// + /// + public static IWebDriver ExpandUserVariableAsWebDriverFromWebElement(this ICanHandleWebElement command, string str, string parameterName, Engine.AutomationEngineInstance engine) + { + (_, var d) = command.ExpandUserVariableAsWebElementAndWebDriver(str, parameterName, engine); + return d; + } + + /// + /// check value is WebElement-WebDriver + /// + /// + /// + /// + private static bool IsWebElementAndWebDriverTuple(object v, out ValueTuple ret) + { + if (v is ValueTuple t) + { + ret = t; + return true; + } + else + { + ret = (null, null); + return false; + } + } + + /// + /// store WebElement (and WebDriver) to user variable + /// + /// + /// + /// + public static void StoreInUserVariable(this ICanHandleWebElement command, IWebElement elem, IWebDriver driver, Engine.AutomationEngineInstance engine, string targetVariable) + { + ExtensionMethods.StoreInUserVariable(targetVariable, (elem, driver), engine, false); + } + + /// + /// get WebElement TagName + /// + /// + /// + public static string TagName(this ICanHandleWebElement command, IWebElement elem) + { + return elem.TagName.ToLower(); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumDoSomethingToWebBroswerInstancePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumDoSomethingToWebBroswerInstancePropertiesExtensionMethods.cs new file mode 100644 index 000000000..19f887b6b --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumDoSomethingToWebBroswerInstancePropertiesExtensionMethods.cs @@ -0,0 +1,84 @@ +using OpenQA.Selenium; +using System; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_SeleniumDoSomethingToWebBroswerInstancePropertiesExtensionMethods + { + /// + /// expand value or user variable as WebBrowser Instance + /// + /// + /// + /// + public static IWebDriver ExpandValueOrUserVariableAsWebBrowserInstance(this ISeleniumDoSomethingToWebDriverProperties command, Engine.AutomationEngineInstance engine) + { + return command.GetWebBrowserIntance(command.v_InstanceName, engine); + } + + /// + /// expand value or user variable as WebBrowser Instance and profile path + /// + /// + /// + /// + public static (IWebDriver, string) ExpandValueOrUserVariableAsWebBrowserInstanceAndProfilePath(this ISeleniumDoSomethingToWebDriverProperties command, Engine.AutomationEngineInstance engine) + { + return command.GetWebBrowserInstanceAndProfilePath(command.v_InstanceName, engine); + } + + /// + /// create WebBrowser instance + /// + /// + /// + /// + /// + public static void CreateWebBrowserInstance(this ISeleniumDoSomethingToWebDriverProperties command, IWebDriver driver, string profilePath, Engine.AutomationEngineInstance engine) + { + command.CreateWebBrowserInstance(command.v_InstanceName, driver, profilePath, engine); + } + + /// + /// general WebDriver action core + /// + /// + /// + /// + public static void WebDriverActionCore(this ISeleniumDoSomethingToWebDriverProperties command, Action actionFunc, AutomationEngineInstance engine, Action errorFunc = null) + { + try + { + (var driver, var profPath) = command.ExpandValueOrUserVariableAsWebBrowserInstanceAndProfilePath(engine); + actionFunc(driver, profPath); + } + catch (Exception ex) + { + if (errorFunc != null) + { + errorFunc(ex); + } + else + { + throw ex; + } + } + } + + /// + /// general WebDriver action core + /// + /// + /// IWebDriver only, not use profile folder + /// + /// + public static void WebDriverActionCore(this ISeleniumDoSomethingToWebDriverProperties command, Action actionFunc, AutomationEngineInstance engine, Action errorFunc = null) + { + command.WebDriverActionCore(new Action((dr, _) => + { + actionFunc(dr); + }), engine, errorFunc); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumDoSomethingToWebElementPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumDoSomethingToWebElementPropertiesExtensionMethods.cs new file mode 100644 index 000000000..97173c8e9 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumDoSomethingToWebElementPropertiesExtensionMethods.cs @@ -0,0 +1,91 @@ +using OpenQA.Selenium; +using System; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_SeleniumDoSomethingToWebElementPropertiesExtensionMethods + { + /// + /// expand variable as WebElement-WebDriver + /// + /// + /// + /// + /// + public static (IWebElement, IWebDriver) ExpandUserVariableAsWebElementAndWebDriver(this ISeleniumDoSomethingToWebElementProperties command, Engine.AutomationEngineInstance engine) + { + //var variableName = command.v_WebElement; + //var v = variableName.GetRawVariable(engine); + //// DBG + ////Console.WriteLine(v.VariableValue.GetType().FullName); + + //if (IsWebElementAndWebDriverTuple(v.VariableValue, out ValueTuple elemDriv)) + //{ + // return elemDriv; + //} + //else + //{ + // throw new Exception($"Variable '{variableName}' is not WebElement-WebDriver tuple"); + //} + + return command.ExpandUserVariableAsWebElementAndWebDriver(command.v_WebElement, "WebElement", engine); + } + + ///// + ///// expand user variable as WebElement + ///// + ///// + ///// + ///// + //public static IWebElement ExpandUserVariableAsWebElement(this ISeleniumDoSomethingToWebElementProperties command, Engine.AutomationEngineInstance engine) + //{ + // (var e, _) = command.ExpandUserVariableAsWebElementAndWebDriver(engine); + // return e; + //} + + ///// + ///// expand user variable as WebDriver from WebElement + ///// + ///// + ///// + ///// + //public static IWebDriver ExpandUserVariableAsWebDriverFromWebElement(this ISeleniumDoSomethingToWebElementProperties command, Engine.AutomationEngineInstance engine) + //{ + // (_, var d) = command.ExpandUserVariableAsWebElementAndWebDriver(engine); + // return d; + //} + + ///// + ///// check object is WebElement-WebDriver tuple + ///// + ///// + ///// + ///// + //private static bool IsWebElementAndWebDriverTuple(object v, out ValueTuple ret) + //{ + // if (v is ValueTuple t) + // { + // ret = t; + // return true; + // } + // else + // { + // ret = (null, null); + // return false; + // } + //} + + /// + /// WebElement action (not use try-catch) + /// + /// + /// + /// + public static void WebElementActionCore(this ISeleniumDoSomethingToWebElementProperties command, Action actionFunc, Engine.AutomationEngineInstance engine) + { + (var el, var dr) = command.ExpandUserVariableAsWebElementAndWebDriver(engine); + + actionFunc(el, dr); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumGetFromWebElementPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumGetFromWebElementPropertiesExtensionMethods.cs new file mode 100644 index 000000000..aea213f17 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumGetFromWebElementPropertiesExtensionMethods.cs @@ -0,0 +1,42 @@ +using OpenQA.Selenium; +using System; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_SeleniumGetFromWebElementPropertiesExtensionMethods + { + /// + /// get from WebElement action + /// + /// + /// + /// + /// + public static void GetFromWebElementAction(this ISeleniumGetFromWebElementProperties command, Action actionFunc, Action emptyValueFunc, Engine.AutomationEngineInstance engine) + { + try + { + command.WebElementActionAndScroll(actionFunc, engine); + } + catch (Exception ex) + { + var script = command.ToScriptCommand(); + switch(script.ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_WebElement), engine)) + { + case "set empty value": + emptyValueFunc(engine); + return; + + case "error": + throw ex; + } + + switch(script.ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_WhenFailAction), engine)) + { + case "error": + throw ex; + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumSearchMultiWebElementsParametersPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumSearchMultiWebElementsParametersPropertiesExtensionMethods.cs new file mode 100644 index 000000000..9580bf2bd --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumSearchMultiWebElementsParametersPropertiesExtensionMethods.cs @@ -0,0 +1,171 @@ +using OpenQA.Selenium; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_SeleniumSearchMultiWebElementsParametersPropertiesExtensionMethods + { + /// + /// get WebElement search func + /// + /// + /// + /// + /// + public static Func> GetSearchMethodFunc(this ISeleniumSearchMultiWebElementsParametersProperties command, AutomationEngineInstance engine) + { + switch (command.ToScriptCommand().ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_SearchMethod), engine)) + { + case "find element by xpath": + return new Func>((webDriver, parameter) => + { + var elem = webDriver.FindElement(By.XPath(parameter)); + return new ReadOnlyCollection(new List() { elem }); + }); + + case "find element by id": + return new Func>((webDriver, parameter) => + { + var elem = webDriver.FindElement(By.Id(parameter)); + return new ReadOnlyCollection(new List() { elem }); + }); + + case "find element by name": + return new Func>((webDriver, parameter) => + { + var elem = webDriver.FindElement(By.Name(parameter)); + return new ReadOnlyCollection(new List() { elem }); + }); + + case "find element by tag name": + return new Func>((webDriver, parameter) => + { + var elem = webDriver.FindElement(By.TagName(parameter)); + return new ReadOnlyCollection(new List() { elem }); + }); + + case "find element by class name": + return new Func>((webDriver, parameter) => + { + var elem = webDriver.FindElement(By.ClassName(parameter)); + return new ReadOnlyCollection(new List() { elem }); + }); + + case "find element by css selector": + return new Func>((webDriver, parameter) => + { + var elem = webDriver.FindElement(By.CssSelector(parameter)); + return new ReadOnlyCollection(new List() { elem }); + }); + + case "find element by link text": + return new Func>((webDriver, parameter) => + { + var elem = webDriver.FindElement(By.LinkText(parameter)); + return new ReadOnlyCollection(new List() { elem }); + }); + + case "find elements by xpath": + return new Func>((webDriver, parameter) => + { + return webDriver.FindElements(By.XPath(parameter)); + }); + + case "find elements by id": + return new Func>((webDriver, parameter) => + { + return webDriver.FindElements(By.Id(parameter)); + }); + + case "find elements by name": + return new Func>((webDriver, parameter) => + { + return webDriver.FindElements(By.Name(parameter)); + }); + + case "find elements by tag name": + return new Func>((webDriver, parameter) => + { + return webDriver.FindElements(By.TagName(parameter)); + }); + + case "find elements by class name": + return new Func>((webDriver, parameter) => + { + return webDriver.FindElements(By.ClassName(parameter)); + }); + + case "find elements by css selector": + return new Func>((webDriver, parameter) => + { + return webDriver.FindElements(By.CssSelector(parameter)); + }); + + case "find elements by link text": + return new Func>((webDriver, parameter) => + { + return webDriver.FindElements(By.LinkText(parameter)); + }); + + default: + throw new Exception($"Strange Search Method '{command.v_SearchMethod}'"); + } + } + + /// + /// search multi WebElements + /// + /// + /// + /// + /// + /// + public static List SearchMultiWebElements(this ISeleniumSearchMultiWebElementsParametersProperties command, ISearchContext root, AutomationEngineInstance engine) + { + var script = command.ToScriptCommand(); + var searchParameter = script.ExpandValueOrUserVariable(nameof(command.v_SearchParameter), "Search Parameter", engine); + var waitTime = script.ExpandValueOrUserVariableAsInteger(nameof(command.v_WaitTimeForWebElement), "Wait Time", engine); + + var searchFunc = command.GetSearchMethodFunc(engine); + + var ret = WaitControls.WaitProcess(waitTime, "WebElement", new Func<(bool, object)>(() => { + try + { + var t = searchFunc(root, searchParameter); + if (t is ReadOnlyCollection elems) + { + if (elems.Count > 0) + { + return (true, elems); + } + else + { + return (false, null); + } + } + else + { + return (false, null); + } + } + catch + { + return (false, null); + } + }), engine); + + if (ret is ReadOnlyCollection resultElems) + { + return resultElems.ToList(); + } + else + { + throw new Exception($"WebElements not found. Search Method: '{command.v_SearchMethod}', Search Parameter: '{command.v_SearchParameter}'"); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumSearchWebElementParametersPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumSearchWebElementParametersPropertiesExtensionMethods.cs new file mode 100644 index 000000000..b5633b3b0 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumSearchWebElementParametersPropertiesExtensionMethods.cs @@ -0,0 +1,49 @@ +using OpenQA.Selenium; +using System; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_SeleniumSearchWebElementParametersPropertiesExtensionMethods + { + /// + /// search WebElement + /// + /// + /// + /// + /// + /// + public static IWebElement SearchWebElement(this ISeleniumSearchWebElementParametersProperties command, ISearchContext root, AutomationEngineInstance engine) + { + var script = command.ToScriptCommand(); + + if (string.IsNullOrEmpty(command.v_WebElementIndex)) + { + command.v_WebElementIndex = "0"; + } + var index = script.ExpandValueOrUserVariableAsInteger(nameof(command.v_WebElementIndex), "Index", engine); + + var elems = command.SearchMultiWebElements(root, engine); + if (elems.Count > 0) + { + if (index < 0) + { + index += elems.Count; + } + if ((index >= 0) && (index < elems.Count)) + { + return elems[index]; + } + else + { + throw new Exception($"WebElement not found, out of index. Search Method: '{command.v_SearchMethod}', Search Parameter: '{command.v_SearchParameter}', Index: '{command.v_WebElementIndex}', Expand Index: '{index}'"); + } + } + else + { + throw new Exception($"WebElement not found. Search Method: '{command.v_SearchMethod}', Search Parameter: '{command.v_SearchParameter}', Index: '{command.v_WebElementIndex}', Expand Index: '{index}'"); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebDriverActionPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebDriverActionPropertiesExtensionMethods.cs new file mode 100644 index 000000000..56c0ab842 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebDriverActionPropertiesExtensionMethods.cs @@ -0,0 +1,83 @@ +using OpenQA.Selenium; +using System; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_SeleniumWebDriverActionPropertiesExtensionMethods + { + /// + /// WebDriver action + /// + /// + /// func(IWebDriver, profilePath) + /// + /// + public static void WebDriverAction(this ISeleniumWebDriverActionProperties command, Action actionFunc, AutomationEngineInstance engine, Action errorFunc = null) + { + try + { + command.WebDriverActionCore(actionFunc, engine, errorFunc); + } + catch (Exception ex) + { + switch (command.ToScriptCommand().ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_WhenFailAction), engine)) + { + case "error": + if (errorFunc != null) + { + errorFunc(ex); + } + else + { + throw ex; + } + break; + + case "ignore": + break; + } + } + + //try + //{ + // (var driver, string prof) = command.ExpandValueOrUserVariableAsWebBrowserInstanceAndProfilePath(engine); + // actionFunc(driver, prof); + //} + //catch (Exception ex) + //{ + // switch(command.ToScriptCommand().ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_WhenFailAction), engine)) + // { + // case "error": + // if (errorFunc != null) + // { + // errorFunc(ex); + // } + // else + // { + // throw ex; + // } + // break; + + // case "ignore": + // break; + // } + //} + } + + /// + /// WebDriver action, not used profile path + /// + /// + /// + /// + /// + public static void WebDriverAction(this ISeleniumWebDriverActionProperties command, Action actionFunc, AutomationEngineInstance engine, Action errorFunc = null) + { + command.WebDriverAction(new Action((driver, _) => + { + actionFunc(driver); + }), engine, errorFunc); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebElementActionAndScrollPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebElementActionAndScrollPropertiesExtensionMethods.cs new file mode 100644 index 000000000..a59c982d8 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebElementActionAndScrollPropertiesExtensionMethods.cs @@ -0,0 +1,33 @@ +using OpenQA.Selenium; +using System; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_SeleniumWebElementActionAndScrollPropertiesExtensionMethods + { + /// + /// WebElement Action and Scroll + /// + /// + /// + /// + /// + public static void WebElementActionAndScroll(this ISeleniumWebElementActionAndScrollProperties command, Action actionFunc, Engine.AutomationEngineInstance engine, Action errorFunc = null) + { + command.WebElementAction(new Action((el, dr) => + { + var cmd = command.ToScriptCommand(); + if (cmd.ExpandValueOrUserVariableAsYesNo(nameof(command.v_ScrollToWebElement), engine)) + { + var scroll = new SeleniumBrowserScrollToWebElementCommand() + { + v_WebElement = command.v_WebElement, + v_WhenFailAction = command.v_WebElement, + }; + scroll.RunCommand(engine); + } + actionFunc(el, dr); + }), engine, errorFunc); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebElementActionPropertiesExtensionMehtods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebElementActionPropertiesExtensionMehtods.cs new file mode 100644 index 000000000..92f68ab92 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebElementActionPropertiesExtensionMehtods.cs @@ -0,0 +1,61 @@ +using OpenQA.Selenium; +using System; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_SeleniumWebElementActionPropertiesExtensionMehtods + { + /// + /// WebElement Action + /// + /// + /// + /// + /// + public static void WebElementAction(this ISeleniumWebElementActionProperties command, Action actionFunc, Engine.AutomationEngineInstance engine, Action errorFunc = null) + { + command.WebElementActionCore(new Action((el, dr) => + { + try + { + actionFunc(el, dr); + } + catch (Exception ex) + { + switch(command.ToScriptCommand().ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_WhenFailAction), engine)) + { + case "ignore": + break; + case "error": + if (errorFunc != null) + { + errorFunc(ex); + } + else + { + throw ex; + } + break; + } + } + }), engine); + } + + /// + /// get fail action message + /// + /// + /// + /// + public static string GetFailActionMessage(string actionName, IWebElement elem = null) + { + var ret = $"Specified WebElement does Not Support {actionName} action."; + if (elem != null) + { + ret+= $"TagName: '{elem.TagName}'"; + } + + return ret; + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebElementResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebElementResultPropertiesExtensionMethods.cs new file mode 100644 index 000000000..5d42c47e6 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/EM_SeleniumWebElementResultPropertiesExtensionMethods.cs @@ -0,0 +1,19 @@ +using OpenQA.Selenium; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class EM_SeleniumWebElementResultPropertiesExtensionMethods + { + /// + /// store WebElement in User variable + /// + /// + /// + /// + /// + public static void StoreWebElementInUserVariable(this ISeleniumWebElementResultProperties command, IWebElement elem, IWebDriver seleniumInstance, Engine.AutomationEngineInstance engine) + { + (elem, seleniumInstance).StoreInUserVariable(engine, command.v_Result); + } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ICanExecuteJavaScriptToWebDriver.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ICanExecuteJavaScriptToWebDriver.cs new file mode 100644 index 000000000..4c3295737 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ICanExecuteJavaScriptToWebDriver.cs @@ -0,0 +1,11 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for execute javascript + /// + public interface ICanExecuteJavaScriptToWebDriver + { + // nothing + // TODO: only use Execute JavScript command + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ICanHandleWebDriver.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ICanHandleWebDriver.cs new file mode 100644 index 000000000..e5f370266 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ICanHandleWebDriver.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// can handle WebDriver + /// + public interface ICanHandleWebDriver + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ICanHandleWebElement.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ICanHandleWebElement.cs new file mode 100644 index 000000000..eb400dc5a --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ICanHandleWebElement.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// can handle WebElement + /// + public interface ICanHandleWebElement : ICanHandleWebDriver + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumCreateWebDriverProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumCreateWebDriverProperties.cs new file mode 100644 index 000000000..6c95a1b1c --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumCreateWebDriverProperties.cs @@ -0,0 +1,23 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for create WebDriver properties + /// + public interface ISeleniumCreateWebDriverProperties : ISeleniumDoSomethingToWebDriverProperties + { + /// + /// WebBrowser type + /// + string v_BrowserType { get; set; } + + /// + /// WebDriver binary path + /// + string v_WebDriverPath { get; set; } + + /// + /// show/hide WebDriver terminal window + /// + string v_HideTerminalWindow { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumDoSomethingToWebDriverProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumDoSomethingToWebDriverProperties.cs new file mode 100644 index 000000000..edfab270f --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumDoSomethingToWebDriverProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// do something to WebDriver properties + /// + public interface ISeleniumDoSomethingToWebDriverProperties : ICanHandleWebDriver, IExpandableProperties + { + /// + /// WebBrowser instance name + /// + string v_InstanceName { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumDoSomethingToWebElementProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumDoSomethingToWebElementProperties.cs new file mode 100644 index 000000000..b53dab44c --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumDoSomethingToWebElementProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// do something to WebElement properties + /// + public interface ISeleniumDoSomethingToWebElementProperties : ICanHandleWebElement, IExpandableProperties + { + /// + /// target WebElement variable name + /// + string v_WebElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumExecuteJavaScriptProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumExecuteJavaScriptProperties.cs new file mode 100644 index 000000000..75e4a325a --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumExecuteJavaScriptProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// selenium Execute JavaScript properties + /// + public interface ISeleniumExecuteJavaScriptProperties : ISeleniumWebDriverActionProperties, IResultProperties, ICanExecuteJavaScriptToWebDriver + { + /// + /// arguments + /// + string v_Arguments { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumGetFromWebElementProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumGetFromWebElementProperties.cs new file mode 100644 index 000000000..035aadd0d --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumGetFromWebElementProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// get from webElement properties + /// + public interface ISeleniumGetFromWebElementProperties : ISeleniumWebElementActionAndScrollProperties + { + /// + /// when value(s) can not retrieved + /// + string v_WhenValueCanNotRetrieved { get;set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumSearchMultiWebElementsParametersProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumSearchMultiWebElementsParametersProperties.cs new file mode 100644 index 000000000..da9ef6589 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumSearchMultiWebElementsParametersProperties.cs @@ -0,0 +1,23 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for search multi WebElements properties + /// + public interface ISeleniumSearchMultiWebElementsParametersProperties : IExpandableProperties + { + /// + /// WebElement search method + /// + string v_SearchMethod { get; set; } + + /// + /// WebElement search parameter + /// + string v_SearchParameter { get; set; } + + /// + /// Wait time for WebElement + /// + string v_WaitTimeForWebElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumSearchWebElementParametersProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumSearchWebElementParametersProperties.cs new file mode 100644 index 000000000..787eb3cad --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumSearchWebElementParametersProperties.cs @@ -0,0 +1,28 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for WebElement search parameters + /// + public interface ISeleniumSearchWebElementParametersProperties : ISeleniumSearchMultiWebElementsParametersProperties, IExpandableProperties + { + ///// + ///// WebElement search method + ///// + //string v_SearchMethod { get; set; } + + ///// + ///// WebElement search parameter + ///// + //string v_SearchParameter { get; set; } + + /// + /// WebElement index + /// + string v_WebElementIndex { get; set; } + + ///// + ///// Wait time for WebElement + ///// + //string v_WaitTimeForWebElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebBrowserInstanceActionProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebBrowserInstanceActionProperties.cs new file mode 100644 index 000000000..3b16c5c84 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebBrowserInstanceActionProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// WebBrowser instance action properties + /// + public interface ISeleniumWebBrowserInstanceActionProperties : ISeleniumDoSomethingToWebDriverProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebDriverActionProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebDriverActionProperties.cs new file mode 100644 index 000000000..bdb07386b --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebDriverActionProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public interface ISeleniumWebDriverActionProperties : ISeleniumDoSomethingToWebDriverProperties + { + /// + /// behavior when fail action + /// + string v_WhenFailAction { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebElementActionAndScrollProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebElementActionAndScrollProperties.cs new file mode 100644 index 000000000..961baa1c9 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebElementActionAndScrollProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for WebElement Action supports scroll to WebElement commands + /// + public interface ISeleniumWebElementActionAndScrollProperties : ISeleniumWebElementActionProperties + { + /// + /// scroll to WebElement before Action + /// + string v_ScrollToWebElement { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebElementActionProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebElementActionProperties.cs new file mode 100644 index 000000000..ab3370ec5 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebElementActionProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// for WebElement action commands properties + /// + public interface ISeleniumWebElementActionProperties : ISeleniumDoSomethingToWebElementProperties + { + /// + /// behavior when Fail action + /// + string v_WhenFailAction { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebElementResultProperties.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebElementResultProperties.cs new file mode 100644 index 000000000..f3a7a6637 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/ISeleniumWebElementResultProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + /// + /// WebElement result properties + /// + public interface ISeleniumWebElementResultProperties : IResultProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserAttachWebBrowserInstanceCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserAttachWebBrowserInstanceCommand.cs new file mode 100644 index 000000000..c33f74a97 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserAttachWebBrowserInstanceCommand.cs @@ -0,0 +1,146 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Instance")] + [Attributes.ClassAttributes.CommandSettings("Attach Web Browser Instance")] + [Attributes.ClassAttributes.Description("This command allows you to Attach to the running WebBrowser and Create an Instance.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Attach to the running WebBrowser and Create an Instance.")] + [Attributes.ClassAttributes.ImplementationDescription("Supported only on Chrome and Edge.Specifying parameters **--remote-debugging-port** and **--user-data-dir** is required.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserAttachCreateWebBrowserInstanceCommand : ASeleniumCreateWebDriverCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_InputInstanceName))] + //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] + //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.TextBox)] + //[PropertyTextBoxSetting(1, false)] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("Web Browser Type")] + //[PropertyUISelectionOption("Edge")] + //[PropertyUISelectionOption("Chrome")] + //[PropertyUISelectionOption("Firefox")] + //[InputSpecification("", true)] + //[Remarks("")] + //[PropertyIsOptional(true, "Chrome")] + //[PropertyFirstValue("Chrome")] + //[PropertyDisplayText(true, "Web Browser Type")] + //public string v_BrowserType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Debugger Address (Edge/Chrome only)")] + [PropertyIsOptional(true, "127.0.0.1")] + [PropertyValidationRule("Debugger Address", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Address")] + [PropertyParameterOrder(7000)] + public string v_DebuggerAddress { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Debugger Port (Edge/Chrome only)")] + [PropertyIsOptional(true, "9222")] + [PropertyValidationRule("Debugger Port", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Port")] + [PropertyParameterOrder(7100)] + public string v_DebuggerPort { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + //public string v_Handle { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Web Driver Binary Path")] + //[InputSpecification("Web Driver Binary Path", true)] + //[PropertyDetailSampleUsage("**C:\\temp\\WebDriverPath.exe**", PropertyDetailSampleUsage.ValueType.Value, "WebDriver Path")] + //[PropertyDetailSampleUsage("**{{{vBrowserPath}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebDriver Path")] + //[Remarks("When path is Empty, taskt uses default WebDriver.\nIE is not supported.\nIf you use a fixed web browser version, use this parameter.")] + //[PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFileSelectionHelper)] + //[PropertyIsOptional(true, "Empty")] + //[PropertyDisplayText(false, "")] + //public string v_WebDriverPath { get; set; } + + public SeleniumBrowserAttachCreateWebBrowserInstanceCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + string GetDebuggerInfo() + { + if (string.IsNullOrEmpty(v_DebuggerAddress)) + { + v_DebuggerAddress = "127.0.0.1"; + } + var address = this.ExpandValueOrUserVariable(nameof(v_DebuggerAddress), "Debugger Address", engine); + + if (string.IsNullOrEmpty(v_DebuggerPort)) + { + v_DebuggerPort = "9222"; + } + var port = this.ExpandValueOrUserVariableAsInteger(nameof(v_DebuggerPort), engine); + if (port < 0 || port > 65535) + { + throw new Exception($"Strange Debugger Port. Port: '{v_DebuggerPort}', Expand Value: '{port}'"); + } + return $"{address}:{port}"; + } + + OpenQA.Selenium.DriverService driverService = null; + OpenQA.Selenium.IWebDriver webDriver = null; + + var seleniumEngine = SelectionItemsControls.ExpandValueOrUserVariableAsSelectionItem(this, nameof(v_BrowserType), engine); + switch(seleniumEngine) + { + case "chrome": + var chromeOptions = new OpenQA.Selenium.Chrome.ChromeOptions + { + DebuggerAddress = GetDebuggerInfo(), + }; + + driverService = CreateWebDriverService(seleniumEngine, engine); + + webDriver = new OpenQA.Selenium.Chrome.ChromeDriver((OpenQA.Selenium.Chrome.ChromeDriverService)driverService, chromeOptions); + break; + + case "edge": + var edgeOptions = new OpenQA.Selenium.Edge.EdgeOptions + { + DebuggerAddress = GetDebuggerInfo(), + }; + + driverService = CreateWebDriverService(seleniumEngine, engine); + + webDriver = new OpenQA.Selenium.Edge.EdgeDriver((OpenQA.Selenium.Edge.EdgeDriverService)driverService, edgeOptions); + break; + + case "firefox": + // https://stackoverflow.com/questions/68340118/how-can-i-attach-firefoxdriver-to-a-running-instance-of-firefox + // https://stackoverflow.com/questions/37514778/adding-second-instance-of-firefox-with-marionette-change-port + var ffOptions = new OpenQA.Selenium.Firefox.FirefoxOptions(); + + driverService = CreateWebDriverService(seleniumEngine, engine); + var ffDriver = (OpenQA.Selenium.Firefox.FirefoxDriverService)driverService; + ffDriver.BrowserCommunicationPort = 2828; + ffDriver.ConnectToRunningBrowser = true; + + webDriver = new OpenQA.Selenium.Firefox.FirefoxDriver((OpenQA.Selenium.Firefox.FirefoxDriverService)driverService, ffOptions); + break; + } + + // add app instance + this.CreateWebBrowserInstance(v_InstanceName, webDriver, string.Empty, engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCheckBrowserInstanceExistsCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCheckBrowserInstanceExistsCommand.cs similarity index 65% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCheckBrowserInstanceExistsCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCheckBrowserInstanceExistsCommand.cs index e8c20a42d..eb6d45c5a 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserCheckBrowserInstanceExistsCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCheckBrowserInstanceExistsCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -14,16 +15,17 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserCheckBrowserInstanceExistsCommand : ScriptCommand + public sealed class SeleniumBrowserCheckBrowserInstanceExistsCommand : ASeleniumGetFromWebDriverCommands { [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_InputInstanceName))] + public override string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] [Remarks("When WebBrowser Instance Exists, Result is **True**")] - public string v_applyToVariableName { get; set; } + [PropertyParameterOrder(6000)] + public override string v_Result { get; set; } public SeleniumBrowserCheckBrowserInstanceExistsCommand() { @@ -36,14 +38,23 @@ public SeleniumBrowserCheckBrowserInstanceExistsCommand() } public override void RunCommand(Engine.AutomationEngineInstance engine) { + //try + //{ + // var _ = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + // true.StoreInUserVariable(engine, v_applyToVariableName); + //} + //catch + //{ + // false.StoreInUserVariable(engine, v_applyToVariableName); + //} try { - var _ = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - true.StoreInUserVariable(engine, v_applyToVariableName); + var ins = this.GetWebBrowserIntance(v_InstanceName, engine); + (ins != null).StoreInUserVariable(engine, v_Result); } catch { - false.StoreInUserVariable(engine, v_applyToVariableName); + false.StoreInUserVariable(engine, v_Result); } } } diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCheckWebElementExistsCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCheckWebElementExistsCommand.cs new file mode 100644 index 000000000..1136f4195 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCheckWebElementExistsCommand.cs @@ -0,0 +1,76 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Search WebElement")] + [Attributes.ClassAttributes.CommandSettings("Check WebElement Exists")] + [Attributes.ClassAttributes.Description("This command allows you to check WebElement existance.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to check WebElement existance.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserCheckWebElementExistsCommand : ASeleniumSearchWebElementFromWebDriverCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] + //public string v_WebElementIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] + [Remarks("When WebElement exists, Result is **True**")] + [PropertyParameterOrder(8000)] + public override string v_Result { get; set; } + + [XmlAttribute] + [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + [PropertyIsOptional(true, "0")] + [PropertyFirstValue("0")] + public override string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserCheckWebElementExistsCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //try + //{ + // SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WebElementIndex), nameof(v_WaitTimeForWebElement), engine); + // true.StoreInUserVariable(engine, v_Result); + //} + //catch + //{ + // false.StoreInUserVariable(engine, v_Result); + //} + try + { + this.SearchWebElementAction(new Action(elem => + { + true.StoreInUserVariable(engine, v_Result); + }), engine); + } + catch + { + false.StoreInUserVariable(engine, v_Result); + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserClearTextInWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserClearTextInWebElementCommand.cs new file mode 100644 index 000000000..00564af42 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserClearTextInWebElementCommand.cs @@ -0,0 +1,104 @@ +using System; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("WebElement Action")] + [Attributes.ClassAttributes.CommandSettings("Clear Text In WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Clear Text in WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Clear Text in WebElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserClearTextInWebElementCommand : ASeleniumWebElementActionAndScrollCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When the WebElement does not support Clear Text")] + //[PropertyUISelectionOption("Error")] + //[PropertyUISelectionOption("Ignore")] + //[PropertyIsOptional(true, "Error")] + //[PropertyDisplayText(false, "")] + //public string v_WhenFailAction { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //[PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] + //public string v_ScrollToWebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyIsOptional(true)] + //public string v_InstanceName { get; set; } + + public SeleniumBrowserClearTextInWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToWebElement), engine)) + //{ + // var scroll = new SeleniumBrowserScrollToWebElementCommand + // { + // //v_InstanceName = this.v_InstanceName, + // v_WebElement = this.v_WebElement, + // v_WhenFailAction = "ignore" + // }; + // scroll.RunCommand(engine); + //} + + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + + //switch (elem.TagName.ToLower()) + //{ + // case "input": + // case "textarea": + // elem.Clear(); + // break; + // default: + // if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailAction), engine) == "error") + // { + // throw new Exception("Specified WebElement does not support Clear Text. TagName: '" + elem.TagName + "'"); + // } + // break; + //} + + this.WebElementActionAndScroll( + new Action((el, dr) => + { + switch (el.TagName.ToLower()) + { + case "input": + case "textarea": + el.Clear(); + break; + default: + //if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailAction), engine) == "error") + //{ + // throw new Exception($"Specified WebElement does not support Clear Text. TagName: '" + elem.TagName + "'"); + //} + throw new Exception(); + //break; + } + }), engine, + new Action(ex => + { + throw new Exception(EM_SeleniumWebElementActionPropertiesExtensionMehtods.GetFailActionMessage("Clear Text")); + }) + ); + } + + //private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserClickWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserClickWebElementCommand.cs new file mode 100644 index 000000000..805989a6f --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserClickWebElementCommand.cs @@ -0,0 +1,171 @@ +using System; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("WebElement Action")] + [Attributes.ClassAttributes.CommandSettings("Click WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Click to WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Click to WebElement.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserClickWebElementCommand : ASeleniumWebElementActionAndScrollCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_MouseClickType))] + [PropertyUISelectionOption("Invoke Click")] + [PropertyFirstValue("Invoke Click")] + [PropertySelectionChangeEvent(nameof(cmdClickType_SelectinChange))] + [PropertyParameterOrder(6000)] + public string v_ClickType { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyIsOptional(true)] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_XOffsetAdjustment))] + [PropertyFirstValue("2")] + //[Remarks("It is strongly recommended to Enter a value between **10** and **20** depending on your WebBrowser.")] + [PropertyParameterOrder(7000)] + public string v_XOffset { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(KeyMouseControls), nameof(KeyMouseControls.v_YOffsetAdjustment))] + [PropertyFirstValue("2")] + //[Remarks("It is strongly recommended to Enter a value between **100** and **200** depending on your WebBrowser.")] + [PropertyParameterOrder(7100)] + public string v_YOffset { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When Fail Click")] + //[PropertyUISelectionOption("Error")] + //[PropertyUISelectionOption("Ignore")] + //[PropertyIsOptional(true, "Error")] + //[PropertyDisplayText(false, "")] + //public string v_WhenFailAction { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //[PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] + //public string v_ScrollToWebElement { get; set; } + + public SeleniumBrowserClickWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WebElementActionAndScroll( + new Action((el, dr) => + { + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ClickType), engine)) + { + case "invoke click": + el.Click(); + break; + + default: + //int baseX, baseY; + //using (var vX = new InnerScriptVariable(engine)) + //{ + // using (var vY = new InnerScriptVariable(engine)) + // { + // var insName = this.GetInstanceNameFromWebBrowserInstance(dr, engine); + + // var getPos = new SeleniumBrowserGetWebBrowserPositionCommand() + // { + // v_InstanceName = insName, + // v_PositionType = "Viewport", + // v_XPosition = vX.VariableName, + // v_YPosition = vY.VariableName, + // }; + // getPos.RunCommand(engine); + + // baseX = int.Parse(vX.VariableValue.ToString()); + // baseY = int.Parse(vY.VariableValue.ToString()); + // } + //} + + //var elementLocation = el.Location; + + int elemX, elemY; + using (var vX = new InnerScriptVariable(engine)) + { + using (var vY = new InnerScriptVariable(engine)) + { + var getPos = new SeleniumBrowserGetWebElementPositionCommand() + { + v_WebElement = this.v_WebElement, + v_XPosition = vX.VariableName, + v_YPosition = vY.VariableName, + v_PositionType = "Screen", + }; + getPos.RunCommand(engine); + elemX = int.Parse(vX.VariableValue.ToString()); + elemY = int.Parse(vY.VariableValue.ToString()); + } + } + + var offsetX = this.ExpandValueOrUserVariableAsInteger(nameof(v_XOffset), engine); + var offsetY = this.ExpandValueOrUserVariableAsInteger(nameof(v_YOffset), engine); + + //var clickX = elementLocation.X + baseX + offsetX; + //var clickY = elementLocation.Y + baseY + offsetY; + var clickX = elemX + offsetX; + var clickY = elemY + offsetY; + + var clickCommand = new MoveMouseCommand() + { + v_MouseClick = this.v_ClickType, + v_XMousePosition = clickX.ToString(), + v_YMousePosition = clickY.ToString(), + }; + clickCommand.RunCommand(engine); + break; + } + }), engine, + new Action(ex => + { + throw new Exception($"{EM_SeleniumWebElementActionPropertiesExtensionMehtods.GetFailActionMessage("Click")} Click Type: '{v_ClickType}'"); + }) + ); + } + + //private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) + //{ + // //SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); + // var useInstance = (((ComboBox)sender).SelectedItem?.ToString().ToLower() ?? "") != "no"; + + // var inst = ControlsList.GetPropertyControl(nameof(v_InstanceName)); + // useInstance = useInstance && ((inst.SelectedItem?.ToString().ToLower() ?? "") != "invoke click"); + + // FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_InstanceName), useInstance); + //} + + private void cmdClickType_SelectinChange(object sender, EventArgs e) + { + var useOffset = (((ComboBox)sender).SelectedItem?.ToString().ToLower() ?? "") != "invoke click"; + FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_XOffset), useOffset); ; + FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_YOffset), useOffset); ; + + var scroll = ControlsList.GetPropertyControl(nameof(v_ScrollToWebElement)); + var useInstance = useOffset || ((scroll.SelectedItem?.ToString().ToLower() ?? "") != "no"); + //FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_InstanceName), useInstance); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCloseWebBrowserInstanceCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCloseWebBrowserInstanceCommand.cs new file mode 100644 index 000000000..cc3d28c20 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCloseWebBrowserInstanceCommand.cs @@ -0,0 +1,91 @@ +using System; +using System.IO; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Instance")] + [Attributes.ClassAttributes.CommandSettings("Close Web Browser Instance")] + [Attributes.ClassAttributes.Description("This command allows you to close a Selenium web browser session.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to close and end a web browser session.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserCloseWebBrowserInstanceCommand : ASeleniumWebDriverActionCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Delete Profile Folder when Specified")] + [PropertyUISelectionOption("Recycle Bin")] + [PropertyIsOptional(true, "Yes")] + [PropertyValidationRule("Delete Profile", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Delete Profile")] + [PropertyParameterOrder(7000)] + public string v_DeleteProfileFolder { get; set; } + + public SeleniumBrowserCloseWebBrowserInstanceCommand() + { + //this.CommandName = "SeleniumBrowserCloseCommand"; + //this.SelectionName = "Close Browser"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var vInstance = v_InstanceName.ExpandValueOrUserVariable(engine); + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + + //seleniumInstance.Quit(); + //seleniumInstance.Dispose(); + + //engine.RemoveAppInstance(vInstance); + + this.WebDriverAction(new Action((seleniumInstance, profilePath) => + { + seleniumInstance.Quit(); + seleniumInstance.Dispose(); + + var instanceName = this.GetInstanceNameFromWebBrowserInstance(seleniumInstance, engine); + engine.RemoveAppInstance(instanceName); + + if (!string.IsNullOrEmpty(profilePath)) + { + if (Directory.Exists(profilePath)) + { + var isRemove = false; + var isRecycle = "no"; + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_DeleteProfileFolder), engine)) + { + case "yes": + isRemove = true; + break; + case "recycle bin": + isRemove = true; + isRecycle = "yes"; + break; + } + if (isRemove) + { + var removeFolder = new DeleteFolderCommand() + { + v_TargetFolderPath = profilePath, + v_MoveToRecycleBin = isRecycle, + }; + removeFolder.RunCommand(engine); + } + } + } + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCreateWebBrowserInstanceCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCreateWebBrowserInstanceCommand.cs new file mode 100644 index 000000000..c5b346a65 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserCreateWebBrowserInstanceCommand.cs @@ -0,0 +1,383 @@ +using OpenQA.Selenium; +using OpenQA.Selenium.Chromium; +using System; +using System.IO; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Instance")] + [Attributes.ClassAttributes.CommandSettings("Create Web Browser Instance")] + [Attributes.ClassAttributes.Description("This command allows you to create a new Selenium web browser session which enables automation for websites.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to create a browser that will eventually perform web automation such as checking an internal company intranet site to retrieve data.\nIf this command does not work, please check your browser version, and WebDriver version.\nYou can check the WebDriver version with \"foo.exe -v\" in command prompt.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserCreateWebBrowserInstanceCommand : ASeleniumCreateWebDriverCommands, ICanHandleWindowHandle + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] + //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.TextBox)] + //[PropertyTextBoxSetting(1, false)] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("Web Browser Type")] + [PropertyUISelectionOption("Edge")] + [PropertyUISelectionOption("Chrome")] + [PropertyUISelectionOption("Firefox")] + [PropertyUISelectionOption("IE")] + //[PropertyUISelectionOptionBehavior(MultiAttributesBehavior.Merge)] + //[InputSpecification("", true)] + //[Remarks("")] + //[PropertyIsOptional(true, "Chrome")] + //[PropertyFirstValue("Chrome")] + //[PropertyDisplayText(true, "Web Browser Type")] + //[PropertyParameterOrder(6000)] + public override string v_BrowserType { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("Instance Tracking (After task ends)")] + //[PropertyUISelectionOption("Forget Instance")] + //[PropertyUISelectionOption("Keep Instance Alive")] + //[InputSpecification("Specify if taskt should remember this instance name after the script has finished executing.")] + ////[SampleUsage("Select **Forget Instance** to or **Keep Instance Alive** to allow subsequent tasks to call the instance by name.")] + //[PropertyDetailSampleUsage("**Forget Instance**", "Forget the instance After tasks ends")] + //[PropertyDetailSampleUsage("**Keep Instance Alive**", "Allow subsequent tasks to call the instance by name")] + //[Remarks("Calling the **Close Browser** command or ending the browser session will end the instance. This command only works during the lifetime of the application. If the application is closed, the references will be forgetten automatically.")] + //[PropertyIsOptional(true, "Forget Instance")] + //[PropertyDisplayText(false, "")] + //public string v_InstanceTracking { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Window State")] + [PropertyUISelectionOption("Normal")] + [PropertyUISelectionOption("Maximize")] + [InputSpecification("Select the window state that the browser should start up with.")] + //[SampleUsage("Select **Normal** to start the browser in normal mode or **Maximize** to start the browser in maximized mode.")] + [PropertyDetailSampleUsage("**Normal**", "Start the WebBrowser in Normal mode")] + [PropertyDetailSampleUsage("**Maximize**", "Start the WebBrowser in maximized mode")] + //[Remarks("")] + [PropertyIsOptional(true, "Normal")] + [PropertyDisplayText(false, "Window State")] + [PropertyParameterOrder(7000)] + public string v_BrowserWindowOption { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Profile Folder Path")] + [PropertyIsOptional(true)] + [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFolderSelectionHelper)] + [PropertyValidationRule("Profile", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Profile")] + [PropertyParameterOrder(8000)] + public string v_ProfileFolder { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Use Headless")] + [PropertyIsOptional(true, "No")] + [PropertyFirstValue("No")] + [PropertyDisplayText(false, "Use Headless")] + [Remarks("Headless mode does not show WebBrowser window")] + [PropertyParameterOrder(9000)] + public string v_HeadlessMode { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_MultiLinesTextBox))] + [PropertyDescription("Web Browser Command Line Options (one option per line)")] + [InputSpecification("Command Line Options", true)] + [SampleUsage("user-data-dir=c:\\users\\public\\SeleniumTasktProfile")] + [Remarks("")] + [PropertyIsOptional(true)] + [PropertyTextBoxSetting(3, true)] + [PropertyDisplayText(false, "")] + [PropertyParameterOrder(10000)] + public string v_SeleniumOptions { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] + [PropertyParameterOrder(11000)] + public string v_WindowHandleResult { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Web Browser Binary Path")] + [InputSpecification("Web Browser Binary Path", true)] + //[SampleUsage("**C:\\temp\\BrowserPath.exe** or **{{{vPath}}}**")] + [PropertyDetailSampleUsage("**C:\\temp\\BrowserPath.exe**", PropertyDetailSampleUsage.ValueType.Value, "WebBrowser Path")] + [PropertyDetailSampleUsage("**{{{vBrowserPath}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebBrowser Path")] + [Remarks("When path is Empty, taskt try open default path.\nEdge and IE is not supported.\nIf you use a fixed web browser version, use this parameter.")] + [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFileSelectionHelper)] + [PropertyIsOptional(true, "Empty")] + [PropertyDisplayText(false, "Web Browser Binary")] + [PropertyParameterOrder(12000)] + public string v_BrowserPath { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Web Driver Binary Path")] + //[InputSpecification("Web Driver Binary Path", true)] + ////[SampleUsage("**C:\\temp\\WebDriverPath.exe** or **{{{vPath}}}**")] + //[PropertyDetailSampleUsage("**C:\\temp\\WebDriverPath.exe**", PropertyDetailSampleUsage.ValueType.Value, "WebDriver Path")] + //[PropertyDetailSampleUsage("**{{{vBrowserPath}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebDriver Path")] + //[Remarks("When path is Empty, taskt uses default WebDriver.\nIE is not supported.\nIf you use a fixed web browser version, use this parameter.")] + //[PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFileSelectionHelper)] + //[PropertyIsOptional(true, "Empty")] + //[PropertyDisplayText(false, "")] + //[PropertyParameterOrder(13000)] + //public string v_WebDriverPath { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Hide Terminal Window")] + //[PropertyIsOptional(true, "No")] + //[PropertyFirstValue("No")] + //[PropertyDisplayText(false, "Hide Terminal")] + //[PropertyParameterOrder(14000)] + //public string v_HideTerminalWindow { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Temporary Profile Folder when does not specified")] + [PropertyUISelectionOption("User Temp")] + [PropertyUISelectionOption("taskt Temporary")] + [PropertyIsOptional(true, "User Temp")] + [PropertyValidationRule("Temporary Folder", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Temporary Folder")] + [PropertyParameterOrder(15000)] + public string v_TemporaryProfileFolder { get; set; } + + public SeleniumBrowserCreateWebBrowserInstanceCommand() + { + //this.CommandName = "SeleniumBrowserCreateCommand"; + //this.SelectionName = "Create Browser"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + //this.v_EngineType = "Chrome"; + //this.v_InstanceName = ""; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + var seleniumEngine = SelectionItemsControls.ExpandValueOrUserVariableAsSelectionItem(this, nameof(v_BrowserType), engine); + + var browserPath = v_BrowserPath.ExpandValueOrUserVariable(engine); + + string profilePath = string.Empty; + + string GetTemporaryProfilePath() + { + var folderName = $"prof-{Guid.NewGuid()}"; + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_TemporaryProfileFolder), engine)) + { + case "user temp": + return Path.Combine(IO.Folders.GetUserTemporaryFolderPath(), folderName); + + case "taskt temporary": + return Path.Combine(IO.Folders.GetTasktTemporaryFolderPath(), folderName); + default: + return string.Empty; + } + } + + void SetChromiumOptions(ChromiumOptions options) + { + if (!string.IsNullOrEmpty(browserPath)) + { + options.BinaryLocation = browserPath; + } + + if (!string.IsNullOrEmpty(v_ProfileFolder)) + { + var profileFolder = v_ProfileFolder.ExpandValueOrUserVariable(engine); + options.AddArgument($"--user-data-dir={profileFolder}"); + profilePath = profileFolder; + } + + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_HeadlessMode), engine)) + { + options.AddArgument("--headless"); + } + + if (!string.IsNullOrEmpty(v_SeleniumOptions)) + { + var convertedOptions = v_SeleniumOptions.ExpandValueOrUserVariable(engine); + + var spt = convertedOptions.Replace("\r\n", "\r").Split(new char[] { '\r', '\n' }); + + foreach (var opt in spt) + { + var opt2 = opt; + options.AddArgument(opt2); + if (opt2.StartsWith("user-data-dir=") || opt2.StartsWith("--user-data-dir=")) + { + if (opt2.StartsWith("user-data-dir=")) + { + profilePath = opt.Substring(14); + } + else + { + profilePath = opt.Substring(16); + } + } + } + } + + // profile folder does not specified + if (string.IsNullOrEmpty(profilePath)) + { + profilePath = GetTemporaryProfilePath(); + options.AddArgument($"user-data-dir={profilePath}"); + } + } + + DriverService driverService = null; + IWebDriver webDriver = null; + + switch (seleniumEngine) + { + case "chrome": + OpenQA.Selenium.Chrome.ChromeOptions chromeOptions = new OpenQA.Selenium.Chrome.ChromeOptions(); + + SetChromiumOptions(chromeOptions); + + driverService = CreateWebDriverService(seleniumEngine, engine); + + webDriver = new OpenQA.Selenium.Chrome.ChromeDriver((OpenQA.Selenium.Chrome.ChromeDriverService)driverService, chromeOptions); + break; + + case "edge": + OpenQA.Selenium.Edge.EdgeOptions edgeOptions = new OpenQA.Selenium.Edge.EdgeOptions(); + SetChromiumOptions(edgeOptions); + + driverService = CreateWebDriverService(seleniumEngine, engine); + + webDriver = new OpenQA.Selenium.Edge.EdgeDriver((OpenQA.Selenium.Edge.EdgeDriverService)driverService, edgeOptions); + break; + + case "firefox": + OpenQA.Selenium.Firefox.FirefoxOptions ffOptions = new OpenQA.Selenium.Firefox.FirefoxOptions(); + if (!string.IsNullOrEmpty(browserPath)) + { + ffOptions.BinaryLocation = browserPath; + } + else + { + ffOptions.BinaryLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe"; + } + + if (!string.IsNullOrEmpty(v_ProfileFolder)) + { + var profileFolder = v_ProfileFolder.ExpandValueOrUserVariable(engine); + + ffOptions.AddArgument($"-profile={profileFolder}"); + profilePath = profileFolder; + } + + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_HeadlessMode), engine)) + { + ffOptions.AddArgument("-headless"); + } + + if (!string.IsNullOrEmpty(v_SeleniumOptions)) + { + var convertedOptions = v_SeleniumOptions.ExpandValueOrUserVariable(engine); + + var spt = convertedOptions.Replace("\r\n", "\r").Split(new char[] { '\r', '\n' }); + + foreach (var opt in spt) + { + var opt2 = opt; + ffOptions.AddArgument(opt2); + if (opt2.StartsWith("-profile=") || opt2.StartsWith("--profile=")) + { + if (opt2.StartsWith("-profile=")) + { + profilePath = opt2.Substring(9); + } + else + { + profilePath = opt2.Substring(10); + } + } + } + } + + // profile folder does not specified + if (string.IsNullOrEmpty(profilePath)) + { + profilePath = GetTemporaryProfilePath(); + ffOptions.AddArgument($"-profile={profilePath}"); + if (!Directory.Exists(profilePath)) + { + Directory.CreateDirectory(profilePath); + } + } + + driverService = CreateWebDriverService(seleniumEngine, engine); + + webDriver = new OpenQA.Selenium.Firefox.FirefoxDriver((OpenQA.Selenium.Firefox.FirefoxDriverService)driverService, ffOptions); + break; + + case "ie": + driverService = CreateWebDriverService(seleniumEngine, engine); + + webDriver = new OpenQA.Selenium.IE.InternetExplorerDriver((OpenQA.Selenium.IE.InternetExplorerDriverService)driverService, new OpenQA.Selenium.IE.InternetExplorerOptions()); + break; + } + + // add app instance + this.CreateWebBrowserInstance(webDriver, profilePath, engine); + + //var instanceTracking = SelectionItemsControls.ExpandValueOrUserVariableAsSelectionItem(this, nameof(v_InstanceTracking), engine); + //if (instanceTracking != "forget instance") + //{ + // GlobalAppInstances.AddInstance(instanceName, webDriver); + //} + + var browserWindowOption = SelectionItemsControls.ExpandValueOrUserVariableAsSelectionItem(this, nameof(v_BrowserWindowOption), engine); + if (browserWindowOption == "maximize") + { + webDriver.Manage().Window.Maximize(); + } + + if (!string.IsNullOrEmpty(v_WindowHandleResult)) + { + var procId = ProcessControls.GetChildProcessId(driverService.ProcessId, 1); + if (seleniumEngine == "firefox") + { + procId = ProcessControls.GetChildProcessId(procId, 0); + } + var whnd = WindowControls.ConvertProcessIdToWindowHandle(procId); + whnd.StoreInUserVariable(engine, v_WindowHandleResult); + } + } + + public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) + { + if (!editor.appSettings.ClientSettings.SupportIECommand) + { + var cmb = ControlsList.GetPropertyControl(nameof(v_BrowserType)); + for (int i = cmb.Items.Count - 1; i >= 0; i--) + { + if (cmb.Items[i].ToString() == "IE") + { + cmb.Items.RemoveAt(i); + break; + } + } + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserExecuteJavaScriptFromCodeCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserExecuteJavaScriptFromCodeCommand.cs new file mode 100644 index 000000000..4d77c7485 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserExecuteJavaScriptFromCodeCommand.cs @@ -0,0 +1,176 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Web Browser Actions")] + [Attributes.ClassAttributes.CommandSettings("Execute JavaScript From Code")] + [Attributes.ClassAttributes.Description("This command allows you to execute a script in a Selenium web browser session.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserExecuteJavaScriptFromCodeCommand : ASeleniumExecuteJavaScriptCommands, ICanExecuteJavaScriptToWebDriver + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("JavaScript Code Type")] + ////[SampleUsage("**Code** or **File**")] + //[PropertyDetailSampleUsage("**Code**", "Use Specfied JavaScript Code")] + //[PropertyDetailSampleUsage("**File**", "Use Specfied JavaScript File")] + //[Remarks("")] + //[PropertyUISelectionOption("Code")] + //[PropertyUISelectionOption("File")] + //[PropertyIsOptional(true, "Code")] + //[PropertyFirstValue("Code")] + //[PropertyParameterOrder(6000)] + //public string v_CodeType { get; set; } + + [XmlAttribute] + [PropertyDescription("JavaScript Code")] + [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)] + [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFileSelectionHelper)] + [InputSpecification("JavaScript", true)] + [PropertyDetailSampleUsage("**return (2);**", "Specify the JavaScript Code")] + //[PropertyDetailSampleUsage("**c:\\js\\mycode.js**", "Specify the JavaScript File Path")] + [PropertyDetailSampleUsage("**{{{vCode}}}**", "Specify the Variable Value **vCode** for JavaScript Code or JavaScript File Path")] + [PropertyShowSampleUsageInDescription(true)] + //[Remarks("When Selected **Code**, plese Enter the JavaScript Code.\nWhen Selected **File**, please Enter the JavaScript File Path.")] + [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.MultiLineTextBox)] + [PropertyValidationRule("JavaScript Code", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(false, "")] + [PropertyParameterOrder(6000)] + public string v_ScriptCode { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Timeout in Seconds")] + //[InputSpecification("Timeout in Seconds", true)] + ////[SampleUsage("**0** or **10** or **{{{vWaitTime}}}**")] + //[PropertyDetailSampleUsage("**0**", "Specify **0** for Timeout. This means Waiting until JavaScript is finished.")] + //[PropertyDetailSampleUsage("**10**", PropertyDetailSampleUsage.ValueType.Value, "Timeout")] + //[PropertyDetailSampleUsage("**{{{vWaitTime}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Timeout")] + //[Remarks("When Value is Less Than or Equals to **0**, this means Waiting until JavaScript is finished.")] + //[PropertyIsOptional(true, "0")] + //[PropertyDisplayText(false, "")] + //[PropertyParameterOrder(8000)] + //public string v_TimeOut { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Arguments")] + //[InputSpecification("Arguments", true)] + //[PropertyDetailSampleUsage("**0**", PropertyDetailSampleUsage.ValueType.Value, "Argument")] + //[PropertyDetailSampleUsage("**{{{vValue}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Argument")] + //[Remarks("The value of the argument can be obtained with 'arguments[0]' in code.")] + //[PropertyIsOptional(true)] + //[PropertyDisplayText(false, "Arguments")] + //[PropertyParameterOrder(7000)] + //public string v_Arguments { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyDescription("Variable Name to Recieve Result Value")] + //[PropertyIsOptional(true)] + //[PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.None)] + //[PropertyParameterOrder(8000)] + //public string v_Result { get; set; } + + public SeleniumBrowserExecuteJavaScriptFromCodeCommand() + { + //this.CommandName = "SeleniumBrowserExecuteScriptCommand"; + //this.SelectionName = "Execute Script"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + + //this.v_InstanceName = ""; + //this.v_CodeType = "Code"; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WebDriverAction(new Action(seleniumInstance => + { + //var codeType = SelectionItemsControls.ExpandValueOrUserVariableAsSelectionItem(this, nameof(v_CodeType), engine); + + //string script = string.Empty; + //switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_CodeType), engine)) + //{ + // case "code": + // script = v_ScriptCode.ExpandValueOrUserVariable(engine); + // break; + // case "file": + // var scriptFile = this.ExpandValueOrUserVariableAsFilePath(nameof(v_ScriptCode), new PropertyFilePathSetting(false, PropertyFilePathSetting.ExtensionBehavior.RequiredExtensionAndExists, PropertyFilePathSetting.FileCounterBehavior.NoSupport, "js"), engine); + // script = System.IO.File.ReadAllText(scriptFile); + // break; + //} + + var script = v_ScriptCode.ExpandValueOrUserVariable(engine); + //var args = v_Arguments.ExpandValueOrUserVariable(engine); + + //// run script + //OpenQA.Selenium.IJavaScriptExecutor js = (OpenQA.Selenium.IJavaScriptExecutor)seleniumInstance; + + //object result; + //if (string.IsNullOrEmpty(args)) + //{ + // if (timeOut > 1) + // { + // result = js.ExecuteAsyncScript(script); + // } + // else + // { + // result = js.ExecuteScript(script); + // } + //} + //else + //{ + // if (timeOut > 1) + // { + // result = js.ExecuteAsyncScript(script, args); + // } + // else + // { + // result = js.ExecuteScript(script, args); + // } + //} + + //// apply result to variable + //if ((result != null) && (!string.IsNullOrEmpty(v_Result))) + //{ + // result.ToString().StoreInUserVariable(engine, v_Result); + //} + + //// run script + //var js = (OpenQA.Selenium.IJavaScriptExecutor)seleniumInstance; + + //object result; + //if (string.IsNullOrEmpty(args)) + //{ + // result = js.ExecuteScript(script); + //} + //else + //{ + // result = js.ExecuteScript(script, args); + //} + + //// apply result to variable + //if (!string.IsNullOrEmpty(v_Result)) + //{ + // (result?.ToString() ?? string.Empty).StoreInUserVariable(engine, v_Result); + //} + + //this.ExecuteJavaScript(seleniumInstance, script); + this.ExecuteJavaScriptProcess(seleniumInstance, script, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserExecuteJavaScriptFromFileCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserExecuteJavaScriptFromFileCommand.cs new file mode 100644 index 000000000..238b8ef58 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserExecuteJavaScriptFromFileCommand.cs @@ -0,0 +1,87 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Web Browser Actions")] + [Attributes.ClassAttributes.CommandSettings("Execute JavaScript From File")] + [Attributes.ClassAttributes.Description("This command allows you to execute a JavaScript from File.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserExecuteJavaScriptFromFileCommand : ASeleniumExecuteJavaScriptCommands, ICanHandleFilePath + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(FilePathControls), nameof(FilePathControls.v_FilePath))] + [PropertyDescription("JavaScript File")] + [PropertyDetailSampleUsage("**c:\\js\\mycode.js**", "Specify the JavaScript File Path")] + [PropertyDetailSampleUsage("**{{{vFile}}}**", "Specify the Variable Value **vCode** for JavaScript Code or JavaScript File Path")] + [PropertyParameterOrder(6000)] + public string v_FilePath { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Arguments")] + //[InputSpecification("Argument", true)] + //[PropertyDetailSampleUsage("**0**", PropertyDetailSampleUsage.ValueType.Value, "Arguments")] + //[PropertyDetailSampleUsage("**{{{vValue}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Arguments")] + //[Remarks("The value of the argument can be obtained with 'arguments[0]' in code.")] + //[PropertyIsOptional(true)] + //[PropertyDisplayText(false, "Arguments")] + //[PropertyParameterOrder(7000)] + //public string v_Arguments { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyDescription("Variable Name to Recieve Result Value")] + //[PropertyIsOptional(true)] + //[PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.None)] + //[PropertyParameterOrder(8000)] + //public string v_Result { get; set; } + + public SeleniumBrowserExecuteJavaScriptFromFileCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WebDriverAction(new Action(seleniumInstance => + { + var scriptFile = this.ExpandValueOrUserVariableAsFilePath(nameof(v_FilePath), new PropertyFilePathSetting(false, PropertyFilePathSetting.ExtensionBehavior.RequiredExtensionAndExists, PropertyFilePathSetting.FileCounterBehavior.NoSupport, "js"), engine); + string script = System.IO.File.ReadAllText(scriptFile); + + //var args = v_Arguments.ExpandValueOrUserVariable(engine); + + //// run script + //var js = (OpenQA.Selenium.IJavaScriptExecutor)seleniumInstance; + + //object result; + //if (string.IsNullOrEmpty(args)) + //{ + // result = js.ExecuteScript(script); + //} + //else + //{ + // result = js.ExecuteScript(script, args); + //} + + //// apply result to variable + //if (!string.IsNullOrEmpty(v_Result)) + //{ + // (result?.ToString() ?? string.Empty).StoreInUserVariable(engine, v_Result); + //} + + this.ExecuteJavaScriptProcess(seleniumInstance, script, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetAttributeFromWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetAttributeFromWebElementCommand.cs new file mode 100644 index 000000000..bcdfc8341 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetAttributeFromWebElementCommand.cs @@ -0,0 +1,137 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From WebElement")] + [Attributes.ClassAttributes.CommandSettings("Get Attribute From WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Get Attribute Value from WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Attribute Value from WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetAttributeFromWebElementCommand : ASeleniumGetOneResultFromWebElementCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_AttributeName))] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Attribute Name")] + //[PropertyDetailSampleUsage("**class**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] + //[PropertyDetailSampleUsage("**{{{vAttribute}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Attribute")] + //[PropertyDetailSampleUsage("**@tag**", "Get Tab name from WebElement. Use Get Special Value From WebElement command.")] + //[PropertyValidationRule("Attribute", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "Attribute")] + [PropertyParameterOrder(6000)] + public string v_AttributeName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(7000)] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When the WebElement does not have the Attribute")] + //[PropertyUISelectionOption("Error")] + //[PropertyUISelectionOption("Ignore")] + //[PropertyIsOptional(true, "Error")] + //[PropertyDisplayText(false, "")] + //public string v_WhenValueCanNotRetrieved { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //[PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] + //public string v_ScrollToWebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyIsOptional(true)] + //public string v_InstanceName { get; set; } + + public SeleniumBrowserGetAttributeFromWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToWebElement), engine)) + //{ + // var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() + // { + // //v_InstanceName = this.v_InstanceName, + // v_WebElement = this.v_WebElement, + // v_WhenFailAction = "ignore" + // }; + // scrollCommand.RunCommand(engine); + //} + + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + + //var attributeName = v_AttributeName.ExpandValueOrUserVariable(engine); + + //var v = elem.GetAttribute(attributeName); + + //if (v != null) + //{ + // v.StoreInUserVariable(engine, v_Result); + //} + //else + //{ + // if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenValueCanNotRetrieved), engine) == "error") + // { + // throw new Exception("Attribute '" + attributeName + "' does not exists."); + // } + // else + // { + // "".StoreInUserVariable(engine, v_Result); + // } + //} + + var attributeName = this.ExpandValueOrUserVariable(nameof(v_AttributeName), "Attribute", engine); + if (attributeName.StartsWith("@")) + { + // get special value + var getSpecial = new SeleniumBrowserGetSpecialValueFromWebElementCommand() + { + v_WebElement = this.v_WebElement, + v_ValueType = attributeName.Substring(1), + v_Result = this.v_Result, + v_ScrollToWebElement = this.v_ScrollToWebElement, + v_WhenFailAction = this.v_WhenFailAction, + v_WhenValueCanNotRetrieved = this.v_WhenValueCanNotRetrieved, + }; + getSpecial.RunCommand(engine); + } + else + { + this.GetFromWebElementAction(new Action((elem, seleniumInstance) => + { + var v = elem.GetAttribute(attributeName); + + if (v != null) + { + v.StoreInUserVariable(engine, v_Result); + } + else + { + throw new Exception($"WebElement does not have Attribute. Attribute: '{v_AttributeName}', Expand: '{attributeName}'"); + } + }), this.StoreEmptyValueToResult, engine); + } + } + + //private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetCSSSelectorFromWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetCSSSelectorFromWebElementCommand.cs new file mode 100644 index 000000000..5af5a8a61 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetCSSSelectorFromWebElementCommand.cs @@ -0,0 +1,114 @@ +using OpenQA.Selenium; +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From WebElement")] + [Attributes.ClassAttributes.CommandSettings("Get CSS Selector From WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Get CSS Selector from WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get CSS Selector from WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetCSSSelectorFromWebElementCommand : ASeleniumGetWebElementSelectorFromWebElementCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyParameterOrder(6000)] + //public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Believe ID Attribute")] + //[PropertyIsOptional(true, "No")] + //[PropertyDisplayText(false, "Believe ID")] + //[PropertyParameterOrder(7000)] + //public string v_BeliveIDAttribute { get; set; } + + public SeleniumBrowserGetCSSSelectorFromWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.GetFromWebElementAction(new Action((elem, seleniumInstance) => + { + // MEMO: it's probably works fine. :-) + var path = string.Empty; + + var believeId = this.ExpandValueOrUserVariableAsYesNo(nameof(v_BeliveIDAttribute), engine); + + var curElem = elem; + var curElemId = curElem.ToString(); + + var pElem = curElem.FindElement(By.XPath("parent::*")); + while (true) + { + var cTag = curElem.TagName.ToLower(); + + var cElems = pElem.FindElements(By.XPath($"{cTag}")); + if (cElems.Count > 1) + { + int index = 1; + foreach (var e in cElems) + { + if (e.ToString() == curElemId) + { + break; + } + index++; + } + + var idAttr = curElem.GetAttribute("id"); + string addPath; + if (!string.IsNullOrEmpty(idAttr) && believeId) + { + addPath = $"{cTag}#{idAttr}"; + } + else + { + addPath = (index == 1) ? $"{cTag}:first-child" : $"{cTag}:nth-child({index})"; + } + path = (path.Length > 0) ? $"{addPath} > {path}" : addPath; + } + else + { + var idAttr = curElem.GetAttribute("id"); + string addPath; + if (!string.IsNullOrEmpty(idAttr) && believeId) + { + addPath = $"{cTag}#{idAttr}"; + } + else + { + addPath = cTag; + } + + path = (path.Length > 0) ? $"{addPath} > {path}" : addPath; + } + + if (cTag == "body") + { + break; + } + else + { + curElem = pElem; + curElemId = curElem.ToString(); + pElem = curElem.FindElement(By.XPath("parent::*")); + } + } + path.StoreInUserVariable(engine, v_Result); + }), new Action(e => + { + string.Empty.StoreInUserVariable(engine, v_Result); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetHTMLFromWebElementCommand .cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetHTMLFromWebElementCommand .cs similarity index 59% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetHTMLFromWebElementCommand .cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetHTMLFromWebElementCommand .cs index 15e66ce7e..ec1e1aaa7 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetHTMLFromWebElementCommand .cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetHTMLFromWebElementCommand .cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -14,24 +15,25 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetHTMLFromWebElementCommand : ScriptCommand + public sealed class SeleniumBrowserGetHTMLFromWebElementCommand : ASeleniumGetOneResultFromWebElementCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_Result { get; set; } + [PropertyParameterOrder(6000)] + public override string v_Result { get; set; } - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - public string v_ScrollToElement { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //public string v_ScrollToWebElement { get; set; } - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - [PropertyIsOptional(true)] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyIsOptional(true)] + //public string v_InstanceName { get; set; } public SeleniumBrowserGetHTMLFromWebElementCommand() { @@ -44,8 +46,9 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) v_WebElement = this.v_WebElement, v_AttributeName = "outerHTML", v_Result = this.v_Result, - v_ScrollToElement = this.v_ScrollToElement, - v_InstanceName = this.v_InstanceName, + v_ScrollToWebElement = this.v_ScrollToWebElement, + v_WhenFailAction = this.v_WhenFailAction, + v_WhenValueCanNotRetrieved = this.v_WhenValueCanNotRetrieved, }; getAttribute.RunCommand(engine); } diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetMatchedWebElementsHTMLAsListCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetMatchedWebElementsHTMLAsListCommand.cs new file mode 100644 index 000000000..ee3cfe807 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetMatchedWebElementsHTMLAsListCommand.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Search WebElement")] + [Attributes.ClassAttributes.CommandSettings("Get Matched WebElements HTML As List")] + [Attributes.ClassAttributes.Description("This command allows you to get Matched WebElements HTML.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Matched WebElements HTML.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetMatchedWebElementsHTMLAsListCommand : ASeleniumSearchMultiWebElementsFromWebDriverCommands, IListResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] + [PropertyParameterOrder(7000)] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetMatchedWebElementsHTMLAsListCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //(var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WaitTimeForWebElement), engine); + + //var lst = new List(); + //foreach(var elem in trgElem) + //{ + // lst.Add(elem.GetAttribute("outerHTML")); + //} + //this.StoreListInUserVariable(lst, engine); + + this.SearchMultiWebElementsAction(new Action>(elems => + { + var lst = this.CreateEmptyList(); + foreach(var elem in elems) + { + lst.Add(elem.GetAttribute("outerHTML")); + } + this.StoreListInUserVariable(lst, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOneWebElementValuesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOneWebElementValuesAsDataTableCommand.cs new file mode 100644 index 000000000..19decc1c5 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOneWebElementValuesAsDataTableCommand.cs @@ -0,0 +1,106 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Scraping")] + [Attributes.ClassAttributes.CommandSettings("Get One WebElement Values As DataTable")] + [Attributes.ClassAttributes.Description("This command allows you to get Attributes value for One WebElement As DataTable.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Attributes value for One WebElement As DataTable.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetOneWebElementValuesAsDataTableCommand : ASeleniumGetOneWebElementValuesAsSomethingCommands, IDataTableResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //[PropertySelectionChangeEvent(nameof(SearchMethodComboBox_SelectionChangeCommitted))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] + //public string v_WebElementIndex { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributesName))] + //public DataTable v_AttributesName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetOneWebElementValuesAsDataTableCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + ////(var _, var trgElem) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), engine); + //(var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WebElementIndex), nameof(v_WaitTimeForWebElement), engine); + + //DataTable newDT = new DataTable(); + + //SeleniumBrowserControls.GetElementAttributes(trgElem, v_AttributesName, engine, new Action( (name, value) => + // { + // if (newDT.Rows.Count == 0) + // { + // newDT.Rows.Add(); + // } + + // if (!newDT.Columns.Contains(name)) + // { + // newDT.Columns.Add(name); + // } + // newDT.Rows[0][name] = value; + // }) + //); + + ////newDT.StoreInUserVariable(engine, v_DataTableVariableName); + //this.StoreDataTableInUserVariable(newDT, nameof(v_Result), engine); + + var res = this.CreateEmptyDataTable(); + + this.GetOneWebElementMultiValuesAction(new Action((attrName, attrValue, idx) => + { + if (res.Rows.Count == 0) + { + res.Rows.Add(); + } + if (!res.Columns.Contains(attrName)) + { + res.Columns.Add(attrName); + } + res.Rows[0][attrName] = attrValue; + }), engine); + this.StoreDataTableInUserVariable(res, engine); + } + + //private void SearchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.SearchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_WebElementIndex)); + //} + + //public override void BeforeValidate() + //{ + // base.BeforeValidate(); + // DataTableControls.BeforeValidate((DataGridView)ControlsList[nameof(v_AttributesName)], v_AttributesName); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOneWebElementValuesAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOneWebElementValuesAsDictionaryCommand.cs new file mode 100644 index 000000000..769f5f141 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOneWebElementValuesAsDictionaryCommand.cs @@ -0,0 +1,102 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Scraping")] + [Attributes.ClassAttributes.CommandSettings("Get One WebElement Values As Dictionary")] + [Attributes.ClassAttributes.Description("This command allows you to get Attributes value for One WebElement As Dictionary.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Attributes value for One WebElement As Dictionary.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetOneWebElementValuesAsDictionaryCommand : ASeleniumGetOneWebElementValuesAsSomethingCommands, IDictionaryResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //[PropertySelectionChangeEvent(nameof(SearchMethodComboBox_SelectionChangeCommitted))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] + //public string v_WebElementIndex { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributesName))] + //public DataTable v_AttributesName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_OutputDictionaryName))] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetOneWebElementValuesAsDictionaryCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + ////(var _, var trgElem) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), engine); + //(var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WebElementIndex), nameof(v_WaitTimeForWebElement), engine); + + //Dictionary newDic = new Dictionary(); + + //SeleniumBrowserControls.GetElementAttributes(trgElem, v_AttributesName, engine, new Action((name, value) => + // { + // if (newDic.Keys.Contains(name)) + // { + // newDic[name] = value; + // } + // else + // { + // newDic.Add(name, value); + // } + // }) + //); + + ////newDic.StoreInUserVariable(engine, v_DictionaryVariableName); + //this.StoreDictionaryInUserVariable(newDic, nameof(v_Result), engine); + + var ret = this.CreateEmptyDictionary(); + this.GetOneWebElementMultiValuesAction(new Action((attrName, attrValue, index) => + { + if (ret.ContainsKey(attrName)) + { + ret[attrName] = attrValue; + } + else + { + ret.Add(attrName, attrValue); + } + }), engine); + this.StoreDictionaryInUserVariable(ret, engine); + } + + //private void SearchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.SearchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_WebElementIndex)); + //} + + //public override void BeforeValidate() + //{ + // base.BeforeValidate(); + // DataTableControls.BeforeValidate((DataGridView)ControlsList[nameof(v_AttributesName)], v_AttributesName); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOneWebElementValuesAsListCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOneWebElementValuesAsListCommand.cs new file mode 100644 index 000000000..2050c543c --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOneWebElementValuesAsListCommand.cs @@ -0,0 +1,105 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Scraping")] + [Attributes.ClassAttributes.CommandSettings("Get One WebElement Values As List")] + [Attributes.ClassAttributes.Description("This command allows you to get Attributes value for One WebElement As List.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Attributes value for One WebElement As List.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetOneWebElementValuesAsListCommand : ASeleniumGetOneWebElementValuesAsSomethingCommands, IListResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //[PropertySelectionChangeEvent(nameof(SearchMethodComboBox_SelectionChangeCommitted))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] + //public string v_WebElementIndex { get; set; } + + //[XmlElement] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributesName))] + //public DataTable v_AttributesName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetOneWebElementValuesAsListCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + ////(var _, var trgElem) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), engine); + //(var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WebElementIndex), nameof(v_WaitTimeForWebElement), engine); + + //List newList = new List(); + + //SeleniumBrowserControls.GetElementAttributes(trgElem, v_AttributesName, engine, new Action((name, value) => + // { + // newList.Add(value); + // }) + //); + + ////newList.StoreInUserVariable(engine, v_ListVariableName); + //this.StoreListInUserVariable(newList, nameof(v_Result), engine); + + using (var dic = new InnerScriptVariable(engine)) + { + var getAsDic = new SeleniumBrowserGetOneWebElementValuesAsDictionaryCommand() + { + v_InstanceName = this.v_InstanceName, + v_SearchMethod = this.v_SearchMethod, + v_SearchParameter = this.v_SearchParameter, + v_WebElementIndex = this.v_WebElementIndex, + v_AttributesName = this.v_AttributesName, + v_Result = dic.VariableName, + v_WaitTimeForWebElement = this.v_WaitTimeForWebElement, + }; + getAsDic.RunCommand(engine); + + var convToList = new ConvertDictionaryToListCommand() + { + v_Dictionary = dic.VariableName, + v_Result = this.v_Result, + }; + convToList.RunCommand(engine); + } + } + + + //private void SearchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.SearchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_WebElementIndex)); + //} + + //public override void BeforeValidate() + //{ + // base.BeforeValidate(); + // DataTableControls.BeforeValidate((DataGridView)ControlsList[nameof(v_AttributesName)], v_AttributesName); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOptionsFromWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOptionsFromWebElementCommand.cs new file mode 100644 index 000000000..f1dda6c1f --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetOptionsFromWebElementCommand.cs @@ -0,0 +1,171 @@ +using OpenQA.Selenium.Support.UI; +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From WebElement")] + [Attributes.ClassAttributes.CommandSettings("Get Options From WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Get Options Value from WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Options Value from WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetOptionsFromWebElementCommand : ASeleniumGetOneResultFromWebElementCommands, IListResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + [XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + //[PropertyDescription("Attribute Name")] + //[PropertyDetailSampleUsage("**textContent**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] + //[PropertyDetailSampleUsage("**value**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] + //[PropertyDetailSampleUsage("**{{{vAttribute}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Attribute")] + //[PropertyValidationRule("Attribute", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "Attribute")] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_AttributeName))] + [PropertyParameterOrder(6000)] + public string v_AttributeName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] + [PropertyParameterOrder(7000)] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When the WebElement does not have the Attribute")] + //[PropertyUISelectionOption("Error")] + //[PropertyUISelectionOption("Ignore")] + //[PropertyIsOptional(true, "Error")] + //[PropertyDisplayText(false, "")] + //public string v_WhenValueCanNotRetrieved { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //[PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] + //public string v_ScrollToWebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyIsOptional(true)] + //public string v_InstanceName { get; set; } + + public SeleniumBrowserGetOptionsFromWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToWebElement), engine)) + //{ + // var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() + // { + // //v_InstanceName = this.v_InstanceName, + // v_WebElement = this.v_WebElement, + // v_WhenFailAction = "ignore" + // }; + // scrollCommand.RunCommand(engine); + //} + + //if (!elem.CheckTagName("select")) + //{ + // throw new Exception("WebElement is not Select"); + //} + + //var sel = new SelectElement(elem); + //var options = sel.Options; + + //var attributeName = v_AttributeName.ExpandValueOrUserVariable(engine); + + //var throwError = (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenValueCanNotRetrieved), engine) == "error"); + + //var lst = new List(); + //foreach(var opt in options) + //{ + // var a = opt.GetAttribute(attributeName); + // if (a == null) + // { + // if (throwError) + // { + // throw new Exception("Attribute '" + attributeName + "' does not exists."); + // } + // else + // { + // lst.Add(""); + // } + // } + // else + // { + // lst.Add(a); + // } + //} + //this.StoreListInUserVariable(lst, engine); + + this.GetFromWebElementAction(new Action((elem, seleniumInstance) => + { + if (this.TagName(elem) != "select") + { + throw new Exception($"WebElement is not Select. Tag Name: '{this.TagName(elem)}'"); + } + + var sel = new SelectElement(elem); + var options = sel.Options; + + var attributeName = v_AttributeName.ExpandValueOrUserVariable(engine); + + bool throwError = false; + bool setEmpty = false; + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenValueCanNotRetrieved), engine)) + { + case "error": + throwError = true; + break; + case "set emtpy value": + setEmpty = true; + break; + } + + var lst = this.CreateEmptyList(); + foreach (var opt in options) + { + var a = opt.GetAttribute(attributeName); + if (a == null) + { + if (throwError) + { + throw new Exception($"Attribute does not exists. Attribute: '{v_AttributeName}', Expand: '{attributeName}'"); + } + else if (setEmpty) + { + lst.Add(string.Empty); + } + } + else + { + lst.Add(a); + } + } + this.StoreListInUserVariable(lst, engine); + }), new Action(e => + { + this.StoreListInUserVariable(this.CreateEmptyList(), engine); + }), engine); + } + + //private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetSpecialValueFromWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetSpecialValueFromWebElementCommand.cs new file mode 100644 index 000000000..a97b0a86b --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetSpecialValueFromWebElementCommand.cs @@ -0,0 +1,110 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From WebElement")] + [Attributes.ClassAttributes.CommandSettings("Get Special Value From WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Get Special Value Value from WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Special Value from WebElement. Enabled, Displayed, Selected, Tag, Size, etc.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetSpecialValueFromWebElementCommand : ASeleniumGetOneResultFromWebElementCommands + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Value Type")] + [PropertyUISelectionOption("Enabled")] + [PropertyUISelectionOption("Displayed")] + [PropertyUISelectionOption("Selected")] + [PropertyUISelectionOption("Text")] + [PropertyUISelectionOption("Tag")] + [PropertyUISelectionOption("X Position")] + [PropertyUISelectionOption("Y Position")] + [PropertyUISelectionOption("Width")] + [PropertyUISelectionOption("Height")] + [PropertyUISelectionOption("Location")] + [PropertyUISelectionOption("Size")] + [PropertyUISelectionOption("TagName")] + [PropertyUISelectionOption("Tag Name")] + [PropertyValidationRule("Value Type", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Value Type")] + [PropertyParameterOrder(6000)] + public string v_ValueType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(7000)] + public override string v_Result { get; set; } + + public SeleniumBrowserGetSpecialValueFromWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.GetFromWebElementAction(new Action((elem, seleniumInstance) => + { + string ret = string.Empty; + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_ValueType), engine)) + { + case "enabled": + ret = elem.Enabled.ToString(); + break; + + case "displayed": + ret = elem.Displayed.ToString(); + break; + + case "selected": + ret = elem.Selected.ToString(); + break; + + case "text": + ret = elem.Text; + break; + + case "tag": + case "tagname": + case "tag name": + ret = elem.TagName; + break; + + case "x position": + ret = elem.Location.X.ToString(); + break; + + case "y position": + ret = elem.Location.Y.ToString(); + break; + + case "width": + ret = elem.Size.Width.ToString(); + break; + + case "height": + ret = elem.Size.Height.ToString(); + break; + + case "location": + var lc = elem.Location; + ret = $"{lc.X},{lc.Y}"; + break; + + case "size": + var sz = elem.Size; + ret = $"{sz.Width},{sz.Height}"; + break; + } + ret.StoreInUserVariable(engine, v_Result); + + }), this.StoreEmptyValueToResult, engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetTableValuesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetTableValuesAsDataTableCommand.cs new file mode 100644 index 000000000..5ed30033f --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetTableValuesAsDataTableCommand.cs @@ -0,0 +1,235 @@ +using OpenQA.Selenium; +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Scraping")] + [Attributes.ClassAttributes.CommandSettings("Get Table Values As DataTable")] + [Attributes.ClassAttributes.Description("This command allows you to get a Table Values As DataTable.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a Table Values As DataTable.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetTableValuesAsDataTableCommand : ASeleniumSearchWebElementFromWebDriverCommands, IDataTableResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //[PropertySelectionChangeEvent(nameof(SearchMethodComboBox_SelectionChangeCommitted))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] + //public string v_WebElementIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_AttributeName))] + [PropertyIsOptional(true, "textContent")] + [PropertyFirstValue("textContent")] + [PropertyParameterOrder(7000)] + public string v_AttributeName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] + [PropertyParameterOrder(8000)] + public override string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Method for the First Row")] + [PropertyDetailSampleUsage("**First Row**", "The First Row is considered the First Row of Data.")] + [PropertyDetailSampleUsage("**Column Name**", "The First Row is considered the Column Name.")] + [PropertyDetailSampleUsage("**Ignore**", "Ignore First Row")] + [PropertyUISelectionOption("First Row")] + [PropertyUISelectionOption("Column Name")] + [PropertyUISelectionOption("Ignore")] + [PropertyIsOptional(true, "First Row")] + [PropertySelectionValueSensitive(false)] + [PropertyDisplayText(false, "First Row")] + [PropertyParameterOrder(9000)] + public string v_FirstRowMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetTableValuesAsDataTableCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + ////(var _, var trgElem) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElement(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), nameof(v_ElementIndex), engine); + //(var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WebElementIndex), nameof(v_WaitTimeForWebElement), engine); + + //if (trgElem.TagName.ToLower() != "table") + //{ + // throw new Exception("Element is not Table"); + //} + + //var attrName = v_AttributeName.ExpandValueOrUserVariable(engine); + + //var firstRowMethod = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_FirstRowMethod), engine); + + //var newDT = new DataTable(); + + //var trs = trgElem.FindElements(By.XPath("child::tr | child::thead/tr | child::tbody/tr | child::tfoot/tr")); + //if (trs.Count > 0) + //{ + // var columns = trs[0].FindElements(By.XPath("child::th | child::td")); + // if (columns.Count > 0) + // { + // int columnSize = columns.Count; + // if (firstRowMethod == "column name") + // { + // for (int i = 0; i < columnSize; i++) + // { + // newDT.Columns.Add(columns[i].GetAttribute("textContent")); + // } + // } + // else + // { + // for (int i = 0; i < columnSize; i++) + // { + // newDT.Columns.Add("Column_" + i.ToString()); + // } + // } + + // int rowBias = 0; + // switch (firstRowMethod) + // { + // case "column name": + // case "ignore": + // rowBias = 1; + // break; + // default: + // break; + // } + + // for (int i = rowBias; i < trs.Count; i++) + // { + // newDT.Rows.Add(); + // var row = trs[i].FindElements(By.XPath("child::th | child::td")); + // int cols = (row.Count > columnSize) ? columnSize : row.Count; + // for (int j = 0; j < cols; j++) + // { + // newDT.Rows[i - rowBias][j] = SeleniumBrowserControls.GetAttribute(row[j], attrName, engine); + // } + // for (int j = cols + 1; j < columnSize; j++) + // { + // newDT.Rows[i - rowBias][j] = ""; + // } + // } + // } + //} + + ////newDT.StoreInUserVariable(engine, v_DataTableVariableName); + //this.StoreDataTableInUserVariable(newDT, nameof(v_Result), engine); + + this.SearchWebElementAction(new Action(elem => + { + if (elem.TagName.ToLower() != "table") + { + throw new Exception("WebElement is not Table"); + } + + //var attrName = v_AttributeName.ExpandValueOrUserVariable(engine); + + var res = this.CreateEmptyDataTable(); + + var trs = elem.FindElements(By.XPath("child::tr | child::thead/tr | child::tbody/tr | child::tfoot/tr")); + if (trs.Count > 0) + { + var columns = trs[0].FindElements(By.XPath("child::th | child::td")); + if (columns.Count > 0) + { + var firstRowMethod = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_FirstRowMethod), engine); + + // set DataTable column headers + int columnSize = columns.Count; + if (firstRowMethod == "column name") + { + for (int i = 0; i < columnSize; i++) + { + res.Columns.Add(columns[i].GetAttribute("textContent")); + } + } + else + { + for (int i = 0; i < columnSize; i++) + { + res.Columns.Add($"Column_{i}"); + } + } + + int rowBias = 0; + switch (firstRowMethod) + { + case "column name": + case "ignore": + rowBias = 1; + break; + default: + break; + } + + using (var resVar = new InnerScriptVariable(engine)) + { + using (var elemVar = new InnerScriptVariable(engine)) + { + var getAttr = new SeleniumBrowserGetAttributeFromWebElementCommand() + { + v_WebElement = elemVar.VariableName, + v_AttributeName = this.v_AttributeName, + v_Result = resVar.VariableName, + }; + + for (int i = rowBias; i < trs.Count; i++) + { + res.Rows.Add(); + var row = trs[i].FindElements(By.XPath("child::th | child::td")); + int cols = (row.Count > columnSize) ? columnSize : row.Count; + for (int j = 0; j < cols; j++) + { + elemVar.VariableValue = new ValueTuple(row[j], null); + getAttr.RunCommand(engine); + + res.Rows[i - rowBias][j] = resVar.VariableValue.ToString(); + } + + // when columns merged + for (int j = cols + 1; j < columnSize; j++) + { + res.Rows[i - rowBias][j] = string.Empty; + } + } + } + + } + } + } + + this.StoreDataTableInUserVariable(res, engine); + }), engine); + } + + //private void SearchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.SearchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_WebElementIndex)); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetTextFromWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetTextFromWebElementCommand.cs new file mode 100644 index 000000000..9fb4a0782 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetTextFromWebElementCommand.cs @@ -0,0 +1,95 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From WebElement")] + [Attributes.ClassAttributes.CommandSettings("Get Text From WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Get Text Value from WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Text Value from WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetTextFromWebElementCommand : ASeleniumGetOneResultFromWebElementCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(6000)] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //[PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] + //public string v_ScrollToWebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyIsOptional(true)] + //public string v_InstanceName { get; set; } + + public SeleniumBrowserGetTextFromWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToWebElement), engine)) + //{ + // var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() + // { + // //v_InstanceName = this.v_InstanceName, + // v_WebElement = this.v_WebElement, + // v_WhenFailAction = "ignore" + // }; + // scrollCommand.RunCommand(engine); + //} + + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + + //var v = elem.Text; + + //if (string.IsNullOrEmpty(v)) + //{ + // v = elem.GetAttribute("textContent"); + //} + //if (string.IsNullOrEmpty(v) && (elem.TagName.ToLower() == "input")) + //{ + // v = elem.GetAttribute("value"); + //} + + //v.StoreInUserVariable(engine, v_Result); + + this.GetFromWebElementAction(new Action((elem, seleniumInstance) => + { + var v = elem.Text; + + if (string.IsNullOrEmpty(v)) + { + v = elem.GetAttribute("textContent"); + } + if (string.IsNullOrEmpty(v) && (this.TagName(elem) == "input")) + { + v = elem.GetAttribute("value"); + } + v.StoreInUserVariable(engine, v_Result); + }), new Action(e => + { + string.Empty.StoreInUserVariable(engine, v_Result); + }), engine); + } + + //private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserHTMLSourceCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserHTMLSourceCommand.cs new file mode 100644 index 000000000..35b1d121f --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserHTMLSourceCommand.cs @@ -0,0 +1,41 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From Web Browser")] + [Attributes.ClassAttributes.CommandSettings("Get Web Browser HTML Source")] + [Attributes.ClassAttributes.Description("This command allows you to Get HTML Source from Web Browser.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get HTML Source from Web Browser.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWebBrowserHTMLSourceCommand : ASeleniumGetFromWebDriverCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(6000)] + public override string v_Result { get; set; } + + public SeleniumBrowserGetWebBrowserHTMLSourceCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WebDriverActionCore(new Action((seleniumInstance, _) => + { + seleniumInstance.PageSource.StoreInUserVariable(engine, v_Result); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebBrowserInformationCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserInformationCommand.cs similarity index 50% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebBrowserInformationCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserInformationCommand.cs index bc80892c8..30da3c2b9 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebBrowserInformationCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserInformationCommand.cs @@ -1,13 +1,13 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { - [Serializable] [Attributes.ClassAttributes.Group("Web Browser")] - [Attributes.ClassAttributes.SubGruop("Instance")] + [Attributes.ClassAttributes.SubGruop("Get From Web Browser")] [Attributes.ClassAttributes.CommandSettings("Get Web Browser Information")] [Attributes.ClassAttributes.Description("This command allows you to Get Web Browser Information.")] [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Web Browser Information.")] @@ -15,11 +15,11 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWebBrowserInformationCommand : ScriptCommand + public sealed class SeleniumBrowserGetWebBrowserInformationCommand : ASeleniumGetFromWebDriverCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] @@ -27,53 +27,47 @@ public sealed class SeleniumBrowserGetWebBrowserInformationCommand : ScriptComma [PropertyUISelectionOption("Window Title")] [PropertyUISelectionOption("Window URL")] [PropertyUISelectionOption("Current Handle")] - [PropertyUISelectionOption("HTML Page Source")] - [PropertyUISelectionOption("Handles JSON Array")] - [InputSpecification("", true)] - [SampleUsage("")] + //[PropertyUISelectionOption("HTML Page Source")] + //[PropertyUISelectionOption("Handles JSON Array")] [PropertyValidationRule("Information Type", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "Information Type")] + [PropertyParameterOrder(6000)] public string v_InfoType { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_applyToVariableName { get; set; } + [PropertyParameterOrder(7000)] + public override string v_Result { get; set; } public SeleniumBrowserGetWebBrowserInformationCommand() { - //this.CommandName = "SeleniumBrowserInfoCommand"; - //this.SelectionName = "Get Browser Info"; - //this.CommandEnabled = true; - //this.CustomRendering = true; } public override void RunCommand(Engine.AutomationEngineInstance engine) { - var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); - - var requestedInfo = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_InfoType), engine); - string info = ""; - switch (requestedInfo) + this.WebDriverActionCore(new Action((seleniumInstance, _) => { - case "window title": - info = seleniumInstance.Title; - break; - case "window url": - info = seleniumInstance.Url; - break; - case "current handle": - info = seleniumInstance.CurrentWindowHandle; - break; - case "html page source": - info = seleniumInstance.PageSource; - break; - case "handles json array": - info = Newtonsoft.Json.JsonConvert.SerializeObject(seleniumInstance.WindowHandles); - break; - } - - //store data - info.StoreInUserVariable(engine, v_applyToVariableName); + var info = string.Empty; + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_InfoType), engine)) + { + case "window title": + info = seleniumInstance.Title; + break; + case "window url": + info = seleniumInstance.Url; + break; + case "current handle": + info = seleniumInstance.CurrentWindowHandle; + break; + //case "html page source": + // info = seleniumInstance.PageSource; + // break; + //case "handles json array": + // info = Newtonsoft.Json.JsonConvert.SerializeObject(seleniumInstance.WindowHandles); + // break; + } + info.StoreInUserVariable(engine, v_Result); + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserPositionCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserPositionCommand.cs new file mode 100644 index 000000000..a829c6493 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserPositionCommand.cs @@ -0,0 +1,143 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From Web Browser")] + [Attributes.ClassAttributes.CommandSettings("Get Web Browser Position")] + [Attributes.ClassAttributes.Description("This command allows you to Get Web Browser Position.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Web Browser Position.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWebBrowserPositionCommand : ASeleniumWebDriverActionCommands, IPositionProperties, ICanExecuteJavaScriptToWebDriver + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_OptionalResult))] + [PropertyDescription("Variable Name to Store X Position")] + [PropertyValidationRule("X Postion", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "X Position")] + [PropertyParameterOrder(6000)] + public string v_XPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_OptionalResult))] + [PropertyDescription("Variable Name to Store X Position")] + [PropertyValidationRule("Y Postion", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Y Position")] + [PropertyParameterOrder(6100)] + public string v_YPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Position Type")] + [PropertyUISelectionOption("Window")] + [PropertyUISelectionOption("Viewport")] + [PropertyIsOptional(true, "Window")] + [PropertyDisplayText(true, "Type")] + [PropertyParameterOrder(7000)] + public string v_PositionType { get; set; } + + public SeleniumBrowserGetWebBrowserPositionCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WebDriverActionCore(new Action((seleniumInstance, _) => + { + var pt = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionType), engine); + if ((pt == "window") || (seleniumInstance is OpenQA.Selenium.IE.InternetExplorerDriver)) + { + (var x, var y) = GetPosition(seleniumInstance); + + this.StoreXYProcess(x, y, engine); + } + else + { + int outerWidth, outerHeight; + int innerWidth, innerHeight; + using (var w = new InnerScriptVariable(engine)) + { + using (var h = new InnerScriptVariable(engine)) + { + var getSize = new SeleniumBrowserGetWebBrowserSizeCommand() + { + v_InstanceName = this.v_InstanceName, + v_Width = w.VariableName, + v_Height = h.VariableName, + v_SizeType = "Window", + }; + getSize.RunCommand(engine); + outerWidth = int.Parse(w.VariableValue.ToString()); + outerHeight = int.Parse(h.VariableValue.ToString()); + + getSize.v_SizeType = "Viewport"; + getSize.RunCommand(engine); + innerWidth = int.Parse(w.VariableValue.ToString()); + innerHeight = int.Parse(h.VariableValue.ToString()); + } + } + + (var px, var py) = GetPosition(seleniumInstance); + var xOffset = (outerWidth - innerWidth) / 2; + + if (seleniumInstance is OpenQA.Selenium.Chrome.ChromeDriver) + { + var yOffset = outerHeight - innerHeight - 6; + this.StoreXYProcess(px + xOffset, py + yOffset, engine); + } + else if (seleniumInstance is OpenQA.Selenium.Edge.EdgeDriver) + { + // 4 is bottom window height, 8 is offset + var yOffset = outerHeight - innerHeight - 4 - 8; + this.StoreXYProcess(px + xOffset, py + yOffset, engine); + } + else if (seleniumInstance is OpenQA.Selenium.Firefox.FirefoxDriver) + { + var yOffset = outerHeight - innerHeight - 8; + this.StoreXYProcess(px + xOffset, py + yOffset, engine); + } + } + }), engine); + } + + /// + /// get WebBrowser position + /// + /// + /// (width, height) + private (int, int) GetPosition(OpenQA.Selenium.IWebDriver d) + { + var script = "return window.screenX+','+window.screenY;"; + var r = this.ExecuteJavaScript(d, script).ToString(); + + var spt = r.Split(','); + return (int.Parse(spt[0]), int.Parse(spt[1])); + } + + /// + /// store variable to x,y result process + /// + /// + /// + /// + private void StoreXYProcess(int x, int y, Engine.AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(v_XPosition)) + { + x.StoreInUserVariable(engine, v_XPosition); + } + if (!string.IsNullOrEmpty(v_YPosition)) + { + y.StoreInUserVariable(engine, v_YPosition); + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserSizeCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserSizeCommand.cs new file mode 100644 index 000000000..cb0029842 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebBrowserSizeCommand.cs @@ -0,0 +1,78 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From Web Browser")] + [Attributes.ClassAttributes.CommandSettings("Get Web Browser Size")] + [Attributes.ClassAttributes.Description("This command allows you to Get Web Browser Size.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Web Browser Position.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWebBrowserSizeCommand : ASeleniumWebDriverActionCommands, ISizeProperties, ICanExecuteJavaScriptToWebDriver + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_OptionalResult))] + [PropertyDescription("Variable Name to Store Width")] + [PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Width")] + [PropertyParameterOrder(6000)] + public string v_Width { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_OptionalResult))] + [PropertyDescription("Variable Name to Store Height")] + [PropertyValidationRule("Height", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Height")] + [PropertyParameterOrder(6100)] + public string v_Height { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Position Type")] + [PropertyUISelectionOption("Window")] + [PropertyUISelectionOption("Viewport")] + [PropertyIsOptional(true, "Window")] + [PropertyParameterOrder(7000)] + public string v_SizeType { get; set; } + + public SeleniumBrowserGetWebBrowserSizeCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WebDriverActionCore(new Action((seleniumInstance, _) => + { + string script = string.Empty; + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SizeType), engine)) + { + case "window": + script = "return window.outerWidth+','+window.outerHeight;"; + break; + case "viewport": + script = "return window.innerWidth+','+window.innerHeight;"; + break; + } + var r = this.ExecuteJavaScript(seleniumInstance, script).ToString(); + + var spt = r.Split(','); + + if (!string.IsNullOrEmpty(v_Width)) + { + spt[0].StoreInUserVariable(engine, v_Width); + } + if (!string.IsNullOrEmpty(v_Height)) + { + spt[1].StoreInUserVariable(engine, v_Height); + } + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementPositionCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementPositionCommand.cs new file mode 100644 index 000000000..b1494ee02 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementPositionCommand.cs @@ -0,0 +1,152 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From WebElement")] + [Attributes.ClassAttributes.CommandSettings("Get WebElement Position")] + [Attributes.ClassAttributes.Description("This command allows you to Get WebElement Position.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get WebElement Position.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWebElementPositionCommand : ASeleniumGetFromWebElementCommands, IPositionProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store X Position")] + [PropertyIsOptional(true)] + [PropertyValidationRule("X Position", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "X Position")] + [PropertyParameterOrder(6000)] + public string v_XPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Y Position")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Y Position", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Y Position")] + [PropertyParameterOrder(6100)] + public string v_YPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Base position")] + [PropertyUISelectionOption("Top Left")] + [PropertyUISelectionOption("Bottom Right")] + [PropertyUISelectionOption("Top Right")] + [PropertyUISelectionOption("Bottom Left")] + [PropertyUISelectionOption("Center")] + [PropertyIsOptional(true, "Top Left")] + [PropertyDisplayText(false, "Base Position")] + [PropertyParameterOrder(7000)] + public string v_PositionBase { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Position Type")] + [PropertyUISelectionOption("Screen")] + [PropertyUISelectionOption("Viewport")] + [PropertyIsOptional(true, "Viewport")] + [PropertyDisplayText(true, "Type")] + [PropertyParameterOrder(7100)] + public string v_PositionType { get; set; } + + public SeleniumBrowserGetWebElementPositionCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.GetFromWebElementAction(new Action((elem, seleniumInstance) => + { + var loc = elem.Location; + var size = elem.Size; + + int x = 0, y = 0; + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) + { + case "top left": + x = loc.X; + y = loc.Y; + break; + case "bottom right": + x = loc.X + size.Width; + y = loc.Y + size.Height; + break; + case "top right": + x = loc.X + size.Width; + y = loc.Y; + break; + case "bottom left": + x = loc.X; + y = loc.Y + size.Height; + break; + case "center": + x = (loc.X + size.Width) / 2; + y = (loc.Y + size.Height) / 2; + break; + } + + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionType), engine)) + { + case "screen": + // get Screen(Desktop) position + int baseX, baseY; + using (var vX = new InnerScriptVariable(engine)) + { + using (var vY = new InnerScriptVariable(engine)) + { + var insName = this.GetInstanceNameFromWebBrowserInstance(seleniumInstance, engine); + + var getPos = new SeleniumBrowserGetWebBrowserPositionCommand() + { + v_InstanceName = insName, + v_PositionType = "Viewport", + v_XPosition = vX.VariableName, + v_YPosition = vY.VariableName, + }; + getPos.RunCommand(engine); + + baseX = int.Parse(vX.VariableValue.ToString()); + baseY = int.Parse(vY.VariableValue.ToString()); + } + } + x += baseX; + y += baseY; + break; + } + + if (!string.IsNullOrEmpty(v_XPosition)) + { + x.StoreInUserVariable(engine, v_XPosition); + } + if (!string.IsNullOrEmpty(v_YPosition)) + { + y.StoreInUserVariable(engine, v_YPosition); + } + }), new Action(e => + { + if (!string.IsNullOrEmpty(v_XPosition)) + { + string.Empty.StoreInUserVariable(engine, v_XPosition); + } + if (!string.IsNullOrEmpty(v_YPosition)) + { + string.Empty.StoreInUserVariable(engine, v_YPosition); + } + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementSizeCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementSizeCommand.cs similarity index 50% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementSizeCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementSizeCommand.cs index e1c4dfbf1..0fa1b83a1 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWebElementSizeCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementSizeCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -14,46 +15,68 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumWebElementSizeCommand : ScriptCommand + public sealed class SeleniumBrowserGetWebElementSizeCommand : ASeleniumGetFromWebElementCommands, ISizeProperties { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] - public string v_WebElement { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] [PropertyDescription("Variable Name to Store Width")] - [InputSpecification("Width")] [PropertyIsOptional(true)] [PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.None)] [PropertyDisplayText(true, "Width")] + [PropertyParameterOrder(6000)] public string v_Width { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] [PropertyDescription("Variable Name to Store Height")] - [InputSpecification("Height")] [PropertyIsOptional(true)] [PropertyValidationRule("Height", PropertyValidationRule.ValidationRuleFlags.None)] [PropertyDisplayText(true, "Height")] + [PropertyParameterOrder(6100)] public string v_Height { get; set; } - public SeleniumWebElementSizeCommand() + public SeleniumBrowserGetWebElementSizeCommand() { } public override void RunCommand(Engine.AutomationEngineInstance engine) { - var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + + //if (!string.IsNullOrEmpty(v_Width)) + //{ + // elem.Size.Width.StoreInUserVariable(engine, v_Width); + //} + //if (!string.IsNullOrEmpty(v_Height)) + //{ + // elem.Size.Height.StoreInUserVariable(engine, v_Height); + //} - if (!string.IsNullOrEmpty(v_Width)) + this.GetFromWebElementAction(new Action((elem, seleniumInstance) => { - elem.Size.Width.StoreInUserVariable(engine, v_Width); - } - if (!string.IsNullOrEmpty(v_Height)) + if (!string.IsNullOrEmpty(v_Width)) + { + elem.Size.Width.StoreInUserVariable(engine, v_Width); + } + if (!string.IsNullOrEmpty(v_Height)) + { + elem.Size.Height.StoreInUserVariable(engine, v_Height); + } + }), new Action(e => { - elem.Size.Height.StoreInUserVariable(engine, v_Height); - } + if (!string.IsNullOrEmpty(v_Width)) + { + string.Empty.StoreInUserVariable(engine, v_Width); + } + if (!string.IsNullOrEmpty(v_Height)) + { + string.Empty.StoreInUserVariable(engine, v_Height); + } + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsCountCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsCountCommand.cs new file mode 100644 index 000000000..b5018d8bd --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsCountCommand.cs @@ -0,0 +1,71 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Search WebElement")] + [Attributes.ClassAttributes.CommandSettings("Get WebElements Count")] + [Attributes.ClassAttributes.Description("This command allows you to count WebElements.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to count WebElements.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWebElementsCountCommand : ASeleniumSearchMultiWebElementsFromWebDriverCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyParameterOrder(7000)] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetWebElementsCountCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //try + //{ + // (var _, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WaitTimeForWebElement), engine); + + // trgElem.Count.ToString().StoreInUserVariable(engine, v_Result); + //} + //catch + //{ + // "0".StoreInUserVariable(engine, v_Result); + //} + + try + { + this.SearchMultiWebElementsAction(new Action>(elems => + { + elems.Count.StoreInUserVariable(engine, v_Result); + }), engine); + } + catch + { + 0.StoreInUserVariable(engine, v_Result); + } + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValueAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValueAsDataTableCommand.cs new file mode 100644 index 000000000..f7f3bd5ad --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValueAsDataTableCommand.cs @@ -0,0 +1,87 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Scraping")] + [Attributes.ClassAttributes.CommandSettings("Get WebElements Value As DataTable")] + [Attributes.ClassAttributes.Description("This command allows you to get a Attribute value for WegElements As DataTable.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a Attribute value for WegElements As DataTable.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWebElementsValueAsDataTableCommand : ASeleniumGetMultiWebElementsValueAsSomethingCommands, IDataTableResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributeName))] + //public string v_AttributeName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetWebElementsValueAsDataTableCommand() + { + //this.CommandName = "SeleniumBrowserGetElementsValueAsDataTableCommand"; + //this.SelectionName = "Get Elements Value As DataTable"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + ////(var _, var elems) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), engine); + //(var _, var elems) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WaitTimeForWebElement), engine); + + //DataTable newDT = new DataTable(); + + //SeleniumBrowserControls.GetElementsAttribute(elems, v_AttributeName, engine, new Action((idx, name, value) => + // { + // if (!newDT.Columns.Contains(name)) + // { + // newDT.Columns.Add(name); + // } + // newDT.Rows.Add(); + // newDT.Rows[idx][0] = value; + // }) + //); + + ////newDT.StoreInUserVariable(engine, v_DataTableVariableName); + //this.StoreDataTableInUserVariable(newDT, nameof(v_Result), engine); + + var ret = this.CreateEmptyDataTable(); + this.GetMultiWebElementValueAction(new Action((attrName, attrValue, idx) => + { + if (!ret.Columns.Contains(attrName)) + { + ret.Columns.Add(attrName); + } + var newRow = ret.NewRow(); + newRow[0] = attrValue; + ret.Rows.Add(newRow); + }), engine); + this.StoreDataTableInUserVariable(ret, engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValueAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValueAsDictionaryCommand.cs new file mode 100644 index 000000000..bad3d68f0 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValueAsDictionaryCommand.cs @@ -0,0 +1,107 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Scraping")] + [Attributes.ClassAttributes.CommandSettings("Get WebElements Value As Dictionary")] + [Attributes.ClassAttributes.Description("This command allows you to get a Attribute value for WegElements As Dictionary.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a Attribute value for WegElements As Dictionary.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWebElementsValueAsDictionaryCommand : ASeleniumGetMultiWebElementsValueAsSomethingCommands, IDictionaryResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_AttributeName))] + //[PropertyParameterOrder(8000)] + //public string v_AttributeName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_OutputDictionaryName))] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetWebElementsValueAsDictionaryCommand() + { + //this.CommandName = "SeleniumBrowserGetElementsValueAsDictionaryCommand"; + //this.SelectionName = "Get Elements Value As Dictionary"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + ////(var _, var elems) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), engine); + //(var _, var elems) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WaitTimeForWebElement), engine); + + //var newDic = new Dictionary(); + + //SeleniumBrowserControls.GetElementsAttribute(elems, v_AttributeName, engine, new Action((idx, name, value) => + // { + // newDic.Add("element_" + idx, value); + // }) + //); + + ////newDic.StoreInUserVariable(engine, v_DictionaryVariableName); + //this.StoreDictionaryInUserVariable(newDic, nameof(v_Result), engine); + + //this.SearchMultiWebElementsAction(new Action>(elems => + //{ + // var newDic = this.CreateEmptyDictionary(); + + // using (var elemVar = new InnerScriptVariable(engine)) + // { + // using (var resVar = new InnerScriptVariable(engine)) + // { + // var getAttr = new SeleniumBrowserGetAttributeFromWebElementCommand() + // { + // v_WebElement = elemVar.VariableName, + // v_AttributeName = this.v_AttributeName, + // v_Result = resVar.VariableName, + // }; + + // int idx = 0; + // foreach (var elem in elems) + // { + // elemVar.VariableValue = new ValueTuple(elem, null); + + // getAttr.RunCommand(engine); + + // newDic.Add($"element_{idx}", resVar.VariableValue.ToString()); + // idx++; + // } + // } + // } + + // this.StoreDictionaryInUserVariable(newDic, engine); + //}), engine); + + var newDic = this.CreateEmptyDictionary(); + this.GetMultiWebElementValueAction(new Action((attrName, attrValue, idx) => { + newDic.Add($"element_{idx}", attrValue); + }), engine); + this.StoreDictionaryInUserVariable(newDic, engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValueAsListCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValueAsListCommand.cs new file mode 100644 index 000000000..90d657214 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValueAsListCommand.cs @@ -0,0 +1,76 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Scraping")] + [Attributes.ClassAttributes.CommandSettings("Get WebElements Value As List")] + [Attributes.ClassAttributes.Description("This command allows you to get a Attribute value for WegElements As List.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a Attribute value for WegElements As List.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWebElementsValueAsListCommand : ASeleniumGetMultiWebElementsValueAsSomethingCommands, IListResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_AttributeName))] + //public string v_AttributeName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetWebElementsValueAsListCommand() + { + //this.CommandName = "SeleniumBrowserGetElementsValueAsListCommand"; + //this.SelectionName = "Get Elements Value As List"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + ////(var _, var elems) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), engine); + //(var _, var elems) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WaitTimeForWebElement), engine); + + //List newList = new List(); + + //SeleniumBrowserControls.GetElementsAttribute(elems, v_AttributeName, engine, new Action((idx, name, value) => + // { + // newList.Add(value); + // }) + //); + + ////newList.StoreInUserVariable(engine, v_ListVariableName); + //this.StoreListInUserVariable(newList, nameof(v_Result), engine); + + var res = this.CreateEmptyList(); + this.GetMultiWebElementValueAction(new Action((attrName, attrValue, idx) => + { + res.Add(attrValue); + }), engine); + this.StoreListInUserVariable(res, engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValuesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValuesAsDataTableCommand.cs new file mode 100644 index 000000000..16efd85a0 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWebElementsValuesAsDataTableCommand.cs @@ -0,0 +1,151 @@ +using OpenQA.Selenium; +using System; +using System.Collections.Generic; +using System.Data; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Scraping")] + [Attributes.ClassAttributes.CommandSettings("Get WebElements Values As DataTable")] + [Attributes.ClassAttributes.Description("This command allows you to get Attributes value for WegElements As DataTable.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get Attributes value for WegElements As DataTable.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWebElementsValuesAsDataTableCommand : ASeleniumSearchMultiWebElementsFromWebDriverCommands, IDataTableResultProperties, IHaveDataTableElements + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] + //public string v_SearchParameter { get; set; } + + [XmlElement] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_AttributeNames))] + [PropertyParameterOrder(7000)] + public DataTable v_AttributesName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] + [PropertyParameterOrder(8000)] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserGetWebElementsValuesAsDataTableCommand() + { + //this.CommandName = "SeleniumBrowserGetElementsValuesAsDataTableCommand"; + //this.SelectionName = "Get Elements Values As DataTable"; + //this.CommandEnabled = true; + //this.CustomRendering = true; + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + ////(var _, var elems) = SeleniumBrowserControls.GetSeleniumBrowserInstanceAndElements(this, nameof(v_InstanceName), nameof(v_SeleniumSearchType), nameof(v_SeleniumSearchParameter), engine); + //(var _, var elems) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElements(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WaitTimeForWebElement), engine); + + //var newDT = new DataTable(); + + //int attrs = v_AttributesName.Rows.Count; + //for (int i = 0; i >(elems => + { + using (var elemVar = new InnerScriptVariable(engine)) + { + using (var resVar = new InnerScriptVariable(engine)) + { + // create attribute names list + var attrs = new List(); + var showAttrs = new List(); + foreach (DataRow row in v_AttributesName.Rows) + { + var expandAttr = (row[0]?.ToString() ?? string.Empty).ExpandValueOrUserVariable(engine); + attrs.Add(expandAttr); + showAttrs.Add((expandAttr.StartsWith("@") ? expandAttr.Substring(1) : expandAttr)); + } + + // set column names + var res = this.CreateEmptyDataTable(); + foreach (var attr in showAttrs) + { + res.Columns.Add(attr); + } + + foreach (var elem in elems) + { + elemVar.VariableValue = new ValueTuple(elem, null); + + var getAttr = new SeleniumBrowserGetAttributeFromWebElementCommand() + { + v_WebElement = elemVar.VariableName, + v_Result = resVar.VariableName, + }; + + var row = res.NewRow(); + + int idx = 0; + foreach (var attr in attrs) + { + getAttr.v_AttributeName = attr; + getAttr.RunCommand(engine); + + row[showAttrs[idx]] = resVar.VariableValue.ToString(); + + idx++; + } + + res.Rows.Add(row); + } + + this.StoreDataTableInUserVariable(res, engine); + } + } + }), engine); + } + + public override void BeforeValidate() + { + base.BeforeValidate(); + DataTableControls.BeforeValidate((DataGridView)ControlsList[nameof(v_AttributesName)], v_AttributesName); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabCountCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabCountCommand.cs similarity index 60% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabCountCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabCountCommand.cs index 6c0cd45d0..253e3149f 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabCountCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabCountCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -14,15 +15,16 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWindowAndTabCountCommand : ScriptCommand + public sealed class SeleniumBrowserGetWindowAndTabCountCommand : ASeleniumGetWindowAndTabInformationCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - public string v_Result { get; set; } + //[PropertyParameterOrder(6000)] + public override string v_Result { get; set; } public SeleniumBrowserGetWindowAndTabCountCommand() { @@ -30,9 +32,14 @@ public SeleniumBrowserGetWindowAndTabCountCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); + //var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); + + //seleniumInstance.WindowHandles.Count.StoreInUserVariable(engine, v_Result); - seleniumInstance.WindowHandles.Count.StoreInUserVariable(engine, v_Result); + this.WebDriverActionCore(new Action(seleniumInstance => + { + seleniumInstance.WindowHandles.Count.StoreInUserVariable(engine, v_Result); + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand.cs similarity index 84% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand.cs index bc5ccfec8..eb6b59a65 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; using taskt.Core.Script; namespace taskt.Core.Automation.Commands @@ -15,15 +16,15 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand : ScriptCommand + public sealed class SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand : ASeleniumGetWindowAndTabInformationCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(JSONControls), nameof(JSONControls.v_OutputJSONName))] - public string v_Result { get; set; } + public override string v_Result { get; set; } public SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand() { diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabHandlesAsListCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabHandlesAsListCommand.cs similarity index 60% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabHandlesAsListCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabHandlesAsListCommand.cs index 92c54ec78..6deb02929 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabHandlesAsListCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabHandlesAsListCommand.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -15,15 +16,16 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWindowAndTabHandlesAsListCommand : ScriptCommand, IListResultProperties + public sealed class SeleniumBrowserGetWindowAndTabHandlesAsListCommand : ASeleniumGetWindowAndTabInformationCommands, IListResultProperties { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] - public string v_Result { get; set; } + //[PropertyParameterOrder(6000)] + public override string v_Result { get; set; } public SeleniumBrowserGetWindowAndTabHandlesAsListCommand() { @@ -31,9 +33,14 @@ public SeleniumBrowserGetWindowAndTabHandlesAsListCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); + //var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); + + //this.StoreListInUserVariable(seleniumInstance.WindowHandles.ToList(), engine); - this.StoreListInUserVariable(seleniumInstance.WindowHandles.ToList(), engine); + this.WebDriverActionCore(new Action(seleniumInstance => + { + this.StoreListInUserVariable(seleniumInstance.WindowHandles.ToList(), engine); + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabInformationsAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabInformationsAsDataTableCommand.cs new file mode 100644 index 000000000..d756d4314 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabInformationsAsDataTableCommand.cs @@ -0,0 +1,87 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Window/Tab")] + [Attributes.ClassAttributes.CommandSettings("Get Window And Tab Informations As DataTable")] + [Attributes.ClassAttributes.Description("This command allows you to Get Handle, Title, and URL of Windows and Tabs.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Handle, Title, and URL of Windows and Tabs.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWindowAndTabInformationsAsDataTableCommand : ASeleniumGetWindowAndTabInformationCommands, IDataTableResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(DataTableControls), nameof(DataTableControls.v_OutputDataTableName))] + //[PropertyParameterOrder(6000)] + public override string v_Result { get; set; } + + public SeleniumBrowserGetWindowAndTabInformationsAsDataTableCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); + + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var ret = this.CreateEmptyDataTable(); + //ret.Columns.Add("handle"); + //ret.Columns.Add("url"); + //ret.Columns.Add("title"); + + //var handles = seleniumInstance.WindowHandles; + //foreach(var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Rows.Add(new string[] { handle, seleniumInstance.Url, seleniumInstance.Title }); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + //this.StoreDataTableInUserVariable(ret, engine); + + this.WebDriverActionCore(new Action(seleniumInstance => + { + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var ret = this.CreateEmptyDataTable(); + //ret.Columns.Add("handle"); + //ret.Columns.Add("url"); + //ret.Columns.Add("title"); + + //var handles = seleniumInstance.WindowHandles; + //foreach (var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Rows.Add(new string[] { handle, seleniumInstance.Url, seleniumInstance.Title }); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + var ret = this.CreateEmptyDataTable(); + ret.Columns.Add("handle"); + ret.Columns.Add("url"); + ret.Columns.Add("title"); + + SeleniumWindowAndTabAction(seleniumInstance, new Action(handle => + { + ret.Rows.Add(new string[] { handle, seleniumInstance.Url, seleniumInstance.Title }); + })); + + this.StoreDataTableInUserVariable(ret, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabInformationsAsJSONCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabInformationsAsJSONCommand.cs similarity index 84% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabInformationsAsJSONCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabInformationsAsJSONCommand.cs index c17d6e110..7962af145 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabInformationsAsJSONCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabInformationsAsJSONCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; using taskt.Core.Script; namespace taskt.Core.Automation.Commands @@ -15,15 +16,15 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWindowAndTabInformationsAsJSONCommand : ScriptCommand + public sealed class SeleniumBrowserGetWindowAndTabInformationsAsJSONCommand : ASeleniumGetWindowAndTabInformationCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(JSONControls), nameof(JSONControls.v_OutputJSONName))] - public string v_Result { get; set; } + public override string v_Result { get; set; } public SeleniumBrowserGetWindowAndTabInformationsAsJSONCommand() { diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabTitlesAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabTitlesAsDictionaryCommand.cs new file mode 100644 index 000000000..f72c24e50 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabTitlesAsDictionaryCommand.cs @@ -0,0 +1,76 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Window/Tab")] + [Attributes.ClassAttributes.CommandSettings("Get Window And Tab Titles As Dictionary")] + [Attributes.ClassAttributes.Description("This command allows you to Get Page Titles of Windows and Tabs As Dictionary.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Page Titles of Windows and Tabs As Dictionary.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWindowAndTabTitlesAsDictionaryCommand : ASeleniumGetWindowAndTabInformationCommands, IDictionaryResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_OutputDictionaryName))] + //[PropertyParameterOrder(6000)] + public override string v_Result { get; set; } + + public SeleniumBrowserGetWindowAndTabTitlesAsDictionaryCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); + + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var ret = this.CreateEmptyDictionary(); + + //var handles = seleniumInstance.WindowHandles; + //foreach(var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Add(handle, seleniumInstance.Title); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + //this.StoreDictionaryInUserVariable(ret, engine); + + this.WebDriverActionCore(new Action(seleniumInstance => + { + var ret = this.CreateEmptyDictionary(); + + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var handles = seleniumInstance.WindowHandles; + //foreach (var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Add(handle, seleniumInstance.Title); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + SeleniumWindowAndTabAction(seleniumInstance, new Action(handle => + { + ret.Add(handle, seleniumInstance.Title); + })); + + this.StoreDictionaryInUserVariable(ret, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabTitlesAsJSONCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabTitlesAsJSONCommand.cs similarity index 84% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabTitlesAsJSONCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabTitlesAsJSONCommand.cs index 27d582cb1..4a21ac3cf 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabTitlesAsJSONCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabTitlesAsJSONCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; using taskt.Core.Script; namespace taskt.Core.Automation.Commands @@ -15,15 +16,15 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWindowAndTabTitlesAsJSONCommand : ScriptCommand + public sealed class SeleniumBrowserGetWindowAndTabTitlesAsJSONCommand : ASeleniumGetWindowAndTabInformationCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(JSONControls), nameof(JSONControls.v_OutputJSONName))] - public string v_Result { get; set; } + public override string v_Result { get; set; } public SeleniumBrowserGetWindowAndTabTitlesAsJSONCommand() { diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabTitlesAsListCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabTitlesAsListCommand.cs new file mode 100644 index 000000000..6c65e5862 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabTitlesAsListCommand.cs @@ -0,0 +1,76 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Window/Tab")] + [Attributes.ClassAttributes.CommandSettings("Get Window And Tab Titles As List")] + [Attributes.ClassAttributes.Description("This command allows you to Get Page Titles of Windows and Tabs As List.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Page Titles of Windows and Tabs As List.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWindowAndTabTitlesAsListCommand : ASeleniumGetWindowAndTabInformationCommands, IListResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] + //[PropertyParameterOrder(6000)] + public override string v_Result { get; set; } + + public SeleniumBrowserGetWindowAndTabTitlesAsListCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); + + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var ret = this.CreateEmptyList(); + + //var handles = seleniumInstance.WindowHandles; + //foreach(var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Add(seleniumInstance.Title); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + //this.StoreListInUserVariable(ret, engine); + + this.WebDriverActionCore(new Action(seleniumInstance => + { + var ret = this.CreateEmptyList(); + + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var handles = seleniumInstance.WindowHandles; + //foreach (var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Add(seleniumInstance.Title); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + SeleniumWindowAndTabAction(seleniumInstance, new Action(handle => + { + ret.Add(seleniumInstance.Title); + })); + + this.StoreListInUserVariable(ret, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabURLsAsDictionaryCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabURLsAsDictionaryCommand.cs new file mode 100644 index 000000000..fb9912e2b --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabURLsAsDictionaryCommand.cs @@ -0,0 +1,76 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Window/Tab")] + [Attributes.ClassAttributes.CommandSettings("Get Window And Tab URLs As Dictionary")] + [Attributes.ClassAttributes.Description("This command allows you to Get Page URLs of Windows and Tabs As Dictionary.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Page URLs of Windows and Tabs As Dictionary.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWindowAndTabURLsAsDictionaryCommand : ASeleniumGetWindowAndTabInformationCommands, IDictionaryResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(DictionaryControls), nameof(DictionaryControls.v_OutputDictionaryName))] + //[PropertyParameterOrder(6000)] + public override string v_Result { get; set; } + + public SeleniumBrowserGetWindowAndTabURLsAsDictionaryCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); + + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var ret = this.CreateEmptyDictionary(); + + //var handles = seleniumInstance.WindowHandles; + //foreach(var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Add(handle, seleniumInstance.Url); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + //this.StoreDictionaryInUserVariable(ret, engine); + + this.WebDriverActionCore(new Action(seleniumInstance => + { + var ret = this.CreateEmptyDictionary(); + + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var handles = seleniumInstance.WindowHandles; + //foreach (var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Add(handle, seleniumInstance.Url); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + SeleniumWindowAndTabAction(seleniumInstance, new Action(handle => + { + ret.Add(handle, seleniumInstance.Url); + })); + + this.StoreDictionaryInUserVariable(ret, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabURLsAsJSONCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabURLsAsJSONCommand.cs similarity index 84% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabURLsAsJSONCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabURLsAsJSONCommand.cs index 26af8742b..d6e73a18f 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserGetWindowAndTabURLsAsJSONCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabURLsAsJSONCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; using taskt.Core.Script; namespace taskt.Core.Automation.Commands @@ -15,15 +16,15 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserGetWindowAndTabURLsAsJSONCommand : ScriptCommand + public sealed class SeleniumBrowserGetWindowAndTabURLsAsJSONCommand : ASeleniumGetWindowAndTabInformationCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(JSONControls), nameof(JSONControls.v_OutputJSONName))] - public string v_Result { get; set; } + public override string v_Result { get; set; } public SeleniumBrowserGetWindowAndTabURLsAsJSONCommand() { diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabURLsAsListCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabURLsAsListCommand.cs new file mode 100644 index 000000000..d7278ed0a --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetWindowAndTabURLsAsListCommand.cs @@ -0,0 +1,76 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Window/Tab")] + [Attributes.ClassAttributes.CommandSettings("Get Window And Tab URLs As List")] + [Attributes.ClassAttributes.Description("This command allows you to Get Page URLs of Windows and Tabs As List.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Page URLs of Windows and Tabs As List.")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetWindowAndTabURLsAsListCommand : ASeleniumGetWindowAndTabInformationCommands, IListResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] + //[PropertyParameterOrder(6000)] + public override string v_Result { get; set; } + + public SeleniumBrowserGetWindowAndTabURLsAsListCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var seleniumInstance = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstance(v_InstanceName, engine); + + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var ret = this.CreateEmptyList(); + + //var handles = seleniumInstance.WindowHandles; + //foreach(var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Add(seleniumInstance.Url); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + //this.StoreListInUserVariable(ret, engine); + + this.WebDriverActionCore(new Action(seleniumInstance => + { + var ret = this.CreateEmptyList(); + + //var currentHandle = seleniumInstance.CurrentWindowHandle; + + //var handles = seleniumInstance.WindowHandles; + //foreach (var handle in handles) + //{ + // seleniumInstance.SwitchTo().Window(handle); + // ret.Add(seleniumInstance.Url); + //} + + //seleniumInstance.SwitchTo().Window(currentHandle); + + SeleniumWindowAndTabAction(seleniumInstance, new Action(handle => + { + ret.Add(seleniumInstance.Url); + })); + + this.StoreListInUserVariable(ret, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetXPathFromWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetXPathFromWebElementCommand.cs new file mode 100644 index 000000000..ee8292b8c --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserGetXPathFromWebElementCommand.cs @@ -0,0 +1,115 @@ +using OpenQA.Selenium; +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Get From WebElement")] + [Attributes.ClassAttributes.CommandSettings("Get XPath From WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Get XPath from WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get XPath from WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserGetXPathFromWebElementCommand : ASeleniumGetWebElementSelectorFromWebElementCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyParameterOrder(6000)] + //public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + //[PropertyDescription("Believe ID Attribute")] + //[PropertyIsOptional(true, "No")] + //[PropertyDisplayText(false, "Believe ID")] + //[PropertyParameterOrder(7000)] + //public string v_BeliveIDAttribute { get; set; } + + public SeleniumBrowserGetXPathFromWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.GetFromWebElementAction(new Action((elem, seleniumInstance) => + { + // MEMO: it's probably works fine. :-) + var path = string.Empty; + + var believeId = this.ExpandValueOrUserVariableAsYesNo(nameof(v_BeliveIDAttribute), engine); + + var curElem = elem; + var curElemId = curElem.ToString(); + + // DBG + //Debug.WriteLine($"curElem: {curElem.ToString()}, {curElem.GetHashCode()}"); + + var pElem = curElem.FindElement(By.XPath("parent::*")); + while (true) + { + var cTag = curElem.TagName.ToLower(); + + var cElems = pElem.FindElements(By.XPath($"{cTag}")); + if (cElems.Count > 1) + { + int index = 1; + foreach (var e in cElems) + { + if (e.ToString() == curElemId) + { + break; + } + index++; + } + var idAttr = curElem.GetAttribute("id"); + if (!string.IsNullOrEmpty(idAttr) && believeId) + { + path = $"/{cTag}[@id=\"{idAttr}\"]{path}"; + } + else + { + path = $"/{cTag}[{index}]{path}"; + } + } + else + { + var idAttr = curElem.GetAttribute("id"); + if (!string.IsNullOrEmpty(idAttr) && believeId) + { + path = $"/{cTag}[@id=\"{idAttr}\"]{path}"; + } + else + { + path = $"/{cTag}{path}"; + } + } + + // DGB + //Debug.WriteLine($"totyu: {path}"); + + if (cTag == "body") + { + path = $"/html{path}"; + break; + } + else + { + curElem = pElem; + curElemId = curElem.ToString(); + pElem = curElem.FindElement(By.XPath("parent::*")); + } + } + path.StoreInUserVariable(engine, v_Result); + }), new Action(e => + { + string.Empty.StoreInUserVariable(engine, v_Result); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserNavigateBackCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserNavigateBackCommand.cs similarity index 64% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserNavigateBackCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserNavigateBackCommand.cs index 6d6ea64d1..ba947729f 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserNavigateBackCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserNavigateBackCommand.cs @@ -1,6 +1,5 @@ using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -15,11 +14,11 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserNavigateBackCommand : ScriptCommand + public sealed class SeleniumBrowserNavigateBackCommand : ASeleniumWebDriverActionCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } public SeleniumBrowserNavigateBackCommand() { @@ -31,9 +30,14 @@ public SeleniumBrowserNavigateBackCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - seleniumInstance.Navigate().Back(); + //seleniumInstance.Navigate().Back(); + + this.WebDriverAction(new Action(seleniumInstance => + { + seleniumInstance.Navigate().Back(); + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserNavigateForwardCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserNavigateForwardCommand.cs similarity index 67% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserNavigateForwardCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserNavigateForwardCommand.cs index 3de370ace..69c03f10d 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserNavigateForwardCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserNavigateForwardCommand.cs @@ -1,6 +1,5 @@ using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -15,11 +14,11 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserNavigateForwardCommand : ScriptCommand + public sealed class SeleniumBrowserNavigateForwardCommand : ASeleniumWebDriverActionCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } public SeleniumBrowserNavigateForwardCommand() { @@ -31,9 +30,14 @@ public SeleniumBrowserNavigateForwardCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - seleniumInstance.Navigate().Forward(); + //seleniumInstance.Navigate().Forward(); + + this.WebDriverAction(new Action(seleniumInstance => + { + seleniumInstance.Navigate().Forward(); + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserNavigateToURLCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserNavigateToURLCommand.cs similarity index 59% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserNavigateToURLCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserNavigateToURLCommand.cs index c43c5c466..8cb4610ad 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserNavigateToURLCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserNavigateToURLCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -14,11 +15,11 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserNavigateToURLCommand : ScriptCommand + public sealed class SeleniumBrowserNavigateToURLCommand : ASeleniumWebDriverActionCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] @@ -30,6 +31,7 @@ public sealed class SeleniumBrowserNavigateToURLCommand : ScriptCommand [Remarks("")] [PropertyValidationRule("URL", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "URL")] + [PropertyParameterOrder(6000)] public string v_URL { get; set; } [XmlAttribute] @@ -44,6 +46,7 @@ public sealed class SeleniumBrowserNavigateToURLCommand : ScriptCommand [PropertyIsOptional(true, "True")] [Remarks("Choose if you want to use HTTP or HTTPS for navigation. If no protocol is specified in the URL above, taskt will resort to this choice.")] [PropertyDisplayText(false, "")] + [PropertyParameterOrder(7000)] public string v_UseHttps { get; set; } public SeleniumBrowserNavigateToURLCommand() @@ -59,26 +62,47 @@ public SeleniumBrowserNavigateToURLCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var parsedURL = v_URL.ExpandValueOrUserVariable(engine); - if (!parsedURL.StartsWith("http")) + //var parsedURL = v_URL.ExpandValueOrUserVariable(engine); + //if (!parsedURL.StartsWith("http")) + //{ + // // check Edge/Chrome/Firefox special + // if (!parsedURL.StartsWith("edge://") && + // !parsedURL.StartsWith("chrome://") && + // !parsedURL.StartsWith("about:")) + // { + // if (string.IsNullOrEmpty(v_UseHttps)) + // { + // v_UseHttps = "True"; + // } + // var useHttps = v_UseHttps.ExpandValueOrUserVariableAsBool("Use HTTPS", engine); + // parsedURL = ((useHttps) ? "https://" : "http://") + parsedURL; + // } + //} + + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + + //seleniumInstance.Navigate().GoToUrl(parsedURL); + + this.WebDriverAction(new Action(seleniumInstance => { - // check Edge/Chrome/Firefox special - if (!parsedURL.StartsWith("edge://") && - !parsedURL.StartsWith("chrome://") && - !parsedURL.StartsWith("about:")) + var parsedURL = v_URL.ExpandValueOrUserVariable(engine); + if (!parsedURL.StartsWith("http")) { - if (string.IsNullOrEmpty(v_UseHttps)) + // check Edge/Chrome/Firefox special + if (!parsedURL.StartsWith("edge://") && + !parsedURL.StartsWith("chrome://") && + !parsedURL.StartsWith("about:")) { - v_UseHttps = "True"; + if (string.IsNullOrEmpty(v_UseHttps)) + { + v_UseHttps = "True"; + } + var useHttps = v_UseHttps.ExpandValueOrUserVariableAsBool("Use HTTPS", engine); + parsedURL = ((useHttps) ? "https://" : "http://") + parsedURL; } - var useHttps = v_UseHttps.ExpandValueOrUserVariableAsBool("Use HTTPS", engine); - parsedURL = ((useHttps) ? "https://" : "http://") + parsedURL; } - } - - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - - seleniumInstance.Navigate().GoToUrl(parsedURL); + seleniumInstance.Navigate().GoToUrl(parsedURL); + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserRefreshCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserRefreshWebBrowserCommand.cs similarity index 57% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserRefreshCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserRefreshWebBrowserCommand.cs index 132656919..762ad428a 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserRefreshCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserRefreshWebBrowserCommand.cs @@ -1,26 +1,25 @@ using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { [Serializable] [Attributes.ClassAttributes.Group("Web Browser")] [Attributes.ClassAttributes.SubGruop("Web Browser Actions")] - [Attributes.ClassAttributes.CommandSettings("Refresh")] + [Attributes.ClassAttributes.CommandSettings("Refresh Web Browser")] [Attributes.ClassAttributes.Description("This command allows you to refresh a Selenium web browser session.")] [Attributes.ClassAttributes.UsesDescription("Use this command when you want to simulate a browser refresh click in the web browser session.")] [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserRefreshCommand : ScriptCommand + public sealed class SeleniumBrowserRefreshWebBrowserCommand : ASeleniumWebDriverActionCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } - public SeleniumBrowserRefreshCommand() + public SeleniumBrowserRefreshWebBrowserCommand() { //this.CommandName = "SeleniumBrowserRefreshCommand"; //this.SelectionName = "Refresh"; @@ -30,9 +29,14 @@ public SeleniumBrowserRefreshCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - seleniumInstance.Navigate().Refresh(); + //seleniumInstance.Navigate().Refresh(); + + this.WebDriverAction(new Action(seleniumInstance => + { + seleniumInstance.Navigate().Refresh(); + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserResizeWebBrowserCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserResizeWebBrowserCommand.cs similarity index 55% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserResizeWebBrowserCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserResizeWebBrowserCommand.cs index 8d0696e7b..e7967713e 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserResizeWebBrowserCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserResizeWebBrowserCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -14,11 +15,11 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserResizeWebBrowserCommand : ScriptCommand + public sealed class SeleniumBrowserResizeWebBrowserCommand : ASeleniumWebDriverActionCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] @@ -29,6 +30,7 @@ public sealed class SeleniumBrowserResizeWebBrowserCommand : ScriptCommand [Remarks("Empty means Current Width")] [PropertyIsOptional(true, "Empty and means Current Width")] [PropertyDisplayText(true, "Width")] + [PropertyParameterOrder(6000)] public string v_BrowserWidth { get; set; } [XmlAttribute] @@ -40,6 +42,7 @@ public sealed class SeleniumBrowserResizeWebBrowserCommand : ScriptCommand [Remarks("Empty means Current Height")] [PropertyIsOptional(true, "Empty and means Current Height")] [PropertyDisplayText(true, "Height")] + [PropertyParameterOrder(6001)] public string v_BrowserHeight { get; set; } public SeleniumBrowserResizeWebBrowserCommand() @@ -52,30 +55,56 @@ public SeleniumBrowserResizeWebBrowserCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); - var currentSize = seleniumInstance.Manage().Window.Size; + //var currentSize = seleniumInstance.Manage().Window.Size; - int width; - if (String.IsNullOrEmpty(v_BrowserWidth)) - { - width = currentSize.Width; - } - else - { - width = this.ExpandValueOrUserVariableAsInteger(nameof(v_BrowserWidth), engine); - } + //int width; + //if (string.IsNullOrEmpty(v_BrowserWidth)) + //{ + // width = currentSize.Width; + //} + //else + //{ + // width = this.ExpandValueOrUserVariableAsInteger(nameof(v_BrowserWidth), engine); + //} - int height; - if (String.IsNullOrEmpty(v_BrowserHeight)) - { - height = currentSize.Height; - } - else + //int height; + //if (string.IsNullOrEmpty(v_BrowserHeight)) + //{ + // height = currentSize.Height; + //} + //else + //{ + // height = this.ExpandValueOrUserVariableAsInteger(nameof(v_BrowserHeight), engine); + //} + //seleniumInstance.Manage().Window.Size = new System.Drawing.Size(width, height); + + this.WebDriverAction(new Action(seleniumInstance => { - height = this.ExpandValueOrUserVariableAsInteger(nameof(v_BrowserHeight), engine); - } - seleniumInstance.Manage().Window.Size = new System.Drawing.Size(width, height); + var currentSize = seleniumInstance.Manage().Window.Size; + + int width; + if (string.IsNullOrEmpty(v_BrowserWidth)) + { + width = currentSize.Width; + } + else + { + width = this.ExpandValueOrUserVariableAsInteger(nameof(v_BrowserWidth), engine); + } + + int height; + if (string.IsNullOrEmpty(v_BrowserHeight)) + { + height = currentSize.Height; + } + else + { + height = this.ExpandValueOrUserVariableAsInteger(nameof(v_BrowserHeight), engine); + } + seleniumInstance.Manage().Window.Size = new System.Drawing.Size(width, height); + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserScrollToWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserScrollToWebElementCommand.cs new file mode 100644 index 000000000..53776b044 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserScrollToWebElementCommand.cs @@ -0,0 +1,77 @@ +using System; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("WebElement Action")] + [Attributes.ClassAttributes.CommandSettings("Scroll To WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Scroll to WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Scroll to WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserScrollToWebElementCommand : ASeleniumWebElementActionCommands, ICanExecuteJavaScriptToWebDriver + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When Fail Scroll")] + //[PropertyUISelectionOption("Error")] + //[PropertyUISelectionOption("Ignore")] + //[PropertyIsOptional(true, "Error")] + //[PropertyDisplayText(false, "")] + //public string v_WhenFailAction { get; set; } + + public SeleniumBrowserScrollToWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + + //try + //{ + // string scroll = string.Format("window.scroll(0, {0})", elem.Location.Y); + // //IJavaScriptExecutor js = seleniumInstance as IJavaScriptExecutor; + // //js.ExecuteScript(scroll); + // SeleniumBrowserControls.ExcecuteScript(seleniumInstance, scroll); + + // // Debug + // //Console.WriteLine("JSJS"); + // //Console.WriteLine(scroll); + //} + //catch + //{ + // if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailAction), engine) == "error") + // { + // throw new Exception("Failed to Scroll To WebElement"); + // } + //} + + this.WebElementAction( + new Action((el, dr) => + { + var script = $"window.scroll(0, {el.Location.Y})"; + //SeleniumBrowserControls.ExcecuteScript(dr, script); + this.ExecuteJavaScript(dr, script); + }), engine, new Action(ex => + { + //throw new Exception("Failed to Scroll To WebElement"); + throw new Exception(EM_SeleniumWebElementActionPropertiesExtensionMehtods.GetFailActionMessage("Scroll")); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSearchWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSearchWebElementCommand.cs new file mode 100644 index 000000000..53b2699da --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSearchWebElementCommand.cs @@ -0,0 +1,69 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Search WebElement")] + [Attributes.ClassAttributes.CommandSettings("Search WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to search WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserSearchWebElementCommand : ASeleniumSearchWebElementFromWebDriverCommands, ISeleniumSearchWebElementParametersProperties, ISeleniumWebElementResultProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchMethod))] + //[PropertyParameterOrder(6000)] + //public string v_SearchMethod { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchParameter))] + //[PropertyParameterOrder(6100)] + //public string v_SearchParameter { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WebElementIndex))] + //[PropertyParameterOrder(6200)] + //public string v_WebElementIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_OutputWebElementName))] + [PropertyParameterOrder(8000)] + public override string v_Result { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] + //[PropertyParameterOrder(8000)] + //public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserSearchWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //(var ins, var trgElem) = SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WebElementIndex), nameof(v_WaitTimeForWebElement), engine); + + //(trgElem, ins).StoreInUserVariable(engine, v_Result); + + // DBG + //SeleniumBrowserControls.CreateXPath(trgElem); + + this.WebDriverActionCore(new Action(seleniumInstance => + { + var elem = this.SearchWebElement(seleniumInstance, engine); + this.StoreWebElementInUserVariable(elem, seleniumInstance, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSearchWebElementFromWebEelementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSearchWebElementFromWebEelementCommand.cs new file mode 100644 index 000000000..724b956e7 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSearchWebElementFromWebEelementCommand.cs @@ -0,0 +1,214 @@ +using OpenQA.Selenium; +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Search WebElement")] + [Attributes.ClassAttributes.CommandSettings("Search WebElement From WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to search WebElement from WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get WebElement from WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserSearchWebElementFromWebElementCommand : ASeleniumDoSomethingToWebElementCommands, ISeleniumSearchWebElementParametersProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchMethod))] + [PropertyParameterOrder(6000)] + public string v_SearchMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchParameter))] + [PropertyParameterOrder(6100)] + public string v_SearchParameter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WebElementIndex))] + [PropertyParameterOrder(6200)] + public string v_WebElementIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_OutputWebElementName))] + [PropertyParameterOrder(7000)] + public string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WaitTimeForWebElement))] + [PropertyParameterOrder(10000)] + public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserSearchWebElementFromWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var targetElement = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + //var webDriver = v_WebElement.ExpandUserVariableAsWebDriverFromWebElement("WebDriver", engine); + + //var searchMethod = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SearchMethod), engine); + //var searchFunc = GetWebElementSearchMethod(searchMethod); + + //var searchParameter = v_SearchParameter.ExpandValueOrUserVariable(engine); + //var waitTime = v_WaitTimeForWebElement.ExpandValueOrUserVariableAsInteger("Wait Time", engine); + + //int index = 0; + //if (!string.IsNullOrEmpty(v_WebElementIndex)) + //{ + // index = v_WebElementIndex.ExpandValueOrUserVariableAsInteger("Index", engine); + //} + + //var ret = WaitControls.WaitProcess(waitTime, "WebElement", new Func<(bool, object)>(() => { + // try + // { + // var t = searchFunc(targetElement, searchParameter); + // if (t is IWebElement elem) + // { + // return (true, elem); + // } + // else if (t is ReadOnlyCollection elems) + // { + // if (index < 0) + // { + // index += elems.Count; + // } + // if ((index >= 0) && (index < elems.Count)) + // { + // return (true, elems[index]); + // } + // else + // { + // return (false, null); + // } + // } + // else + // { + // return (false, null); + // } + // } + // catch + // { + // return (false, null); + // } + //}), engine); + + //if (ret is IWebElement resultElem) + //{ + // (resultElem, webDriver).StoreInUserVariable(engine, v_Result); + //} + //else + //{ + // throw new Exception("WebElement not found"); + //} + + this.WebElementActionCore(new Action((elem, seleniumInstance) => + { + var findElem = this.SearchWebElement(elem, engine); + this.StoreInUserVariable(findElem, seleniumInstance, engine, v_Result); + }), engine); + } + + //private static Func GetWebElementSearchMethod(string searchMethod) + //{ + // switch (searchMethod.ToLower()) + // { + // case "find element by xpath": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.XPath(parameter)); + // }); + + // case "find element by id": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.Id(parameter)); + // }); + + // case "find element by name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.Name(parameter)); + // }); + + // case "find element by tag name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.TagName(parameter)); + // }); + + // case "find element by class name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.ClassName(parameter)); + // }); + + // case "find element by css selector": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.CssSelector(parameter)); + // }); + + // case "find element by link text": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElement(By.LinkText(parameter)); + // }); + + // case "find elements by xpath": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.XPath(parameter)); + // }); + + // case "find elements by id": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.Id(parameter)); + // }); + + // case "find elements by name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.Name(parameter)); + // }); + + // case "find elements by tag name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.TagName(parameter)); + // }); + + // case "find elements by class name": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.ClassName(parameter)); + // }); + + // case "find elements by css selector": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.CssSelector(parameter)); + // }); + + // case "find elements by link text": + // return new Func((webDriver, parameter) => + // { + // return webDriver.FindElements(By.LinkText(parameter)); + // }); + + // default: + // throw new Exception("Strange Search Method '" + searchMethod + "'"); + // } + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSelectOptionForWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSelectOptionForWebElementCommand.cs new file mode 100644 index 000000000..18a203318 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSelectOptionForWebElementCommand.cs @@ -0,0 +1,215 @@ +using OpenQA.Selenium; +using OpenQA.Selenium.Support.UI; +using System; +using System.Windows.Forms; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("WebElement Action")] + [Attributes.ClassAttributes.CommandSettings("Select Option For WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Select an Option for WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Select an Option for WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserSelectOptionForWebElementCommand : ASeleniumWebElementActionAndScrollCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Selection Type")] + [PropertyUISelectionOption("Select By Index")] + [PropertyUISelectionOption("Select By Text")] + [PropertyUISelectionOption("Select By Value")] + [PropertyUISelectionOption("Deselect By Index")] + [PropertyUISelectionOption("Deselect By Text")] + [PropertyUISelectionOption("Deselect By Value")] + [PropertyUISelectionOption("Deselect All")] + [PropertySelectionChangeEvent(nameof(cmbSelectionType_SelectionChange))] + [PropertyValidationRule("Select Type", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Select Type")] + [PropertyParameterOrder(6000)] + public string v_SelectionType { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Option Value to Select")] + [PropertyDetailSampleUsage("**Hello**", PropertyDetailSampleUsage.ValueType.Value, "Value")] + [PropertyDetailSampleUsage("**{{{vValue}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Value")] + [PropertyValidationRule("Value", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Value")] + [PropertyParameterOrder(6100)] + public string v_SelectionValue { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When Fail Select Action")] + //[PropertyUISelectionOption("Error")] + //[PropertyUISelectionOption("Ignore")] + //[PropertyIsOptional(true, "Error")] + //[PropertyDisplayText(false, "")] + //public string v_WhenFailAction { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //[PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] + //public string v_ScrollToWebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyIsOptional(true)] + //public string v_InstanceName { get; set; } + + public SeleniumBrowserSelectOptionForWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToWebElement), engine)) + //{ + // var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() + // { + // //v_InstanceName = this.v_InstanceName, + // v_WebElement = this.v_WebElement, + // v_WhenFailAction = "ignore" + // }; + // scrollCommand.RunCommand(engine); + //} + + //if (!elem.CheckTagName("select")) + //{ + // throw new Exception("WebElement is not Select"); + //} + + //var sel = new SelectElement(elem); + //var value = v_SelectionValue.ExpandValueOrUserVariable(engine); + //var selectType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SelectionType), engine); + //try + //{ + // switch (selectType) + // { + // case "select by index": + // case "deselect by index": + // if (int.TryParse(value, out int index)) + // { + // switch (selectType) + // { + // case "select by index": + // sel.SelectByIndex(index); + // break; + // default: + // sel.DeselectByIndex(index); + // break; + // } + // } + // break; + // case "select by text": + // sel.SelectByText(value); + // break; + // case "select by value": + // sel.SelectByValue(value); + // break; + // case "deselect by text": + // sel.DeselectByText(value); + // break; + // case "deselect by value": + // sel.DeselectByValue(value); + // break; + // case "deselect all": + // sel.DeselectAll(); + // break; + // } + //} + //catch + //{ + // if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailAction), engine) == "error") + // { + // throw new Exception($"Fail Select Option. Type:'{selectType}', Value:'{value}'"); + // } + //} + + this.WebElementActionAndScroll( + new Action((el, dr) => + { + if (this.TagName(el) != "select") + { + throw new Exception(); + } + var sel = new SelectElement(el); + var value = v_SelectionValue.ExpandValueOrUserVariable(engine); + var selectType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SelectionType), engine); + switch (selectType) + { + case "select by index": + case "deselect by index": + if (int.TryParse(value, out int index)) + { + var options = el.FindElements(By.TagName("option")); + if (index < 0) + { + index += options.Count; + } + if ((index < 0) && (index >= options.Count)) + { + throw new Exception(); + } + + switch (selectType) + { + case "select by index": + sel.SelectByIndex(index); + break; + default: + sel.DeselectByIndex(index); + break; + } + } + break; + case "select by text": + sel.SelectByText(value); + break; + case "select by value": + sel.SelectByValue(value); + break; + case "deselect by text": + sel.DeselectByText(value); + break; + case "deselect by value": + sel.DeselectByValue(value); + break; + case "deselect all": + sel.DeselectAll(); + break; + } + }), engine, + new Action(ex => + { + throw new Exception($"{EM_SeleniumWebElementActionPropertiesExtensionMehtods.GetFailActionMessage("Select")} Selection Type: '{v_SelectionType}', Value: '{v_SelectionValue}'"); + }) + ); + } + + private void cmbSelectionType_SelectionChange(object sender, EventArgs e) + { + var showFlag = (((ComboBox)sender).SelectedItem?.ToString().ToLower() != "deselect all"); + FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_SelectionValue), showFlag); + } + + //private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSendSpecialKeystrokesToWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSendSpecialKeystrokesToWebElementCommand.cs new file mode 100644 index 000000000..b1f1afcf6 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSendSpecialKeystrokesToWebElementCommand.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("WebElement Action")] + [Attributes.ClassAttributes.CommandSettings("Send Special Keystrokes To WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Send Special Keystrokes in WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to SendSpecial Keystrokes in WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserSendSpecialKeystrokesToWebElementCommand : ASeleniumWebElementActionAndScrollCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Send Key")] + [PropertyValidationRule("Send Key", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Send Key")] + [PropertyComboBoxItemMethod(nameof(CreateSendKeyList))] + [PropertyParameterOrder(6000)] + public string v_SendKey { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Use Control Key")] + [PropertyIsOptional(true, "No")] + [PropertyFirstValue("No")] + [PropertyParameterOrder(6100)] + public string v_ControlKey { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Use Shift Key")] + [PropertyIsOptional(true, "No")] + [PropertyFirstValue("No")] + [PropertyParameterOrder(6200)] + public string v_ShiftKey { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Use Alt Key")] + [PropertyIsOptional(true, "No")] + [PropertyFirstValue("No")] + [PropertyParameterOrder(6300)] + public string v_AltKey { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When the WebElement does not support Set Text")] + //[PropertyUISelectionOption("Error")] + //[PropertyUISelectionOption("Ignore")] + //[PropertyIsOptional(true, "Error")] + //[PropertyDisplayText(false, "")] + //public string v_WhenFailAction { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //[PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] + //public string v_ScrollToWebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyIsOptional(true)] + //public string v_InstanceName { get; set; } + + public SeleniumBrowserSendSpecialKeystrokesToWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToWebElement), engine)) + //{ + // var scroll = new SeleniumBrowserScrollToWebElementCommand + // { + // //v_InstanceName = this.v_InstanceName, + // v_WebElement = this.v_WebElement, + // v_WhenFailAction = "ignore" + // }; + // scroll.RunCommand(engine); + //} + + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + + //string sendKey = ""; + + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ControlKey), engine)) + //{ + // sendKey += OpenQA.Selenium.Keys.Control; + //} + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ShiftKey), engine)) + //{ + // sendKey += OpenQA.Selenium.Keys.Shift; + //} + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_AltKey), engine)) + //{ + // sendKey += OpenQA.Selenium.Keys.Alt; + //} + + //// TODO: not case sensitive + //// send key + //var key = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SendKey), "Send Key", engine); + + //// get key value + //var tp = typeof(OpenQA.Selenium.Keys); + //var info = tp.GetField(key); + + //sendKey += $"{info.GetValue(null)}"; + + //try + //{ + // elem.SendKeys(sendKey); + //} + //catch + //{ + // if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailAction), engine) == "error") + // { + // throw new Exception("Fail Setting Text. TagName: '" + elem.TagName + "'"); + // } + //} + + this.WebElementActionAndScroll( + new Action((el, dr) => + { + var sendKey = string.Empty; + + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ControlKey), engine)) + { + sendKey += OpenQA.Selenium.Keys.Control; + } + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ShiftKey), engine)) + { + sendKey += OpenQA.Selenium.Keys.Shift; + } + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_AltKey), engine)) + { + sendKey += OpenQA.Selenium.Keys.Alt; + } + + // TODO: not case sensitive + // send key + var key = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SendKey), "Send Key", engine); + + // get key value + var tp = typeof(OpenQA.Selenium.Keys); + var info = tp.GetField(key); + + sendKey += $"{info.GetValue(null)}"; + + el.SendKeys(sendKey); + }), engine, + new Action(ex => + { + throw new Exception($"{EM_SeleniumWebElementActionPropertiesExtensionMehtods.GetFailActionMessage("Send Key")} SendKey: '{v_SendKey}'"); + }) + ); + } + + //private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); + //} + + /// + /// OpenQAのキー一覧を取得する + /// + /// + private List CreateSendKeyList() + { + var fields = typeof(OpenQA.Selenium.Keys).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); + return fields.Select(f => f.Name).ToList(); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSetTextToWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSetTextToWebElementCommand.cs new file mode 100644 index 000000000..ab30dcf18 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSetTextToWebElementCommand.cs @@ -0,0 +1,144 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("WebElement Action")] + [Attributes.ClassAttributes.CommandSettings("Set Text To WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Set Text in WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Set Text in WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserSetTextToWebElementCommand : ASeleniumWebElementActionAndScrollCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_MultiLinesTextBox))] + [PropertyDescription("Text To Set")] + [PropertyParameterOrder(6000)] + public string v_TextToSet { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Clear Text before Setting Text")] + [PropertyIsOptional(true, "No")] + [PropertyParameterOrder(6100)] + public string v_ClearTextBeforeSetting { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Encrypted Text")] + [PropertyIsOptional(true, "No")] + [PropertyParameterOrder(6200)] + public string v_EncryptedText { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When the WebElement does not support Set Text")] + //[PropertyUISelectionOption("Error")] + //[PropertyUISelectionOption("Ignore")] + //[PropertyIsOptional(true, "Error")] + //[PropertyDisplayText(false, "")] + //public string v_WhenFailAction { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //[PropertySelectionChangeEvent(nameof(cmbScrollToElement_SelectionChange))] + //public string v_ScrollToWebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //[PropertyIsOptional(true)] + //public string v_InstanceName { get; set; } + + public SeleniumBrowserSetTextToWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToWebElement), engine)) + //{ + // var scroll = new SeleniumBrowserScrollToWebElementCommand + // { + // //v_InstanceName = this.v_InstanceName, + // v_WebElement = this.v_WebElement, + // v_WhenFailAction = "ignore" + // }; + // scroll.RunCommand(engine); + //} + + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ClearTextBeforeSetting), engine)) + //{ + // var clearText = new SeleniumBrowserClearTextInWebElementCommand + // { + // v_WebElement = v_WebElement, + // v_WhenFailAction = "Ignore" + // }; + // clearText.RunCommand(engine); + //} + + //var textToSet = v_TextToSet.ExpandValueOrUserVariable(engine); + + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_EncryptedText), engine)) + //{ + // textToSet = EncryptionServices.DecryptString(textToSet, "TASKT"); + //} + + //try + //{ + // elem.SendKeys(textToSet); + //} + //catch + //{ + // if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailAction), engine) == "error") + // { + // throw new Exception("Fail Setting Text. TagName: '" + elem.TagName + "'"); + // } + //} + + this.WebElementActionAndScroll( + new Action((el, dr) => + { + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ClearTextBeforeSetting), engine)) + { + var clearText = new SeleniumBrowserClearTextInWebElementCommand + { + v_WebElement = v_WebElement, + v_WhenFailAction = "Ignore" + }; + clearText.RunCommand(engine); + } + + var textToSet = v_TextToSet.ExpandValueOrUserVariable(engine); + + if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_EncryptedText), engine)) + { + textToSet = EncryptionServices.DecryptString(textToSet, "TASKT"); + } + el.SendKeys(textToSet); + }), engine, + new Action(ex => + { + throw new Exception($"{EM_SeleniumWebElementActionPropertiesExtensionMehtods.GetFailActionMessage("Set Text")} Text: '{v_TextToSet}'"); + }) + ); + } + + //private void cmbScrollToElement_SelectionChange(object sender, EventArgs e) + //{ + // SeleniumBrowserControls.ScrollToWebElement_SelectionChange((ComboBox)sender, ControlsList, nameof(v_InstanceName)); + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSwitchToFrameWebElementCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSwitchToFrameWebElementCommand.cs new file mode 100644 index 000000000..dd1e793b2 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSwitchToFrameWebElementCommand.cs @@ -0,0 +1,100 @@ +using System; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("WebElement Action")] + [Attributes.ClassAttributes.CommandSettings("Switch To Frame WebElement")] + [Attributes.ClassAttributes.Description("This command allows you to Switch to Frame WebElement.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Switch to Frame WebElement.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserSwitchToFrameWebElementCommand : ASeleniumWebElementActionAndScrollCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputWebElementName))] + //public string v_WebElement { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("When Fail Switch")] + //[PropertyUISelectionOption("Error")] + //[PropertyUISelectionOption("Ignore")] + //[PropertyIsOptional(true, "Error")] + //[PropertyDisplayText(false, "")] + //public string v_WhenFailAction { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] + //public string v_ScrollToWebElement { get; set; } + + public SeleniumBrowserSwitchToFrameWebElementCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //if (this.ExpandValueOrUserVariableAsYesNo(nameof(v_ScrollToWebElement), engine)) + //{ + // var scrollCommand = new SeleniumBrowserScrollToWebElementCommand() + // { + // //v_InstanceName = this.v_InstanceName, + // v_WebElement = this.v_WebElement, + // v_WhenFailAction = "ignore" + // }; + // scrollCommand.RunCommand(engine); + //} + + //var elem = v_WebElement.ExpandUserVariableAsWebElement("WebElement", engine); + //switch (elem.TagName.ToLower()) + //{ + // case "frame": + // case "iframe": + // break; + // default: + // throw new Exception("WebElement is not frame or iframe"); + //} + + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + + //try + //{ + // seleniumInstance.SwitchTo().Frame(elem); + //} + //catch + //{ + // if (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenFailAction), engine) == "error") + // { + // throw new Exception("Fail Switch to Frame."); + // } + //} + + this.WebElementActionAndScroll( + new Action((el, dr) => + { + switch (this.TagName(el)) + { + case "frame": + case "iframe": + break; + default: + throw new Exception(); + } + dr.SwitchTo().Frame(el); + }), engine, + new Action(ex => + { + throw new Exception(EM_SeleniumWebElementActionPropertiesExtensionMehtods.GetFailActionMessage("Switch To Frame")); + }) + ); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSwitchWebBrowserFrameCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSwitchWebBrowserFrameCommand.cs similarity index 52% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSwitchWebBrowserFrameCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSwitchWebBrowserFrameCommand.cs index de0e15da9..1aced0a00 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserSwitchWebBrowserFrameCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSwitchWebBrowserFrameCommand.cs @@ -1,6 +1,7 @@ using System; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { @@ -14,11 +15,11 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserSwitchWebBrowserFrameCommand : ScriptCommand + public sealed class SeleniumBrowserSwitchWebBrowserFrameCommand : ASeleniumWebDriverActionCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] @@ -39,6 +40,7 @@ public sealed class SeleniumBrowserSwitchWebBrowserFrameCommand : ScriptCommand [PropertyFirstValue("Index")] [PropertyValidationRule("Frame Type", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "Frame Type")] + [PropertyParameterOrder(6000)] public string v_SelectionType { get; set; } [XmlAttribute] @@ -49,6 +51,7 @@ public sealed class SeleniumBrowserSwitchWebBrowserFrameCommand : ScriptCommand [PropertyIsOptional(true)] [PropertyFirstValue("0")] [PropertyDisplayText(true, "Frame")] + [PropertyParameterOrder(7000)] public string v_FrameParameter { get; set; } public SeleniumBrowserSwitchWebBrowserFrameCommand() @@ -61,37 +64,70 @@ public SeleniumBrowserSwitchWebBrowserFrameCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + + //var selectionType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SelectionType), engine); + //switch (selectionType) + //{ + // case "index": + // if (string.IsNullOrEmpty(v_FrameParameter)) + // { + // v_FrameParameter = "0"; + // } + // var frameIndex = this.ExpandValueOrUserVariableAsInteger(nameof(v_FrameParameter), engine); + // seleniumInstance.SwitchTo().Frame(frameIndex); + // break; + + // case "name or id": + // var frameName = v_FrameParameter.ExpandValueOrUserVariable(engine); + // seleniumInstance.SwitchTo().Frame(frameName); + // break; + + // case "parent frame": + // seleniumInstance.SwitchTo().ParentFrame(); + // break; + + // case "default content": + // seleniumInstance.SwitchTo().DefaultContent(); + // break; + + // case "alert": + // seleniumInstance.SwitchTo().Alert(); + // break; + //} - var selectionType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SelectionType), engine); - switch (selectionType) + this.WebDriverAction(new Action(seleniumInstance => { - case "index": - if (string.IsNullOrEmpty(v_FrameParameter)) - { - v_FrameParameter = "0"; - } - var frameIndex = this.ExpandValueOrUserVariableAsInteger(nameof(v_FrameParameter), engine); - seleniumInstance.SwitchTo().Frame(frameIndex); - break; + var selectionType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SelectionType), engine); + switch (selectionType) + { + case "index": + if (string.IsNullOrEmpty(v_FrameParameter)) + { + v_FrameParameter = "0"; + } + var frameIndex = this.ExpandValueOrUserVariableAsInteger(nameof(v_FrameParameter), engine); + seleniumInstance.SwitchTo().Frame(frameIndex); + break; - case "name or id": - var frameName = v_FrameParameter.ExpandValueOrUserVariable(engine); - seleniumInstance.SwitchTo().Frame(frameName); - break; + case "name or id": + var frameName = v_FrameParameter.ExpandValueOrUserVariable(engine); + seleniumInstance.SwitchTo().Frame(frameName); + break; - case "parent frame": - seleniumInstance.SwitchTo().ParentFrame(); - break; + case "parent frame": + seleniumInstance.SwitchTo().ParentFrame(); + break; - case "default content": - seleniumInstance.SwitchTo().DefaultContent(); - break; + case "default content": + seleniumInstance.SwitchTo().DefaultContent(); + break; - case "alert": - seleniumInstance.SwitchTo().Alert(); - break; - } + case "alert": + seleniumInstance.SwitchTo().Alert(); + break; + } + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSwitchWebBrowserWindowAndTabCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSwitchWebBrowserWindowAndTabCommand.cs new file mode 100644 index 000000000..17e08a8ea --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserSwitchWebBrowserWindowAndTabCommand.cs @@ -0,0 +1,274 @@ +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using OpenQA.Selenium; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Web Browser Actions")] + [Attributes.ClassAttributes.CommandSettings("Switch Web Browser Window And Tab")] + [Attributes.ClassAttributes.Description("This command allows you to create a new Selenium web browser session which enables automation for websites.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to create a browser that will eventually perform web automation such as checking an internal company intranet site to retrieve data")] + [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserSwitchWebBrowserWindowAndTabCommand : ASeleniumWebDriverActionCommands, ITextCheckProperties, ISelectionMethodProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Type of Match to Make")] + [PropertyUISelectionOption("URL")] + [PropertyUISelectionOption("Page Title")] + [PropertyUISelectionOption("Handle")] + [PropertyFirstValue("URL")] + [PropertyValidationRule("Target", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Target")] + [PropertyParameterOrder(6000)] + public string v_CheckTarget { get; set; } + + [XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("Match Specification")] + //[PropertyUISelectionOption("Exact Match")] + //[PropertyUISelectionOption("Contains")] + //[PropertyIsOptional(true, "Exact Match")] + //[PropertyDisplayText(false, "")] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CheckMethod))] + [PropertyParameterOrder(7000)] + public string v_CheckMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Text to Check")] + [PropertyDetailSampleUsage("**http://www.mysite.com**", PropertyDetailSampleUsage.ValueType.Value, "Parameter")] + [PropertyDetailSampleUsage("**Welcome to Homepage**", PropertyDetailSampleUsage.ValueType.Value, "Parameter")] + [PropertyDetailSampleUsage("**{{{vTitle}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Parameter")] + [PropertyDetailSampleUsage("**{{{vURL}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Parameter", false)] + [InputSpecification("Parameter to Match", true)] + [Remarks("")] + [PropertyValidationRule("Parameter", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Parameter")] + [PropertyParameterOrder(8000)] + public string v_CheckText { get; set; } + + [XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("Search is Case-Sensitive")] + //[PropertyUISelectionOption("Yes")] + //[PropertyUISelectionOption("No")] + //[PropertyIsOptional(true, "No")] + //[PropertyDisplayText(false, "")] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveNo))] + [PropertyParameterOrder(8000)] + public string v_CaseSensitive { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_TrimBeforeCheck))] + [PropertyParameterOrder(8100)] + public string v_TrimBeforeCheck { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Selection Method for Window or Tab")] + [PropertyUISelectionOption("First")] + [PropertyUISelectionOption("Last")] + [PropertyUISelectionOption("Index")] + [PropertyDetailSampleUsage("**First**", "Specify the First Window or Tab")] + [PropertyDetailSampleUsage("**Last**", "Specify the Last Window or Tab")] + [PropertyDetailSampleUsage("**Index**", "the Window specifed by Index. **0** means First Window or Tab")] + [PropertyIsOptional(true, "First")] + [PropertyValidationRule("Selection Method", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "Select")] + [PropertyParameterOrder(8200)] + public string v_SelectionMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Window or Tab Index")] + [PropertyDetailSampleUsage("**0**", "Specify the First")] + [PropertyDetailSampleUsage("**-1**", PropertyDetailSampleUsage.ValueType.Value, "Specify the Last")] + [PropertyDetailSampleUsage("**{{{vIndex}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Window or Tab Index")] + [PropertyIsOptional(true, "0")] + [PropertyValidationRule("Index", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Index")] + [PropertyParameterOrder(8300)] + public string v_SelectionIndex { get; set; } + + + public SeleniumBrowserSwitchWebBrowserWindowAndTabCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WebDriverAction(new Action(seleniumInstance => + { + //var matchType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_CheckTarget), engine); + + //var exactMatchRequired = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_CheckMethod), engine); + //var caseSensitive = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_CaseSensitive), engine); + + //var matchFunc = GetMatchFunc(matchType, exactMatchRequired, caseSensitive); + + //var matchParam = v_CheckText.ExpandValueOrUserVariable(engine); + //var handles = seleniumInstance.WindowHandles; + //var currentHandle = seleniumInstance.CurrentWindowHandle; + //var matchFound = false; + //foreach (var hndl in handles) + //{ + // var tempHandle = seleniumInstance.SwitchTo().Window(hndl); + + // // array ordering is not guaranteed so skip if current window + // if (tempHandle.CurrentWindowHandle == currentHandle) + // { + // continue; + // } + + // matchFound = matchFunc(tempHandle, matchParam); + // if (matchFound) + // { + // break; + // } + //} + + //if (!matchFound) + //{ + // throw new Exception("Unable to find the specified window!"); + //} + + var conditionText = this.ExpandValueOrUserVariable(nameof(v_CheckText), "Check Text", engine); + + // text check method + var checkFunc = this.GetTextCheckFunction(engine); + + Func valueFunc = null; + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_CheckTarget), engine)) + { + case "url": + valueFunc = new Func(() => seleniumInstance.Url); + break; + case "page title": + valueFunc = new Func(() => seleniumInstance.Title); + break; + case "handle": + valueFunc = new Func(() => seleniumInstance.CurrentWindowHandle); + break; + } + + var whnds = new List(seleniumInstance.WindowHandles); + //var currentHandle = seleniumInstance.CurrentWindowHandle; + var handles = new List(); + foreach (var h in whnds) + { + seleniumInstance.SwitchTo().Window(h); + if (checkFunc(valueFunc(), conditionText)) + { + handles.Add(h); + } + } + + if (handles.Count == 0) + { + throw new Exception($"Window or Tab does not Found. Name: '{v_CheckText}', Expand Value: '{conditionText}'"); + } + + var targetHandle = string.Empty; + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SelectionMethod), engine)) + { + case "first": + targetHandle = handles[0]; + break; + case "last": + targetHandle = handles[handles.Count - 1]; + break; + case "index": + var index = this.ExpandValueOrUserVariableAsInteger(nameof(v_SelectionIndex), engine); + if (index < 0) + { + index += handles.Count; + } + + if (index >= 0 && index < handles.Count) + { + targetHandle = handles[index]; + } + else + { + throw new Exception($"Index is out of Range. Index: '{v_SelectionIndex}', Expand Value: '{index}'"); + } + break; + } + seleniumInstance.SwitchTo().Window(targetHandle); + }), engine); + } + + //private static Func GetMatchFunc(string targetType, string searchType, string caseSensitive) + //{ + // Func caseFunc; + // if (caseSensitive == "yes") + // { + // caseFunc = new Func((str) => + // { + // return str; + // }); + // } + // else + // { + // caseFunc = new Func((str) => + // { + // return str.ToLower(); + // }); + // } + + // Func compFunc = null; + // switch (searchType) + // { + // case "exact match": + // compFunc = new Func( (a, b) => { + // return (caseFunc(a) == caseFunc(b)); + // }); + // break; + // case "contains": + // compFunc = new Func((a, b) => + // { + // return caseFunc(a).Contains(caseFunc(b)); + // }); + // break; + // } + + // Func retFunc = null; + // switch(targetType) + // { + // case "url": + // retFunc = new Func((iw, str) => + // { + // return compFunc(iw.Url, str); + // }); + // break; + // case "page title": + // retFunc = new Func((iw, str) => + // { + // return compFunc(iw.Title, str); + // }); + // break; + // case "handle": + // retFunc = new Func((iw, str) => + // { + // return compFunc(iw.CurrentWindowHandle, str); + // }); + // break; + // } + // return retFunc; + //} + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserTakeScreenshotCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserTakeScreenshotOfWebBrowserCommand.cs similarity index 64% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserTakeScreenshotCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserTakeScreenshotOfWebBrowserCommand.cs index f37edd0f9..506b9e713 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserTakeScreenshotCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserTakeScreenshotOfWebBrowserCommand.cs @@ -1,25 +1,27 @@ using OpenQA.Selenium; using System; +using System.IO; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; namespace taskt.Core.Automation.Commands { [Serializable] [Attributes.ClassAttributes.Group("Web Browser")] [Attributes.ClassAttributes.SubGruop("Web Browser Actions")] - [Attributes.ClassAttributes.CommandSettings("Take Screenshot")] + [Attributes.ClassAttributes.CommandSettings("Take Screenshot Of Web Browser")] [Attributes.ClassAttributes.Description("This command allows you to take a screenshot in Selenium web browser session.")] [Attributes.ClassAttributes.UsesDescription("Use this command when you want to take a screenshot from the current displayed webpage within the web browser.")] [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SeleniumBrowserTakeScreenshotCommand : ScriptCommand + public sealed class SeleniumBrowserTakeScreenshotOfWebBrowserCommand : ASeleniumWebDriverActionCommands { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] @@ -32,6 +34,7 @@ public sealed class SeleniumBrowserTakeScreenshotCommand : ScriptCommand [PropertyUIHelper(PropertyUIHelper.UIAdditionalHelperType.ShowFolderSelectionHelper)] [PropertyValidationRule("Folder", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "Folder")] + [PropertyParameterOrder(6000)] public string v_SeleniumScreenshotPathParameter { get; set; } [XmlAttribute] @@ -46,9 +49,10 @@ public sealed class SeleniumBrowserTakeScreenshotCommand : ScriptCommand [PropertyFirstValue("screenshot_001")] [PropertyValidationRule("File Name", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "File Name")] + [PropertyParameterOrder(7000)] public string v_SeleniumScreenshotFileNameParameter { get; set; } - public SeleniumBrowserTakeScreenshotCommand() + public SeleniumBrowserTakeScreenshotOfWebBrowserCommand() { //this.CommandName = "SeleniumBrowserTakeScreenshotCommand"; //this.SelectionName = "Take Screenshot"; @@ -61,16 +65,29 @@ public SeleniumBrowserTakeScreenshotCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + //var seleniumInstance = v_InstanceName.ExpandValueOrUserVariableAsSeleniumBrowserInstance(engine); + + //var screenshotPath = v_SeleniumScreenshotPathParameter.ExpandValueOrUserVariable(engine); + //var screenshotFileName = v_SeleniumScreenshotFileNameParameter.ExpandValueOrUserVariable(engine); + + //// take the screenshot + //Screenshot image = ((ITakesScreenshot)seleniumInstance).GetScreenshot(); + //// save the screenshot to the entered folder by provided name for the screenshot file name + ////image.SaveAsFile(screenshotPath + "/" + screenshotFileName + ".png", ScreenshotImageFormat.Png); + //image.SaveAsFile(screenshotPath + "/" + screenshotFileName + ".png"); + + this.WebDriverAction(new Action(seleniumInstance => + { + var screenshotPath = v_SeleniumScreenshotPathParameter.ExpandValueOrUserVariable(engine); + var screenshotFileName = v_SeleniumScreenshotFileNameParameter.ExpandValueOrUserVariable(engine); - var screenshotPath = v_SeleniumScreenshotPathParameter.ExpandValueOrUserVariable(engine); - var screenshotFileName = v_SeleniumScreenshotFileNameParameter.ExpandValueOrUserVariable(engine); + var saveFilePath = Path.Combine(screenshotPath, $"{screenshotFileName}.png"); - // take the screenshot - Screenshot image = ((ITakesScreenshot)seleniumInstance).GetScreenshot(); - // save the screenshot to the entered folder by provided name for the screenshot file name - //image.SaveAsFile(screenshotPath + "/" + screenshotFileName + ".png", ScreenshotImageFormat.Png); - image.SaveAsFile(screenshotPath + "/" + screenshotFileName + ".png"); + // take the screenshot + var image = ((ITakesScreenshot)seleniumInstance).GetScreenshot(); + // save the screenshot to the entered folder by provided name for the screenshot file name + image.SaveAsFile(saveFilePath); + }), engine); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserWaitForWebElementToExistsCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserWaitForWebElementToExistsCommand.cs new file mode 100644 index 000000000..baade23c1 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserWaitForWebElementToExistsCommand.cs @@ -0,0 +1,58 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Web Browser")] + [Attributes.ClassAttributes.SubGruop("Search WebElement")] + [Attributes.ClassAttributes.CommandSettings("Wait For WebElement To Exists")] + [Attributes.ClassAttributes.Description("This command allows you to Wait for WebElement exists.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Wait for WebElement exists.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SeleniumBrowserWaitForWebElementToExistsCommand : ASeleniumDoSomethingToWebDriverCommands, ISeleniumSearchWebElementParametersProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_InputInstanceName))] + public override string v_InstanceName { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchMethod))] + [PropertyParameterOrder(6000)] + public string v_SearchMethod { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchParameter))] + [PropertyParameterOrder(6100)] + public string v_SearchParameter { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WebElementIndex))] + [PropertyParameterOrder(6200)] + public string v_WebElementIndex { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WaitTimeForWebElement))] + [PropertyParameterOrder(10000)] + public string v_WaitTimeForWebElement { get; set; } + + public SeleniumBrowserWaitForWebElementToExistsCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //SeleniumBrowserControls.ExpandValueOrUserVariableAsSeleniumBrowserInstanceAndWebElement(this, nameof(v_InstanceName), nameof(v_SearchMethod), nameof(v_SearchParameter), nameof(v_WebElementIndex), nameof(v_WaitTimeForWebElement), engine); + + this.WebDriverActionCore(new Action(seleniumInstance => + { + this.SearchWebElement(seleniumInstance, engine); + }), engine); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserWebElementActionCommand.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserWebElementActionCommand.cs similarity index 65% rename from taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserWebElementActionCommand.cs rename to taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserWebElementActionCommand.cs index fec1fbafd..6a68b0018 100644 --- a/taskt/Core/Automation/Commands/WebBrowser/SeleniumBrowserWebElementActionCommand.cs +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/SeleniumBrowserWebElementActionCommand.cs @@ -3,6 +3,7 @@ using System.Windows.Forms; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.WebBrowserGroup; using taskt.Core.Script; namespace taskt.Core.Automation.Commands @@ -16,24 +17,27 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.ImplementationDescription("This command implements Selenium to achieve automation.")] [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_web))] [Attributes.ClassAttributes.EnableAutomateRender(true)] - public sealed class SeleniumBrowserWebElementActionCommand : ScriptCommand, IHaveDataTableElements + public sealed class SeleniumBrowserWebElementActionCommand : ASeleniumWebDriverActionCommands, ISeleniumSearchWebElementParametersProperties, IHaveDataTableElements { - [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_InputInstanceName))] - public string v_InstanceName { get; set; } + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_InputInstanceName))] + //public string v_InstanceName { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchMethod))] + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchMethod))] [PropertySelectionChangeEvent(nameof(cmbSearchType_SelectionChangeCommited))] - public string v_SeleniumSearchType { get; set; } + [PropertyParameterOrder(6000)] + public string v_SearchMethod { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_SearchParameter))] - public string v_SeleniumSearchParameter { get; set; } + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_SearchParameter))] + [PropertyParameterOrder(6100)] + public string v_SearchParameter { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ElementIndex))] - public string v_SeleniumElementIndex { get; set; } + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WebElementIndex))] + [PropertyParameterOrder(6200)] + public string v_WebElementIndex { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] @@ -53,7 +57,8 @@ public sealed class SeleniumBrowserWebElementActionCommand : ScriptCommand, IHav [PropertyUISelectionOption("Select Option")] [PropertySelectionChangeEvent(nameof(cmbSeleniumAction_SelectionChangeCommitted))] [PropertyValidationRule("WebElement Action", PropertyValidationRule.ValidationRuleFlags.Empty)] - public string v_SeleniumElementAction { get; set; } + [PropertyParameterOrder(7000)] + public string v_WebElementAction { get; set; } [XmlElement] [PropertyDescription("Additional Parameters")] @@ -67,15 +72,18 @@ public sealed class SeleniumBrowserWebElementActionCommand : ScriptCommand, IHav [PropertyDataGridViewColumnSettings("Parameter Value", "Parameter Value", false)] [PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.FirstColumnReadonlySubsequentEditableDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] [PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.FirstColumnReadonlySubsequentEditableDataGridView_CellBeginEdit), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellBeginEdit)] + [PropertyParameterOrder(8000)] public DataTable v_WebActionParameterTable { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_WaitTime))] - public string v_WaitTime { get; set; } + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_WaitTimeForWebElement))] + [PropertyParameterOrder(10000)] + public string v_WaitTimeForWebElement { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(SeleniumBrowserControls), nameof(SeleniumBrowserControls.v_ScrollToElement))] - public string v_ScrollToElement { get; set; } + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_ScrollToWebElement))] + [PropertyParameterOrder(11000)] + public string v_ScrollToWebElement { get; set; } public SeleniumBrowserWebElementActionCommand() { @@ -83,7 +91,7 @@ public SeleniumBrowserWebElementActionCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - var actionType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_SeleniumElementAction), engine); + var actionType = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WebElementAction), engine); var parameters = DataTableControls.GetFieldValues(v_WebActionParameterTable, "Parameter Name", "Parameter Value", false, engine); switch (actionType) { @@ -91,20 +99,20 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) var waitCommand = new SeleniumBrowserWaitForWebElementToExistsCommand() { v_InstanceName = this.v_InstanceName, - v_SeleniumSearchType = this.v_SeleniumSearchType, - v_SeleniumSearchParameter = this.v_SeleniumSearchParameter, - v_ElementIndex = this.v_SeleniumElementIndex, - v_WaitTime = this.v_WaitTime, + v_SearchMethod = this.v_SearchMethod, + v_SearchParameter = this.v_SearchParameter, + v_WebElementIndex = this.v_WebElementIndex, + v_WaitTimeForWebElement = this.v_WaitTimeForWebElement, }; waitCommand.RunCommand(engine); break; case "get matching webelements": - var getMatching = new SeleniumBrowserGetMatchedWebElementsCommand() + var getMatching = new SeleniumBrowserGetMatchedWebElementsHTMLAsListCommand() { v_InstanceName = this.v_InstanceName, - v_SeleniumSearchType = this.v_SeleniumSearchType, - v_SeleniumSearchParameter = this.v_SeleniumSearchParameter, - v_WaitTime = this.v_WaitTime, + v_SearchMethod = this.v_SearchMethod, + v_SearchParameter = this.v_SearchParameter, + v_WaitTimeForWebElement = this.v_WaitTimeForWebElement, v_Result = parameters["Variable Name"], }; getMatching.RunCommand(engine); @@ -113,129 +121,24 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) var getCount = new SeleniumBrowserGetWebElementsCountCommand() { v_InstanceName = this.v_InstanceName, - v_SeleniumSearchType = this.v_SeleniumSearchType, - v_SeleniumSearchParameter = this.v_SeleniumSearchParameter, - v_WaitTime = this.v_WaitTime, + v_SearchMethod = this.v_SearchMethod, + v_SearchParameter = this.v_SearchParameter, + v_WaitTimeForWebElement = this.v_WaitTimeForWebElement, v_Result = parameters["Variable Name"], }; getCount.RunCommand(engine); break; default: - //var elemVariable = VariableNameControls.GetInnerVariableName(0, engine); - //var searchElement = new SeleniumBrowserSearchWebElementCommand() - //{ - // v_InstanceName = this.v_InstanceName, - // v_SeleniumSearchType = this.v_SeleniumSearchType, - // v_SeleniumSearchParameter = this.v_SeleniumSearchParameter, - // v_ElementIndex = this.v_SeleniumElementIndex, - // v_Result = elemVariable, - // v_WaitTime = this.v_WaitTime, - //}; - //searchElement.RunCommand(engine); - - //switch (actionType) - //{ - // case "click webelement": - // var clickElement = new SeleniumBrowserClickWebElementCommand() - // { - // v_WebElement = elemVariable, - // v_ClickType = parameters["Click Type"], - // v_XOffset = parameters["X Offset"], - // v_YOffset = parameters["Y Offset"], - // v_ScrollToElement = this.v_ScrollToElement, - // }; - // clickElement.RunCommand(engine); - // break; - // case "clear text": - // var clearElement = new SeleniumBrowserClearTextInWebElementCommand() - // { - // v_WebElement = elemVariable, - // }; - // clearElement.RunCommand(engine); - // break; - // case "set text": - // var setText = new SeleniumBrowserSetTextToWebElementCommand() - // { - // v_WebElement = elemVariable, - // v_TextToSet = parameters["Text To Set"], - // v_ClearTextBeforeSetting = parameters["Clear Element Before Setting Text"], - // v_EncryptedText = parameters["Encrypted Text"], - // }; - // setText.RunCommand(engine); - // break; - // case "get text": - // var getText = new SeleniumBrowserGetTextFromWebElementCommand() - // { - // v_WebElement = elemVariable, - // v_Result = parameters["Variable Name"], - // }; - // getText.RunCommand(engine); - // break; - // case "get attribute": - // var getAttribute = new SeleniumBrowserGetAttributeFromWebElementCommand() - // { - // v_WebElement = elemVariable, - // v_AttributeName = parameters["Attribute Name"], - // v_Result = parameters["Variable Name"], - // }; - // getAttribute.RunCommand(engine); - // break; - // case "switch to frame": - // var switchToFrame = new SeleniumBrowserSwitchFrameToWebElementCommand() - // { - // v_InstanceName = this.v_InstanceName, - // v_WebElement = elemVariable, - // }; - // switchToFrame.RunCommand(engine); - // break; - // case "get options": - // var getOptions = new SeleniumBrowserGetOptionsFromWebElementCommand() - // { - // v_WebElement = elemVariable, - // v_AttributeName = parameters["Attribute Name"], - // v_Result = parameters["Variable Name"], - // }; - // getOptions.RunCommand(engine); - // break; - // case "get webelement position": - // var getPos = new SeleniumWebElementPositionCommand() - // { - // v_WebElement = elemVariable, - // v_XPosition = parameters["X Variable"], - // v_YPosition = parameters["Y Variable"], - // v_PositionBase = parameters["Base Position"], - // }; - // getPos.RunCommand(engine); - // break; - // case "get webelement size": - // var getSize = new SeleniumWebElementSizeCommand() - // { - // v_WebElement = elemVariable, - // v_Width = parameters["Width Variable"], - // v_Height = parameters["Height Variable"], - // }; - // getSize.RunCommand(engine); - // break; - // case "select option": - // var selectOption = new SeleniumBrowserSelectOptionForWebElementCommand() - // { - // v_WebElement = elemVariable, - // v_SelectionType = parameters["Selection Type"], - // v_SelectionValue = parameters["Selection Parameter"], - // }; - // selectOption.RunCommand(engine); - // break; - //} using (var myWebElem = new InnerScriptVariable(engine)) { var searchElement = new SeleniumBrowserSearchWebElementCommand() { v_InstanceName = this.v_InstanceName, - v_SeleniumSearchType = this.v_SeleniumSearchType, - v_SeleniumSearchParameter = this.v_SeleniumSearchParameter, - v_ElementIndex = this.v_SeleniumElementIndex, + v_SearchMethod = this.v_SearchMethod, + v_SearchParameter = this.v_SearchParameter, + v_WebElementIndex = this.v_WebElementIndex, v_Result = myWebElem.VariableName, - v_WaitTime = this.v_WaitTime, + v_WaitTimeForWebElement = this.v_WaitTimeForWebElement, }; searchElement.RunCommand(engine); @@ -248,7 +151,7 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) v_ClickType = parameters["Click Type"], v_XOffset = parameters["X Offset"], v_YOffset = parameters["Y Offset"], - v_ScrollToElement = this.v_ScrollToElement, + v_ScrollToWebElement = this.v_ScrollToWebElement, }; clickElement.RunCommand(engine); break; @@ -287,9 +190,9 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) getAttribute.RunCommand(engine); break; case "switch to frame": - var switchToFrame = new SeleniumBrowserSwitchFrameToWebElementCommand() + var switchToFrame = new SeleniumBrowserSwitchToFrameWebElementCommand() { - v_InstanceName = this.v_InstanceName, + //v_InstanceName = this.v_InstanceName, v_WebElement = myWebElem.VariableName, }; switchToFrame.RunCommand(engine); @@ -304,7 +207,7 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) getOptions.RunCommand(engine); break; case "get webelement position": - var getPos = new SeleniumWebElementPositionCommand() + var getPos = new SeleniumBrowserGetWebElementPositionCommand() { v_WebElement = myWebElem.VariableName, v_XPosition = parameters["X Variable"], @@ -314,7 +217,7 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) getPos.RunCommand(engine); break; case "get webelement size": - var getSize = new SeleniumWebElementSizeCommand() + var getSize = new SeleniumBrowserGetWebElementSizeCommand() { v_WebElement = myWebElem.VariableName, v_Width = parameters["Width Variable"], @@ -339,7 +242,7 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) { - var cmb = FormUIControls.GetPropertyControl(ControlsList, nameof(v_SeleniumElementAction)); + var cmb = FormUIControls.GetPropertyControl(ControlsList, nameof(v_WebElementAction)); var dgv = FormUIControls.GetPropertyControl(ControlsList, nameof(v_WebActionParameterTable)); actionParameterProcess(dgv, cmb.SelectedItem?.ToString() ?? ""); } @@ -347,7 +250,7 @@ public override void AfterShown(UI.Forms.ScriptBuilder.CommandEditor.frmCommandE private void cmbSearchType_SelectionChangeCommited(object sender, EventArgs e) { var searchType = ((ComboBox)sender).SelectedItem?.ToString().ToLower() ?? ""; - FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_SeleniumElementIndex), !searchType.StartsWith("find element ")); + FormUIControls.SetVisibleParameterControlGroup(ControlsList, nameof(v_WebElementIndex), !searchType.StartsWith("find element ")); } private void cmbSeleniumAction_SelectionChangeCommitted(object sender, EventArgs e) @@ -477,7 +380,7 @@ private static void actionParameterProcess(DataGridView dgv, string actionType) public override string GetDisplayValue() { - return base.GetDisplayValue() + " [" + v_SeleniumSearchType + " and " + v_SeleniumElementAction + ", Instance Name: '" + v_InstanceName + "']"; + return base.GetDisplayValue() + " [" + v_SearchMethod + " and " + v_WebElementAction + ", Instance Name: '" + v_InstanceName + "']"; } public override void BeforeValidate() diff --git a/taskt/Core/Automation/Commands/WebBrowserGroup/VP_WebBrowserControls.cs b/taskt/Core/Automation/Commands/WebBrowserGroup/VP_WebBrowserControls.cs new file mode 100644 index 000000000..ee61770d1 --- /dev/null +++ b/taskt/Core/Automation/Commands/WebBrowserGroup/VP_WebBrowserControls.cs @@ -0,0 +1,170 @@ +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands.WebBrowserGroup +{ + public static class VP_WebBrowserControls + { + /// + /// WebBrowser instance name + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_InputInstanceName))] + [PropertyDescription("WebBrowser Instance Name")] + [InputSpecification("WebBrowser Instance Name", true)] + [PropertyDetailSampleUsage("**RPABrowser**", PropertyDetailSampleUsage.ValueType.Value, "WebBrowser Instance")] + [PropertyDetailSampleUsage("**{{{vInstance}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebBrowser Instance")] + [Remarks("Failure to enter the correct instance name or failure to first call **Create Broser** command will cause an error")] + [PropertyInstanceType(PropertyInstanceType.InstanceType.WebBrowser)] + [PropertyValidationRule("WebBrowser Instance", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Instance")] + [PropertyFirstValue("%kwd_default_browser_instance%")] + public static string v_InputInstanceName { get; } + + /// + /// WebBrowser Instance name + /// + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_InputInstanceName))] + [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.TextBox)] + [PropertyTextBoxSetting(1, false)] + [PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] + public static string v_OutputInstanceName { get; } + + /// + /// input WebElement variable name + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_InputInstanceName))] + [PropertyDescription("WebElement Variable Name")] + [InputSpecification("WebElement Variable Name", true)] + [PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyInstanceType(PropertyInstanceType.InstanceType.WebElement, true)] + [PropertyValidationRule("WebElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "WebElement")] + public static string v_InputWebElementName { get; } + + /// + /// output WebElement property + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store WebElement")] + [InputSpecification("WebElement Variable Name", true)] + [PropertyDetailSampleUsage("**vElement**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyDetailSampleUsage("**{{{vElement}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [PropertyInstanceType(PropertyInstanceType.InstanceType.WebElement, true)] + [PropertyValidationRule("WebElement", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "WebElement")] + public static string v_OutputWebElementName { get; } + + /// + /// behavior when fail action + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnore))] + [PropertyDescription("When Fail Action")] + [PropertyUISelectionOption("Error")] + [PropertyUISelectionOption("Ignore")] + [PropertyIsOptional(true, "Error")] + [PropertyDisplayText(false, "When Fail Action")] + public static string v_WhenFailAction { get; } + + /// + /// scroll to WebElement before Action + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Scroll to WebElement")] + [PropertyIsOptional(true, "No")] + [PropertyDisplayText(false, "Scroll")] + public static string v_ScrollToWebElement { get; } + + /// + /// WebElements search method property + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("WebElement Search Method")] + [PropertyUISelectionOption("Find Elements By XPath")] + [PropertyUISelectionOption("Find Elements By ID")] + [PropertyUISelectionOption("Find Elements By Name")] + [PropertyUISelectionOption("Find Elements By Tag Name")] + [PropertyUISelectionOption("Find Elements By Class Name")] + [PropertyUISelectionOption("Find Elements By CSS Selector")] + [PropertyUISelectionOption("Find Elements By Link Text")] + [PropertyUISelectionOption("Find Element By XPath")] + [PropertyUISelectionOption("Find Element By ID")] + [PropertyUISelectionOption("Find Element By Name")] + [PropertyUISelectionOption("Find Element By Tag Name")] + [PropertyUISelectionOption("Find Element By Class Name")] + [PropertyUISelectionOption("Find Element By CSS Selector")] + [PropertyUISelectionOption("Find Element By Link Text")] + [Remarks("Select the specific search type that you want to use to isolate the WebElement in the web page.")] + [PropertyValidationRule("Search Method", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Search Method")] + public static string v_SearchMethod { get; } + + /// + /// WebElements search parameter property + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("WebElement Search Parameter")] + [InputSpecification("WebElement Search Parameter", true)] + [PropertyValidationRule("Search Parameter", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Search Parameter")] + [Remarks("Specifies the parameter text that matches to the element based on the previously selected search type.")] + public static string v_SearchParameter { get; } + + /// + /// WebElement index + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("WebElement Index")] + [InputSpecification("Number", true)] + [PropertyDetailSampleUsage("**0**", "Specify the First WebElement Index")] + [PropertyDetailSampleUsage("**1**", PropertyDetailSampleUsage.ValueType.Value, "WebElement Index")] + [PropertyDetailSampleUsage("**{{{vIndex}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "WebElement Index")] + [PropertyDisplayText(true, "WebElement Index")] + public static string v_WebElementIndex { get; } + + /// + /// WebElement wait time + /// + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time for the WebElement to Exist (sec)")] + [Remarks("Specify how long to Wait before an Error will occur because the WebElement is Not Found.")] + [PropertyIsOptional(true, "120")] + [PropertyFirstValue("120")] + [PropertyDisplayText(false, "Wait Time")] + public static string v_WaitTimeForWebElement { get; } + + /// + /// when Value(s) can not retrieved + /// + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnoreSetEmpty))] + [PropertyDescription("When the Value(s) can not Retrieved")] + [PropertyIsOptional(true, "Error")] + [PropertyValidationRule("When Value can not Retrieved", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "When can not Retrieved")] + public static string v_WhenValueCanNotRetrieved { get; } + + /// + /// attribute name + /// + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] + [PropertyDescription("Attribute Name")] + [PropertyDetailSampleUsage("**textContent**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] + [PropertyDetailSampleUsage("**value**", PropertyDetailSampleUsage.ValueType.Value, "Attribute")] + [PropertyDetailSampleUsage("**{{{vAttribute}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Attribute")] + [PropertyDetailSampleUsage("**@tag**", "Get Tab name from WebElement. Use Get Special Value From WebElement command.")] + [PropertyValidationRule("Attribute", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "Attribute")] + public static string v_AttributeName { get; } + + /// + /// Attribute Names + /// + [PropertyVirtualProperty(nameof(VP_WebBrowserControls), nameof(VP_WebBrowserControls.v_AttributeName))] + [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.DataGridView)] + [PropertyDescription("Attribute Names")] + [InputSpecification("Attribute Names", true)] + [PropertyDataGridViewSetting(true, true, true)] + [PropertyDataGridViewColumnSettings("AttributeName", "Attribute Name")] + [PropertyDataGridViewCellEditEvent(nameof(DataTableControls) + "+" + nameof(DataTableControls.AllEditableDataGridView_CellClick), PropertyDataGridViewCellEditEvent.DataGridViewCellEvent.CellClick)] + public static string v_AttributeNames { get; } + } +} diff --git a/taskt/Core/Automation/Commands/Window/ActivateWindowCommand.cs b/taskt/Core/Automation/Commands/Window/ActivateWindowCommand.cs deleted file mode 100644 index 74f1ae719..000000000 --- a/taskt/Core/Automation/Commands/Window/ActivateWindowCommand.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Actions")] - [Attributes.ClassAttributes.CommandSettings("Activate Window")] - [Attributes.ClassAttributes.Description("This command activates a window and brings it to the front.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to active a window by name or bring it to attention.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ActivateWindowCommand : AWindowNameCommands - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] - //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - //public string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] - //public string v_NameResult { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] - //public string v_HandleResult { get; set; } - - public ActivateWindowCommand() - { - //this.CommandName = "ActivateWindowCommand"; - //this.SelectionName = "Activate Window"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - foreach (var win in wins) - { - WindowControls.ActivateWindow(win.Item1); - } - }) - ); - } - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // //ComboBox cmb = (ComboBox)ControlsList[nameof(v_WindowName)]; - // //cmb.AddWindowNames(); - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/CloseWindowCommand.cs b/taskt/Core/Automation/Commands/Window/CloseWindowCommand.cs deleted file mode 100644 index 027851bab..000000000 --- a/taskt/Core/Automation/Commands/Window/CloseWindowCommand.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Actions")] - [Attributes.ClassAttributes.CommandSettings("Close Window")] - [Attributes.ClassAttributes.Description("This command closes an open window.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to close an existing window by name.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window_close))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class CloseWindowCommand : AWindowNameCommands - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] - //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - //public string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] - //public string v_NameResult { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] - //public string v_HandleResult { get; set; } - - public CloseWindowCommand() - { - //this.CommandName = "CloseWindowCommand"; - //this.SelectionName = "Close Window"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - foreach (var win in wins) - { - WindowControls.CloseWindow(win.Item1); - } - }) - ); - } - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/GetProcessNameFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/Window/GetProcessNameFromWindowHandleCommand.cs deleted file mode 100644 index 3fec13905..000000000 --- a/taskt/Core/Automation/Commands/Window/GetProcessNameFromWindowHandleCommand.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Diagnostics; -using System.Linq; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Get From Window Handle")] - [Attributes.ClassAttributes.CommandSettings("Get Process Name From Window Handle")] - [Attributes.ClassAttributes.Description("This command returns process name.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get process name.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetProcessNameFromWindowHandleCommand : AWindowHandleCommands - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] - //public string v_WindowHandle { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Store Process Name")] - [PropertyParameterOrder(5500)] - public string v_Result { get; set; } - - [XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - [PropertyIsOptional(true, "0")] - [PropertyFirstValue("0")] - public override string v_WaitTimeForWindow { get; set; } - - public GetProcessNameFromWindowHandleCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => - { - var proc = Process.GetProcesses().Where(p => (p.MainWindowHandle == whnd)).First(); - proc.ProcessName.StoreInUserVariable(engine, v_Result); - }) - ); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/GetProcessNameFromWindowName.cs b/taskt/Core/Automation/Commands/Window/GetProcessNameFromWindowName.cs deleted file mode 100644 index 992d34edd..000000000 --- a/taskt/Core/Automation/Commands/Window/GetProcessNameFromWindowName.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Diagnostics; -using System.Xml.Serialization; -using System.Collections.Generic; -using taskt.Core.Automation.Attributes.PropertyAttributes; -using System.Linq; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Actions")] - [Attributes.ClassAttributes.CommandSettings("Get Process Name From Window Name")] - [Attributes.ClassAttributes.Description("This command allows you to Get Process Name from Window Name.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Process Name from Window Name.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetProcessNameFromWindowNameCommand : AWindowNameCommands - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyParameterOrder(6500)] - public string v_Result { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod_Single))] - //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - //public string v_MatchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - public override string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //public string v_NameResult { get; set; } - - //[XmlAttribute] - //public string v_HandleResult { get; set; } - - public GetProcessNameFromWindowNameCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction( this, engine, - new Action>(wins => - { - var proc = Process.GetProcesses().Where(p => (p.MainWindowHandle == wins[0].Item1)).First(); - proc.ProcessName.StoreInUserVariable(engine, v_Result); - }) - ); - } - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/GetWindowHandleFromWindowName.cs b/taskt/Core/Automation/Commands/Window/GetWindowHandleFromWindowName.cs deleted file mode 100644 index f0d393e2d..000000000 --- a/taskt/Core/Automation/Commands/Window/GetWindowHandleFromWindowName.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Collections.Generic; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Actions")] - [Attributes.ClassAttributes.CommandSettings("Get Window Handle From Window Name")] - [Attributes.ClassAttributes.Description("This command allows you to Get Window Handle from Window Name.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Window Handle from Window Name.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetWindowHandleFromWindowNameCommand : AWindowNameCommands - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - [XmlAttribute] - [PropertyIsOptional(false)] - [PropertyValidationRule("Window Handle", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyParameterOrder(6500)] - public override string v_HandleResult { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - public override string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] - //public string v_NameResult { get; set; } - - public GetWindowHandleFromWindowNameCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - wins[0].Item1.StoreInUserVariable(engine, v_HandleResult); - }) - ); - } - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/GetWindowPositionCommand.cs b/taskt/Core/Automation/Commands/Window/GetWindowPositionCommand.cs deleted file mode 100644 index 242782f01..000000000 --- a/taskt/Core/Automation/Commands/Window/GetWindowPositionCommand.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Collections.Generic; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window State")] - [Attributes.ClassAttributes.CommandSettings("Get Window Position")] - [Attributes.ClassAttributes.Description("This command returns window position.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want window position.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetWindowPositionCommand : AWindowNameCommands, IWindowPositionProperties - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Recieve the Window Position X")] - [PropertyIsOptional(true)] - [PropertyDisplayText(false, "")] - [PropertyParameterOrder(6500)] - public string v_XPosition { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Recieve the Window Position Y")] - [PropertyIsOptional(true)] - [PropertyDisplayText(false, "")] - [PropertyParameterOrder(6500)] - public string v_YPosition { get; set; } - - [XmlAttribute] - [PropertyDescription("Base position")] - [InputSpecification("", true)] - [SampleUsage("")] - [Remarks("")] - [PropertyUISelectionOption("Top Left")] - [PropertyUISelectionOption("Bottom Right")] - [PropertyUISelectionOption("Top Right")] - [PropertyUISelectionOption("Bottom Left")] - [PropertyUISelectionOption("Center")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - [PropertyIsOptional(true, "Top Left")] - [PropertyParameterOrder(6500)] - public string v_PositionBase { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - public override string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] - //public string v_NameResult { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] - //public string v_HandleResult { get; set; } - - public GetWindowPositionCommand() - { - //this.CommandName = "GetWindowPositionCommand"; - //this.SelectionName = "Get Window Position"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - var whnd = wins[0].Item1; - - var pos = WindowControls.GetWindowRect(whnd); - - int x = 0, y = 0; - switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) - { - case "top left": - x = pos.left; - y = pos.top; - break; - case "bottom right": - x = pos.right; - y = pos.bottom; - break; - case "top right": - x = pos.right; - y = pos.top; - break; - case "bottom left": - x = pos.left; - y = pos.bottom; - break; - case "center": - x = (pos.right + pos.left) / 2; - y = (pos.top + pos.bottom) / 2; - break; - } - if (!string.IsNullOrEmpty(v_XPosition)) - { - x.ToString().StoreInUserVariable(engine, v_XPosition); - } - if (!string.IsNullOrEmpty(v_YPosition)) - { - y.ToString().StoreInUserVariable(engine, v_YPosition); - } - }) - ); - } - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/GetWindowPositionFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/Window/GetWindowPositionFromWindowHandleCommand.cs deleted file mode 100644 index d0c4abf58..000000000 --- a/taskt/Core/Automation/Commands/Window/GetWindowPositionFromWindowHandleCommand.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Get From Window Handle")] - [Attributes.ClassAttributes.CommandSettings("Get Window Position From Window Handle")] - [Attributes.ClassAttributes.Description("This command returns window position.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want window position.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetWindowPositionFromWindowHandleCommand : AWindowHandleCommands, IWindowPositionProperties - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] - //public string v_WindowHandle { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Recieve the Window Position X")] - [PropertyIsOptional(true)] - [PropertyDisplayText(false, "")] - [PropertyParameterOrder(5001)] - public string v_XPosition { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Recieve the Window Position Y")] - [PropertyIsOptional(true)] - [PropertyDisplayText(false, "")] - [PropertyParameterOrder(5002)] - public string v_YPosition { get; set; } - - [XmlAttribute] - [PropertyDescription("Base position")] - [InputSpecification("", true)] - [SampleUsage("")] - [Remarks("")] - [PropertyUISelectionOption("Top Left")] - [PropertyUISelectionOption("Bottom Right")] - [PropertyUISelectionOption("Top Right")] - [PropertyUISelectionOption("Bottom Left")] - [PropertyUISelectionOption("Center")] - [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - [PropertyIsOptional(true, "Top Left")] - [PropertyParameterOrder(5003)] - public string v_PositionBase { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - public GetWindowPositionFromWindowHandleCommand() - { - } - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => - { - var pos = WindowControls.GetWindowRect(whnd); - - int x = 0, y = 0; - switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) - { - case "top left": - x = pos.left; - y = pos.top; - break; - case "bottom right": - x = pos.right; - y = pos.bottom; - break; - case "top right": - x = pos.right; - y = pos.top; - break; - case "bottom left": - x = pos.left; - y = pos.bottom; - break; - case "center": - x = (pos.right + pos.left) / 2; - y = (pos.top + pos.bottom) / 2; - break; - } - if (!string.IsNullOrEmpty(v_XPosition)) - { - x.ToString().StoreInUserVariable(engine, v_XPosition); - } - if (!string.IsNullOrEmpty(v_YPosition)) - { - y.ToString().StoreInUserVariable(engine, v_YPosition); - } - }) - ); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/GetWindowSizeCommand.cs b/taskt/Core/Automation/Commands/Window/GetWindowSizeCommand.cs deleted file mode 100644 index ab96c779c..000000000 --- a/taskt/Core/Automation/Commands/Window/GetWindowSizeCommand.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Collections.Generic; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window State")] - [Attributes.ClassAttributes.CommandSettings("Get Window Size")] - [Attributes.ClassAttributes.Description("This command returns window size.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want window size.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetWindowSizeCommand : AWindowNameCommands, IWindowSizeProperties - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Recieve the Window Width")] - [PropertyIsOptional(true)] - [PropertyDisplayText(false, "")] - [PropertyParameterOrder(6500)] - public string v_Width { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Recieve the Window Height")] - [PropertyIsOptional(true)] - [PropertyDisplayText(false, "")] - [PropertyParameterOrder(6500)] - public string v_Height { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - public override string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] - //public string v_NameResult { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] - //public string v_HandleResult { get; set; } - - public GetWindowSizeCommand() - { - } - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - var whnd = wins[0].Item1; - - var rct = WindowControls.GetWindowRect(whnd); - - if (!string.IsNullOrEmpty(v_Width)) - { - (rct.right - rct.left).StoreInUserVariable(engine, v_Width); - } - if (!string.IsNullOrEmpty(v_Height)) - { - (rct.bottom - rct.top).StoreInUserVariable(engine, v_Height); - } - }) - ); - } - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/GetWindowStateCommand.cs b/taskt/Core/Automation/Commands/Window/GetWindowStateCommand.cs deleted file mode 100644 index 3fff75113..000000000 --- a/taskt/Core/Automation/Commands/Window/GetWindowStateCommand.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Collections.Generic; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window State")] - [Attributes.ClassAttributes.CommandSettings("Get Window State")] - [Attributes.ClassAttributes.Description("This command returns a state of window name.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a window state.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetWindowStateCommand : AWindowNameCommands - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [Remarks("Restore is **1**, Minimize is **2**, Maximize is **3**")] - [PropertyParameterOrder(6500)] - public string v_WindowState { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - public override string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] - //public string v_NameResult { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] - //public string v_HandleResult { get; set; } - - public GetWindowStateCommand() - { - //this.CommandName = "GetWindowStateCommand"; - //this.SelectionName = "Get Window State"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - var whnd = wins[0].Item1; - - var state = WindowControls.GetWindowState(whnd); - state.ToString().StoreInUserVariable(engine, v_WindowState); - }) - ); - } - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/GetWindowStateFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/Window/GetWindowStateFromWindowHandleCommand.cs deleted file mode 100644 index 8f1b655b1..000000000 --- a/taskt/Core/Automation/Commands/Window/GetWindowStateFromWindowHandleCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Get From Window Handle")] - [Attributes.ClassAttributes.CommandSettings("Get Window State From Window Handle")] - [Attributes.ClassAttributes.Description("This command returns a state of window name.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a window state.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetWindowStateFromWindowHandleCommand : AWindowHandleCommands - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] - //public string v_WindowHandle { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [Remarks("Restore is **1**, Minimize is **2**, Maximize is **3**")] - [PropertyParameterOrder(5500)] - public string v_WindowState { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - public GetWindowStateFromWindowHandleCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => - { - var state = WindowControls.GetWindowState(whnd); - state.StoreInUserVariable(engine, v_WindowState); - }) - ); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/ILAnyWindowNameProperties.cs b/taskt/Core/Automation/Commands/Window/ILAnyWindowNameProperties.cs deleted file mode 100644 index 93166da64..000000000 --- a/taskt/Core/Automation/Commands/Window/ILAnyWindowNameProperties.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace taskt.Core.Automation.Commands -{ - /// - /// any window name commands properties - /// - public interface ILAnyWindowNameProperties : ILExpandableProperties - { - /// - /// window name - /// - string v_WindowName { get; set; } - - /// - /// compare method (contains, starts-with, ...) - /// - string v_CompareMethod { get; set; } - - /// - /// wait time for window - /// - string v_WaitTimeForWindow { get; set; } - - /// - /// found window name - /// - string v_NameResult { get; set; } - - /// - /// found window handle - /// - string v_HandleResult { get; set; } - } -} diff --git a/taskt/Core/Automation/Commands/Window/IWindowNameProperties.cs b/taskt/Core/Automation/Commands/Window/IWindowNameProperties.cs deleted file mode 100644 index 69edf2f65..000000000 --- a/taskt/Core/Automation/Commands/Window/IWindowNameProperties.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace taskt.Core.Automation.Commands -{ - /// - /// window name commands properties - /// - public interface IWindowNameProperties : ILAnyWindowNameProperties - { - /// - /// match method (first, last, index) - /// - string v_MatchMethod { get; set; } - - /// - /// match method index - /// - string v_TargetWindowIndex { get; set; } - } -} diff --git a/taskt/Core/Automation/Commands/Window/IWindowPositionProperties.cs b/taskt/Core/Automation/Commands/Window/IWindowPositionProperties.cs deleted file mode 100644 index be4dc444a..000000000 --- a/taskt/Core/Automation/Commands/Window/IWindowPositionProperties.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace taskt.Core.Automation.Commands -{ - /// - /// window position properties - /// - public interface IWindowPositionProperties : ILPositionProperties - { - } -} diff --git a/taskt/Core/Automation/Commands/Window/IWindowSizeProperties.cs b/taskt/Core/Automation/Commands/Window/IWindowSizeProperties.cs deleted file mode 100644 index 90c6cd008..000000000 --- a/taskt/Core/Automation/Commands/Window/IWindowSizeProperties.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace taskt.Core.Automation.Commands -{ - /// - /// window size properties - /// - public interface IWindowSizeProperties : ILSizeProperties - { - } -} diff --git a/taskt/Core/Automation/Commands/Window/MoveWindowCommand.cs b/taskt/Core/Automation/Commands/Window/MoveWindowCommand.cs deleted file mode 100644 index b2abeb8a2..000000000 --- a/taskt/Core/Automation/Commands/Window/MoveWindowCommand.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Collections.Generic; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Actions")] - [Attributes.ClassAttributes.CommandSettings("Move Window")] - [Attributes.ClassAttributes.Description("This command moves a window to a specified location on screen.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to move an existing window by name to a certain point on the screen.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class MoveWindowCommand : AWindowNameCommands, IWindowPositionProperties - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - [XmlAttribute] - //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - //[PropertyDescription("X horizontal coordinate (pixel) for the Window's Location")] - //[InputSpecification("X Window Location", true)] - //[PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] - //[PropertyDetailSampleUsage("**0**", "Specify X Top Position")] - //[PropertyDetailSampleUsage("**100**", PropertyDetailSampleUsage.ValueType.Value, "X Position")] - //[PropertyDetailSampleUsage("**{{{vXPos}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "X Position")] - //[PropertyDetailSampleUsage("**%kwd_current_position%**", "Specify Current Position for X Position")] - //[PropertyDetailSampleUsage("**%kwd_current_xposition%**", "Specify Current X Position for X Position", false)] - //[PropertyDetailSampleUsage("**%kwd_current_yposition%**", "Specify Current Y Position for X Position", false)] - //[Remarks("This number is the pixel location on screen. Maximum value should be the maximum value allowed by your resolution. For 1920x1080, the valid range could be 0-1920")] - //[PropertyValidationRule("X Position", PropertyValidationRule.ValidationRuleFlags.Empty)] - //[PropertyDisplayText(true, "X Position")] - //[PropertyIntermediateConvert(nameof(ApplicationSettings.EngineSettings.convertToIntermediateWindowPosition), nameof(ApplicationSettings.EngineSettings.convertToRawWindowPosition))] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputXPosition))] - [PropertyParameterOrder(6500)] - public string v_XPosition { get; set; } - - [XmlAttribute] - //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] - //[PropertyDescription("Y vertical coordinate (pixel) for the Window's Location")] - //[InputSpecification("Y Window Location", true)] - //[PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] - //[PropertyDetailSampleUsage("**0**", "Specify Y Left Position")] - //[PropertyDetailSampleUsage("**100**", PropertyDetailSampleUsage.ValueType.Value, "Y Position")] - //[PropertyDetailSampleUsage("**{{{vYPos}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Y Position")] - //[PropertyDetailSampleUsage("**%kwd_current_position%**", "Specify Current Position for Y Position")] - //[PropertyDetailSampleUsage("**%kwd_current_xposition%**", "Specify Current X Position for Y Position", false)] - //[PropertyDetailSampleUsage("**%kwd_current_yposition%**", "Specify Current Y Position for Y Position", false)] - //[Remarks("This number is the pixel location on screen. Maximum value should be the maximum value allowed by your resolution. For 1920x1080, the valid range could be 0-1080")] - //[PropertyValidationRule("Y Position", PropertyValidationRule.ValidationRuleFlags.Empty)] - //[PropertyDisplayText(true, "Y Position")] - //[PropertyIntermediateConvert(nameof(ApplicationSettings.EngineSettings.convertToIntermediateWindowPosition), nameof(ApplicationSettings.EngineSettings.convertToRawWindowPosition))] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputYPosition))] - [PropertyParameterOrder(6500)] - public string v_YPosition { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] - //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - //public string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] - //public string v_NameResult { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] - //public string v_HandleResult { get; set; } - - public MoveWindowCommand() - { - //this.CommandName = "MoveWindowCommand"; - //this.SelectionName = "Move Window"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - foreach (var win in wins) - { - //var pos = WindowControls.GetWindowRect(win.Item1); - - //var variableXPosition = v_XPosition.ExpandValueOrUserVariable(engine); - //int xPos; - //if ((variableXPosition == engine.engineSettings.CurrentWindowPositionKeyword) || (variableXPosition == engine.engineSettings.CurrentWindowXPositionKeyword)) - //{ - // xPos = pos.left; - //} - //else if (variableXPosition == engine.engineSettings.CurrentWindowYPositionKeyword) - //{ - // xPos = pos.top; - //} - //else - //{ - // xPos = v_XPosition.ExpandValueOrUserVariableAsInteger("X Position", engine); - //} - - //var variableYPosition = v_YPosition.ExpandValueOrUserVariable(engine); - //int yPos; - //if ((variableYPosition == engine.engineSettings.CurrentWindowPositionKeyword) || (variableYPosition == engine.engineSettings.CurrentWindowYPositionKeyword)) - //{ - // yPos = pos.top; - //} - //else if (variableYPosition == engine.engineSettings.CurrentWindowXPositionKeyword) - //{ - // yPos = pos.left; - //} - //else - //{ - // yPos = v_YPosition.ExpandValueOrUserVariableAsInteger("Y Position", engine); - //} - - var whnd = win.Item1; - - var xPos = this.ExpandValueOrVariableAsWindowXPosition(whnd, engine); - var yPos = this.ExpandValueOrVariableAsWindowYPosition(whnd, engine); - - WindowControls.SetWindowPosition(win.Item1, xPos, yPos); - } - }) - ); - } - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/ResizeWindowByWindowHandleCommand.cs b/taskt/Core/Automation/Commands/Window/ResizeWindowByWindowHandleCommand.cs deleted file mode 100644 index bf79cabae..000000000 --- a/taskt/Core/Automation/Commands/Window/ResizeWindowByWindowHandleCommand.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Handle Actions")] - [Attributes.ClassAttributes.CommandSettings("Resize Window By Window Handle")] - [Attributes.ClassAttributes.Description("This command resizes a window to a specified size.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to reize a window by name to a specific size on screen.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ResizeWindowByWindowHandleCommand : AWindowHandleCommands, IWindowSizeProperties - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] - //public string v_WindowHandle { get; set; } - - [XmlAttribute] - //[PropertyDescription("Window Width (Pixcel)")] - //[InputSpecification("Window Width", true)] - //[PropertyDetailSampleUsage("**640**", PropertyDetailSampleUsage.ValueType.Value, "Width")] - //[PropertyDetailSampleUsage("**{{{vWidth}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Width")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] - //[PropertyDisplayText(true, "Width")] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWidth))] - [PropertyParameterOrder(5500)] - public string v_Width { get; set; } - - [XmlAttribute] - //[PropertyDescription("Window Height (Pixcel)")] - //[InputSpecification("Window Height", true)] - //[PropertyDetailSampleUsage("**480**", PropertyDetailSampleUsage.ValueType.Value, "Height")] - //[PropertyDetailSampleUsage("**{{{vHeight}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Height")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyValidationRule("Height", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] - //[PropertyDisplayText(true, "Height")] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputHeight))] - [PropertyParameterOrder(5500)] - public string v_Height { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - public ResizeWindowByWindowHandleCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => - { - //var width = this.ExpandValueOrUserVariableAsInteger(nameof(v_Width), engine); - //var height = this.ExpandValueOrUserVariableAsInteger(nameof(v_Height), engine); - var width = this.ExpandValueOrVariableAsWindowWidth(whnd, engine); - var height = this.ExpandValueOrVariableAsWindowHeight(whnd, engine); - - WindowControls.SetWindowSize(whnd, width, height); - }) - ); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/ResizeWindowCommand.cs b/taskt/Core/Automation/Commands/Window/ResizeWindowCommand.cs deleted file mode 100644 index 6ea0312b5..000000000 --- a/taskt/Core/Automation/Commands/Window/ResizeWindowCommand.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Collections.Generic; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Actions")] - [Attributes.ClassAttributes.CommandSettings("Resize Window")] - [Attributes.ClassAttributes.Description("This command resizes a window to a specified size.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to reize a window by name to a specific size on screen.")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class ResizeWindowCommand : AWindowNameCommands, IWindowSizeProperties - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - [XmlAttribute] - //[PropertyDescription("Window Width (Pixcel)")] - //[InputSpecification("Window Width", true)] - //[PropertyDetailSampleUsage("**640**", PropertyDetailSampleUsage.ValueType.Value, "Width")] - //[PropertyDetailSampleUsage("**{{{vWidth}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Width")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] - //[PropertyDisplayText(true, "Width")] - //[PropertyAvailableSystemVariable(Engine.SystemVariables.LimitedSystemVariableNames.Window_Size)] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWidth))] - [PropertyParameterOrder(6500)] - public string v_Width { get; set; } - - [XmlAttribute] - //[PropertyDescription("Window Height (Pixcel)")] - //[InputSpecification("Window Height", true)] - //[PropertyDetailSampleUsage("**480**", PropertyDetailSampleUsage.ValueType.Value, "Height")] - //[PropertyDetailSampleUsage("**{{{vHeight}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Height")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyValidationRule("Height", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] - //[PropertyDisplayText(true, "Height")] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputHeight))] - [PropertyParameterOrder(6500)] - public string v_Height { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] - //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - //public string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] - //public string v_NameResult { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] - //public string v_HandleResult { get; set; } - - public ResizeWindowCommand() - { - //this.CommandName = "ResizeWindowCommand"; - //this.SelectionName = "Resize Window"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - //var width = this.ExpandValueOrUserVariableAsInteger(nameof(v_Width), engine); - //var height = this.ExpandValueOrUserVariableAsInteger(nameof(v_Height), engine); - - foreach (var win in wins) - { - var whnd = win.Item1; - - var width = this.ExpandValueOrVariableAsWindowWidth(whnd, engine); - var height = this.ExpandValueOrVariableAsWindowHeight(whnd, engine); - - WindowControls.SetWindowSize(whnd, width, height); - } - }) - ); - } - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/SetWindowStateByWindowHandleCommand.cs b/taskt/Core/Automation/Commands/Window/SetWindowStateByWindowHandleCommand.cs deleted file mode 100644 index e5c261b64..000000000 --- a/taskt/Core/Automation/Commands/Window/SetWindowStateByWindowHandleCommand.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Xml.Serialization; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Handle Actions")] - [Attributes.ClassAttributes.CommandSettings("Set Window State By Window Handle")] - [Attributes.ClassAttributes.Description("This command sets a target window's state.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to change a window's state to minimized, maximized, or restored state")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SetWindowStateByWindowHandleCommand : AWindowHandleCommands - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] - //public string v_WindowHandle { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("State of the Window")] - [PropertyUISelectionOption("Maximize")] - [PropertyUISelectionOption("Minimize")] - [PropertyUISelectionOption("Restore")] - [InputSpecification("", true)] - [PropertyValidationRule("Window State", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "State")] - [PropertyParameterOrder(5500)] - public string v_WindowState { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - public SetWindowStateByWindowHandleCommand() - { - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => - { - var windowState = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WindowState), engine); - var state = WindowControls.WindowState.SW_RESTORE; - switch (windowState.ToLower()) - { - case "maximize": - state = WindowControls.WindowState.SW_MAXIMIZE; - break; - case "minimize": - state = WindowControls.WindowState.SW_MINIMIZE; - break; - } - - if (WindowControls.IsIconic(whnd) && (state != WindowControls.WindowState.SW_MINIMIZE)) - { - WindowControls.ShowIconicWindow(whnd); - } - WindowControls.SetWindowState(whnd, state); - }) - ); - } - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/SetWindowStateCommand.cs b/taskt/Core/Automation/Commands/Window/SetWindowStateCommand.cs deleted file mode 100644 index c23dbc52a..000000000 --- a/taskt/Core/Automation/Commands/Window/SetWindowStateCommand.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Xml.Serialization; -using System.Collections.Generic; -using taskt.Core.Automation.Attributes.PropertyAttributes; - -namespace taskt.Core.Automation.Commands -{ - [Serializable] - [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Actions")] - [Attributes.ClassAttributes.CommandSettings("Set Window State")] - [Attributes.ClassAttributes.Description("This command sets a target window's state.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want to change a window's state to minimized, maximized, or restored state")] - [Attributes.ClassAttributes.ImplementationDescription("")] - [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] - [Attributes.ClassAttributes.EnableAutomateRender(true)] - [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class SetWindowStateCommand : AWindowNameCommands - { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] - //public string v_WindowName { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] - //public string v_SearchMethod { get; set; } - - [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("State of the Window")] - [PropertyUISelectionOption("Maximize")] - [PropertyUISelectionOption("Minimize")] - [PropertyUISelectionOption("Restore")] - [InputSpecification("", true)] - [PropertyValidationRule("Window State", PropertyValidationRule.ValidationRuleFlags.Empty)] - [PropertyDisplayText(true, "State")] - [PropertyParameterOrder(6500)] - public string v_WindowState { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] - //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] - //public string v_MatchMethod { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] - //public string v_TargetWindowIndex { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] - //public string v_NameResult { get; set; } - - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] - //public string v_HandleResult { get; set; } - - public SetWindowStateCommand() - { - //this.CommandName = "SetWindowStateCommand"; - //this.SelectionName = "Set Window State"; - //this.CommandEnabled = true; - //this.CustomRendering = true; - } - - public override void RunCommand(Engine.AutomationEngineInstance engine) - { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - var windowState = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WindowState), engine); - var state = WindowControls.WindowState.SW_RESTORE; - switch (windowState.ToLower()) - { - case "maximize": - state = WindowControls.WindowState.SW_MAXIMIZE; - break; - case "minimize": - state = WindowControls.WindowState.SW_MINIMIZE; - break; - } - - foreach (var win in wins) - { - var whnd = win.Item1; - if (WindowControls.IsIconic(whnd) && (state != WindowControls.WindowState.SW_MINIMIZE)) - { - WindowControls.ShowIconicWindow(whnd); - } - WindowControls.SetWindowState(whnd, state); - } - }) - ); - } - - //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) - //{ - // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); - //} - - //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) - //{ - // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); - //} - } -} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowControls.cs b/taskt/Core/Automation/Commands/WindowControls.cs index 2ffeb7e14..be35154f6 100644 --- a/taskt/Core/Automation/Commands/WindowControls.cs +++ b/taskt/Core/Automation/Commands/WindowControls.cs @@ -1,14 +1,11 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; -using System.Linq; -using System.Drawing; -using System.ComponentModel; using System.Windows.Forms; -using taskt.UI.CustomControls; using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Automation.Commands.TextGroup; using taskt.Core.Automation.Engine; +using taskt.UI.CustomControls; namespace taskt.Core.Automation.Commands { @@ -17,7 +14,6 @@ namespace taskt.Core.Automation.Commands /// internal static class WindowControls { - #region fields /// @@ -77,34 +73,36 @@ internal static class WindowControls [PropertyIsWindowNamesList(true)] [PropertyValidationRule("Window Name", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "Window Name")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyShowSampleUsageInDescription(true)] - //[Remarks("")] - //[PropertyParameterOrder(5000)] public static string v_WindowName { get; } /// - /// windows name compare(search) method + /// windows name check(search) method /// - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Compare Method for the Window Name")] - [PropertyUISelectionOption("Contains")] - [PropertyUISelectionOption("Starts with")] - [PropertyUISelectionOption("Ends with")] - [PropertyUISelectionOption("Exact match")] + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CheckMethod))] + [PropertyDescription("Check Method for the Window Name")] [PropertyIsOptional(true, "Contains")] - [PropertyDisplayText(true, "Compare Method")] - //[InputSpecification("", true)] - //[Remarks("")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterOrder(5000)] - public static string v_CompareMethod { get; } + [PropertyDisplayText(true, "Check Method")] + public static string v_CheckMethod { get; } + + /// + /// window check case sensitive + /// + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_CaseSensitiveNo))] + [PropertyDescription("Case Sensitive Checking for Window Names")] + public static string v_CaseSensitive { get; } + + /// + /// trim before check window name + /// + [PropertyVirtualProperty(nameof(VP_TextCheckMethodControls), nameof(VP_TextCheckMethodControls.v_TrimBeforeCheck))] + [PropertyDescription("Trim before Check Window Names")] + public static string v_TrimBeforeCheck { get; } /// /// match method get one window, please specify PropertySelectionChangeEvent /// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] - [PropertyDescription("Match Method for the Window Name")] + [PropertyDescription("Selection Method for the Window Name")] [PropertyUISelectionOption("First")] [PropertyUISelectionOption("Last")] [PropertyUISelectionOption("Index")] @@ -113,30 +111,8 @@ internal static class WindowControls [PropertyDetailSampleUsage("**Index**", "the Window specifed by Index. **0** means First Window")] [Remarks("Specify when there are Multiple Matching Windows")] [PropertyIsOptional(true, "First")] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[InputSpecification("", true)] - //[PropertyParameterOrder(5000)] - public static string v_MatchMethod_Single { get; } - - /// - /// match method, please specify PropertySelectionChangeEvent - /// - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] - [PropertyUISelectionOption("All")] - [PropertyDetailSampleUsage("**All**", "Specify the All Windows")] - //[PropertyDescription("Match Method for the Window Name")] - //[PropertyUISelectionOption("First")] - //[PropertyUISelectionOption("Last")] - //[PropertyUISelectionOption("Index")] - //[PropertyDetailSampleUsage("**First**", "Specify the First Window")] - //[PropertyDetailSampleUsage("**Last**", "Specify the Last Window")] - //[PropertyDetailSampleUsage("**Index**", "the Window specifed by Index. **0** means First Window")] - //[Remarks("Specify when there are Multiple Matching Windows")] - //[PropertyIsOptional(true, "First")] - //[InputSpecification("", true)] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterOrder(5000)] - public static string v_MatchMethod { get; } + [PropertyDisplayText(true, "Select")] + public static string v_SelectionMethod_Single { get; } /// /// window index for match @@ -149,10 +125,7 @@ internal static class WindowControls [PropertyDetailSampleUsage("**{{{vIndex}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Window Index")] [PropertyIsOptional(true, "0")] [PropertyFirstValue("0")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] + [PropertyDisplayText(true, "Window Index")] public static string v_TargetWindowIndex { get; } /// @@ -163,14 +136,18 @@ internal static class WindowControls [Remarks("Specify how long to Wait before an Error will occur because the Window is Not Found.")] [PropertyIsOptional(true, "60")] [PropertyFirstValue("60")] - //[InputSpecification("Wait Time", true)] - //[PropertyDetailSampleUsage("**60**", PropertyDetailSampleUsage.ValueType.Value, "Wait Time")] - //[PropertyDetailSampleUsage("**{{{vTime}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Wait Time")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] public static string v_WaitTime { get; } + /// + /// wait time between find the window and execute action + /// + [PropertyVirtualProperty(nameof(WaitControls), nameof(WaitControls.v_WaitTime))] + [PropertyDescription("Wait Time between Finding the Window and Executing Action (sec)")] + [PropertyIsOptional(true, "0")] + [PropertyFirstValue("0")] + [PropertyDisplayText(false, "Wait Time Between", "s")] + public static string v_WaitTimeBetweenFindAndAction { get; } + /// /// window name result /// @@ -183,11 +160,6 @@ internal static class WindowControls [Remarks("When Match Method is **All**, data type is LIST, otherwise it is BASIC")] [PropertyValidationRule("Window Name Result", PropertyValidationRule.ValidationRuleFlags.None)] [PropertyDisplayText(false, "Window Name Result")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyIsVariablesList(true)] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] - //[PropertyParameterOrder(5000)] public static string v_WindowNameResult { get; } /// @@ -203,11 +175,6 @@ internal static class WindowControls [PropertyValidationRule("Window Handle Result", PropertyValidationRule.ValidationRuleFlags.None)] [PropertyDisplayText(false, "Window Handle Result")] [PropertyInstanceType(PropertyInstanceType.InstanceType.WindowHandle, true)] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyIsVariablesList(true)] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Output)] - //[PropertyParameterOrder(5000)] public static string v_OutputWindowHandle { get; } /// @@ -221,11 +188,6 @@ internal static class WindowControls [PropertyInstanceType(PropertyInstanceType.InstanceType.WindowHandle, true)] [PropertyValidationRule("Window Handle Result", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyDisplayText(true, "Window Handle")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] - //[PropertyParameterDirection(PropertyParameterDirection.ParameterDirection.Input)] - //[PropertyParameterOrder(5000)] public static string v_InputWindowHandle { get; } /// @@ -241,10 +203,6 @@ internal static class WindowControls [PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] [PropertyDisplayText(true, "Width")] [PropertyAvailableSystemVariable(SystemVariables.LimitedSystemVariableNames.Window_Size)] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] public static string v_InputWidth { get; } /// @@ -260,10 +218,6 @@ internal static class WindowControls [PropertyValidationRule("Height", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] [PropertyAvailableSystemVariable(SystemVariables.LimitedSystemVariableNames.Window_Size)] [PropertyDisplayText(true, "Height")] - //[Remarks("")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] public static string v_InputHeight { get; } /// @@ -272,7 +226,6 @@ internal static class WindowControls [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] [PropertyDescription("X horizontal coordinate (pixel) for the Window's Location")] [InputSpecification("X Window Location", true)] - [PropertyDetailSampleUsage("**0**", "Specify X Top Position")] [PropertyDetailSampleUsage("**100**", PropertyDetailSampleUsage.ValueType.Value, "X Position")] [PropertyDetailSampleUsage("**{{{vXPos}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "X Position")] @@ -283,9 +236,6 @@ internal static class WindowControls [PropertyValidationRule("X Position", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyAvailableSystemVariable(SystemVariables.LimitedSystemVariableNames.Window_Position)] [PropertyDisplayText(true, "X Position")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] public static string v_InputXPosition { get; } /// @@ -304,524 +254,95 @@ internal static class WindowControls [PropertyValidationRule("Y Position", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyAvailableSystemVariable(SystemVariables.LimitedSystemVariableNames.Window_Position)] [PropertyDisplayText(true, "Y Position")] - //[PropertyShowSampleUsageInDescription(true)] - //[PropertyTextBoxSetting(1, false)] - //[PropertyParameterOrder(5000)] public static string v_InputYPosition { get; } - #endregion - - #region enum, struct - public enum WindowState - { - [Description("Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread.")] - SW_FORCEMINIMIZE = 11, - [Description("Hides the window and activates another window.")] - SW_HIDE = 0, - [Description("Maximizes the specified window.")] - SW_MAXIMIZE = 3, - [Description("Minimizes the specified window and activates the next top-level window in the Z order.")] - SW_MINIMIZE = 6, - [Description("Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.")] - SW_RESTORE = 9, - [Description("Activates the window and displays it in its current size and position.")] - SW_SHOW = 5, - [Description("Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.")] - SW_SHOWDEFAULT = 10, - [Description("Activates the window and displays it as a maximized window.")] - SW_SHOWMAXIMIZED = 3, - [Description("Activates the window and displays it as a minimized window.")] - SW_SHOWMINIMIZED = 2, - [Description("Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated.")] - SW_SHOWMINNOACTIVE = 7, - [Description("Displays the window in its current size and position. This value is similar to SW_SHOW, except that the window is not activated.")] - SW_SHOWNA = 8, - [Description("Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated.")] - SW_SHOWNOACTIVATE = 4, - [Description("Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.")] - SW_SHOWNORMAL = 1, - } - - ///// - ///// Window Rect - ///// - //public struct RECT - //{ - // public int left; - // public int top; - // public int right; - // public int bottom; - //} - - public struct WINDOWPLACEMENT - { - public int length; - public int flags; - public int showCmd; - Point ptMinPosition; - Point ptMaxPosition; - RECT rcNormalPosition; - RECT rcDevice; - } - #endregion - - #region win api - - private static List<(IntPtr, string)> windowTitles; - - private delegate bool EnumWindowsDelegate(IntPtr hWnd, IntPtr lparam); - - [DllImport("user32.dll")] - private static extern int EnumWindows(EnumWindowsDelegate lpEnumFunc, IntPtr lparam); - - [DllImport("user32.dll")] - private static extern bool IsWindowVisible(IntPtr hWnd); - - [DllImport("user32.dll")] - private static extern bool IsWindow(IntPtr hWnd); - - [DllImport("user32.dll", CharSet = CharSet.Unicode)] - private static extern int GetWindowTextLengthW(IntPtr hWnd); - - [DllImport("user32.dll", CharSet = CharSet.Unicode)] - private static extern int GetWindowTextW(IntPtr hWnd, StringBuilder text, int count); - - [DllImport("user32.dll")] - private static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId); - - [DllImport("user32.dll")] - private static extern IntPtr GetForegroundWindow(); - - [DllImport("user32.dll")] - public static extern bool IsIconic(IntPtr hWnd); - - [DllImport("user32.dll")] - private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); - - [DllImport("User32.dll", EntryPoint = "SetForegroundWindow")] - private static extern IntPtr SetForegroundWindowNative(IntPtr hWnd); - - [DllImport("user32.dll", EntryPoint = "GetWindowRect")] - private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); - - [DllImport("user32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam); - - [DllImport("user32.dll", EntryPoint = "SetWindowPos")] - private static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags); - - [DllImport("user32.dll")] - private static extern bool ShowWindowAsync(IntPtr hWnd, WindowState nCmdShow); - - [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] - private static extern IntPtr GetDesktopWindow(); - - /// - /// get all window name and handle as Dictionary. Key is WindowHandle, Value is Window name - /// - /// - public static List<(IntPtr, string)> GetAllWindowNamesAndHandles() - { - windowTitles = new List<(IntPtr, string)>(); - - EnumWindows(new EnumWindowsDelegate(EnumerateWindow), IntPtr.Zero); - - return new List<(IntPtr, string)>(windowTitles); - } - - /// - /// enum windows - /// - /// - /// - /// - private static bool EnumerateWindow(IntPtr hWnd, IntPtr lParam) - { - int titleLengthA = GetWindowTextLengthW(hWnd); - if (IsWindowVisible(hWnd) && (titleLengthA > 0)) - { - StringBuilder title = new StringBuilder(titleLengthA + 1); - GetWindowTextW(hWnd, title, title.Capacity); - - windowTitles.Add((hWnd, title.ToString())); - } - return true; - } - - /// - /// get window name from window handle - /// - /// - /// - public static string GetWindowTitle(IntPtr hWnd) - { - int titleLengthA = GetWindowTextLengthW(hWnd); - StringBuilder title = new StringBuilder(titleLengthA + 1); - GetWindowTextW(hWnd, title, title.Capacity); - return title.ToString(); - } - - /// - /// get active window handlw - /// - /// - public static IntPtr GetActiveWindowHandle() - { - return GetForegroundWindow(); - } - - /// - /// set window state - /// - /// - /// - public static void SetWindowState(IntPtr hWnd, WindowState windowState) - { - ShowWindow(hWnd, (int)windowState); - } - - /// - /// set foreground to window - /// - /// - public static void SetToForegroundWindow(IntPtr hWnd) - { - SetForegroundWindowNative(hWnd); - } - - /// - /// get window RECT - /// - /// - /// - public static RECT GetWindowRect(IntPtr hWnd) - { - GetWindowRect(hWnd, out RECT clientArea); - return clientArea; - } - - /// - /// get window state - /// - /// - /// - public static int GetWindowState(IntPtr hWnd) - { - var wInfo = new WINDOWPLACEMENT(); - GetWindowPlacement(hWnd, ref wInfo); - return wInfo.showCmd; - } - /// - /// close window. send SendMessage + /// window state /// - /// - public static void CloseWindow(IntPtr hWnd) - { - const UInt32 WM_CLOSE = 0x0010; - SendMessage(hWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); - } + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("State of the Window")] + [PropertyUISelectionOption("Maximize")] + [PropertyUISelectionOption("Minimize")] + [PropertyUISelectionOption("Restore")] + [PropertyUISelectionOption("3")] + [PropertyUISelectionOption("2")] + [PropertyUISelectionOption("1")] + [PropertyDetailSampleUsage("**Maximize**", "Specifiy Maximize")] + [PropertyDetailSampleUsage("**3**", "Specifiy Maximize")] + [PropertyDetailSampleUsage("**2**", "Specifiy Minimize")] + [PropertyDetailSampleUsage("**1**", "Specifiy Restore")] + [PropertyDetailSampleUsage("**{{{vState}}}**", PropertyDetailSampleUsage.ValueType.VariableValue)] + [InputSpecification("Window State Text or Number", true)] + [PropertyValidationRule("Window State", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyDisplayText(true, "State")] + public static string v_WindowState { get; } /// - /// set window position + /// when target window is minimized for Set-commands /// - /// - /// - /// - public static void SetWindowPosition(IntPtr hWnd, int newXPosition, int newYPosition) - { - const short SWP_NOSIZE = 1; - const short SWP_NOZORDER = 0X4; - const int SWP_SHOWWINDOW = 0x0040; - - SetWindowPos(hWnd, 0, newXPosition, newYPosition, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); - } + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnore))] + [PropertyDescription("When Window Is Minimized")] + [PropertyUISelectionOption("Execute")] + [PropertyUISelectionOption("Restore")] + [PropertyIsOptional(true, "Restore")] + [PropertyDisplayText(false, "When Window Is Minimized")] + public static string v_WhenWindowIsMinimizedForSet { get; } /// - /// set window size + /// when target window is minimized for Get-commands /// - /// - /// - /// - public static void SetWindowSize(IntPtr hWnd, int newXSize, int newYSize) - { - const short SWP_NOZORDER = 0X4; - const int SWP_SHOWWINDOW = 0x0040; - - GetWindowRect(hWnd, out RECT windowRect); - - SetWindowPos(hWnd, 0, windowRect.left, windowRect.top, newXSize, newYSize, SWP_NOZORDER | SWP_SHOWWINDOW); - } + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyDescription("When Window Is Minimized")] + [PropertyUISelectionOption("Set Zero")] + [PropertyDisplayText(false, "When Window Is Minimized")] + public static string v_WhenWindowIsMinimizedForGet { get; } /// - /// ? + /// when target window is maximized for Set-commands /// - /// - public static void ShowIconicWindow(IntPtr hWind) - { - ShowWindowAsync(hWind, WindowState.SW_SHOWNORMAL); - } + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyDescription("When Window Is Maximized")] + [PropertyDisplayText(false, "When Window Is Maximized")] + public static string v_WhenWindowIsMaximizedForSet { get; } /// - /// get active window name (title) + /// when target window is maximized for Get-commands /// - /// - public static string GetActiveWindowTitle() - { - var whnd = GetActiveWindowHandle(); - return GetWindowTitle(whnd); - } - #endregion - - #region Func<> - - /// - /// get window name compare method (Func) - /// - /// - /// - /// - public static Func GetWindowNameCompareMethod(string compareType) - { - Func ret; - switch (compareType.ToLower()) - { - case "starts with": - ret = (a, b) => a.StartsWith(b); - break; - case "ends with": - ret = (a, b) => a.EndsWith(b); - break; - case "exact match": - ret = (a, b) => (a == b); - break; - case "contains": - ret = (a, b) => a.Contains(b); - break; - default: - throw new Exception("Search method " + compareType + " is not support."); - } - return ret; - } + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] + [PropertyDescription("When Window Is Maximized")] + [PropertyDisplayText(false, "When Window Is Maximized")] + public static string v_WhenWindowIsMaximizedForGet { get; } /// - /// Get Window Match Function + /// activate window before action /// - /// - /// - /// - /// - private static Func, List<(IntPtr, string)>> GetWindowMatchMethod(string matchType, int index) - { - Func, List<(IntPtr, string)>> ret; - switch(matchType.ToLower()) - { - case "first": - ret = (lst) => - { - return (lst.Count > 0 ? new List<(IntPtr, string)>() { lst[0] } : throw new Exception("No Matched Windows exists.")); - }; - break; - case "last": - ret = (lst) => - { - return (lst.Count > 0 ? new List<(IntPtr, string)>() { lst[lst.Count - 1] } : throw new Exception("No Matched Windows exists.")); - }; - break; - case "all": - ret = (lst) => - { - return (lst.Count > 0 ? new List<(IntPtr, string)>(lst) : throw new Exception("No Matched Windows exists.")); - }; - break; - case "index": - ret = (lst) => - { - var count = lst.Count; - if (count == 0) - { - throw new Exception("No Matched Windows exists."); - } - if (index < 0) - { - index += count; - } - if (index >= 0 && index < count) - { - return new List<(IntPtr, string)>() { lst[index] }; - } - else - { - throw new Exception("No Item Exists. Index: " + index); - } - }; - break; - default: - throw new Exception("Match type " + matchType + " is not support."); - } - return ret; - } + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_YesNoComboBox))] + [PropertyDescription("Activate Window Before Action")] + [PropertyIsOptional(true, "No")] + [PropertyValidationRule("Activate Window", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Activate Window")] + public static string v_ActivateBeforeAction { get; } /// - /// get window name search method (Func) + /// base position /// - /// - /// - /// - /// - /// - /// - private static Func> GetWindowSearchMethod(string window, string searchMethod, string matchType, int index, Engine.AutomationEngineInstance engine) - { - if (window == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_Desktop.VariableName, engine)) - { - // Desktop - var whnd = GetDesktopWindow(); - return new Func>(() => - { - return new List<(IntPtr, string)>() { (whnd, "") }; - }); - } - else if (window == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_AllWindows.VariableName, engine)) - { - // all windows & match-type - return new Func>(() => - { - var matchedWindows = GetAllWindowNamesAndHandles(); - var matchFunc = GetWindowMatchMethod(matchType, index); - return matchFunc(matchedWindows); - }); - } - else - { - // matched windows - return new Func>(() => { - var wins = GetAllWindowNamesAndHandles(); - var searchFunc = GetWindowNameCompareMethod(searchMethod); - - var matchedWindows = wins.Where(w => searchFunc(w.Item2, window)).ToList(); - - var matchFunc = GetWindowMatchMethod(matchType, index); - return matchFunc(matchedWindows); - }); - } - } + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyDescription("Base Position")] + [PropertyUISelectionOption("Top Left")] + [PropertyUISelectionOption("Bottom Right")] + [PropertyUISelectionOption("Top Right")] + [PropertyUISelectionOption("Bottom Left")] + [PropertyUISelectionOption("Center")] + [PropertyIsOptional(true, "Top Left")] + [PropertyDisplayText(false, "Base Position")] + public static string v_PositionBase { get; } #endregion - #region methods - /// - /// get current window name - /// - /// - public static string GetCurrentWindowName() - { - var whnd = GetActiveWindowHandle(); - return GetWindowTitle(whnd); - } - - /// - /// find window handle from specified from args - /// - /// - /// - /// - /// - /// - public static IntPtr FindWindowHandle(string windowName, string searchMethod, Automation.Engine.AutomationEngineInstance engine) - { - if (windowName == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentWindowName.VariableName, engine)) - { - return GetActiveWindowHandle(); - } - else - { - var wins = GetAllWindowNamesAndHandles(); - var method = GetWindowNameCompareMethod(searchMethod); - - try - { - var whnd = wins.Where(w => method(w.Item2, windowName)).First(); - return whnd.Item1; - } - catch - { - // not found - throw new Exception("Window Name '" + windowName + "' not found"); - } - } - } - - /// - /// get all window titles - /// - /// - public static List GetAllWindowTitles() - { - return GetAllWindowNamesAndHandles().Select(w => w.Item2).ToList(); - } - - /// - /// get all window handles - /// - /// - public static List GetAllWindowHandles() - { - return GetAllWindowNamesAndHandles().Select(w => w.Item1).ToList(); - } - - /// - /// get all window names for frmCommandEditor ComboBox - /// - /// - /// - /// - /// - /// - public static List GetAllWindowTitles(SafeApplicationSettings settings, bool addCurrentWindow = true, bool addAllWindows = false, bool addDesktop = false) - { - var lst = new List(); - - if (addCurrentWindow) - { - lst.Add(VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentWindowName.VariableName, settings)); - } - - // TODO: use system variable like keyword - if (addAllWindows) - { - //lst.Add(settings?.EngineSettings.AllWindowsKeyword ?? "All Windows"); - lst.Add(VariableNameControls.GetWrappedVariableName(SystemVariables.Window_AllWindows.VariableName, settings)); - } - - if (addDesktop) - { - //lst.Add(settings?.EngineSettings.DesktopKeyword ?? "Desktop"); - lst.Add(VariableNameControls.GetWrappedVariableName(SystemVariables.Window_Desktop.VariableName, settings)); - } - - lst.AddRange(GetAllWindowTitles()); + [DllImport("user32.dll")] + private static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId); - return lst; - } - - /// - /// Activate Window - /// - /// - public static void ActivateWindow(IntPtr handle) - { - if (IsIconic(handle)) - { - SetWindowState(handle, WindowState.SW_SHOWNORMAL); - } - SetToForegroundWindow(handle); - } /// /// convert processId to Window Handle @@ -831,497 +352,49 @@ public static void ActivateWindow(IntPtr handle) /// public static IntPtr ConvertProcessIdToWindowHandle(int pid) { - var whnds = GetAllWindowHandles(); - foreach(var whnd in whnds) + var whnds = EM_CanHandleWindowHandleExtentionMethods.GetAllWindowHandles(); + foreach (var whnd in whnds) { - int myPid; - GetWindowThreadProcessId(whnd, out myPid); + GetWindowThreadProcessId(whnd, out int myPid); if (myPid == pid) { return whnd; } } - throw new Exception("ProcessID: " + pid + " does not found."); + throw new Exception($"ProcessID: {pid} does not found."); } - - //public static Bitmap CaptureWindow(string windowName, Engine.AutomationEngineInstance engine) + + ///// + ///// get all window names for frmCommandEditor ComboBox + ///// + ///// + ///// + ///// + ///// + ///// + //public static List GetAllWindowTitles(SafeApplicationSettings settings, bool addCurrentWindow = true, bool addAllWindows = false, bool addDesktop = false) //{ - // IntPtr hWnd; - // if (windowName == "Desktop") + // var lst = new List(); + + // if (addCurrentWindow) // { - // hWnd = GetDesktopWindow(); + // lst.Add(VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentWindowName.VariableName, settings)); // } - // else - // { - // //hWnd = FindWindow(windowName); - // var wins = FindWindows(windowName, "", "", 0, 60, engine); - // hWnd = wins[0].Item1; - // SetWindowState(hWnd, WindowState.SW_RESTORE); - // SetToForegroundWindow(hWnd); + // if (addAllWindows) + // { + // lst.Add(VariableNameControls.GetWrappedVariableName(SystemVariables.Window_AllWindows.VariableName, settings)); // } - - // var rect = new RECT(); - - // //sleep to allow repaint - // System.Threading.Thread.Sleep(500); - - // GetWindowRect(hWnd, out rect); - // var bounds = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); - // var screenshot = new Bitmap(bounds.Width, bounds.Height); - - // using (var graphics = Graphics.FromImage(screenshot)) + + // if (addDesktop) // { - // graphics.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size); + // lst.Add(VariableNameControls.GetWrappedVariableName(SystemVariables.Window_Desktop.VariableName, settings)); // } - // return screenshot; - //} - - /// - /// capture window - /// - /// - /// - /// - public static Bitmap CaptureWindow(IntPtr whnd) - { - if (GetWindowRect(whnd, out RECT r)) - { - var bounds = new Rectangle(r.left, r.top, r.right - r.left, r.bottom - r.top); - var screenshot = new Bitmap(bounds.Width, bounds.Height); - - using (var graphics = Graphics.FromImage(screenshot)) - { - graphics.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size); - } - - return screenshot; - } - else - { - throw new Exception($"Fail Capture Window. WindowHandle: {whnd}"); - } - } - - /// - /// search & wait window name. this method use argument values, DON'T convert variable. - /// - /// - /// - /// - /// - /// - /// - /// - /// - private static List<(IntPtr, string)> FindWindows(string window, string searchMethod, string matchType, int index, int waitTime, Engine.AutomationEngineInstance engine) - { - var searchFunc = GetWindowSearchMethod(window, searchMethod, matchType, index, engine); - - var waitFunc = new Func<(bool, object)>(() => - { - try - { - var ret = searchFunc(); - if (ret.Count > 0) - { - return (true, ret); - } - else - { - return (false, null); - } - } - catch - { - return (false, null); - } - }); - - var obj = WaitControls.WaitProcess(waitTime, "Window", waitFunc, engine); - - if (obj is List<(IntPtr, string)> lst) - { - return lst; - } - else - { - throw new Exception("Strange Value returned in FindWindows. Type: " + obj.GetType().FullName); - } - } - - /// - /// search & wait window name. this method use argument values, convert variable. - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static List<(IntPtr, string)> FindWindows(ScriptCommand command, string windowName, string compareMethodName, string matchTypeName, string indexName, string waitName, Engine.AutomationEngineInstance engine) - { - var window = command.ExpandValueOrUserVariableAsWindowName(windowName, engine); - var compareMethod = command.ExpandValueOrUserVariableAsSelectionItem(compareMethodName, engine); - var matchType = command.ExpandValueOrUserVariableAsSelectionItem(matchTypeName, engine); - var index = command.ExpandValueOrUserVariableAsInteger(indexName, engine); - var waitTime = command.ExpandValueOrUserVariableAsInteger(waitName, engine); - - return FindWindows(window, compareMethod, matchType, index, waitTime, engine); - } - - /// - /// search & wait window name. this method use argument values, convert variable. - /// - /// - /// - /// - /// - /// - /// - public static List<(IntPtr, string)> FindWindows(ScriptCommand command, string windowName, string compareMethodName, string waitName, Engine.AutomationEngineInstance engine) - { - var window = command.ExpandValueOrUserVariableAsWindowName(windowName, engine); - var compareMethod = command.ExpandValueOrUserVariableAsSelectionItem(compareMethodName, engine); - var waitTime = command.ExpandValueOrUserVariableAsInteger(waitName, engine); - - return FindWindows(window, compareMethod, "All", 60, waitTime, engine); - } - - /// - /// general window action. This method search window before execute actionFunc, and try store Found Window Name and Handle after execute actionFunc. - /// - /// - /// - /// - /// - /// - /// - /// - /// - private static void WindowAction(ScriptCommand command, string matchType, Func> searchFunc, Engine.AutomationEngineInstance engine, Action> actionFunc, string nameResultName = "", string handleResultName = "", Action errorFunc = null) - { - try - { - var wins = searchFunc(); - actionFunc(wins); - - matchType = matchType.ToLower(); - - if (!string.IsNullOrEmpty(nameResultName)) - { - var nameResult = command.GetRawPropertyValueAsString(nameResultName, "Window Name Result"); - if (!string.IsNullOrEmpty(nameResult)) - { - if (matchType == "all") - { - wins.Select(w => w.Item2).ToList().StoreInUserVariable(engine, nameResult); - } - else - { - wins[0].Item2.StoreInUserVariable(engine, nameResult); - } - } - } - if (!string.IsNullOrEmpty(handleResultName)) - { - var handleResult = command.GetRawPropertyValueAsString(handleResultName, "Window Handle Result"); - if (!string.IsNullOrEmpty(handleResult)) - { - if (matchType == "all") - { - wins.Select(w => w.Item1.ToString()).ToList().StoreInUserVariable(engine, handleResult); - } - else - { - //wins[0].Item1.ToString().StoreInUserVariable(engine, handleResult); - wins[0].Item1.StoreInUserVariable(engine, handleResult); - } - } - } - } - catch (Exception ex) - { - if (errorFunc == null) - { - throw ex; - } - else - { - errorFunc(ex); - } - } - } - - /// - /// general window action. This method search window before execute actionFunc, and try store Found Window Name and Handle after execute actionFunc. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private static void WindowAction(ScriptCommand command, string windowName, string compareMethodName, string matchTypeName, string indexName, string waitName, Engine.AutomationEngineInstance engine, Action> actionFunc, string nameResultName = "", string handleResultName = "", Action errorFunc = null) - { - var matchType = command.ExpandValueOrUserVariableAsSelectionItem(matchTypeName, engine); - - WindowAction(command, matchType, new Func>(() => - { - return FindWindows(command, windowName, compareMethodName, matchTypeName, indexName, waitName, engine); - }), engine, actionFunc, nameResultName, handleResultName, errorFunc); - } - - /// - /// general window action. This method search window before execute actionFunc, and try store Found Window Name and Handle after execute actionFunc. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private static void WindowAction(ScriptCommand command, string windowName, string compareMethodName, string waitName, Engine.AutomationEngineInstance engine, Action> actionFunc, string nameResultName = "", string handleResultName = "", Action errorFunc = null) - { - WindowAction(command, "all", new Func>(() => - { - return FindWindows(command, windowName, compareMethodName, waitName, engine); - }), engine, actionFunc, nameResultName, handleResultName, errorFunc); - } - - /// - /// window general action. This method search window before execute actionFunc, and try store Found Window Name and Handle after execute actionFunc. This method specifies the parameter names from the value of PropertyVirtualProperty - /// - /// - /// - /// - /// - public static void WindowAction(ScriptCommand command, Engine.AutomationEngineInstance engine, Action> actionFunc, Action errorFunc = null) - { - var props = command.GetParameterProperties(); - var windowName = props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_WindowName)))?.Name ?? ""; - var compareMethod = props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_CompareMethod)))?.Name ?? ""; - var waitTime = props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_WaitTime)))?.Name ?? ""; - var nameResult = props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_WindowNameResult)))?.Name ?? ""; - var handleResult = props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_OutputWindowHandle)))?.Name ?? ""; + // lst.AddRange(EM_CanHandleWindowNameExtensionMethods.GetAllWindowNames()); - var matchType = props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_MatchMethod)))?.Name ?? - props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_MatchMethod_Single)))?.Name ?? ""; - var index = props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_TargetWindowIndex)))?.Name ?? ""; - - if (matchType == "") - { - WindowAction(command, windowName, compareMethod, waitTime, engine, actionFunc, nameResult, handleResult, errorFunc); - } - else - { - WindowAction(command, windowName, compareMethod, matchType, index, waitTime, engine, actionFunc, nameResult, handleResult, errorFunc); - } - } - - /// - /// window general action. This method search window before execute actionFunc, and try store Found Window Name and Handle after execute actionFunc. This method specifies the parameter names from interface - /// - /// - /// - /// - /// - public static void WindowAction(AWindowNameCommands command, Engine.AutomationEngineInstance engine, Action> actionFunc, Action errorFunc = null) - { - WindowAction(command, - nameof(command.v_WindowName), nameof(command.v_CompareMethod), nameof(command.v_MatchMethod), - nameof(command.v_TargetWindowIndex), nameof(command.v_WaitTimeForWindow), engine, actionFunc, - nameof(command.v_NameResult), nameof(command.v_HandleResult), errorFunc); - } - - /// - /// window general action. This method search window before execute actionFunc, and try store Found Window Name and Handle after execute actionFunc. This method specifies the parameter names from interface - /// - /// - /// - /// - /// - public static void WindowAction(AAnyWindowNameCommands command, Engine.AutomationEngineInstance engine, Action> actionFunc, Action errorFunc = null) - { - WindowAction(command, - nameof(command.v_WindowName), nameof(command.v_CompareMethod), nameof(command.v_WaitTimeForWindow), - engine, actionFunc, nameof(command.v_NameResult), nameof(command.v_HandleResult), errorFunc); - } - - /// - /// inner window handle action - /// - /// - /// - /// - /// - /// - private static void WindowHandleAction(string handleValue, int waitTime, Engine.AutomationEngineInstance engine, Action actionFunc, Action errorFunc = null) - { - try - { - var whnd = handleValue.ExpandUserVariableAsWindowHandle(engine); - - var obj = WaitControls.WaitProcess(waitTime, "Window Handle", new Func<(bool, object)>(() => - { - if (IsWindow(whnd)) - { - return (true, whnd); - } - else - { - return (false, null); - } - - }), engine); - - if (obj is IntPtr ptr) - { - actionFunc(ptr); - } - } - catch (Exception ex) - { - if (errorFunc != null) - { - errorFunc(ex); - } - else - { - throw ex; - } - } - } - - /// - /// window handle action. specified Window Handle, Wait Time parameter names - /// - /// - /// - /// - /// - /// - /// - public static void WindowHandleAction(ScriptCommand command, string handleName, string waitTimeName, Engine.AutomationEngineInstance engine, Action actionFunc, Action errorFunc = null) - { - //var handle = command.ExpandValueOrUserVariable(handleName, "Window Handle", engine); - var handle = command.GetRawPropertyValueAsString(handleName, "Window Handle"); - var waitTime = command.ExpandValueOrUserVariableAsInteger(waitTimeName, "Wait Time", engine); - WindowHandleAction(handle, waitTime, engine, actionFunc, errorFunc); - } - - /// - /// general window handle action. Infer parameter names from VirtualProperty - /// - /// - /// - /// - /// - public static void WindowHandleAction(ScriptCommand command, Engine.AutomationEngineInstance engine, Action actionFunc, Action errorFunc = null) - { - var props = command.GetParameterProperties(); - var handleName = props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_InputWindowHandle)))?.Name ?? ""; - var waitTimeName = props.GetProperty(new PropertyVirtualProperty(nameof(WindowControls), nameof(v_WaitTime)))?.Name ?? ""; - WindowHandleAction(command, handleName, waitTimeName, engine, actionFunc, errorFunc); - } - - - #endregion - - #region variable - - /// - /// expand variable as Window Name - /// - /// - /// - /// - private static string ExpandValueOrUserVariableAsWindowName(this string value, Engine.AutomationEngineInstance engine) - { - if ((value == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_AllWindows.VariableName, engine)) || - (value == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_Desktop.VariableName, engine))) - { - return value; - } - else - { - return value.ExpandValueOrUserVariable(engine); - } - } - - /// - /// expand specified property value as Window Name - /// - /// - /// - /// - /// - private static string ExpandValueOrUserVariableAsWindowName(this ScriptCommand command, string windowName, Engine.AutomationEngineInstance engine) - { - var prop = command.GetProperty(windowName); - var value = prop.GetValue(command)?.ToString() ?? ""; - return value.ExpandValueOrUserVariableAsWindowName(engine); - } - - /// - /// expand variable as WindowHandle specified by parameter value - /// - /// - /// - /// - /// - public static IntPtr ExpandUserVariableAsWindowHandle(this string value, Engine.AutomationEngineInstance engine) - { - var v = value.GetRawVariable(engine); - var vv = v.VariableValue; - string handleStr; - if (vv is string str) - { - handleStr = str; - } - else if (vv is List lst) - { - handleStr = lst[v.CurrentPosition]; - } - else - { - throw new Exception($"Value '{value}' is not Window Handle value type."); - } - - if (int.TryParse(handleStr, out int whnd)) - { - return (IntPtr)whnd; - } - else - { - throw new Exception($"Value '{value}' is not Window Handle value type."); - } - } - - /// - /// expand variable as WindowHanle specified by parameter name - /// - /// - /// - /// - /// - public static IntPtr ExpandUserVariableAsWindowHandle(this ScriptCommand command, string windowName, Engine.AutomationEngineInstance engine) - { - var prop = command.GetProperty(windowName); - var value = prop.GetValue(command)?.ToString() ?? ""; - return value.ExpandUserVariableAsWindowHandle(engine); - } + // return lst; + //} /// /// store IntPtr In User Variable @@ -1334,10 +407,6 @@ public static void StoreInUserVariable(this IntPtr value, Engine.AutomationEngin ExtensionMethods.StoreInUserVariable(targetVariable, value.ToString(), engine, false); } - #endregion - - #region Events - public static void lnkWindowNameUpToDate_Click(object sender, EventArgs e) { ComboBox cmb = (ComboBox)((CommandItemControl)sender).Tag; @@ -1346,7 +415,7 @@ public static void lnkWindowNameUpToDate_Click(object sender, EventArgs e) cmb.BeginUpdate(); cmb.Items.Clear(); - var winList = GetAllWindowTitles(); + var winList = EM_CanHandleWindowNameExtensionMethods.GetAllWindowNames(); cmb.Items.AddRange(winList.ToArray()); @@ -1364,10 +433,6 @@ public static void MatchMethodComboBox_SelectionChangeCommitted(Dictionary /// Replace Internal Keywords to SystemVariable Names /// @@ -1407,6 +472,5 @@ public static string ReplaceKeywordsToSystemVariable(string txt, IApplicationSet .Replace(INTERNAL_CURRENT_WINDOW_Y_POSITION_KEYWORD, VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentYPosition.VariableName, settings)) .Replace(INTERNAL_CURRENT_WINDOW_HANDLE_KEYWORD, VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentWindowHandle.VariableName, settings)); } - #endregion } } diff --git a/taskt/Core/Automation/Commands/WindowGroup/AGetFromWindowNamesAsDataTableCommands.cs b/taskt/Core/Automation/Commands/WindowGroup/AGetFromWindowNamesAsDataTableCommands.cs new file mode 100644 index 000000000..c396188a0 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/AGetFromWindowNamesAsDataTableCommands.cs @@ -0,0 +1,18 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + /// + /// for Get***FromWindowNamesAsDataTable commands + /// + public abstract class GetFromWindowNamesAsDataTableCommands : AWindowNamesCommands, IDataTableResultProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyInstanceType(PropertyInstanceType.InstanceType.DataTable)] + [PropertyParameterOrder(6500)] + public virtual string v_Result { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/AGetFromWindowNamesAsListCommands.cs b/taskt/Core/Automation/Commands/WindowGroup/AGetFromWindowNamesAsListCommands.cs new file mode 100644 index 000000000..7b62e0272 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/AGetFromWindowNamesAsListCommands.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.Data; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + /// + /// for Get***FromWindowNamesAsList commands + /// + public abstract class GetFromWindowNamesAsListCommands : AWindowNamesCommands, ICanHandleList + { + // nothing, result paramters will be multiple + + /// + /// get datatable column values as list + /// + /// + /// + /// + protected static List GetColumnValues(ScriptVariable tableVar, int columnIndex) + { + var table = (DataTable)tableVar.VariableValue; + + var ret = new List(); + + int rows = table.Rows.Count; + for (int i = 0; i < rows; i++) + { + ret.Add(table.Rows[i][columnIndex]?.ToString() ?? string.Empty); + } + + return ret; + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/AOneWindowNameActionCommands.cs b/taskt/Core/Automation/Commands/WindowGroup/AOneWindowNameActionCommands.cs new file mode 100644 index 000000000..1a1371b30 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/AOneWindowNameActionCommands.cs @@ -0,0 +1,21 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + /// + /// for one window name action commands + /// + public abstract class AOneWindowNameActionCommands : AOneWindowNameCommands, IOneWindowNameActionProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTimeBetweenFindAndAction))] + [PropertyParameterOrder(10000)] + public virtual string v_WaitTimeBetweenFindAndAction { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_ActivateBeforeAction))] + [PropertyParameterOrder(10010)] + public virtual string v_ActivateBeforeAction { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/Window/AWindowNameCommands.cs b/taskt/Core/Automation/Commands/WindowGroup/AOneWindowNameCommands.cs similarity index 86% rename from taskt/Core/Automation/Commands/Window/AWindowNameCommands.cs rename to taskt/Core/Automation/Commands/WindowGroup/AOneWindowNameCommands.cs index 000e555fb..6b069cf4d 100644 --- a/taskt/Core/Automation/Commands/Window/AWindowNameCommands.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/AOneWindowNameCommands.cs @@ -6,10 +6,10 @@ namespace taskt.Core.Automation.Commands { /// - /// Abstract class for Window Name commands + /// Abstract class for one Window Name commands /// [Serializable] - public abstract class AWindowNameCommands : AAnyWindowNameCommands, IWindowNameProperties + public abstract class AOneWindowNameCommands : AWindowNameCoreCommands, IOneWindowNameProperties { //[XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] @@ -22,10 +22,10 @@ public abstract class AWindowNameCommands : AAnyWindowNameCommands, IWindowNameP //public string v_SearchMethod { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod))] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_SelectionMethod_Single))] [PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] [PropertyParameterOrder(7000)] - public virtual string v_MatchMethod { get; set; } + public virtual string v_SelectionMethod { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TargetWindowIndex))] @@ -45,9 +45,9 @@ public abstract class AWindowNameCommands : AAnyWindowNameCommands, IWindowNameP //[PropertyParameterOrder(7400)] //public string v_HandleResult { get; set; } - public AWindowNameCommands() - { - } + //public AOneWindowNameCommands() + //{ + //} protected void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) { diff --git a/taskt/Core/Automation/Commands/WindowGroup/AWindowHandleActionCommands.cs b/taskt/Core/Automation/Commands/WindowGroup/AWindowHandleActionCommands.cs new file mode 100644 index 000000000..ff95552bf --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/AWindowHandleActionCommands.cs @@ -0,0 +1,21 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + /// + /// window handle action commands + /// + public abstract class AWindowHandleActionCommands : AWindowHandleCommands, IWindowHandleActionPropeties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTimeBetweenFindAndAction))] + [PropertyParameterOrder(10000)] + public virtual string v_WaitTimeBetweenFindAndAction { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_ActivateBeforeAction))] + [PropertyParameterOrder(10010)] + public virtual string v_ActivateBeforeAction { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/Window/AWindowHandleCommands.cs b/taskt/Core/Automation/Commands/WindowGroup/AWindowHandleCommands.cs similarity index 57% rename from taskt/Core/Automation/Commands/Window/AWindowHandleCommands.cs rename to taskt/Core/Automation/Commands/WindowGroup/AWindowHandleCommands.cs index 88fdbf9b6..9e5faa769 100644 --- a/taskt/Core/Automation/Commands/Window/AWindowHandleCommands.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/AWindowHandleCommands.cs @@ -8,7 +8,7 @@ namespace taskt.Core.Automation.Commands /// Abstract class for Window Handle command /// [Serializable] - public abstract class AWindowHandleCommands : ScriptCommand, ILWindowHandleProperties + public abstract class AWindowHandleCommands : ScriptCommand, IWindowHandleProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWindowHandle))] @@ -20,8 +20,17 @@ public abstract class AWindowHandleCommands : ScriptCommand, ILWindowHandlePrope [PropertyParameterOrder(6000)] public virtual string v_WaitTimeForWindow { get; set; } - public AWindowHandleCommands() - { - } + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Window Name")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Window Name", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(false, "Window Name")] + [PropertyParameterOrder(10000)] + public virtual string v_WindowNameResult { get; set; } + + //public AWindowHandleCommands() + //{ + //} } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/AAnyWindowNameCommands.cs b/taskt/Core/Automation/Commands/WindowGroup/AWindowNameCoreCommands.cs similarity index 61% rename from taskt/Core/Automation/Commands/Window/AAnyWindowNameCommands.cs rename to taskt/Core/Automation/Commands/WindowGroup/AWindowNameCoreCommands.cs index 494f0f617..fba0f7b8a 100644 --- a/taskt/Core/Automation/Commands/Window/AAnyWindowNameCommands.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/AWindowNameCoreCommands.cs @@ -7,10 +7,10 @@ namespace taskt.Core.Automation.Commands { /// - /// Abstract class for Any Window Name commands + /// Abstract class for Window Name commands core /// [Serializable] - public abstract class AAnyWindowNameCommands : ScriptCommand, ILAnyWindowNameProperties + public abstract class AWindowNameCoreCommands : ScriptCommand, IWindowNameCoreProperties { [XmlAttribute] [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] @@ -18,9 +18,9 @@ public abstract class AAnyWindowNameCommands : ScriptCommand, ILAnyWindowNamePro public virtual string v_WindowName { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CompareMethod))] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CheckMethod))] [PropertyParameterOrder(6000)] - public virtual string v_CompareMethod { get; set; } + public virtual string v_CheckMethod { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] @@ -30,16 +30,26 @@ public abstract class AAnyWindowNameCommands : ScriptCommand, ILAnyWindowNamePro [XmlAttribute] [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowNameResult))] [PropertyParameterOrder(8100)] - public virtual string v_NameResult { get; set; } + public virtual string v_WindowNameResult { get; set; } [XmlAttribute] [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_OutputWindowHandle))] [PropertyParameterOrder(8200)] - public virtual string v_HandleResult { get; set; } + public virtual string v_WindowHandleResult { get; set; } - public AAnyWindowNameCommands() - { - } + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_CaseSensitive))] + [PropertyParameterOrder(8300)] + public virtual string v_CaseSensitive { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_TrimBeforeCheck))] + [PropertyParameterOrder(8400)] + public virtual string v_TrimBeforeCheck { get; set; } + + //public AWindowNameCoreCommands() + //{ + //} public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) { diff --git a/taskt/Core/Automation/Commands/WindowGroup/AWindowNamesActionCommnads.cs b/taskt/Core/Automation/Commands/WindowGroup/AWindowNamesActionCommnads.cs new file mode 100644 index 000000000..891bd76a3 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/AWindowNamesActionCommnads.cs @@ -0,0 +1,21 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + /// + /// for window names action commands + /// + public abstract class AWindowNamesActionCommnads : AWindowNamesCommands, IWindowNamesActionProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTimeBetweenFindAndAction))] + [PropertyParameterOrder(10000)] + public virtual string v_WaitTimeBetweenFindAndAction { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_ActivateBeforeAction))] + [PropertyParameterOrder(10010)] + public virtual string v_ActivateBeforeAction { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/AWindowNamesCommands.cs b/taskt/Core/Automation/Commands/WindowGroup/AWindowNamesCommands.cs new file mode 100644 index 000000000..2030dd009 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/AWindowNamesCommands.cs @@ -0,0 +1,29 @@ +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + /// + /// for window names commands + /// + public abstract class AWindowNamesCommands : AWindowNameCoreCommands, IWindowNamesProperties, ICanHandleList + { + /// + /// found window names list + /// + [XmlAttribute] + [PropertyDescription("Variable Name to Store Window Names List")] + [PropertyInstanceType(PropertyInstanceType.InstanceType.List, false)] + public override string v_WindowNameResult { get; set; } + + /// + /// found window handles list + /// + [XmlAttribute] + [PropertyDescription("Variable Name to Store Window Handles List")] + [PropertyInstanceType(PropertyInstanceType.InstanceType.List, false)] + public override string v_WindowHandleResult { get; set; } + + // todo: add sort order? + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/ActivateOneWindowCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/ActivateOneWindowCommand.cs new file mode 100644 index 000000000..e219b5f19 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/ActivateOneWindowCommand.cs @@ -0,0 +1,33 @@ +using System; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("One Window Name Actions")] + [Attributes.ClassAttributes.CommandSettings("Activate One Window")] + [Attributes.ClassAttributes.Description("This command Activate one Window.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Activate one Windown.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class ActivateOneWindowCommand : AOneWindowNameCommands + { + public ActivateOneWindowCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNameAction(engine, new Action((whnd, name) => + { + var activateCommand = new ActivateWindowByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + }; + activateCommand.RunCommand(engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/Window/ActivateWindowByWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/ActivateWindowByWindowHandleCommand.cs similarity index 52% rename from taskt/Core/Automation/Commands/Window/ActivateWindowByWindowHandleCommand.cs rename to taskt/Core/Automation/Commands/WindowGroup/ActivateWindowByWindowHandleCommand.cs index e266e3be7..d8c28e36d 100644 --- a/taskt/Core/Automation/Commands/Window/ActivateWindowByWindowHandleCommand.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/ActivateWindowByWindowHandleCommand.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; namespace taskt.Core.Automation.Commands { @@ -14,6 +15,28 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] public sealed class ActivateWindowByWindowHandleCommand : AWindowHandleCommands { + /// + /// set window state + /// + /// + /// + /// + [DllImport("user32.dll", EntryPoint = "ShowWindow")] + private static extern bool SetWindowState(IntPtr hWnd, int nCmdShow); + + /// + /// set window is ForeGround + /// + /// + /// + [DllImport("User32.dll")] + private static extern IntPtr SetForegroundWindow(IntPtr hWnd); + + /// + /// window state is normal + /// + private const int WINDOW_NORMAL = 1; + //[XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] //public string v_WindowHandle { get; set; } @@ -22,18 +45,28 @@ public sealed class ActivateWindowByWindowHandleCommand : AWindowHandleCommands //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] //public string v_WaitTime { get; set; } + //public string v_WindowTitleResult {get;set;} + public ActivateWindowByWindowHandleCommand() { } public override void RunCommand(Engine.AutomationEngineInstance engine) { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => + //var whnd = this.GetWindowHandle(engine); + //if (IsIconic(whnd)) + //{ + // SetWindowState(whnd, WINDOW_NORMAL); + //} + //SetForegroundWindow(whnd); + this.WindowHandleAction(engine, new Action((whnd) => + { + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowMinimized(whnd)) { - WindowControls.ActivateWindow(whnd); - }) - ); + SetWindowState(whnd, WINDOW_NORMAL); + } + SetForegroundWindow(whnd); + })); } } -} \ No newline at end of file +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/ActivateWindowsCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/ActivateWindowsCommand.cs new file mode 100644 index 000000000..d6371b523 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/ActivateWindowsCommand.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Multi Window Actions")] + [Attributes.ClassAttributes.CommandSettings("Activate Windows")] + [Attributes.ClassAttributes.Description("This command activates windows")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to active a windows by name")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class ActivateWindowsCommand : AWindowNamesCommands + { + public ActivateWindowsCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + foreach((var whnd, _) in wins) + { + var activateWindow = new ActivateWindowByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + }; + activateWindow.RunCommand(engine); + } + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/Window/CheckWindowHandleExistsCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/CheckWindowHandleExistsCommand.cs similarity index 63% rename from taskt/Core/Automation/Commands/Window/CheckWindowHandleExistsCommand.cs rename to taskt/Core/Automation/Commands/WindowGroup/CheckWindowHandleExistsCommand.cs index f0426b049..b3896f600 100644 --- a/taskt/Core/Automation/Commands/Window/CheckWindowHandleExistsCommand.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/CheckWindowHandleExistsCommand.cs @@ -28,22 +28,45 @@ public sealed class CheckWindowHandleExistsCommand : AWindowHandleCommands [XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - [PropertyIsOptional(true, "0")] - [PropertyFirstValue("0")] + //[PropertyIsOptional(true, "0")] + //[PropertyValidationRule("WaitTime", PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + //[PropertyFirstValue("0")] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] public override string v_WaitTimeForWindow { get; set; } + //public string v_WindowTitleResult {get;set;} + public CheckWindowHandleExistsCommand() { } public override void RunCommand(Engine.AutomationEngineInstance engine) { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => + //WindowControls.WindowHandleAction(this, engine, + // new Action(whnd => + // { + // true.StoreInUserVariable(engine, v_Result); + // }), + // new Action(ex => + // { + // false.StoreInUserVariable(engine, v_Result); + // }) + //); + //try + //{ + // this.GetWindowHandle(engine); + // true.StoreInUserVariable(engine, v_Result); + //} + //catch + //{ + // false.StoreInUserVariable(engine, v_Result); + //} + this.WindowHandleAction(engine, + new Action((whnd) => { true.StoreInUserVariable(engine, v_Result); }), - new Action(ex => + new Action((ex) => { false.StoreInUserVariable(engine, v_Result); }) diff --git a/taskt/Core/Automation/Commands/Window/CheckWindowNameExistsCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/CheckWindowNameExistsCommand.cs similarity index 78% rename from taskt/Core/Automation/Commands/Window/CheckWindowNameExistsCommand.cs rename to taskt/Core/Automation/Commands/WindowGroup/CheckWindowNameExistsCommand.cs index 03fade591..c93c744dd 100644 --- a/taskt/Core/Automation/Commands/Window/CheckWindowNameExistsCommand.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/CheckWindowNameExistsCommand.cs @@ -7,7 +7,7 @@ namespace taskt.Core.Automation.Commands { [Serializable] [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window State")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] [Attributes.ClassAttributes.CommandSettings("Check Window Name Exists")] [Attributes.ClassAttributes.Description("This command returns a existence of window name.")] [Attributes.ClassAttributes.UsesDescription("Use this command when you want to check a existence of window name.")] @@ -15,7 +15,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class CheckWindowNameExistsCommand : AAnyWindowNameCommands + public sealed class CheckWindowNameExistsCommand : AWindowNamesCommands { //[XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] @@ -29,7 +29,7 @@ public sealed class CheckWindowNameExistsCommand : AAnyWindowNameCommands [PropertyVirtualProperty(nameof(BooleanControls), nameof(BooleanControls.v_Result))] [Remarks("When Window Exists, Result is **True**")] [PropertyParameterOrder(6100)] - public string v_UserVariableName { get; set; } + public string v_Result { get; set; } [XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] @@ -56,14 +56,25 @@ public CheckWindowNameExistsCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - WindowControls.WindowAction(this, engine, + //WindowControls.WindowAction(this, engine, + // new Action>(wins => + // { + // (wins.Count > 0).StoreInUserVariable(engine, v_UserVariableName); + // }), + // new Action(ex => + // { + // false.StoreInUserVariable(engine, v_UserVariableName); + // }) + //); + + this.WindowNamesAction(engine, new Action>(wins => { - (wins.Count > 0).StoreInUserVariable(engine, v_UserVariableName); + true.StoreInUserVariable(engine, v_Result); }), - new Action(ex => + new Action((ex) => { - false.StoreInUserVariable(engine, v_UserVariableName); + false.StoreInUserVariable(engine, v_Result); }) ); } diff --git a/taskt/Core/Automation/Commands/WindowGroup/CloseOneWindowCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/CloseOneWindowCommand.cs new file mode 100644 index 000000000..9fe3d6fe9 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/CloseOneWindowCommand.cs @@ -0,0 +1,44 @@ +using System; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("One Window Name Actions")] + [Attributes.ClassAttributes.CommandSettings("Close One Window")] + [Attributes.ClassAttributes.Description("This command Close one Window.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Close one Windown.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class CloseOneWindowCommand : AOneWindowNameActionCommands + { + public CloseOneWindowCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //this.WindowNameActionAndWaitActivate(engine, new Action((whnd, name) => + //{ + // var closeWindow = new CloseWindowByWindowHandle() + // { + // v_WindowHandle = whnd.ToString(), + // v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + // }; + // closeWindow.RunCommand(engine); + //})); + this.WindowNameAction(engine, new Action((whnd, name) => + { + var closeWindow = new CloseWindowByWindowHandle() + { + v_WindowHandle = whnd.ToString(), + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + }; + closeWindow.RunCommand(engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/Window/CloseWindowByWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/CloseWindowByWindowHandleCommand.cs similarity index 53% rename from taskt/Core/Automation/Commands/Window/CloseWindowByWindowHandleCommand.cs rename to taskt/Core/Automation/Commands/WindowGroup/CloseWindowByWindowHandleCommand.cs index f25291781..6217daafb 100644 --- a/taskt/Core/Automation/Commands/Window/CloseWindowByWindowHandleCommand.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/CloseWindowByWindowHandleCommand.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; namespace taskt.Core.Automation.Commands { @@ -12,7 +13,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window_close))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class CloseWindowByWindowHandle : AWindowHandleCommands + public sealed class CloseWindowByWindowHandle : AWindowHandleActionCommands { //[XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] @@ -22,18 +23,43 @@ public sealed class CloseWindowByWindowHandle : AWindowHandleCommands //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] //public string v_WaitTime { get; set; } + //public string v_WindowTitleResult {get;set;} + + /// + /// for close window by whnd + /// + /// + /// + /// + /// + /// + [DllImport("user32.dll")] + private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam); + + /// + /// close value + /// + private static readonly UInt32 WM_CLOSE = 0x0010; + public CloseWindowByWindowHandle() { } public override void RunCommand(Engine.AutomationEngineInstance engine) { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => - { - WindowControls.CloseWindow(whnd); - }) - ); + //WindowControls.WindowHandleAction(this, engine, + // new Action(whnd => + // { + // WindowControls.CloseWindow(whnd); + // }) + //); + //var whnd = this.GetWindowHandle(engine); + //SendMessage(whnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); + + this.WindowHandleActionBeforeWaitActivate(engine, new Action((whnd) => + { + SendMessage(whnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero); + })); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/CloseWindowsCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/CloseWindowsCommand.cs new file mode 100644 index 000000000..b93215b1a --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/CloseWindowsCommand.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Multi Window Actions")] + [Attributes.ClassAttributes.CommandSettings("Close Windows")] + [Attributes.ClassAttributes.Description("This command closes windows.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to close an existing windows by name.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window_close))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class CloseWindowsCommand : AWindowNamesActionCommnads + { + public CloseWindowsCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + foreach ((var whnd, _) in wins) + { + var closeWindow = new CloseWindowByWindowHandle() + { + v_WindowHandle = whnd.ToString(), + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + }; + closeWindow.RunCommand(engine); + } + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_CanHandleDesktopWindowHandleExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_CanHandleDesktopWindowHandleExtensionMethods.cs new file mode 100644 index 000000000..0954800cc --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_CanHandleDesktopWindowHandleExtensionMethods.cs @@ -0,0 +1,20 @@ +using System; +using System.Runtime.InteropServices; + +namespace taskt.Core.Automation.Commands.WindowGroup +{ + public static class EM_CanHandleDesktopWindowHandleExtensionMethods + { + [DllImport("user32.dll", SetLastError = false)] + private static extern IntPtr GetDesktopWindow(); + + /// + /// get Desktop Window Handle + /// + /// + public static IntPtr GetDesktopWindowHandle() + { + return GetDesktopWindow(); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_CanHandleWindowHandleExtentionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_CanHandleWindowHandleExtentionMethods.cs new file mode 100644 index 000000000..d32483a82 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_CanHandleWindowHandleExtentionMethods.cs @@ -0,0 +1,182 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace taskt.Core.Automation.Commands +{ + public class EM_CanHandleWindowHandleExtentionMethods + { + /// + /// templorary window handles list + /// + private static List windowHandle = null; + + /// + /// check window handle exists + /// + /// + /// + [DllImport("user32.dll")] + private static extern bool IsWindow(IntPtr hWnd); + + /// + /// get window title length + /// + /// + /// + [DllImport("user32.dll")] + private static extern int GetWindowTextLengthW(IntPtr hWnd); + + /// + /// get window title + /// + /// + /// + /// + /// + [DllImport("user32.dll", CharSet = CharSet.Unicode)] + private static extern int GetWindowTextW(IntPtr hWnd, StringBuilder text, int count); + + /// + /// check window is minimized + /// + /// + /// + [DllImport("user32.dll")] + private static extern bool IsIconic(IntPtr hWnd); + + /// + /// check window is maximized + /// + /// + /// + [DllImport("user32.dll")] + private static extern bool IsZoomed(IntPtr hWhnd); + + /// + /// get active window handle + /// + /// + [DllImport("user32.dll")] + private static extern IntPtr GetForegroundWindow(); + + /// + /// enum window delegate + /// + /// + /// + /// + public delegate bool EnumWindowsDelegate(IntPtr hWnd, IntPtr lparam); + + /// + /// enum all windows + /// + /// + /// + /// + [DllImport("user32.dll")] + public static extern int EnumWindows(EnumWindowsDelegate lpEnumFunc, IntPtr lparam); + + /// + /// check window is visible + /// + /// + /// + [DllImport("user32.dll")] + public static extern bool IsWindowVisible(IntPtr hWnd); + + /// + /// check window handle exists + /// + /// + /// + public static bool CheckWindowHandleExists(IntPtr wHnd) + { + return IsWindow(wHnd); + } + + /// + /// check window is minimized + /// + /// + /// + public static bool IsWindowMinimized(IntPtr wHnd) + { + return IsIconic(wHnd); + } + + /// + /// check window is maximized + /// + /// + /// + public static bool IsWindowMaximized(IntPtr wHnd) + { + return IsZoomed(wHnd); + } + + /// + /// get window name + /// + /// + /// + public static string GetWindowName(IntPtr wHnd) + { + int titleLengthA = GetWindowTextLengthW(wHnd); + StringBuilder title = new StringBuilder(titleLengthA + 1); + GetWindowTextW(wHnd, title, title.Capacity); + return title.ToString(); + } + + /// + /// get window handle + /// + /// + public static IntPtr GetActiveWindowHandle() + { + return GetForegroundWindow(); + } + + /// + /// check text is current window handle keyword + /// + /// + /// + /// + public static bool IsCurrentWindowHandleKeyword(string str, Engine.AutomationEngineInstance engine) + { + return (str == VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowHandle.VariableName, engine)); + } + + /// + /// enum windows + /// + /// + /// + /// + private static bool EnumerateWindowHandle(IntPtr wHnd, IntPtr lParam) + { + if (IsWindowVisible(wHnd)) + { + windowHandle.Add(wHnd); + } + return true; + } + + /// + /// get all window handles + /// + /// + public static List GetAllWindowHandles() + { + windowHandle = new List(); + + EnumWindows(new EnumWindowsDelegate(EnumerateWindowHandle), IntPtr.Zero); + + var ret = new List(windowHandle); + windowHandle = null; + return ret; + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_CanHandleWindowNameExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_CanHandleWindowNameExtensionMethods.cs new file mode 100644 index 000000000..bd00fd855 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_CanHandleWindowNameExtensionMethods.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_CanHandleWindowNameExtensionMethods + { + /// + /// templorary window handle name pair + /// + private static List<(IntPtr, string)> windowHandleNamePair = null; + + ///// + ///// enum window delegate + ///// + ///// + ///// + ///// + //private delegate bool EnumWindowsDelegate(IntPtr hWnd, IntPtr lparam); + + ///// + ///// enum all windows + ///// + ///// + ///// + ///// + //[DllImport("user32.dll")] + //private static extern int EnumWindows(EnumWindowsDelegate lpEnumFunc, IntPtr lparam); + + ///// + ///// check window is visible + ///// + ///// + ///// + //[DllImport("user32.dll")] + //private static extern bool IsWindowVisible(IntPtr hWnd); + + /// + /// enum window names + /// + /// + /// + /// + private static bool EnumerateWindowNames(IntPtr hWnd, IntPtr lParam) + { + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowVisible(hWnd)) + { + var title = EM_CanHandleWindowHandleExtentionMethods.GetWindowName(hWnd); + windowHandleNamePair.Add((hWnd, title)); + } + return true; + } + + /// + /// get window names and handles + /// + /// + public static List<(IntPtr, string)> GetAllWindowNamesAndHandles() + { + windowHandleNamePair = CreateEmptyWindowNameAndHandleList(); + + EM_CanHandleWindowHandleExtentionMethods.EnumWindows(new EM_CanHandleWindowHandleExtentionMethods.EnumWindowsDelegate(EnumerateWindowNames), IntPtr.Zero); + + var ret = new List<(IntPtr, string)>(windowHandleNamePair); + windowHandleNamePair = null; + return ret; + } + + /// + /// get all window names + /// + /// + /// + public static List GetAllWindowNames(bool useDistinct = true) + { + var t = GetAllWindowNamesAndHandles().Select(item => item.Item2); + if (useDistinct) + { + t = t.Distinct(); + } + return t.ToList(); + } + + /// + /// get active window name + /// + /// + public static string GetActiveWindowName() + { + return EM_CanHandleWindowHandleExtentionMethods.GetWindowName(EM_CanHandleWindowHandleExtentionMethods.GetActiveWindowHandle()); + } + + /// + /// create empty window name and handle list + /// + /// + public static List<(IntPtr, string)> CreateEmptyWindowNameAndHandleList() + { + return new List<(IntPtr, string)>(); + } + + /// + /// check text is current window name keyword + /// + /// + /// + /// + public static bool IsCurrentWindowNameKeyword(string str, Engine.AutomationEngineInstance engine) + { + return (str == VariableNameControls.GetWrappedVariableName(Engine.SystemVariables.Window_CurrentWindowName.VariableName, engine)); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_FromWindowHandlePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_FromWindowHandlePropertiesExtensionMethods.cs new file mode 100644 index 000000000..c22d30785 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_FromWindowHandlePropertiesExtensionMethods.cs @@ -0,0 +1,19 @@ +namespace taskt.Core.Automation.Commands.WindowGroup +{ + public static class EM_FromWindowHandlePropertiesExtensionMethods + { + /// + /// store window name result in user variable + /// + /// + /// + /// + public static void StoreWindowNameResultInUserVariable(this IFromWindowHandleResultsProperties command, string windowName, Engine.AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(command.v_WindowNameResult)) + { + windowName.StoreInUserVariable(engine, command.v_WindowNameResult); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_FromWindowNameResultPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_FromWindowNameResultPropertiesExtensionMethods.cs new file mode 100644 index 000000000..d69a7db71 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_FromWindowNameResultPropertiesExtensionMethods.cs @@ -0,0 +1,44 @@ +using System; + +namespace taskt.Core.Automation.Commands.WindowGroup +{ + public static class EM_FromWindowNameResultPropertiesExtensionMethods + { + /// + /// store window handle in user variable + /// + /// + /// + /// + public static void StoreWindowHandleInUserVariable(this IFromWindowNameResultsProperties command, IntPtr windowHandle, Engine.AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(command.v_WindowHandleResult)) + { + windowHandle.StoreInUserVariable(engine, command.v_WindowHandleResult); + } + } + + /// + /// store window name and window handle results in user variables + /// + /// + /// + /// + /// + public static void StoreWindowNameAndWindowHandleResultsInUserVariables(this IFromWindowNameResultsProperties command, string windowName, IntPtr windowHandle, Engine.AutomationEngineInstance engine) + { + command.StoreWindowNameResultInUserVariable(windowName, engine); + command.StoreWindowHandleInUserVariable(windowHandle, engine); + } + + /// + /// check window name or window handle results is specified + /// + /// + /// + public static bool IsWindowNameOrWindowHandleResultsSpecified(this IFromWindowNameResultsProperties command) + { + return (!string.IsNullOrEmpty(command.v_WindowNameResult)) || (!string.IsNullOrEmpty(command.v_WindowHandleResult)); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_OneWindowNamePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_OneWindowNamePropertiesExtensionMethods.cs new file mode 100644 index 000000000..c9977cfc9 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_OneWindowNamePropertiesExtensionMethods.cs @@ -0,0 +1,118 @@ +using System; +using System.Linq; +using taskt.Core.Automation.Commands.WindowGroup; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_OneWindowNamePropertiesExtensionMethods + { + /// + /// expand value or user variable as window index + /// + /// + /// + /// + public static int ExpandValueOrUserVariableAsWindowIndex(this IOneWindowNameProperties command, AutomationEngineInstance engine) + { + return ((ScriptCommand)command).ExpandValueOrUserVariableAsInteger(nameof(command.v_TargetWindowIndex), engine); + } + + ///// + ///// store window name result + ///// + ///// + ///// + ///// + //public static void StoreWindowNameResultInUserVariable(this IOneWindowNameProperties command, string name, AutomationEngineInstance engine) + //{ + // if (!string.IsNullOrEmpty(command.v_WindowNameResult)) + // { + // name.StoreInUserVariable(engine, command.v_WindowNameResult); + // } + //} + + ///// + ///// store window handle result + ///// + ///// + ///// + ///// + //public static void StoreWindowHandleResultInUserVariable(this IOneWindowNameProperties command, IntPtr whnd, AutomationEngineInstance engine) + //{ + // if (!string.IsNullOrEmpty(command.v_WindowHandleResult)) + // { + // whnd.StoreInUserVariable(engine, command.v_WindowHandleResult); + // } + //} + + /// + /// wait for window name + /// + /// + /// + /// + /// + public static (IntPtr whnd, string name) WaitForWindowName(this IOneWindowNameProperties command, AutomationEngineInstance engine) + { + var wins = command.WaitForWindowNames(engine); + (IntPtr whnd, string name) windowSet = (IntPtr.Zero, null); + switch(((ScriptCommand)command).ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_SelectionMethod), engine)) + { + case "first": + windowSet = wins[0]; + break; + case "last": + windowSet = wins[wins.Count() - 1]; + break; + case "index": + var idx = command.ExpandValueOrUserVariableAsWindowIndex(engine); + if (idx < 0) + { + idx += wins.Count(); + } + if (idx >= 0 && idx < wins.Count()) + { + windowSet = wins[idx]; + } + else + { + throw new Exception($"Strange Window Index. Value: '{command.v_TargetWindowIndex}_', Expand Value: '{idx}', Windows Count: '{wins.Count()}'"); + } + break; + } + return windowSet; + } + + /// + /// window name action + /// + /// + /// + /// + /// + public static void WindowNameAction(this IOneWindowNameProperties command, AutomationEngineInstance engine, Action actionFunc, Action errorFunc = null) + { + try + { + (var whnd, var name) = command.WaitForWindowName(engine); + actionFunc(whnd, name); + //command.StoreWindowNameResultInUserVariable(name, engine); + //command.StoreWindowHandleResultInUserVariable(whnd, engine); + + command.StoreWindowNameAndWindowHandleResultsInUserVariables(name, whnd, engine); + } + catch (Exception ex) + { + if (errorFunc != null) + { + errorFunc(ex); + } + else + { + throw ex; + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_WindowActivatePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowActivatePropertiesExtensionMethods.cs new file mode 100644 index 000000000..f7c430a54 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowActivatePropertiesExtensionMethods.cs @@ -0,0 +1,25 @@ +using System; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_WindowActivatePropertiesExtensionMethods + { + /// + /// window activate process + /// + /// + /// + public static void ActivateWindowProcess(this IWindowActivateProperties command, IntPtr whnd, AutomationEngineInstance engine) + { + if (((ScriptCommand)command).ExpandValueOrUserVariableAsYesNo(nameof(command.v_ActivateBeforeAction), engine)) + { + var activate = new ActivateWindowByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + }; + activate.RunCommand(engine); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_WindowHandleActionPropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowHandleActionPropertiesExtentionMethods.cs new file mode 100644 index 000000000..0c51b3a78 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowHandleActionPropertiesExtentionMethods.cs @@ -0,0 +1,28 @@ +using System; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_WindowHandleActionPropertiesExtentionMethods + { + /// + /// window handle action and wait/activate before execute action + /// + /// + /// + /// + public static void WindowHandleActionBeforeWaitActivate(this IWindowHandleActionPropeties command, AutomationEngineInstance engine, Action actionFunc, Action errorFunc = null) + { + command.WindowHandleAction(engine, + new Action((w) => + { + command.ActivateWindowProcess(w, engine); + + command.WaitAfterFindWindowProcess(engine); + actionFunc(w); + }), + errorFunc + ); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_WindowHandlePropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowHandlePropertiesExtentionMethods.cs new file mode 100644 index 000000000..cc7ddfe08 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowHandlePropertiesExtentionMethods.cs @@ -0,0 +1,150 @@ +using System; +using taskt.Core.Automation.Commands.WindowGroup; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_WindowHandlePropertiesExtentionMethods + { + /// + /// expand value or user variable as WindowHandle + /// + /// + /// + /// + /// + public static IntPtr ExpandValueOrUserVariableAsWindowHandle(this IWindowHandleProperties command, AutomationEngineInstance engine) + { + if (command.v_WindowHandle == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentWindowHandle.VariableName, engine)) + { + return EM_CanHandleWindowHandleExtentionMethods.GetActiveWindowHandle(); + } + else + { + var whnd = ((ScriptCommand)command).ExpandValueOrUserVariableAsInteger(nameof(command.v_WindowHandle), "WindowHandle", engine); + if (whnd >= 0) + { + return (IntPtr)whnd; + } + else + { + throw new Exception($"Strange WindowHandle Value. Value: '{whnd}'"); + } + } + } + + /// + /// expand value or user variable as WidowHandle wait time + /// + /// + /// + /// + public static int ExpandValueOrUserVariableAsWaitTimeForWindowHandle(this IWindowHandleProperties command, AutomationEngineInstance engine) + { + return ((ScriptCommand)command).ExpandValueOrUserVariableAsInteger(nameof(command.v_WaitTimeForWindow), "Window Wait Time", engine); + } + + /// + /// expand value or user variable as WindowHandle and WaitTime for window handle + /// + /// + /// + /// (handle, wait time) + public static (IntPtr, int) ExpandValueOrUserVariableAsWindowHandleAndWaitTime(this IWindowHandleProperties command, AutomationEngineInstance engine) + { + return (command.ExpandValueOrUserVariableAsWindowHandle(engine), command.ExpandValueOrUserVariableAsWaitTimeForWindowHandle(engine)); + } + + ///// + ///// store window title to user variable + ///// + ///// + ///// + ///// + //public static void StoreWindowTitleInUserVariable(this IWindowHandleProperties command, string title, AutomationEngineInstance engine) + //{ + // if (!string.IsNullOrEmpty(command.v_WindowNameResult)) + // { + // title.StoreInUserVariable(engine, command.v_WindowNameResult); + // } + //} + + /// + /// wait for window handle + /// + /// + /// + /// + /// + public static IntPtr WaitForWindowHandle(this IWindowHandleProperties command, AutomationEngineInstance engine) + { + (var whnd, var waitTime) = command.ExpandValueOrUserVariableAsWindowHandleAndWaitTime(engine); + var ret = WaitControls.WaitProcess(waitTime, "WindowHandle", + new Func<(bool, object)>(() => + { + if (EM_CanHandleWindowHandleExtentionMethods.CheckWindowHandleExists(whnd)) + { + return (true, whnd); + } + else + { + return (false, null); + } + }), engine + ); + if (ret is IntPtr handle) + { + return handle; + } + else + { + throw new Exception($"Window Handle does not Exists. Value: '{command.v_WindowHandle}', Expand Value: '{whnd}'"); + } + } + + /// + /// check specified current window handle keyword + /// + /// + /// + /// + public static bool IsCurrentWindowHandleKeyword(this IWindowHandleProperties command, AutomationEngineInstance engine) + { + return EM_CanHandleWindowHandleExtentionMethods.IsCurrentWindowHandleKeyword(command.v_WindowHandle, engine); + } + + /// + /// window handle action + /// + /// + /// + /// + /// + public static void WindowHandleAction(this IWindowHandleProperties command, AutomationEngineInstance engine, Action actionFunc, Action errorFunc = null) + { + try + { + var whnd = command.WaitForWindowHandle(engine); + + // get window title before handle expired + var title = EM_CanHandleWindowHandleExtentionMethods.GetWindowName(whnd); + + actionFunc(whnd); + + //command.StoreWindowTitleInUserVariable(title, engine); + command.StoreWindowNameResultInUserVariable(title, engine); + } + catch (Exception ex) + { + if (errorFunc != null) + { + errorFunc(ex); + } + else + { + throw ex; + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_WindowNameCorePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowNameCorePropertiesExtensionMethods.cs new file mode 100644 index 000000000..0ea803b8f --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowNameCorePropertiesExtensionMethods.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using taskt.Core.Automation.Commands.TextGroup; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_WindowNameCorePropertiesExtensionMethods + { + ///// + ///// get window name check method + ///// + ///// + ///// + ///// Func(a,b) is a.Contains(b) + ///// + //public static Func GetWindowNameCheckMethod(this IWindowNameCoreProperties command, AutomationEngineInstance engine) + //{ + // switch (((ScriptCommand)command).ExpandValueOrUserVariableAsSelectionItem(nameof(command.v_CompareMethod), engine)) + // { + // case "contains": + // return new Func((a, b) => { return a.Contains(b); }); + + // case "starts with": + // return new Func((a, b) => { return a.StartsWith(b); }); + + // case "ends with": + // return new Func((a, b) => { return a.EndsWith(b); }); + + // case "exact match": + // return new Func((a, b) => { return (a == b); }); + // default: + // throw new Exception($"Error. Strange method. Value: '{command.v_CompareMethod}'"); + // } + //} + + /// + /// expand value or user variable as window name + /// + /// + /// + /// + public static string ExpandValueOrUserVariableAsWindowName(this IWindowNameCoreProperties command, AutomationEngineInstance engine) + { + if (command.v_WindowName == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentWindowName.VariableName, engine)) + { + return EM_CanHandleWindowNameExtensionMethods.GetActiveWindowName(); + } + else + { + return ((ScriptCommand)command).ExpandValueOrUserVariable(nameof(command.v_WindowName), "Window Name", engine); + } + } + + /// + /// expand value or user variable as Window Wait Time + /// + /// + /// + /// + /// + public static int ExpandValueOrUserVariableAsWindowWaitTime(this IWindowNameCoreProperties command, AutomationEngineInstance engine) + { + var wait = ((ScriptCommand)command).ExpandValueOrUserVariableAsInteger(nameof(command.v_WaitTimeForWindow), engine); + if (wait >= 0) + { + return wait; + } + else + { + throw new Exception($"Strange Window Wait Time. Value: '{command.v_WaitTimeForWindow}', Expand Value: '{wait}'"); + } + } + + /// + /// expand value or user variable as window name, window wait time, and check method + /// + /// + /// + /// Func(a,b) is like a.Contains(b) + public static (string, int, Func) ExpandValueOrUserVariableAsWindowNameWindowWaitTimeAndMethod(this IWindowNameCoreProperties command, AutomationEngineInstance engine) + { + // all window system variable + if (command.v_WindowName == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_AllWindows.VariableName, engine)) + { + return ("", command.ExpandValueOrUserVariableAsWindowWaitTime(engine), + new Func((a, b) => true)); + } + else + { + return (command.ExpandValueOrUserVariableAsWindowName(engine), command.ExpandValueOrUserVariableAsWindowWaitTime(engine), + command.GetTextCheckFunction(engine)); + } + } + + /// + /// check specified current window name keyword + /// + /// + /// + /// + public static bool IsCurrentWindowNameKeyword(this IWindowNameCoreProperties command, AutomationEngineInstance engine) + { + return EM_CanHandleWindowNameExtensionMethods.IsCurrentWindowNameKeyword(command.v_WindowName, engine); + } + + /// + /// wait for window names + /// + /// + /// + /// + /// + public static List<(IntPtr, string)> WaitForWindowNames(this IWindowNameCoreProperties command, AutomationEngineInstance engine) + { + (var windowName, var waitTime, var checkFunc) = command.ExpandValueOrUserVariableAsWindowNameWindowWaitTimeAndMethod(engine); + + var ret = WaitControls.WaitProcess(waitTime, "Window Name", new Func<(bool, object)>(() => + { + var allWindows = EM_CanHandleWindowNameExtensionMethods.GetAllWindowNamesAndHandles(); + var matchWindows = new List<(IntPtr, string)>(); + foreach ((var whnd, var name) in allWindows) + { + if (checkFunc(name, windowName)) + { + matchWindows.Add((whnd, name)); + } + } + if (matchWindows.Count > 0) + { + return (true, matchWindows); + } + else + { + return (false, null); + } + }), engine); + + if (ret is List<(IntPtr, string)> wins) + { + if (wins.Count > 0) + { + return wins; + } + else + { + throw new Exception($"Target Window not Found. Value: '{command.v_WindowName}', Expand Value: '{windowName}'"); + } + } + else + { + throw new Exception($"Target Window not Found. Value: '{command.v_WindowName}', Expand Value: '{windowName}'"); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_WindowNamesPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowNamesPropertiesExtensionMethods.cs new file mode 100644 index 000000000..54154d59a --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowNamesPropertiesExtensionMethods.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_WindowNamesPropertiesExtensionMethods + { + + /// + /// store window name result to user variable + /// + /// + /// + /// + public static void StoreWindowNameResultInUserVariable(this IWindowNamesProperties command, List result, AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(command.v_WindowNameResult)) + { + result.StoreInUserVariable(engine, command.v_WindowNameResult); + } + } + + /// + /// store window handle result in user variable + /// + /// + /// + /// + public static void StoreWindowHandleResultInUserVariable(this IWindowNamesProperties command, List result, AutomationEngineInstance engine) + { + if (!string.IsNullOrEmpty(command.v_WindowHandleResult)) + { + result.StoreInUserVariable(engine, command.v_WindowHandleResult); + } + } + + /// + /// store window name and handle in user variable + /// + /// + /// + /// + /// + public static void StoreWindowNameAndHandleResultsInUserVariables(this IWindowNamesProperties command, List names, List handles, AutomationEngineInstance engine) + { + command.StoreWindowNameResultInUserVariable(names, engine); + command.StoreWindowHandleResultInUserVariable(handles, engine); + } + + /// + /// convert match window to window name and window handle list + /// + /// + /// (name, handle) + private static (List, List) ConvertWindowNameAndWindowHandleList(List<(IntPtr, string)> windows) + { + var handles = new List(); + var names = new List(); + foreach ((var whnd, var name) in windows) + { + handles.Add(whnd.ToString()); + names.Add(name); + } + return (names, handles); + } + + /// + /// window names action + /// + /// + /// + public static void WindowNamesAction(this IWindowNamesProperties command, AutomationEngineInstance engine, Action> actionFunc, Action errorFunc = null) + { + try + { + var wins = command.WaitForWindowNames(engine); + + actionFunc(wins); + + (var names, var handles) = ConvertWindowNameAndWindowHandleList(wins); + command.StoreWindowNameAndHandleResultsInUserVariables(names, handles, engine); + } + catch (Exception ex) + { + if (errorFunc != null) + { + errorFunc(ex); + } + else + { + throw ex; + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/Window/EM_WindowPositionPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowPositionPropertiesExtensionMethods.cs similarity index 69% rename from taskt/Core/Automation/Commands/Window/EM_WindowPositionPropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/WindowGroup/EM_WindowPositionPropertiesExtensionMethods.cs index 491dcee10..939591c87 100644 --- a/taskt/Core/Automation/Commands/Window/EM_WindowPositionPropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowPositionPropertiesExtensionMethods.cs @@ -8,6 +8,17 @@ namespace taskt.Core.Automation.Commands /// public static class EM_WindowPositionPropertiesExtensionMethods { + /// + /// get window position + /// + /// + /// (top, left) + public static (int, int) GetWindowPosition(IntPtr whnd) + { + var rect = EM_WindowRECTPropertiesExtentionMethods.GetWindowRect(whnd); + return (rect.top, rect.left); + } + /// /// expand value or variable as Window X Position /// @@ -18,16 +29,16 @@ public static class EM_WindowPositionPropertiesExtensionMethods public static int ExpandValueOrVariableAsWindowXPosition(this IWindowPositionProperties command, IntPtr whnd, AutomationEngineInstance engine) { var v = command.v_XPosition; - var rect = WindowControls.GetWindowRect(whnd); + (var top, var left) = GetWindowPosition(whnd); if ((v == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentPosition.VariableName, engine)) || (v == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentXPosition.VariableName, engine))) { - return rect.left; + return left; } else if (v == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentYPosition.VariableName, engine)) { - return rect.top; + return top; } else { @@ -45,21 +56,33 @@ public static int ExpandValueOrVariableAsWindowXPosition(this IWindowPositionPro public static int ExpandValueOrVariableAsWindowYPosition(this IWindowPositionProperties command, IntPtr whnd, AutomationEngineInstance engine) { var v = command.v_YPosition; - var rect = WindowControls.GetWindowRect(whnd); + (var top, var left) = GetWindowPosition(whnd); if ((v == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentPosition.VariableName, engine)) || (v == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentYPosition.VariableName, engine))) { - return rect.top; + return top; } else if (v == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentXPosition.VariableName, engine)) { - return rect.left; + return left; } else { return v.ExpandValueOrUserVariableAsInteger("Window Y Position", engine); } } + + /// + /// move window + /// + /// + /// + /// + public static void MoveWindow(IntPtr whnd, int x, int y) + { + const uint flag = 0x0045; // 0x0001 | 0x0004 | 0x0040; + EM_WindowRECTPropertiesExtentionMethods.SetWindowPos(whnd, 0, x, y, 0, 0, flag); + } } } diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_WindowRECTPropertiesExtentionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowRECTPropertiesExtentionMethods.cs new file mode 100644 index 000000000..7c35ad592 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowRECTPropertiesExtentionMethods.cs @@ -0,0 +1,42 @@ +using System; +using System.Runtime.InteropServices; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_WindowRECTPropertiesExtentionMethods + { + /// + /// get window rect + /// + /// + /// + /// + [DllImport("user32.dll")] + private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); + + /// + /// move or resize window + /// + /// + /// + /// + /// + /// + /// + /// + /// + [DllImport("user32.dll")] + public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, uint wFlags); + + /// + /// get window rect + /// + /// + /// + public static RECT GetWindowRect(IntPtr whnd) + { + GetWindowRect(whnd, out RECT r); + return r; + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_WindowResizePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowResizePropertiesExtensionMethods.cs new file mode 100644 index 000000000..7b76829c3 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowResizePropertiesExtensionMethods.cs @@ -0,0 +1,20 @@ +using System; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_WindowResizePropertiesExtensionMethods + { + + /// + /// resize window + /// + /// + /// + /// + public static void ResizeWindow(IntPtr whnd, int width, int height) + { + uint flag = 0x0046; // 0x0002 | 0x0004 | 0x0040; + EM_WindowRECTPropertiesExtentionMethods.SetWindowPos(whnd, 0, 0, 0, width, height, flag); + } + } +} diff --git a/taskt/Core/Automation/Commands/Window/EM_WindowSizePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowSizePropertiesExtensionMethods.cs similarity index 79% rename from taskt/Core/Automation/Commands/Window/EM_WindowSizePropertiesExtensionMethods.cs rename to taskt/Core/Automation/Commands/WindowGroup/EM_WindowSizePropertiesExtensionMethods.cs index 5709b3ee2..bdb823289 100644 --- a/taskt/Core/Automation/Commands/Window/EM_WindowSizePropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowSizePropertiesExtensionMethods.cs @@ -8,6 +8,17 @@ namespace taskt.Core.Automation.Commands /// public static class EM_WindowSizePropertiesExtensionMethods { + /// + /// get window size + /// + /// + /// (width, height) + public static (int, int) GetWindowSize(IntPtr whnd) + { + var r = EM_WindowRECTPropertiesExtentionMethods.GetWindowRect(whnd); + return (r.GetWidth(), r.GetHeight()); + } + /// /// expand value or variable as Window Width /// @@ -18,16 +29,16 @@ public static class EM_WindowSizePropertiesExtensionMethods public static int ExpandValueOrVariableAsWindowWidth(this IWindowSizeProperties command, IntPtr whnd, AutomationEngineInstance engine) { var w = command.v_Width; - var rect = WindowControls.GetWindowRect(whnd); + (var width, var height) = GetWindowSize(whnd); if ((w == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentSize.VariableName, engine)) || (w == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentWidth.VariableName, engine))) { - return rect.GetWidth(); + return width; } else if (w == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentHeight.VariableName, engine)) { - return rect.GetHeight(); + return height; } else { @@ -45,16 +56,16 @@ public static int ExpandValueOrVariableAsWindowWidth(this IWindowSizeProperties public static int ExpandValueOrVariableAsWindowHeight(this IWindowSizeProperties command, IntPtr whnd, AutomationEngineInstance engine) { var w = command.v_Height; - var rect = WindowControls.GetWindowRect(whnd); + (var width, var height) = GetWindowSize(whnd); if ((w == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentSize.VariableName, engine)) || (w == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentHeight.VariableName, engine))) { - return rect.GetHeight(); + return height; } else if (w == VariableNameControls.GetWrappedVariableName(SystemVariables.Window_CurrentWidth.VariableName, engine)) { - return rect.GetWidth(); + return width; } else { diff --git a/taskt/Core/Automation/Commands/WindowGroup/EM_WindowWaitTimeBetweenFindAndActionPropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowWaitTimeBetweenFindAndActionPropertiesExtensionMethods.cs new file mode 100644 index 000000000..c3b0189fb --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/EM_WindowWaitTimeBetweenFindAndActionPropertiesExtensionMethods.cs @@ -0,0 +1,32 @@ +using taskt.Core.Automation.Engine; + +namespace taskt.Core.Automation.Commands +{ + public static class EM_WindowWaitTimeBetweenFindAndActionPropertiesExtensionMethods + { + /// + /// expand value or user variable as wait time between find and action + /// + /// + /// + /// + public static double ExpandValueOrUserVariableAsWaitTimeBetweenFindAndAction(this IWindowWaitTimeBetweenFindAndActionProperties command, AutomationEngineInstance engine) + { + return (double)((ScriptCommand)command).ExpandValueOrUserVariableAsDecimal(nameof(command.v_WaitTimeBetweenFindAndAction), engine); + } + + /// + /// wait process after window found + /// + /// + /// + public static void WaitAfterFindWindowProcess(this IWindowWaitTimeBetweenFindAndActionProperties command, AutomationEngineInstance engine) + { + var waitTime = command.ExpandValueOrUserVariableAsWaitTimeBetweenFindAndAction(engine); + if (waitTime > 0) + { + System.Threading.Thread.Sleep((int)(waitTime * 1000)); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetOneProcessNameFromOneWindowNameCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetOneProcessNameFromOneWindowNameCommand.cs new file mode 100644 index 000000000..328e3e900 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetOneProcessNameFromOneWindowNameCommand.cs @@ -0,0 +1,42 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get One Process Name From One Window Name")] + [Attributes.ClassAttributes.Description("This command returns one window process name.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get one window process name.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetOneProcessNameFromOneWindowNameCommand : AOneWindowNameCommands + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyParameterOrder(6500)] + public string v_Result { get; set; } + + public GetOneProcessNameFromOneWindowNameCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNameAction(engine, new Action((whnd, name) => + { + var getProcess = new GetProcessNameFromWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_Result = this.v_Result, + }; + getProcess.RunCommand(engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowHandleFromOneWindowNameCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowHandleFromOneWindowNameCommand.cs new file mode 100644 index 000000000..4a259c415 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowHandleFromOneWindowNameCommand.cs @@ -0,0 +1,37 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get One Window Handle From One Window Name")] + [Attributes.ClassAttributes.Description("This command returns one window handle.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get one window handle.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetOneWindowHandleFromOneWindowNameCommand : AOneWindowNameCommands + { + [XmlAttribute] + [PropertyValidationRule("Window Handle", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyIsOptional(false)] + [PropertyParameterOrder(6500)] + public override string v_WindowHandleResult { get; set; } + + public GetOneWindowHandleFromOneWindowNameCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNameAction(engine, new Action((whnd, name) => + { + whnd.StoreInUserVariable(engine, v_WindowHandleResult); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowPositionCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowPositionCommand.cs new file mode 100644 index 000000000..4bfb951dc --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowPositionCommand.cs @@ -0,0 +1,83 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get One Window Position")] + [Attributes.ClassAttributes.Description("This command returns one window position.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want one window position.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetOneWindowPositionCommand : AOneWindowNameCommands, IWindowPositionProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Position X")] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "")] + [PropertyParameterOrder(6500)] + public string v_XPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Position Y")] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "")] + [PropertyParameterOrder(6500)] + public string v_YPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_PositionBase))] + //[PropertyDescription("Base position")] + //[InputSpecification("", true)] + //[SampleUsage("")] + //[Remarks("")] + //[PropertyUISelectionOption("Top Left")] + //[PropertyUISelectionOption("Bottom Right")] + //[PropertyUISelectionOption("Top Right")] + //[PropertyUISelectionOption("Bottom Left")] + //[PropertyUISelectionOption("Center")] + //[PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] + //[PropertyIsOptional(true, "Top Left")] + [PropertyParameterOrder(6500)] + public string v_PositionBase { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMaximizedForGet))] + [PropertyIsOptional(true, "Execute")] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + public GetOneWindowPositionCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNameAction(engine, new Action((whnd, name) => + { + var getPosition = new GetWindowPositionFromWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_PositionBase = this.v_PositionBase, + v_XPosition = this.v_XPosition, + v_YPosition = this.v_YPosition, + v_WhenWindowIsMaximized = this.v_WhenWindowIsMaximized, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + }; + getPosition.RunCommand(engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/Window/GetWindowSizeFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowSizeCommand.cs similarity index 50% rename from taskt/Core/Automation/Commands/Window/GetWindowSizeFromWindowHandleCommand.cs rename to taskt/Core/Automation/Commands/WindowGroup/GetOneWindowSizeCommand.cs index 9d002a99a..0213b6a20 100644 --- a/taskt/Core/Automation/Commands/Window/GetWindowSizeFromWindowHandleCommand.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowSizeCommand.cs @@ -6,27 +6,22 @@ namespace taskt.Core.Automation.Commands { [Serializable] [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Get From Window Handle")] - [Attributes.ClassAttributes.CommandSettings("Get Window Size From Window Handle")] - [Attributes.ClassAttributes.Description("This command returns window size.")] - [Attributes.ClassAttributes.UsesDescription("Use this command when you want window size.")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get One Window Size")] + [Attributes.ClassAttributes.Description("This command returns one window size.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want one window size.")] [Attributes.ClassAttributes.ImplementationDescription("")] [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetWindowSizeFromWindowHandleCommand : AWindowHandleCommands, IWindowSizeProperties + public sealed class GetOneWindowSizeCommand : AOneWindowNameCommands, IWindowSizeProperties { - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] - //public string v_WindowHandle { get; set; } - - [XmlAttribute] [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] [PropertyDescription("Variable Name to Recieve the Window Width")] [PropertyIsOptional(true)] [PropertyDisplayText(false, "")] - [PropertyParameterOrder(5500)] + [PropertyParameterOrder(6500)] public string v_Width { get; set; } [XmlAttribute] @@ -34,33 +29,31 @@ public sealed class GetWindowSizeFromWindowHandleCommand : AWindowHandleCommands [PropertyDescription("Variable Name to Recieve the Window Height")] [PropertyIsOptional(true)] [PropertyDisplayText(false, "")] - [PropertyParameterOrder(5500)] + [PropertyParameterOrder(6500)] public string v_Height { get; set; } - //[XmlAttribute] - //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - //public string v_WaitTime { get; set; } + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } - public GetWindowSizeFromWindowHandleCommand() + public GetOneWindowSizeCommand() { } + public override void RunCommand(Engine.AutomationEngineInstance engine) { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => + this.WindowNameAction(engine, new Action((whnd, name) => + { + var getSize = new GetWindowSizeFromWindowHandleCommand() { - var rct = WindowControls.GetWindowRect(whnd); - - if (!string.IsNullOrEmpty(v_Width)) - { - (rct.right - rct.left).StoreInUserVariable(engine, v_Width); - } - if (!string.IsNullOrEmpty(v_Height)) - { - (rct.bottom - rct.top).StoreInUserVariable(engine, v_Height); - } - }) - ); + v_WindowHandle = whnd.ToString(), + v_Width = this.v_Width, + v_Height = this.v_Height, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + }; + getSize.RunCommand(engine); + })); } } -} \ No newline at end of file +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowStateCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowStateCommand.cs new file mode 100644 index 000000000..e5d584dba --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetOneWindowStateCommand.cs @@ -0,0 +1,52 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get One Window State")] + [Attributes.ClassAttributes.Description("This command returns one window state.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want one window state.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetOneWindowStateCommand : AOneWindowNameCommands + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [Remarks("Restore is **1**, Minimize is **2**, Maximize is **3**")] + [PropertyParameterOrder(6500)] + public string v_WindowState { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Window State Text")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Window State Text", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "State Text")] + [PropertyParameterOrder(6501)] + public string v_WindowStateText { get; set; } + + public GetOneWindowStateCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNameAction(engine, new Action((whnd, name) => + { + var getState = new GetWindowStateFromWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_WindowState = this.v_WindowState, + v_WindowStateText = this.v_WindowStateText, + }; + getState.RunCommand(engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetProcessNameFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetProcessNameFromWindowHandleCommand.cs new file mode 100644 index 000000000..0d558f91d --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetProcessNameFromWindowHandleCommand.cs @@ -0,0 +1,125 @@ +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Handle")] + [Attributes.ClassAttributes.CommandSettings("Get Process Name From Window Handle")] + [Attributes.ClassAttributes.Description("This command returns process name.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get process name.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetProcessNameFromWindowHandleCommand : AWindowHandleCommands + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] + //public string v_WindowHandle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Process Name")] + [PropertyParameterOrder(5500)] + public string v_Result { get; set; } + + [XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] + //[PropertyIsOptional(true, "0")] + //[PropertyFirstValue("0")] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] + public override string v_WaitTimeForWindow { get; set; } + + //public string v_WindowTitleResult {get;set;} + + /// + /// get process id from window handle + /// + /// + /// + /// + [DllImport("user32.dll")] + static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); + + ///// + ///// open process from pid + ///// + ///// + ///// + ///// + ///// + //[DllImport("kernel32.dll")] + //public static extern IntPtr OpenProcess(uint processAccess, bool bInheritHandle, uint processId); + + ///// + ///// https://www.pinvoke.net/default.aspx/kernel32.openprocess + ///// + //private const uint AccessMode = 0x0410; // 0x0400 | 0x0010 + + ///// + ///// get process name + ///// + ///// + ///// + ///// + ///// + ///// + //[DllImport("psapi.dll", CharSet = CharSet.Ansi)] + //static extern uint GetModuleBaseName(IntPtr hProcess, IntPtr hModule, [MarshalAs(UnmanagedType.LPStr), Out] StringBuilder lpBaseName, uint nSize); + + ///// + ///// close handle + ///// + ///// + ///// + //[DllImport("kernel32.dll")] + //private static extern bool CloseHandle(IntPtr handle); + + public GetProcessNameFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //WindowControls.WindowHandleAction(this, engine, + // new Action(whnd => + // { + // var proc = Process.GetProcesses().Where(p => (p.MainWindowHandle == whnd)).First(); + // proc.ProcessName.StoreInUserVariable(engine, v_Result); + // }) + //); + //var whnd = this.GetWindowHandle(engine); + //var proc = Process.GetProcesses().Where(p => (p.MainWindowHandle == whnd)).First(); + //proc.ProcessName.StoreInUserVariable(engine, v_Result); + + this.WindowHandleAction(engine, new Action((whnd) => + { + //var ps = Process.GetProcesses(); + //// DBG + //foreach(var p in ps) + //{ + // Console.WriteLine(p.MainWindowHandle); + //} + //var proc = ps.Where(p => (p.MainWindowHandle == whnd)).First(); + ////var proc = Process.GetProcesses().Where(p => (p.MainWindowHandle == whnd)).First(); + //proc.ProcessName.StoreInUserVariable(engine, v_Result); + + GetWindowThreadProcessId(whnd, out uint pid); + if (pid != 0) + { + var p = Process.GetProcessById((int)pid); + p.ProcessName.StoreInUserVariable(engine, v_Result); + } + else + { + throw new Exception($"Error. Can not find Process Name. Handle: '{v_WindowHandle}', Expand Value: '{whnd}'"); + } + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetProcessNamesFromWindowNamesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetProcessNamesFromWindowNamesAsDataTableCommand.cs new file mode 100644 index 000000000..a8faaaf6a --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetProcessNamesFromWindowNamesAsDataTableCommand.cs @@ -0,0 +1,58 @@ +using System; +using System.Data; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Process Names From Window Names As DataTable")] + [Attributes.ClassAttributes.Description("This command returns window process names.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window process names.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetProcessNamesFromWindowNamesAsDataTableCommand : GetFromWindowNamesAsDataTableCommands + { + [XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyInstanceType(PropertyInstanceType.InstanceType.DataTable)] + [Remarks("Column Names are **WindowName**, **WindowHandle**, and **ProcessName**")] + //[PropertyParameterOrder(6500)] + public override string v_Result { get; set; } + + public GetProcessNamesFromWindowNamesAsDataTableCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + var ret = new DataTable(); + ret.Columns.Add("WindowName"); + ret.Columns.Add("WindowHandle"); + ret.Columns.Add("ProcessName"); + foreach ((var whnd, var name) in wins) + { + using(var p = new InnerScriptVariable(engine)) + { + var getProcess = new GetProcessNameFromWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_Result = p.VariableName, + }; + getProcess.RunCommand(engine); + ret.Rows.Add(new string[] { name, whnd.ToString(), p.VariableValue.ToString(), }); + } + } + this.StoreDataTableInUserVariable(ret, engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetProcessNamesFromWindowNamesAsListCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetProcessNamesFromWindowNamesAsListCommand.cs new file mode 100644 index 000000000..973be0d07 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetProcessNamesFromWindowNamesAsListCommand.cs @@ -0,0 +1,48 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Process Names From Window Names As List")] + [Attributes.ClassAttributes.Description("This command returns window process names.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window process names.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetProcessNamesFromWindowNamesAsListCommand : GetFromWindowNamesAsListCommands + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyInstanceType(PropertyInstanceType.InstanceType.List)] + [PropertyParameterOrder(6500)] + public string v_Result { get; set; } + + public GetProcessNamesFromWindowNamesAsListCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using (var tb = new InnerScriptVariable(engine)) + { + var getProcesses = new GetProcessNamesFromWindowNamesAsDataTableCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = tb.VariableName, + }; + getProcesses.RunCommand(engine); + + this.StoreListInUserVariable(GetColumnValues(tb, 2), nameof(v_Result), engine); + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowHandlesFromWindowNamesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowHandlesFromWindowNamesAsDataTableCommand.cs new file mode 100644 index 000000000..6c21c2ccd --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowHandlesFromWindowNamesAsDataTableCommand.cs @@ -0,0 +1,43 @@ +using System; +using System.Data; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Window Handles From Window Names As DataTable")] + [Attributes.ClassAttributes.Description("This command returns window handles.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window handles.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowHandlesFromWindowNamesAsDataTableCommand : GetFromWindowNamesAsDataTableCommands + { + [XmlAttribute] + [Remarks("Column Names are **WindowName**, **WindowHandle**")] + public override string v_Result { get; set; } + + public GetWindowHandlesFromWindowNamesAsDataTableCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + var ret = new DataTable(); + ret.Columns.Add("WindowName"); + ret.Columns.Add("WindowHandle"); + foreach ((var whnd, var name) in wins) + { + ret.Rows.Add(new string[] { name, whnd.ToString(), }); + } + this.StoreDataTableInUserVariable(ret, engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowHandlesFromWindowNamesAsListCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowHandlesFromWindowNamesAsListCommand.cs new file mode 100644 index 000000000..15f862571 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowHandlesFromWindowNamesAsListCommand.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Window Handles From Window Names As List")] + [Attributes.ClassAttributes.Description("This command returns window handles.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window handles.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowHandlesFromWindowNamesAsListCommand : GetFromWindowNamesAsListCommands + { + [XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyInstanceType(PropertyInstanceType.InstanceType.List)] + [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] + [PropertyIsOptional(false)] + [PropertyValidationRule("Window Handle", PropertyValidationRule.ValidationRuleFlags.Empty)] + [PropertyParameterOrder(6500)] + public override string v_WindowHandleResult { get; set; } + + public GetWindowHandlesFromWindowNamesAsListCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + //var res = new List(); + //foreach((var whnd, _) in wins) + //{ + // res.Add(whnd.ToString()); + //} + //this.StoreListInUserVariable(res, nameof(v_WindowHandleResult), engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/Window/GetWindowNameFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowNameFromWindowHandleCommand.cs similarity index 50% rename from taskt/Core/Automation/Commands/Window/GetWindowNameFromWindowHandleCommand.cs rename to taskt/Core/Automation/Commands/WindowGroup/GetWindowNameFromWindowHandleCommand.cs index b2705b5c4..1b0f21ae3 100644 --- a/taskt/Core/Automation/Commands/Window/GetWindowNameFromWindowHandleCommand.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowNameFromWindowHandleCommand.cs @@ -21,15 +21,19 @@ public sealed class GetWindowNameFromWindowHandleCommand : AWindowHandleCommands //public string v_WindowHandle { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] - [PropertyDescription("Variable Name to Store Window Name")] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + //[PropertyDescription("Variable Name to Store Window Name")] + [PropertyIsOptional(false)] + [PropertyValidationRule("Window Name", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyParameterOrder(5500)] - public string v_Result { get; set; } + public override string v_WindowNameResult { get; set; } [XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - [PropertyIsOptional(true, "0")] - [PropertyFirstValue("0")] + //[PropertyIsOptional(true, "0")] + //[PropertyFirstValue("0")] + //[PropertyValidationRule("WaitTime", PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WaitTime))] public override string v_WaitTimeForWindow { get; set; } public GetWindowNameFromWindowHandleCommand() @@ -38,13 +42,25 @@ public GetWindowNameFromWindowHandleCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => - { - var n = WindowControls.GetWindowTitle(whnd); - n.StoreInUserVariable(engine, v_Result); - }) - ); + //WindowControls.WindowHandleAction(this, engine, + // new Action(whnd => + // { + // var n = WindowControls.GetWindowTitle(whnd); + // n.StoreInUserVariable(engine, v_Result); + // }) + //); + + //var whnd = this.GetWindowHandle(engine); + //int titleLengthA = GetWindowTextLengthW(whnd); + //StringBuilder title = new StringBuilder(titleLengthA + 1); + //GetWindowTextW(whnd, title, title.Capacity); + //title.ToString().StoreInUserVariable(engine, v_Result); + + this.WindowHandleAction(engine, new Action((whnd) => + { + //EM_CanHandleWindowHandleExtentionMethods.GetWindowName(whnd).StoreInUserVariable(engine, v_Result); + // nothing + })); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/GetWindowNamesCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowNamesCommand.cs similarity index 63% rename from taskt/Core/Automation/Commands/Window/GetWindowNamesCommand.cs rename to taskt/Core/Automation/Commands/WindowGroup/GetWindowNamesCommand.cs index ff7302a27..67a424f34 100644 --- a/taskt/Core/Automation/Commands/Window/GetWindowNamesCommand.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowNamesCommand.cs @@ -1,15 +1,15 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Xml.Serialization; using taskt.Core.Automation.Attributes.PropertyAttributes; -using System.Linq; using taskt.Core.Automation.Engine; namespace taskt.Core.Automation.Commands { [Serializable] [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window State")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] [Attributes.ClassAttributes.CommandSettings("Get Window Names")] [Attributes.ClassAttributes.Description("This command returns window names.")] [Attributes.ClassAttributes.UsesDescription("Use this command when you want window names.")] @@ -17,7 +17,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class GetWindowNamesCommand : AAnyWindowNameCommands, ICanHandleList + public sealed class GetWindowNamesCommand : AWindowNamesCommands, ICanHandleList { [XmlAttribute] [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowName))] @@ -31,25 +31,23 @@ public sealed class GetWindowNamesCommand : AAnyWindowNameCommands, ICanHandleLi [XmlAttribute] [PropertyVirtualProperty(nameof(ListControls), nameof(ListControls.v_OutputListName))] + [PropertyIsOptional(false)] + [PropertyValidationRule("Window Name", PropertyValidationRule.ValidationRuleFlags.Empty)] [PropertyParameterOrder(6500)] - public string v_UserVariableName { get; set; } + public override string v_WindowNameResult { get; set; } [XmlAttribute] - [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + [PropertyVirtualProperty(nameof(SelectionItemsControls), nameof(SelectionItemsControls.v_ComboBoxHasErrorIgnore))] [PropertyDescription("When Window Not Found")] - [InputSpecification("", true)] - [Remarks("")] - [PropertyUISelectionOption("Ignore")] - [PropertyUISelectionOption("Error")] - [PropertyDetailSampleUsage("**Ignore**", "Nothing to do. Get Empty LIST")] - [PropertyDetailSampleUsage("**Error**", "Rise a Error")] - [PropertyIsOptional(true, "Ignore")] + [PropertyUISelectionOption("Set Empty")] + [PropertyDetailSampleUsage("**Set Empty**", "Window Names Result Is Empty LIST")] + [PropertyIsOptional(true, "Set Empty")] [PropertyParameterOrder(6600)] public string v_WhenWindowNotFound { get; set; } [XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] - [PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + //[PropertyValidationRule("Wait Time", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] [PropertyIsOptional(true, "0")] [PropertyFirstValue("0")] public override string v_WaitTimeForWindow { get; set; } @@ -64,28 +62,23 @@ public sealed class GetWindowNamesCommand : AAnyWindowNameCommands, ICanHandleLi public GetWindowNamesCommand() { - //this.CommandName = "GetWindowNamesCommand"; - //this.SelectionName = "Get Window Names"; - //this.CommandEnabled = true; - //this.CustomRendering = true; } public override void RunCommand(Engine.AutomationEngineInstance engine) { - WindowControls.WindowAction(this, engine, - new Action>(wins => + this.WindowNamesAction(engine, + new Action>((wins) => { - //wins.Select(w => w.Item2).ToList().StoreInUserVariable(engine, v_UserVariableName); - this.StoreListInUserVariable(wins.Select(w => w.Item2).ToList(), nameof(v_UserVariableName), engine); - }), - new Action(ex => + //this.StoreListInUserVariable(wins.Select(w => w.Item2).ToList(), nameof(v_WindowNameResult), engine); + }), + new Action((ex) => { - var whenNotFound = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenWindowNotFound), engine); - switch (whenNotFound) + switch(this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenWindowNotFound), engine)) { + case "set empty": + this.StoreListInUserVariable(new List(), nameof(v_WindowNameResult), engine); + break; case "ignore": - //new List().StoreInUserVariable(engine, v_UserVariableName); - this.StoreListInUserVariable(new List(), nameof(v_UserVariableName), engine); break; case "error": throw ex; diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowPositionFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowPositionFromWindowHandleCommand.cs new file mode 100644 index 000000000..0205020f9 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowPositionFromWindowHandleCommand.cs @@ -0,0 +1,248 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Handle")] + [Attributes.ClassAttributes.CommandSettings("Get Window Position From Window Handle")] + [Attributes.ClassAttributes.Description("This command returns window position.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want window position.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowPositionFromWindowHandleCommand : AWindowHandleCommands, IWindowPositionProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] + //public string v_WindowHandle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Position X")] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "Position X")] + [PropertyParameterOrder(5001)] + public string v_XPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Position Y")] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "Position Y")] + [PropertyParameterOrder(5002)] + public string v_YPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_PositionBase))] + [PropertyParameterOrder(5003)] + public string v_PositionBase { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] + //public string v_WaitTime { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMaximizedForGet))] + [PropertyIsOptional(true, "Execute")] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + + public GetWindowPositionFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //WindowControls.WindowHandleAction(this, engine, + // new Action(whnd => + // { + // var pos = WindowControls.GetWindowRect(whnd); + + // int x = 0, y = 0; + // switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) + // { + // case "top left": + // x = pos.left; + // y = pos.top; + // break; + // case "bottom right": + // x = pos.right; + // y = pos.bottom; + // break; + // case "top right": + // x = pos.right; + // y = pos.top; + // break; + // case "bottom left": + // x = pos.left; + // y = pos.bottom; + // break; + // case "center": + // x = (pos.right + pos.left) / 2; + // y = (pos.top + pos.bottom) / 2; + // break; + // } + // if (!string.IsNullOrEmpty(v_XPosition)) + // { + // x.ToString().StoreInUserVariable(engine, v_XPosition); + // } + // if (!string.IsNullOrEmpty(v_YPosition)) + // { + // y.ToString().StoreInUserVariable(engine, v_YPosition); + // } + // }) + //); + + //var whnd = this.GetWindowHandle(engine); + //var r = EM_WindowRECTPropertiesExtentionMethods.GetWindowRect(whnd); + //int x = 0, y = 0; + //switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) + //{ + // case "top left": + // x = r.left; + // y = r.top; + // break; + // case "bottom right": + // x = r.right; + // y = r.bottom; + // break; + // case "top right": + // x = r.right; + // y = r.top; + // break; + // case "bottom left": + // x = r.left; + // y = r.bottom; + // break; + // case "center": + // x = (r.right + r.left) / 2; + // y = (r.top + r.bottom) / 2; + // break; + //} + //if (!string.IsNullOrEmpty(v_XPosition)) + //{ + // x.StoreInUserVariable(engine, v_XPosition); + //} + //if (!string.IsNullOrEmpty(v_YPosition)) + //{ + // y.StoreInUserVariable(engine, v_YPosition); + //} + + void GetWindowPositionProcess(IntPtr wh) + { + var r = EM_WindowRECTPropertiesExtentionMethods.GetWindowRect(wh); + int x = 0, y = 0; + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) + { + case "top left": + x = r.left; + y = r.top; + break; + case "bottom right": + x = r.right; + y = r.bottom; + break; + case "top right": + x = r.right; + y = r.top; + break; + case "bottom left": + x = r.left; + y = r.bottom; + break; + case "center": + x = (r.right + r.left) / 2; + y = (r.top + r.bottom) / 2; + break; + } + if (!string.IsNullOrEmpty(v_XPosition)) + { + x.StoreInUserVariable(engine, v_XPosition); + } + if (!string.IsNullOrEmpty(v_YPosition)) + { + y.StoreInUserVariable(engine, v_YPosition); + } + } + + void SetZeroPositionProcess() + { + if (!string.IsNullOrEmpty(v_XPosition)) + { + 0.StoreInUserVariable(engine, v_XPosition); + } + if (!string.IsNullOrEmpty(v_YPosition)) + { + 0.StoreInUserVariable(engine, v_YPosition); + } + } + + void RestoreWindowProcess(IntPtr wh) + { + var setRestore = new SetWindowStateByWindowHandleCommand + { + v_WindowHandle = wh.ToString(), + v_WindowState = "Restore", + }; + setRestore.RunCommand(engine); + } + + this.WindowHandleAction(engine, new Action((whnd) => + { + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowMinimized(whnd)) + { + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenWindowIsMinimized), engine)) + { + case "execute": + GetWindowPositionProcess(whnd); + return; + case "set zero": + SetZeroPositionProcess(); + return; + case "ignore": + return; + case "error": + throw new Exception($"Error. Target Window is Minimized. Handle: '{v_WindowHandle}', Exand Value: '{whnd}'"); + + case "restore": + RestoreWindowProcess(whnd); + break; + } + } + + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowMaximized(whnd)) + { + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenWindowIsMaximized), engine)) + { + case "execute": + GetWindowPositionProcess(whnd); + return; + case "set zero": + SetZeroPositionProcess(); + return; + case "ignore": + return; + case "error": + throw new Exception($"Error. Target Window is Maximized. Handle: '{v_WindowHandle}', Exand Value: '{whnd}'"); + + case "restore": + RestoreWindowProcess(whnd); + break; + } + } + + GetWindowPositionProcess(whnd); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowPositionsFromWindowNamesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowPositionsFromWindowNamesAsDataTableCommand.cs new file mode 100644 index 000000000..a86b1aa83 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowPositionsFromWindowNamesAsDataTableCommand.cs @@ -0,0 +1,78 @@ +using System; +using System.Data; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Window Positions From Window Names As DataTable")] + [Attributes.ClassAttributes.Description("This command returns window process names.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window positions.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowPositionsFromWindowNamesAsDataTableCommand : GetFromWindowNamesAsDataTableCommands + { + [XmlAttribute] + [Remarks("Column Names are **WindowName**, **WindowHandle**, **X**, and **Y**")] + public override string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_PositionBase))] + [PropertyParameterOrder(7000)] + public string v_PositionBase { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMaximizedForGet))] + [PropertyIsOptional(true, "Execute")] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + public GetWindowPositionsFromWindowNamesAsDataTableCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + var ret = new DataTable(); + ret.Columns.Add("WindowName"); + ret.Columns.Add("WindowHandle"); + ret.Columns.Add("X"); + ret.Columns.Add("Y"); + foreach ((var whnd, var name) in wins) + { + using(var x = new InnerScriptVariable(engine)) + { + using (var y = new InnerScriptVariable(engine)) + { + var getPos = new GetWindowPositionFromWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_XPosition = x.VariableName, + v_YPosition = y.VariableName, + v_PositionBase = this.v_PositionBase, + v_WhenWindowIsMaximized = this.v_WhenWindowIsMaximized, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + }; + getPos.RunCommand(engine); + ret.Rows.Add(new string[] { name, whnd.ToString(), x.VariableValue.ToString(), y.VariableValue.ToString() }); + } + } + } + this.StoreDataTableInUserVariable(ret, engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowPositionsFromWindowNamesAsListCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowPositionsFromWindowNamesAsListCommand.cs new file mode 100644 index 000000000..4a71b235d --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowPositionsFromWindowNamesAsListCommand.cs @@ -0,0 +1,85 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Window Positions From Window Names As List")] + [Attributes.ClassAttributes.Description("This command returns window handles.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window positions.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowPositionsFromWindowNamesAsListCommand : GetFromWindowNamesAsListCommands, IWindowPositionProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Position X")] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "Position X")] + [PropertyInstanceType(PropertyInstanceType.InstanceType.List)] + [PropertyParameterOrder(5001)] + public string v_XPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Position Y")] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "Position Y")] + [PropertyInstanceType(PropertyInstanceType.InstanceType.List)] + [PropertyParameterOrder(5002)] + public string v_YPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_PositionBase))] + [PropertyParameterOrder(5003)] + public string v_PositionBase { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMaximizedForGet))] + [PropertyIsOptional(true, "Execute")] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + public GetWindowPositionsFromWindowNamesAsListCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using (var table = new InnerScriptVariable(engine)) + { + var getPos = new GetWindowPositionsFromWindowNamesAsDataTableCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_PositionBase = this.v_PositionBase, + v_WhenWindowIsMaximized = this.v_WhenWindowIsMaximized, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + v_Result = table.VariableName, + }; + getPos.RunCommand(engine); + + if (!string.IsNullOrEmpty(v_XPosition)) + { + this.StoreListInUserVariable(GetColumnValues(table, 2), nameof(v_XPosition), engine); + } + if (!string.IsNullOrEmpty(v_YPosition)) + { + this.StoreListInUserVariable(GetColumnValues(table, 3), nameof(v_YPosition), engine); + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowSizeFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowSizeFromWindowHandleCommand.cs new file mode 100644 index 000000000..9b558cfac --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowSizeFromWindowHandleCommand.cs @@ -0,0 +1,108 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Handle")] + [Attributes.ClassAttributes.CommandSettings("Get Window Size From Window Handle")] + [Attributes.ClassAttributes.Description("This command returns window size.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want window size.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowSizeFromWindowHandleCommand : AWindowHandleCommands, IWindowSizeProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] + //public string v_WindowHandle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Width")] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "Width")] + [PropertyParameterOrder(5500)] + public string v_Width { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Height")] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "Height")] + [PropertyParameterOrder(5501)] + public string v_Height { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] + //public string v_WaitTime { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + public GetWindowSizeFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + void GetWindowSizeProcess(IntPtr h) + { + (var width, var height) = EM_WindowSizePropertiesExtensionMethods.GetWindowSize(h); + if (!string.IsNullOrEmpty(v_Width)) + { + width.StoreInUserVariable(engine, v_Width); + } + if (!string.IsNullOrEmpty(v_Height)) + { + height.StoreInUserVariable(engine, v_Height); + } + } + + this.WindowHandleAction(engine, new Action((whnd) => + { + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowMinimized(whnd)) + { + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenWindowIsMinimized), engine)) + { + case "execute": + GetWindowSizeProcess(whnd); + break; + case "restore": + var setRestore = new SetWindowStateByWindowHandleCommand + { + v_WindowHandle = whnd.ToString(), + v_WindowState = "Restore", + }; + setRestore.RunCommand(engine); + GetWindowSizeProcess(whnd); + break; + case "set zero": + if (!string.IsNullOrEmpty(v_Width)) + { + 0.StoreInUserVariable(engine, v_Width); + } + if (!string.IsNullOrEmpty(v_Height)) + { + 0.StoreInUserVariable(engine, v_Height); + } + break; + case "ignore": + break; + case "error": + throw new Exception($"Error. Target Window is Minimized. Handle: '{v_WindowHandle}', Expand Value: '{whnd}'"); + } + } + else + { + GetWindowSizeProcess(whnd); + } + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowSizesFromWindowNamesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowSizesFromWindowNamesAsDataTableCommand.cs new file mode 100644 index 000000000..594cf1322 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowSizesFromWindowNamesAsDataTableCommand.cs @@ -0,0 +1,68 @@ +using System; +using System.Data; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Window Sizes From Window Names As DataTable")] + [Attributes.ClassAttributes.Description("This command returns window process names.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window sizes.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowSizesFromWindowNamesAsDataTableCommand : GetFromWindowNamesAsDataTableCommands + { + [XmlAttribute] + [Remarks("Column Names are **WindowName**, **WindowHandle**, **Width**, and **Height**")] + public override string v_Result { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + public GetWindowSizesFromWindowNamesAsDataTableCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + var ret = new DataTable(); + ret.Columns.Add("WindowName"); + ret.Columns.Add("WindowHandle"); + ret.Columns.Add("Width"); + ret.Columns.Add("Height"); + + foreach ((var whnd, var name) in wins) + { + using (var w = new InnerScriptVariable(engine)) + { + using (var h = new InnerScriptVariable(engine)) + { + var getSize = new GetWindowSizeFromWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_Width = w.VariableName, + v_Height = h.VariableName, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + }; + getSize.RunCommand(engine); + + ret.Rows.Add(new string[] { name, whnd.ToString(), w.VariableValue.ToString(), h.VariableValue.ToString() }); + } + } + } + + this.StoreDataTableInUserVariable(ret, engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowSizesFromWindowNamesAsListCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowSizesFromWindowNamesAsListCommand.cs new file mode 100644 index 000000000..5b3c00720 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowSizesFromWindowNamesAsListCommand.cs @@ -0,0 +1,72 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Window Sizes From Window Names As List")] + [Attributes.ClassAttributes.Description("This command returns window handles.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window sizes.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowSizesFromWindowNamesAsListCommand : GetFromWindowNamesAsListCommands, IWindowSizeProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Width")] + [PropertyInstanceType(PropertyInstanceType.InstanceType.List)] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "Width")] + [PropertyParameterOrder(5500)] + public string v_Width { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Recieve the Window Height")] + [PropertyInstanceType(PropertyInstanceType.InstanceType.List)] + [PropertyIsOptional(true)] + [PropertyDisplayText(false, "Height")] + [PropertyParameterOrder(5501)] + public string v_Height { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + public GetWindowSizesFromWindowNamesAsListCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using (var table = new InnerScriptVariable(engine)) + { + var getSize = new GetWindowSizesFromWindowNamesAsDataTableCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + v_Result = table.VariableName, + }; + getSize.RunCommand(engine); + + if (!string.IsNullOrEmpty(v_Width)) + { + this.StoreListInUserVariable(GetColumnValues(table, 2), nameof(v_Width), engine); + } + if (!string.IsNullOrEmpty(v_Height)) + { + this.StoreListInUserVariable(GetColumnValues(table, 3), nameof(v_Height), engine); + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowStateFromWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowStateFromWindowHandleCommand.cs new file mode 100644 index 000000000..dc594f645 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowStateFromWindowHandleCommand.cs @@ -0,0 +1,144 @@ +using System; +using System.Runtime.InteropServices; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Handle")] + [Attributes.ClassAttributes.CommandSettings("Get Window State From Window Handle")] + [Attributes.ClassAttributes.Description("This command returns a state of window name.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a window state.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowStateFromWindowHandleCommand : AWindowHandleCommands, IWindowStateProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] + //public string v_WindowHandle { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Window State Text")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Window State", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "State")] + [Remarks("Restore is **1**, Minimize is **2**, Maximize is **3**")] + [PropertyParameterOrder(5500)] + public string v_WindowState { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Window State Text")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Window State Text", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "State Text")] + [PropertyParameterOrder(5501)] + public string v_WindowStateText { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] + //public string v_WaitTime { get; set; } + + private struct WINDOWPLACEMENT + { + uint length; + uint flags; + public uint showCmd; + System.Drawing.Point ptMinPosition; + System.Drawing.Point ptMaxPosition; + RECT rcNormalPosition; + RECT rcDevice; + } + + /// + /// get window state + /// + /// + /// + /// + [DllImport("user32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl); + + public GetWindowStateFromWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //WindowControls.WindowHandleAction(this, engine, + // new Action(whnd => + // { + // var state = WindowControls.GetWindowState(whnd); + // state.StoreInUserVariable(engine, v_WindowState); + // }) + //); + //var whnd = this.GetWindowHandle(engine); + //var info = new WINDOWPLACEMENT(); + //GetWindowPlacement(whnd, ref info); + + //if (!string.IsNullOrEmpty(v_WindowState)) + //{ + // ((int)info.showCmd).StoreInUserVariable(engine, v_WindowState); + //} + + //if (!string.IsNullOrEmpty(v_WindowStateText)) + //{ + // string txt; + // switch (info.showCmd) + // { + // case 1: + // txt = "Restore"; + // break; + // case 2: + // txt = "Minimize"; + // break; + // case 3: + // txt = "Maximize"; + // break; + // default: + // txt = "Unknown"; + // break; + // } + // txt.StoreInUserVariable(engine, v_WindowStateText); + //} + + this.WindowHandleAction(engine, new Action((whnd) => + { + var info = new WINDOWPLACEMENT(); + GetWindowPlacement(whnd, ref info); + + if (!string.IsNullOrEmpty(v_WindowState)) + { + ((int)info.showCmd).StoreInUserVariable(engine, v_WindowState); + } + + if (!string.IsNullOrEmpty(v_WindowStateText)) + { + string txt; + switch (info.showCmd) + { + case 1: + txt = "Restore"; + break; + case 2: + txt = "Minimize"; + break; + case 3: + txt = "Maximize"; + break; + default: + txt = "Unknown"; + break; + } + txt.StoreInUserVariable(engine, v_WindowStateText); + } + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowStatesFromWindowNamesAsDataTableCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowStatesFromWindowNamesAsDataTableCommand.cs new file mode 100644 index 000000000..351bfa05a --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowStatesFromWindowNamesAsDataTableCommand.cs @@ -0,0 +1,62 @@ +using System; +using System.Data; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Window States From Window Names As DataTable")] + [Attributes.ClassAttributes.Description("This command returns window process states.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window states.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowStatesFromWindowNamesAsDataTableCommand : GetFromWindowNamesAsDataTableCommands + { + [XmlAttribute] + [Remarks("Column Names are **WindowName**, **WindowHandle**, **State**, and **StateText**")] + public override string v_Result { get; set; } + + public GetWindowStatesFromWindowNamesAsDataTableCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + var ret = new DataTable(); + ret.Columns.Add("WindowName"); + ret.Columns.Add("WindowHandle"); + ret.Columns.Add("State"); + ret.Columns.Add("StateText"); + + foreach ((var whnd, var name) in wins) + { + using (var s = new InnerScriptVariable(engine)) + { + using (var st = new InnerScriptVariable(engine)) + { + var getState = new GetWindowStateFromWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_WindowState = s.VariableName, + v_WindowStateText = st.VariableName, + }; + getState.RunCommand(engine); + + ret.Rows.Add(new string[] { name, whnd.ToString(), s.VariableValue.ToString(), st.VariableValue.ToString() }); + } + } + } + + this.StoreDataTableInUserVariable(ret, engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/GetWindowStatesFromWindowNamesAsListCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/GetWindowStatesFromWindowNamesAsListCommand.cs new file mode 100644 index 000000000..520245694 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/GetWindowStatesFromWindowNamesAsListCommand.cs @@ -0,0 +1,69 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; +using taskt.Core.Script; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Get From Window Name")] + [Attributes.ClassAttributes.CommandSettings("Get Window States From Window States As List")] + [Attributes.ClassAttributes.Description("This command returns window handles.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get window states.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class GetWindowStatesFromWindowNamesAsListCommand : GetFromWindowNamesAsListCommands, IWindowStateProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyDescription("Variable Name to Store Window State Text")] + [PropertyInstanceType(PropertyInstanceType.InstanceType.List)] + [PropertyIsOptional(true)] + [PropertyValidationRule("Window State", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "State")] + [Remarks("Restore is **1**, Minimize is **2**, Maximize is **3**")] + [PropertyParameterOrder(5500)] + public string v_WindowState { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] + [PropertyInstanceType(PropertyInstanceType.InstanceType.List)] + [PropertyDescription("Variable Name to Store Window State Text")] + [PropertyIsOptional(true)] + [PropertyValidationRule("Window State Text", PropertyValidationRule.ValidationRuleFlags.None)] + [PropertyDisplayText(true, "State Text")] + [PropertyParameterOrder(5501)] + public string v_WindowStateText { get; set; } + + public GetWindowStatesFromWindowNamesAsListCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + using (var table = new InnerScriptVariable(engine)) + { + var getState = new GetWindowStatesFromWindowNamesAsDataTableCommand() + { + v_WindowName = this.v_WindowName, + v_CheckMethod = this.v_CheckMethod, + v_WaitTimeForWindow = this.v_WaitTimeForWindow, + v_Result = table.VariableName, + }; + getState.RunCommand(engine); + + if (!string.IsNullOrEmpty(v_WindowState)) + { + this.StoreListInUserVariable(GetColumnValues(table, 2), nameof(v_WindowState), engine); + } + if (!string.IsNullOrEmpty(v_WindowStateText)) + { + this.StoreListInUserVariable(GetColumnValues(table, 3), nameof(v_WindowStateText), engine); + } + } + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/ICanHandleWindowHandle.cs b/taskt/Core/Automation/Commands/WindowGroup/ICanHandleWindowHandle.cs new file mode 100644 index 000000000..13c1d1b7f --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/ICanHandleWindowHandle.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// for window handle + /// + public interface ICanHandleWindowHandle : IExpandableProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/ICanHandleWindowName.cs b/taskt/Core/Automation/Commands/WindowGroup/ICanHandleWindowName.cs new file mode 100644 index 000000000..655a00b2b --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/ICanHandleWindowName.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// for handle window name + /// + public interface ICanHandleWindowName : IExpandableProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IFromWindowHandleResultsProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IFromWindowHandleResultsProperties.cs new file mode 100644 index 000000000..cf61e7ad1 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IFromWindowHandleResultsProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.WindowGroup +{ + /// + /// window name results properites + /// + public interface IFromWindowHandleResultsProperties : IExpandableProperties + { + /// + /// found window name + /// + string v_WindowNameResult { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IFromWindowNameResultsProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IFromWindowNameResultsProperties.cs new file mode 100644 index 000000000..c1e467f33 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IFromWindowNameResultsProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands.WindowGroup +{ + /// + /// window name & handle results properties + /// + public interface IFromWindowNameResultsProperties : IFromWindowHandleResultsProperties + { + /// + /// found window handle + /// + string v_WindowHandleResult { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IOneWindowNameActionProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IOneWindowNameActionProperties.cs new file mode 100644 index 000000000..3dd38a08c --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IOneWindowNameActionProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// for one window name action properties + /// + public interface IOneWindowNameActionProperties : IOneWindowNameProperties, IWindowWaitTimeBetweenFindAndActionProperties, IWindowActivateProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IOneWindowNameProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IOneWindowNameProperties.cs new file mode 100644 index 000000000..dda31397d --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IOneWindowNameProperties.cs @@ -0,0 +1,18 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// one window name commands properties + /// + public interface IOneWindowNameProperties : IWindowNameCoreProperties, ISelectionMethodProperties + { + ///// + ///// selection method (first, last, index) + ///// + //string v_SelectionMethod { get; set; } + + /// + /// selection method index + /// + string v_TargetWindowIndex { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowActivateProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowActivateProperties.cs new file mode 100644 index 000000000..9261d816a --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowActivateProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands +{ + public interface IWindowActivateProperties + { + /// + /// activate window before action + /// + string v_ActivateBeforeAction { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowHandleActionPropeties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowHandleActionPropeties.cs new file mode 100644 index 000000000..76fde0684 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowHandleActionPropeties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// for window handle action + /// + public interface IWindowHandleActionPropeties : IWindowHandleProperties, IWindowWaitTimeBetweenFindAndActionProperties, IWindowActivateProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/Window/ILWindowHandleProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowHandleProperties.cs similarity index 50% rename from taskt/Core/Automation/Commands/Window/ILWindowHandleProperties.cs rename to taskt/Core/Automation/Commands/WindowGroup/IWindowHandleProperties.cs index cc931542b..9556a661f 100644 --- a/taskt/Core/Automation/Commands/Window/ILWindowHandleProperties.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowHandleProperties.cs @@ -1,9 +1,11 @@ -namespace taskt.Core.Automation.Commands +using taskt.Core.Automation.Commands.WindowGroup; + +namespace taskt.Core.Automation.Commands { /// /// window handle command properties /// - public interface ILWindowHandleProperties : ILExpandableProperties + public interface IWindowHandleProperties : IFromWindowHandleResultsProperties, ICanHandleWindowHandle { /// /// window handle @@ -14,5 +16,10 @@ public interface ILWindowHandleProperties : ILExpandableProperties /// wait time for window /// string v_WaitTimeForWindow { get; set; } + + ///// + ///// window name + ///// + //string v_WindowNameResult { get; set; } } } diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowNameCoreProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowNameCoreProperties.cs new file mode 100644 index 000000000..247b300a6 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowNameCoreProperties.cs @@ -0,0 +1,37 @@ +using taskt.Core.Automation.Commands.TextGroup; +using taskt.Core.Automation.Commands.WindowGroup; + +namespace taskt.Core.Automation.Commands +{ + /// + /// window name commands core properties + /// + public interface IWindowNameCoreProperties : IFromWindowNameResultsProperties, ICanHandleWindowName, ITextCheckProperties + { + /// + /// window name + /// + string v_WindowName { get; set; } + + // memo: imple text-check interface + ///// + ///// compare method (contains, starts-with, ...) + ///// + //string v_CompareMethod { get; set; } + + /// + /// wait time for window + /// + string v_WaitTimeForWindow { get; set; } + + ///// + ///// found window name + ///// + //string v_WindowNameResult { get; set; } + + ///// + ///// found window handle + ///// + //string v_WindowHandleResult { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowNamesActionProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowNamesActionProperties.cs new file mode 100644 index 000000000..374e12148 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowNamesActionProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// window names action properties + /// + public interface IWindowNamesActionProperties : IWindowNamesProperties, IWindowWaitTimeBetweenFindAndActionProperties, IWindowActivateProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowNamesProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowNamesProperties.cs new file mode 100644 index 000000000..3339b274c --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowNamesProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// for multi window names properties + /// + public interface IWindowNamesProperties : IWindowNameCoreProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowPositionProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowPositionProperties.cs new file mode 100644 index 000000000..4a2bf86fb --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowPositionProperties.cs @@ -0,0 +1,18 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// window position properties + /// + public interface IWindowPositionProperties : IPositionProperties, IWindowRECTProperties + { + /// + /// when window is minimized + /// + string v_WhenWindowIsMinimized { get; set; } + + /// + /// when window is maximized + /// + string v_WhenWindowIsMaximized { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowRECTProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowRECTProperties.cs new file mode 100644 index 000000000..1bc92be73 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowRECTProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// for window position, size properties + /// + public interface IWindowRECTProperties + { + // nothing + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowResizeProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowResizeProperties.cs new file mode 100644 index 000000000..d8b3202c7 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowResizeProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// window resize commands properties + /// + public interface IWindowResizeProperties : IWindowSizeProperties + { + /// + /// behavior when window is maximized + /// + string v_WhenWindowIsMaximized { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowSizeProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowSizeProperties.cs new file mode 100644 index 000000000..1fe063ab8 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowSizeProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// window size properties + /// + public interface IWindowSizeProperties : ISizeProperties, IWindowRECTProperties + { + /// + /// when target window is minimized + /// + string v_WhenWindowIsMinimized { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowStateProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowStateProperties.cs new file mode 100644 index 000000000..57415f61c --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowStateProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// for set/get window state commands properties + /// + public interface IWindowStateProperties : IExpandableProperties + { + /// + /// window state string or number + /// + string v_WindowState { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/IWindowWaitTimeBetweenFindAndActionProperties.cs b/taskt/Core/Automation/Commands/WindowGroup/IWindowWaitTimeBetweenFindAndActionProperties.cs new file mode 100644 index 000000000..12d8f3d9c --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/IWindowWaitTimeBetweenFindAndActionProperties.cs @@ -0,0 +1,10 @@ +namespace taskt.Core.Automation.Commands +{ + public interface IWindowWaitTimeBetweenFindAndActionProperties : IExpandableProperties + { + /// + /// wait time between finding window and exection action + /// + string v_WaitTimeBetweenFindAndAction { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/MoveOneWindowCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/MoveOneWindowCommand.cs new file mode 100644 index 000000000..6df4bb14b --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/MoveOneWindowCommand.cs @@ -0,0 +1,74 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("One Window Name Actions")] + [Attributes.ClassAttributes.CommandSettings("Move One Window")] + [Attributes.ClassAttributes.Description("This command Move one Window.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Move one Window.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class MoveOneWindowCommand : AOneWindowNameActionCommands, IWindowPositionProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputXPosition))] + [PropertyParameterOrder(5500)] + public string v_XPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputYPosition))] + [PropertyParameterOrder(5500)] + public string v_YPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMaximizedForSet))] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + public MoveOneWindowCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //this.WindowNameActionAndWaitActivate(engine, new Action((whnd, name) => + //{ + // var moveWindow = new MoveWindowByWindowHandleCommand() + // { + // v_WindowHandle = whnd.ToString(), + // v_XPosition = this.v_XPosition, + // v_YPosition = this.v_YPosition, + // v_WhenWindowIsMaximized = this.v_WhenWindowIsMaximized, + // v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + // }; + // moveWindow.RunCommand(engine); + //})); + + this.WindowNameAction(engine, new Action((whnd, name) => + { + var moveWindow = new MoveWindowByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_XPosition = this.v_XPosition, + v_YPosition = this.v_YPosition, + v_WhenWindowIsMaximized = this.v_WhenWindowIsMaximized, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + v_WaitTimeBetweenFindAndAction= this.v_WaitTimeBetweenFindAndAction, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + }; + moveWindow.RunCommand(engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/Window/MoveWindowByWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/MoveWindowByWindowHandleCommand.cs similarity index 59% rename from taskt/Core/Automation/Commands/Window/MoveWindowByWindowHandleCommand.cs rename to taskt/Core/Automation/Commands/WindowGroup/MoveWindowByWindowHandleCommand.cs index 4aed8de17..2062b7a9b 100644 --- a/taskt/Core/Automation/Commands/Window/MoveWindowByWindowHandleCommand.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/MoveWindowByWindowHandleCommand.cs @@ -14,7 +14,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class MoveWindowByWindowHandleCommand : AWindowHandleCommands, IWindowPositionProperties + public sealed class MoveWindowByWindowHandleCommand : AWindowHandleActionCommands, IWindowPositionProperties { //[XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] @@ -62,53 +62,92 @@ public sealed class MoveWindowByWindowHandleCommand : AWindowHandleCommands, IWi //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] //public string v_WaitTime { get; set; } + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMaximizedForSet))] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + //public string v_WaintTimeFindAndAction {get; set;} + public MoveWindowByWindowHandleCommand() { } public override void RunCommand(Engine.AutomationEngineInstance engine) { - WindowControls.WindowHandleAction(this, engine, - new Action(whnd => + //WindowControls.WindowHandleAction(this, engine, + // new Action(whnd => + // { + // var xPos = this.ExpandValueOrVariableAsWindowXPosition(whnd, engine); + // var yPos = this.ExpandValueOrVariableAsWindowYPosition(whnd, engine); + + // WindowControls.SetWindowPosition(whnd, xPos, yPos); + // }) + //); + + void MoveWindowProcess(IntPtr wh) + { + var xPos = this.ExpandValueOrVariableAsWindowXPosition(wh, engine); + var yPos = this.ExpandValueOrVariableAsWindowYPosition(wh, engine); + + EM_WindowPositionPropertiesExtensionMethods.MoveWindow(wh, xPos, yPos); + } + + void RestoreWindowProcess(IntPtr wh) + { + var restoreCommand = new SetWindowStateByWindowHandleCommand() + { + v_WindowHandle = wh.ToString(), + v_WindowState = "Restore", + }; + restoreCommand.RunCommand(engine); + } + + this.WindowHandleActionBeforeWaitActivate(engine, new Action((whnd) => + { + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowMinimized(whnd)) + { + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenWindowIsMinimized), engine)) + { + case "execute": + MoveWindowProcess(whnd); + return; + case "ignore": + return; + case "error": + throw new Exception($"Error. Target Window is Minimized. Handle: '{v_WindowHandle}', Expand Value: '{whnd}'"); + + case "restore": + RestoreWindowProcess(whnd); + break; + } + } + + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowMaximized(whnd)) { - //var pos = WindowControls.GetWindowRect(whnd); - - //var variableXPosition = v_XPosition.ExpandValueOrUserVariable(engine); - //int xPos; - //if ((variableXPosition == engine.engineSettings.CurrentWindowPositionKeyword) || (variableXPosition == engine.engineSettings.CurrentWindowXPositionKeyword)) - //{ - // xPos = pos.left; - //} - //else if (variableXPosition == engine.engineSettings.CurrentWindowYPositionKeyword) - //{ - // xPos = pos.top; - //} - //else - //{ - // xPos = v_XPosition.ExpandValueOrUserVariableAsInteger("X Position", engine); - //} - - //var variableYPosition = v_YPosition.ExpandValueOrUserVariable(engine); - //int yPos; - //if ((variableYPosition == engine.engineSettings.CurrentWindowPositionKeyword) || (variableYPosition == engine.engineSettings.CurrentWindowYPositionKeyword)) - //{ - // yPos = pos.top; - //} - //else if (variableYPosition == engine.engineSettings.CurrentWindowXPositionKeyword) - //{ - // yPos = pos.left; - //} - //else - //{ - // yPos = v_YPosition.ExpandValueOrUserVariableAsInteger("Y Position", engine); - //} - - var xPos = this.ExpandValueOrVariableAsWindowXPosition(whnd, engine); - var yPos = this.ExpandValueOrVariableAsWindowYPosition(whnd, engine); - - WindowControls.SetWindowPosition(whnd, xPos, yPos); - }) - ); + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenWindowIsMinimized), engine)) + { + case "execute": + MoveWindowProcess(whnd); + return; + case "ignore": + return; + case "error": + throw new Exception($"Error. Target Window is Maximized. Handle: '{v_WindowHandle}', Expand Value: '{whnd}'"); + + case "restore": + RestoreWindowProcess(whnd); + break; + } + } + + MoveWindowProcess(whnd); + })); } } } \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/MoveWindowsCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/MoveWindowsCommand.cs new file mode 100644 index 000000000..f9a179a13 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/MoveWindowsCommand.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Multi Window Actions")] + [Attributes.ClassAttributes.CommandSettings("Move Windows")] + [Attributes.ClassAttributes.Description("This command Move windows.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Move Windows")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window_close))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class MoveWindowsCommand : AWindowNamesActionCommnads, IWindowPositionProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputXPosition))] + [PropertyParameterOrder(5500)] + public string v_XPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputYPosition))] + [PropertyParameterOrder(5500)] + public string v_YPosition { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMaximizedForSet))] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + public MoveWindowsCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + foreach ((var whnd, _) in wins) + { + var moveWindow = new MoveWindowByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_XPosition = this.v_XPosition, + v_YPosition = this.v_YPosition, + v_WhenWindowIsMaximized = this.v_WhenWindowIsMaximized, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + }; + moveWindow.RunCommand(engine); + } + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/ResizeOneWindowCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/ResizeOneWindowCommand.cs new file mode 100644 index 000000000..8bbae20b4 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/ResizeOneWindowCommand.cs @@ -0,0 +1,74 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("One Window Name Actions")] + [Attributes.ClassAttributes.CommandSettings("Resize One Window")] + [Attributes.ClassAttributes.Description("This command Resize one Window.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Resize one Window.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class ResizeOneWindowCommand : AOneWindowNameActionCommands, IWindowSizeProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWidth))] + [PropertyParameterOrder(5500)] + public string v_Width { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputHeight))] + [PropertyParameterOrder(5500)] + public string v_Height { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + public ResizeOneWindowCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //this.WindowNameActionAndWaitActivate(engine, new Action((whnd, name) => + //{ + // var resizeWindow = new ResizeWindowByWindowHandleCommand() + // { + // v_WindowHandle = whnd.ToString(), + // v_Width = this.v_Width, + // v_Height = this.v_Height, + // v_WhenWindowIsMaximized = this.v_WhenWindowIsMaximized, + // v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + // }; + // resizeWindow.RunCommand(engine); + //})); + + this.WindowNameAction(engine, new Action((whnd, name) => + { + var resizeWindow = new ResizeWindowByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_Width = this.v_Width, + v_Height = this.v_Height, + v_WhenWindowIsMaximized = this.v_WhenWindowIsMaximized, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + }; + resizeWindow.RunCommand(engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/ResizeWindowByWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/ResizeWindowByWindowHandleCommand.cs new file mode 100644 index 000000000..1467fec73 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/ResizeWindowByWindowHandleCommand.cs @@ -0,0 +1,141 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Window Handle Actions")] + [Attributes.ClassAttributes.CommandSettings("Resize Window By Window Handle")] + [Attributes.ClassAttributes.Description("This command resizes a window to a specified size.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to reize a window by name to a specific size on screen.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class ResizeWindowByWindowHandleCommand : AWindowHandleActionCommands, IWindowResizeProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] + //public string v_WindowHandle { get; set; } + + [XmlAttribute] + //[PropertyDescription("Window Width (Pixcel)")] + //[InputSpecification("Window Width", true)] + //[PropertyDetailSampleUsage("**640**", PropertyDetailSampleUsage.ValueType.Value, "Width")] + //[PropertyDetailSampleUsage("**{{{vWidth}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Width")] + //[Remarks("")] + //[PropertyShowSampleUsageInDescription(true)] + //[PropertyTextBoxSetting(1, false)] + //[PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + //[PropertyDisplayText(true, "Width")] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWidth))] + [PropertyParameterOrder(5500)] + public string v_Width { get; set; } + + [XmlAttribute] + //[PropertyDescription("Window Height (Pixcel)")] + //[InputSpecification("Window Height", true)] + //[PropertyDetailSampleUsage("**480**", PropertyDetailSampleUsage.ValueType.Value, "Height")] + //[PropertyDetailSampleUsage("**{{{vHeight}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Height")] + //[Remarks("")] + //[PropertyShowSampleUsageInDescription(true)] + //[PropertyTextBoxSetting(1, false)] + //[PropertyValidationRule("Height", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] + //[PropertyDisplayText(true, "Height")] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputHeight))] + [PropertyParameterOrder(5500)] + public string v_Height { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] + //public string v_WaitTime { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + public ResizeWindowByWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //WindowControls.WindowHandleAction(this, engine, + // new Action(whnd => + // { + // var width = this.ExpandValueOrVariableAsWindowWidth(whnd, engine); + // var height = this.ExpandValueOrVariableAsWindowHeight(whnd, engine); + + // WindowControls.SetWindowSize(whnd, width, height); + // }) + //); + + void ResizeWindowProcess(IntPtr wh) + { + var width = this.ExpandValueOrVariableAsWindowWidth(wh, engine); + var height = this.ExpandValueOrVariableAsWindowHeight(wh, engine); + + EM_WindowResizePropertiesExtensionMethods.ResizeWindow(wh, width, height); + } + + void RestoreWindowProcess(IntPtr wh) + { + var restoreCommand = new SetWindowStateByWindowHandleCommand() + { + v_WindowHandle = wh.ToString(), + v_WindowState = "Restore", + }; + restoreCommand.RunCommand(engine); + } + + this.WindowHandleActionBeforeWaitActivate(engine, new Action((whnd) => + { + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowMinimized(whnd)) + { + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenWindowIsMinimized), engine)) + { + case "execute": + ResizeWindowProcess(whnd); + return; + case "ignore": + return; + case "error": + throw new Exception($"Error. Target Window is Minimized. Handle: '{v_WindowHandle}', Expand Value: '{whnd}'"); + + case "restore": + RestoreWindowProcess(whnd); + break; + } + } + + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowMaximized(whnd)) + { + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WhenWindowIsMinimized), engine)) + { + case "execute": + ResizeWindowProcess(whnd); + return; + case "ignore": + return; + case "error": + throw new Exception($"Error. Target Window is Maximized. Handle: '{v_WindowHandle}', Expand Value: '{whnd}'"); + + case "restore": + RestoreWindowProcess(whnd); + break; + } + } + + ResizeWindowProcess(whnd); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/ResizeWindowsCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/ResizeWindowsCommand.cs new file mode 100644 index 000000000..2a6089d3a --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/ResizeWindowsCommand.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Multi Window Actions")] + [Attributes.ClassAttributes.CommandSettings("Resize Windows")] + [Attributes.ClassAttributes.Description("This command resizes windows.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to reize windows.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class ResizeWindowsCommand : AWindowNamesActionCommnads, IWindowSizeProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWidth))] + [PropertyParameterOrder(5500)] + public string v_Width { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputHeight))] + [PropertyParameterOrder(5500)] + public string v_Height { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyParameterOrder(9000)] + public string v_WhenWindowIsMinimized { get; set; } + + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] + [PropertyParameterOrder(9001)] + public string v_WhenWindowIsMaximized { get; set; } + + public ResizeWindowsCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + foreach ((var whnd, _) in wins) + { + var resizeWindow = new ResizeWindowByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_Width = this.v_Width, + v_Height = this.v_Height, + v_WhenWindowIsMaximized = this.v_WhenWindowIsMaximized, + v_WhenWindowIsMinimized = this.v_WhenWindowIsMinimized, + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + }; + resizeWindow.RunCommand(engine); + } + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/SetOneWindowStateCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/SetOneWindowStateCommand.cs new file mode 100644 index 000000000..fa675df18 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/SetOneWindowStateCommand.cs @@ -0,0 +1,53 @@ +using System; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("One Window Name Actions")] + [Attributes.ClassAttributes.CommandSettings("Set One Window State")] + [Attributes.ClassAttributes.Description("This command Set State one Window.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Set State one Window.")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SetOneWindowStateCommand : AOneWindowNameActionCommands, IWindowStateProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowState))] + [PropertyParameterOrder(6500)] + public string v_WindowState { get; set; } + + public SetOneWindowStateCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //this.WindowNameActionAndWaitActivate(engine, new Action((whnd, name) => + //{ + // var setState = new SetWindowStateByWindowHandleCommand() + // { + // v_WindowHandle = whnd.ToString(), + // v_WindowState = this.v_WindowState, + // }; + // setState.RunCommand(engine); + //})); + + this.WindowNameAction(engine, new Action((whnd, name) => + { + var setState = new SetWindowStateByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_WindowState = this.v_WindowState, + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + }; + setState.RunCommand(engine); + })); + } + } +} diff --git a/taskt/Core/Automation/Commands/WindowGroup/SetWindowStateByWindowHandleCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/SetWindowStateByWindowHandleCommand.cs new file mode 100644 index 000000000..f19ca3870 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/SetWindowStateByWindowHandleCommand.cs @@ -0,0 +1,133 @@ +using System; +using System.Runtime.InteropServices; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Window Handle Actions")] + [Attributes.ClassAttributes.CommandSettings("Set Window State By Window Handle")] + [Attributes.ClassAttributes.Description("This command sets a target window's state.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to change a window's state to minimized, maximized, or restored state")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SetWindowStateByWindowHandleCommand : AWindowHandleActionCommands, IWindowStateProperties + { + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_InputWindowHandle))] + //public string v_WindowHandle { get; set; } + + [XmlAttribute] + //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] + //[PropertyDescription("State of the Window")] + //[PropertyUISelectionOption("Maximize")] + //[PropertyUISelectionOption("Minimize")] + //[PropertyUISelectionOption("Restore")] + //[InputSpecification("", true)] + //[PropertyValidationRule("Window State", PropertyValidationRule.ValidationRuleFlags.Empty)] + //[PropertyDisplayText(true, "State")] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowState))] + [PropertyParameterOrder(5500)] + public string v_WindowState { get; set; } + + //[XmlAttribute] + //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] + //public string v_WaitTime { get; set; } + + //public string v_WaitTimeBetweenFindAndAction + + ///// + ///// check minimize + ///// + ///// + ///// + //[DllImport("user32.dll")] + //private static extern bool IsIconic(IntPtr hWnd); + + + [DllImport("user32.dll")] + private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + + [DllImport("user32.dll")] + private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); + + /// + /// window maximize value + /// + private const int MAXIMIZE = 3; + /// + /// window minimize value + /// + private const int MINIMIZE = 6; + /// + /// window restore value + /// + private const int RESTORE = 9; + + public SetWindowStateByWindowHandleCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + //WindowControls.WindowHandleAction(this, engine, + // new Action(whnd => + // { + // var windowState = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WindowState), engine); + // var state = WindowControls.WindowState.SW_RESTORE; + // switch (windowState.ToLower()) + // { + // case "maximize": + // state = WindowControls.WindowState.SW_MAXIMIZE; + // break; + // case "minimize": + // state = WindowControls.WindowState.SW_MINIMIZE; + // break; + // } + + // if (WindowControls.IsIconic(whnd) && (state != WindowControls.WindowState.SW_MINIMIZE)) + // { + // WindowControls.ShowIconicWindow(whnd); + // } + // WindowControls.SetWindowState(whnd, state); + // }) + //); + + this.WindowHandleActionBeforeWaitActivate(engine, new Action((whnd) => + { + int state = 0; + switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WindowState), engine)) + { + case "maximize": + state = MAXIMIZE; + break; + case "minimize": + state = MINIMIZE; + break; + case "restore": + state = RESTORE; + break; + case "3": + state = MAXIMIZE; + break; + case "2": + state = MINIMIZE; + break; + case "1": + state = RESTORE; + break; + } + + if (EM_CanHandleWindowHandleExtentionMethods.IsWindowMinimized(whnd) && (state != MINIMIZE)) + { + ShowWindowAsync(whnd, state); + } + ShowWindow(whnd, state); + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/WindowGroup/SetWindowsStateCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/SetWindowsStateCommand.cs new file mode 100644 index 000000000..010818a77 --- /dev/null +++ b/taskt/Core/Automation/Commands/WindowGroup/SetWindowsStateCommand.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using taskt.Core.Automation.Attributes.PropertyAttributes; + +namespace taskt.Core.Automation.Commands +{ + [Serializable] + [Attributes.ClassAttributes.Group("Window")] + [Attributes.ClassAttributes.SubGruop("Multi Window Actions")] + [Attributes.ClassAttributes.CommandSettings("Set Windows State")] + [Attributes.ClassAttributes.Description("This command sets a target windows state.")] + [Attributes.ClassAttributes.UsesDescription("Use this command when you want to change a windows state to minimized, maximized, or restored state")] + [Attributes.ClassAttributes.ImplementationDescription("")] + [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] + [Attributes.ClassAttributes.EnableAutomateRender(true)] + [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] + public sealed class SetWindowsStateCommand : AWindowNamesActionCommnads, IWindowStateProperties + { + [XmlAttribute] + [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WindowState))] + [PropertyParameterOrder(6500)] + public string v_WindowState { get; set; } + + public SetWindowsStateCommand() + { + } + + public override void RunCommand(Engine.AutomationEngineInstance engine) + { + this.WindowNamesAction(engine, new Action>(wins => + { + foreach ((var whnd, _) in wins) + { + var setState = new SetWindowStateByWindowHandleCommand() + { + v_WindowHandle = whnd.ToString(), + v_WindowState = this.v_WindowState, + v_WaitTimeBetweenFindAndAction = this.v_WaitTimeBetweenFindAndAction, + v_ActivateBeforeAction = this.v_ActivateBeforeAction, + }; + setState.RunCommand(engine); + } + })); + } + } +} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/Window/WaitForWindowToExistsCommand.cs b/taskt/Core/Automation/Commands/WindowGroup/WaitForWindowToExistsCommand.cs similarity index 86% rename from taskt/Core/Automation/Commands/Window/WaitForWindowToExistsCommand.cs rename to taskt/Core/Automation/Commands/WindowGroup/WaitForWindowToExistsCommand.cs index 070a5ae61..178832d2e 100644 --- a/taskt/Core/Automation/Commands/Window/WaitForWindowToExistsCommand.cs +++ b/taskt/Core/Automation/Commands/WindowGroup/WaitForWindowToExistsCommand.cs @@ -1,11 +1,10 @@ using System; -using System.Collections.Generic; namespace taskt.Core.Automation.Commands { [Serializable] [Attributes.ClassAttributes.Group("Window")] - [Attributes.ClassAttributes.SubGruop("Window Actions")] + [Attributes.ClassAttributes.SubGruop("One Window Name Actions")] [Attributes.ClassAttributes.CommandSettings("Wait For Window To Exists")] [Attributes.ClassAttributes.Description("This command waits for a window to exist.")] [Attributes.ClassAttributes.UsesDescription("Use this command when you want to explicitly wait for a window to exist before continuing script execution.")] @@ -13,7 +12,7 @@ namespace taskt.Core.Automation.Commands [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] [Attributes.ClassAttributes.EnableAutomateRender(true)] [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] - public sealed class WaitForWindowToExistsCommand : AAnyWindowNameCommands + public sealed class WaitForWindowToExistsCommand : AWindowNameCoreCommands { //[XmlAttribute] //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] @@ -49,12 +48,13 @@ public WaitForWindowToExistsCommand() public override void RunCommand(Engine.AutomationEngineInstance engine) { - WindowControls.WindowAction(this, engine, - new Action>(wins => - { - // nothing to do - }) - ); + //WindowControls.WindowAction(this, engine, + // new Action>(wins => + // { + // // nothing to do + // }) + //); + this.WaitForWindowNames(engine); } //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) diff --git a/taskt/Core/Automation/Commands/Word/WordAddDocumentCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordAddDocumentCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordAddDocumentCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordAddDocumentCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordAppendDataTableCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordAppendDataTableCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordAppendDataTableCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordAppendDataTableCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordAppendImageCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordAppendImageCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordAppendImageCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordAppendImageCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordAppendTextCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordAppendTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordAppendTextCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordAppendTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordCheckWordInstanceExistsCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordCheckWordInstanceExistsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordCheckWordInstanceExistsCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordCheckWordInstanceExistsCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordCloseWordInstanceCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordCloseWordInstanceCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordCloseWordInstanceCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordCloseWordInstanceCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordCreateWordInstanceCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordCreateWordInstanceCommand.cs similarity index 97% rename from taskt/Core/Automation/Commands/Word/WordCreateWordInstanceCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordCreateWordInstanceCommand.cs index 9dc6524e1..800e98a40 100644 --- a/taskt/Core/Automation/Commands/Word/WordCreateWordInstanceCommand.cs +++ b/taskt/Core/Automation/Commands/WordGroup/WordCreateWordInstanceCommand.cs @@ -58,7 +58,7 @@ public override void RunCommand(Engine.AutomationEngineInstance engine) newWordSession.Application.Caption = newCaption; bool isFound = false; - foreach(var p in Process.GetProcessesByName("winword")) + foreach(var p in System.Diagnostics.Process.GetProcessesByName("winword")) { if (p.MainWindowTitle == newCaption) { diff --git a/taskt/Core/Automation/Commands/Word/WordExportToPDFCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordExportToPDFCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordExportToPDFCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordExportToPDFCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordOpenDocumentCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordOpenDocumentCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordOpenDocumentCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordOpenDocumentCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordReadDocumentCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordReadDocumentCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordReadDocumentCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordReadDocumentCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordReplaceTextCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordReplaceTextCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordReplaceTextCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordReplaceTextCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordSaveAsCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordSaveAsCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordSaveAsCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordSaveAsCommand.cs diff --git a/taskt/Core/Automation/Commands/Word/WordSaveCommand.cs b/taskt/Core/Automation/Commands/WordGroup/WordSaveCommand.cs similarity index 100% rename from taskt/Core/Automation/Commands/Word/WordSaveCommand.cs rename to taskt/Core/Automation/Commands/WordGroup/WordSaveCommand.cs diff --git a/taskt/Core/Automation/Commands/_General/EM_ExpandablePropertiesExtensionMethods.cs b/taskt/Core/Automation/Commands/_General/EM_ExpandablePropertiesExtensionMethods.cs index 8484f29e8..cfe8ab6b3 100644 --- a/taskt/Core/Automation/Commands/_General/EM_ExpandablePropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Commands/_General/EM_ExpandablePropertiesExtensionMethods.cs @@ -10,7 +10,7 @@ public static class EM_ExpandablePropertiesExtensionMethods /// /// /// - public static ScriptCommand ToScriptCommand(this ILExpandableProperties command) + public static ScriptCommand ToScriptCommand(this IExpandableProperties command) { // TODO: It will eventually go out of use. return (ScriptCommand)command; diff --git a/taskt/Core/Automation/Commands/_General/ICanHandleFileOrFolderName.cs b/taskt/Core/Automation/Commands/_General/ICanHandleFileOrFolderName.cs index 8bc703d20..febbb3229 100644 --- a/taskt/Core/Automation/Commands/_General/ICanHandleFileOrFolderName.cs +++ b/taskt/Core/Automation/Commands/_General/ICanHandleFileOrFolderName.cs @@ -3,7 +3,7 @@ /// /// for handle file or folder name /// - public interface ICanHandleFileOrFolderName : ILExpandableProperties + public interface ICanHandleFileOrFolderName : IExpandableProperties { // nothing } diff --git a/taskt/Core/Automation/Commands/_General/ICanHandleFileOrFolderPath.cs b/taskt/Core/Automation/Commands/_General/ICanHandleFileOrFolderPath.cs index d4ae81c0a..b39e5e7df 100644 --- a/taskt/Core/Automation/Commands/_General/ICanHandleFileOrFolderPath.cs +++ b/taskt/Core/Automation/Commands/_General/ICanHandleFileOrFolderPath.cs @@ -3,7 +3,7 @@ /// /// for file or folder path /// - public interface ICanHandleFileOrFolderPath : ILExpandableProperties + public interface ICanHandleFileOrFolderPath : IExpandableProperties { // nothing } diff --git a/taskt/Core/Automation/Commands/_General/ICheckProperties.cs b/taskt/Core/Automation/Commands/_General/ICheckProperties.cs new file mode 100644 index 000000000..0848a43a5 --- /dev/null +++ b/taskt/Core/Automation/Commands/_General/ICheckProperties.cs @@ -0,0 +1,13 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// general check properties + /// + public interface ICheckProperties : IExpandableProperties + { + /// + /// check method + /// + string v_CheckMethod { get; set; } + } +} diff --git a/taskt/Core/Automation/Commands/_General/ILExpandableProperties.cs b/taskt/Core/Automation/Commands/_General/IExpandableProperties.cs similarity index 82% rename from taskt/Core/Automation/Commands/_General/ILExpandableProperties.cs rename to taskt/Core/Automation/Commands/_General/IExpandableProperties.cs index 377c2ebaa..017089b78 100644 --- a/taskt/Core/Automation/Commands/_General/ILExpandableProperties.cs +++ b/taskt/Core/Automation/Commands/_General/IExpandableProperties.cs @@ -4,7 +4,7 @@ /// expandable properties (base of interfaces) /// for future process changes /// - public interface ILExpandableProperties + public interface IExpandableProperties { // nothing } diff --git a/taskt/Core/Automation/Commands/_General/ILFilterValueProperties.cs b/taskt/Core/Automation/Commands/_General/IFilterValueProperties.cs similarity index 88% rename from taskt/Core/Automation/Commands/_General/ILFilterValueProperties.cs rename to taskt/Core/Automation/Commands/_General/IFilterValueProperties.cs index 4ed549acc..3e1cd3b53 100644 --- a/taskt/Core/Automation/Commands/_General/ILFilterValueProperties.cs +++ b/taskt/Core/Automation/Commands/_General/IFilterValueProperties.cs @@ -5,7 +5,7 @@ namespace taskt.Core.Automation.Commands /// /// Filter Value Properties /// - public interface ILFilterValueProperties : ILExpandableProperties + public interface IFilterValueProperties : IExpandableProperties { /// /// Value Type (Text or Number) diff --git a/taskt/Core/Automation/Commands/_General/ILCompareProperties.cs b/taskt/Core/Automation/Commands/_General/ILCompareProperties.cs deleted file mode 100644 index ff2c43762..000000000 --- a/taskt/Core/Automation/Commands/_General/ILCompareProperties.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace taskt.Core.Automation.Commands -{ - /// - /// general compare properties - /// - public interface ILCompareProperties : ILExpandableProperties - { - /// - /// compare method - /// - string v_CompareMethod { get; set; } - - /// - /// compare method is case sensitive or not - /// - string v_CaseSensitive { get; set; } - } -} diff --git a/taskt/Core/Automation/Commands/_General/ILPositionProperties.cs b/taskt/Core/Automation/Commands/_General/IPositionProperties.cs similarity index 84% rename from taskt/Core/Automation/Commands/_General/ILPositionProperties.cs rename to taskt/Core/Automation/Commands/_General/IPositionProperties.cs index 5ee3ef342..e240c2796 100644 --- a/taskt/Core/Automation/Commands/_General/ILPositionProperties.cs +++ b/taskt/Core/Automation/Commands/_General/IPositionProperties.cs @@ -3,7 +3,7 @@ /// /// general position properties /// - public interface ILPositionProperties : ILExpandableProperties + public interface IPositionProperties : IExpandableProperties { /// /// x position diff --git a/taskt/Core/Automation/Commands/_General/ILReplaceValueProperties.cs b/taskt/Core/Automation/Commands/_General/IReplaceValueProperties.cs similarity index 90% rename from taskt/Core/Automation/Commands/_General/ILReplaceValueProperties.cs rename to taskt/Core/Automation/Commands/_General/IReplaceValueProperties.cs index d8dd58476..227d4258d 100644 --- a/taskt/Core/Automation/Commands/_General/ILReplaceValueProperties.cs +++ b/taskt/Core/Automation/Commands/_General/IReplaceValueProperties.cs @@ -5,7 +5,7 @@ namespace taskt.Core.Automation.Commands /// /// Replace value properties /// - public interface ILReplaceValueProperties : ILExpandableProperties + public interface IReplaceValueProperties : IExpandableProperties { /// /// Value Type (Text or Number) diff --git a/taskt/Core/Automation/Commands/_General/ILResultProperties.cs b/taskt/Core/Automation/Commands/_General/IResultProperties.cs similarity index 86% rename from taskt/Core/Automation/Commands/_General/ILResultProperties.cs rename to taskt/Core/Automation/Commands/_General/IResultProperties.cs index e5abfe50a..a7100abc2 100644 --- a/taskt/Core/Automation/Commands/_General/ILResultProperties.cs +++ b/taskt/Core/Automation/Commands/_General/IResultProperties.cs @@ -3,7 +3,7 @@ /// /// Result properties /// - public interface ILResultProperties + public interface IResultProperties { /// /// Variable Name to Store Result diff --git a/taskt/Core/Automation/Commands/_General/ISelectionMethodProperties.cs b/taskt/Core/Automation/Commands/_General/ISelectionMethodProperties.cs new file mode 100644 index 000000000..b47bb45ba --- /dev/null +++ b/taskt/Core/Automation/Commands/_General/ISelectionMethodProperties.cs @@ -0,0 +1,15 @@ +namespace taskt.Core.Automation.Commands +{ + /// + /// general selection properties + /// + public interface ISelectionMethodProperties + { + /// + /// selection method + /// + string v_SelectionMethod { get; set; } + + // index property name is v_Target***Index + } +} diff --git a/taskt/Core/Automation/Commands/_General/ILSizeProperties.cs b/taskt/Core/Automation/Commands/_General/ISizeProperties.cs similarity index 84% rename from taskt/Core/Automation/Commands/_General/ILSizeProperties.cs rename to taskt/Core/Automation/Commands/_General/ISizeProperties.cs index 5444ee11f..e4346fd89 100644 --- a/taskt/Core/Automation/Commands/_General/ILSizeProperties.cs +++ b/taskt/Core/Automation/Commands/_General/ISizeProperties.cs @@ -3,7 +3,7 @@ /// /// general size properties /// - public interface ILSizeProperties : ILExpandableProperties + public interface ISizeProperties : IExpandableProperties { /// /// width diff --git a/taskt/Core/Automation/Commands/_General/ITextCompareProperties.cs b/taskt/Core/Automation/Commands/_General/ITextCompareProperties.cs deleted file mode 100644 index 6e578258f..000000000 --- a/taskt/Core/Automation/Commands/_General/ITextCompareProperties.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace taskt.Core.Automation.Commands -{ - /// - /// text compare properties - /// - public interface ITextCompareProperties : ILCompareProperties - { - /// - /// Trim Before Compare - /// - string v_TrimBeforeCompare { get; set; } - } -} diff --git a/taskt/Core/Automation/Commands/_General/ILUIParameterProperties.cs b/taskt/Core/Automation/Commands/_General/IUIParameterProperties.cs similarity index 86% rename from taskt/Core/Automation/Commands/_General/ILUIParameterProperties.cs rename to taskt/Core/Automation/Commands/_General/IUIParameterProperties.cs index 8241c33cb..9f0efd5f0 100644 --- a/taskt/Core/Automation/Commands/_General/ILUIParameterProperties.cs +++ b/taskt/Core/Automation/Commands/_General/IUIParameterProperties.cs @@ -6,7 +6,7 @@ namespace taskt.Core.Automation.Commands /// /// for search & use Control for ScriptCommand parameters /// - public interface ILUIParameterProperties + public interface IUIParameterProperties { Dictionary ControlsList { get; } } diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/ActivateWindowCommand.cs b/taskt/Core/Automation/Commands/_RemovedCommands/ActivateWindowCommand.cs new file mode 100644 index 000000000..7e69eb1e6 --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/ActivateWindowCommand.cs @@ -0,0 +1,80 @@ +//using System; +//using System.Collections.Generic; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Window Actions")] +// [Attributes.ClassAttributes.CommandSettings("Activate Window")] +// [Attributes.ClassAttributes.Description("This command activates a window and brings it to the front.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want to active a window by name or bring it to attention.")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class ActivateWindowCommand : AOneWindowNameCommands +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] +// //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] +// //public string v_MatchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] +// //public string v_NameResult { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] +// //public string v_HandleResult { get; set; } + +// public ActivateWindowCommand() +// { +// //this.CommandName = "ActivateWindowCommand"; +// //this.SelectionName = "Activate Window"; +// //this.CommandEnabled = true; +// //this.CustomRendering = true; +// } + +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction(this, engine, +// new Action>(wins => +// { +// foreach (var win in wins) +// { +// WindowControls.ActivateWindow(win.Item1); +// } +// }) +// ); +// } + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // //ComboBox cmb = (ComboBox)ControlsList[nameof(v_WindowName)]; +// // //cmb.AddWindowNames(); +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/CloseWindowCommand.cs b/taskt/Core/Automation/Commands/_RemovedCommands/CloseWindowCommand.cs new file mode 100644 index 000000000..e7ce037fe --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/CloseWindowCommand.cs @@ -0,0 +1,78 @@ +//using System; +//using System.Collections.Generic; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Window Actions")] +// [Attributes.ClassAttributes.CommandSettings("Close Window")] +// [Attributes.ClassAttributes.Description("This command closes an open window.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want to close an existing window by name.")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window_close))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class CloseWindowCommand : AOneWindowNameCommands +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] +// //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] +// //public string v_MatchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] +// //public string v_NameResult { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] +// //public string v_HandleResult { get; set; } + +// public CloseWindowCommand() +// { +// //this.CommandName = "CloseWindowCommand"; +// //this.SelectionName = "Close Window"; +// //this.CommandEnabled = true; +// //this.CustomRendering = true; +// } + +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction(this, engine, +// new Action>(wins => +// { +// foreach (var win in wins) +// { +// WindowControls.CloseWindow(win.Item1); +// } +// }) +// ); +// } + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/GetProcessNameFromWindowName.cs b/taskt/Core/Automation/Commands/_RemovedCommands/GetProcessNameFromWindowName.cs new file mode 100644 index 000000000..e2caa9c49 --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/GetProcessNameFromWindowName.cs @@ -0,0 +1,84 @@ +//using System; +//using System.Diagnostics; +//using System.Xml.Serialization; +//using System.Collections.Generic; +//using taskt.Core.Automation.Attributes.PropertyAttributes; +//using System.Linq; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Get From Window Name")] +// [Attributes.ClassAttributes.CommandSettings("Get Process Name From Window Name")] +// [Attributes.ClassAttributes.Description("This command allows you to Get Process Name from Window Name.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Process Name from Window Name.")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class GetProcessNameFromWindowNameCommand : AOneWindowNameCommands +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] +// [PropertyValidationRule("Result", PropertyValidationRule.ValidationRuleFlags.Empty)] +// [PropertyParameterOrder(6500)] +// public string v_Result { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod_Single))] +// //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] +// //public string v_MatchMethod { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] +// public override string v_MatchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //public string v_NameResult { get; set; } + +// //[XmlAttribute] +// //public string v_HandleResult { get; set; } + +// public GetProcessNameFromWindowNameCommand() +// { +// } + +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction( this, engine, +// new Action>(wins => +// { +// var proc = Process.GetProcesses().Where(p => (p.MainWindowHandle == wins[0].Item1)).First(); +// proc.ProcessName.StoreInUserVariable(engine, v_Result); +// }) +// ); +// } + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowHandleFromWindowName.cs b/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowHandleFromWindowName.cs new file mode 100644 index 000000000..e9aa57579 --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowHandleFromWindowName.cs @@ -0,0 +1,74 @@ +//using System; +//using System.Xml.Serialization; +//using System.Collections.Generic; +//using taskt.Core.Automation.Attributes.PropertyAttributes; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Get From Window Name")] +// [Attributes.ClassAttributes.CommandSettings("Get Window Handle From Window Name")] +// [Attributes.ClassAttributes.Description("This command allows you to Get Window Handle from Window Name.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want to Get Window Handle from Window Name.")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class GetWindowHandleFromWindowNameCommand : AOneWindowNameCommands +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// [XmlAttribute] +// [PropertyIsOptional(false)] +// [PropertyValidationRule("Window Handle", PropertyValidationRule.ValidationRuleFlags.Empty)] +// [PropertyParameterOrder(6500)] +// public override string v_HandleResult { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] +// public override string v_MatchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] +// //public string v_NameResult { get; set; } + +// public GetWindowHandleFromWindowNameCommand() +// { +// } + +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction(this, engine, +// new Action>(wins => +// { +// wins[0].Item1.StoreInUserVariable(engine, v_HandleResult); +// }) +// ); +// } + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowPositionCommand.cs b/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowPositionCommand.cs new file mode 100644 index 000000000..94c85e69f --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowPositionCommand.cs @@ -0,0 +1,152 @@ +//using System; +//using System.Xml.Serialization; +//using System.Collections.Generic; +//using taskt.Core.Automation.Attributes.PropertyAttributes; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Get From Window Name")] +// [Attributes.ClassAttributes.CommandSettings("Get Window Position")] +// [Attributes.ClassAttributes.Description("This command returns window position.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want window position.")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class GetWindowPositionCommand : AOneWindowNameCommands, IWindowPositionProperties +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] +// [PropertyDescription("Variable Name to Recieve the Window Position X")] +// [PropertyIsOptional(true)] +// [PropertyDisplayText(false, "")] +// [PropertyParameterOrder(6500)] +// public string v_XPosition { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] +// [PropertyDescription("Variable Name to Recieve the Window Position Y")] +// [PropertyIsOptional(true)] +// [PropertyDisplayText(false, "")] +// [PropertyParameterOrder(6500)] +// public string v_YPosition { get; set; } + +// [XmlAttribute] +// [PropertyDescription("Base position")] +// [InputSpecification("", true)] +// [SampleUsage("")] +// [Remarks("")] +// [PropertyUISelectionOption("Top Left")] +// [PropertyUISelectionOption("Bottom Right")] +// [PropertyUISelectionOption("Top Right")] +// [PropertyUISelectionOption("Bottom Left")] +// [PropertyUISelectionOption("Center")] +// [PropertyRecommendedUIControl(PropertyRecommendedUIControl.RecommendeUIControlType.ComboBox)] +// [PropertyIsOptional(true, "Top Left")] +// [PropertyParameterOrder(6500)] +// public string v_PositionBase { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] +// public override string v_MatchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] +// //public string v_NameResult { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] +// //public string v_HandleResult { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] +// [PropertyParameterOrder(9000)] +// public string v_WhenWindowIsMinimized { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMaximizedForGet))] +// [PropertyIsOptional(true, "Execute")] +// [PropertyParameterOrder(9001)] +// public string v_WhenWindowIsMaximized { get; set; } + +// public GetWindowPositionCommand() +// { +// //this.CommandName = "GetWindowPositionCommand"; +// //this.SelectionName = "Get Window Position"; +// //this.CommandEnabled = true; +// //this.CustomRendering = true; +// } +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction(this, engine, +// new Action>(wins => +// { +// var whnd = wins[0].Item1; + +// var pos = WindowControls.GetWindowRect(whnd); + +// int x = 0, y = 0; +// switch (this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_PositionBase), engine)) +// { +// case "top left": +// x = pos.left; +// y = pos.top; +// break; +// case "bottom right": +// x = pos.right; +// y = pos.bottom; +// break; +// case "top right": +// x = pos.right; +// y = pos.top; +// break; +// case "bottom left": +// x = pos.left; +// y = pos.bottom; +// break; +// case "center": +// x = (pos.right + pos.left) / 2; +// y = (pos.top + pos.bottom) / 2; +// break; +// } +// if (!string.IsNullOrEmpty(v_XPosition)) +// { +// x.ToString().StoreInUserVariable(engine, v_XPosition); +// } +// if (!string.IsNullOrEmpty(v_YPosition)) +// { +// y.ToString().StoreInUserVariable(engine, v_YPosition); +// } +// }) +// ); +// } + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowSizeCommand.cs b/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowSizeCommand.cs new file mode 100644 index 000000000..b6fcaf98e --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowSizeCommand.cs @@ -0,0 +1,103 @@ +//using System; +//using System.Xml.Serialization; +//using System.Collections.Generic; +//using taskt.Core.Automation.Attributes.PropertyAttributes; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Get From Window Name")] +// [Attributes.ClassAttributes.CommandSettings("Get Window Size")] +// [Attributes.ClassAttributes.Description("This command returns window size.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want window size.")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class GetWindowSizeCommand : AOneWindowNameCommands, IWindowSizeProperties +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] +// [PropertyDescription("Variable Name to Recieve the Window Width")] +// [PropertyIsOptional(true)] +// [PropertyDisplayText(false, "")] +// [PropertyParameterOrder(6500)] +// public string v_Width { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] +// [PropertyDescription("Variable Name to Recieve the Window Height")] +// [PropertyIsOptional(true)] +// [PropertyDisplayText(false, "")] +// [PropertyParameterOrder(6500)] +// public string v_Height { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] +// public override string v_MatchMethod { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForGet))] +// [PropertyParameterOrder(9000)] +// public string v_WhenWindowIsMinimized { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] +// //public string v_NameResult { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] +// //public string v_HandleResult { get; set; } + +// public GetWindowSizeCommand() +// { +// } +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction(this, engine, +// new Action>(wins => +// { +// var whnd = wins[0].Item1; + +// var rct = WindowControls.GetWindowRect(whnd); + +// if (!string.IsNullOrEmpty(v_Width)) +// { +// (rct.right - rct.left).StoreInUserVariable(engine, v_Width); +// } +// if (!string.IsNullOrEmpty(v_Height)) +// { +// (rct.bottom - rct.top).StoreInUserVariable(engine, v_Height); +// } +// }) +// ); +// } + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowStateCommand.cs b/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowStateCommand.cs new file mode 100644 index 000000000..2d968b950 --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/GetWindowStateCommand.cs @@ -0,0 +1,85 @@ +//using System; +//using System.Xml.Serialization; +//using System.Collections.Generic; +//using taskt.Core.Automation.Attributes.PropertyAttributes; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Get From Window Name")] +// [Attributes.ClassAttributes.CommandSettings("Get Window State")] +// [Attributes.ClassAttributes.Description("This command returns a state of window name.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want to get a window state.")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class GetWindowStateCommand : AOneWindowNameCommands, IWindowStateProperties +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_Result))] +// [Remarks("Restore is **1**, Minimize is **2**, Maximize is **3**")] +// [PropertyParameterOrder(6500)] +// public string v_WindowState { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_MatchMethod_Single))] +// public override string v_MatchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] +// //public string v_NameResult { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] +// //public string v_HandleResult { get; set; } + +// public GetWindowStateCommand() +// { +// //this.CommandName = "GetWindowStateCommand"; +// //this.SelectionName = "Get Window State"; +// //this.CommandEnabled = true; +// //this.CustomRendering = true; +// } + +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction(this, engine, +// new Action>(wins => +// { +// var whnd = wins[0].Item1; + +// var state = WindowControls.GetWindowState(whnd); +// state.ToString().StoreInUserVariable(engine, v_WindowState); +// }) +// ); +// } + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/MoveWindowCommand.cs b/taskt/Core/Automation/Commands/_RemovedCommands/MoveWindowCommand.cs new file mode 100644 index 000000000..ae3a5c80b --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/MoveWindowCommand.cs @@ -0,0 +1,165 @@ +//using System; +//using System.Xml.Serialization; +//using System.Collections.Generic; +//using taskt.Core.Automation.Attributes.PropertyAttributes; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Window Actions")] +// [Attributes.ClassAttributes.CommandSettings("Move Window")] +// [Attributes.ClassAttributes.Description("This command moves a window to a specified location on screen.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want to move an existing window by name to a certain point on the screen.")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class MoveWindowCommand : AOneWindowNameCommands, IWindowPositionProperties +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// [XmlAttribute] +// //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] +// //[PropertyDescription("X horizontal coordinate (pixel) for the Window's Location")] +// //[InputSpecification("X Window Location", true)] +// //[PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] +// //[PropertyDetailSampleUsage("**0**", "Specify X Top Position")] +// //[PropertyDetailSampleUsage("**100**", PropertyDetailSampleUsage.ValueType.Value, "X Position")] +// //[PropertyDetailSampleUsage("**{{{vXPos}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "X Position")] +// //[PropertyDetailSampleUsage("**%kwd_current_position%**", "Specify Current Position for X Position")] +// //[PropertyDetailSampleUsage("**%kwd_current_xposition%**", "Specify Current X Position for X Position", false)] +// //[PropertyDetailSampleUsage("**%kwd_current_yposition%**", "Specify Current Y Position for X Position", false)] +// //[Remarks("This number is the pixel location on screen. Maximum value should be the maximum value allowed by your resolution. For 1920x1080, the valid range could be 0-1920")] +// //[PropertyValidationRule("X Position", PropertyValidationRule.ValidationRuleFlags.Empty)] +// //[PropertyDisplayText(true, "X Position")] +// //[PropertyIntermediateConvert(nameof(ApplicationSettings.EngineSettings.convertToIntermediateWindowPosition), nameof(ApplicationSettings.EngineSettings.convertToRawWindowPosition))] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputXPosition))] +// [PropertyParameterOrder(6500)] +// public string v_XPosition { get; set; } + +// [XmlAttribute] +// //[PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_DisallowNewLine_OneLineTextBox))] +// //[PropertyDescription("Y vertical coordinate (pixel) for the Window's Location")] +// //[InputSpecification("Y Window Location", true)] +// //[PropertyDetailSampleUsageBehavior(MultiAttributesBehavior.Overwrite)] +// //[PropertyDetailSampleUsage("**0**", "Specify Y Left Position")] +// //[PropertyDetailSampleUsage("**100**", PropertyDetailSampleUsage.ValueType.Value, "Y Position")] +// //[PropertyDetailSampleUsage("**{{{vYPos}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Y Position")] +// //[PropertyDetailSampleUsage("**%kwd_current_position%**", "Specify Current Position for Y Position")] +// //[PropertyDetailSampleUsage("**%kwd_current_xposition%**", "Specify Current X Position for Y Position", false)] +// //[PropertyDetailSampleUsage("**%kwd_current_yposition%**", "Specify Current Y Position for Y Position", false)] +// //[Remarks("This number is the pixel location on screen. Maximum value should be the maximum value allowed by your resolution. For 1920x1080, the valid range could be 0-1080")] +// //[PropertyValidationRule("Y Position", PropertyValidationRule.ValidationRuleFlags.Empty)] +// //[PropertyDisplayText(true, "Y Position")] +// //[PropertyIntermediateConvert(nameof(ApplicationSettings.EngineSettings.convertToIntermediateWindowPosition), nameof(ApplicationSettings.EngineSettings.convertToRawWindowPosition))] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputYPosition))] +// [PropertyParameterOrder(6500)] +// public string v_YPosition { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] +// //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] +// //public string v_MatchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] +// //public string v_NameResult { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] +// //public string v_HandleResult { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] +// [PropertyParameterOrder(9000)] +// public string v_WhenWindowIsMinimized { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMaximizedForSet))] +// [PropertyParameterOrder(9001)] +// public string v_WhenWindowIsMaximized { get; set; } + +// public MoveWindowCommand() +// { +// //this.CommandName = "MoveWindowCommand"; +// //this.SelectionName = "Move Window"; +// //this.CommandEnabled = true; +// //this.CustomRendering = true; +// } + +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction(this, engine, +// new Action>(wins => +// { +// foreach (var win in wins) +// { +// //var pos = WindowControls.GetWindowRect(win.Item1); + +// //var variableXPosition = v_XPosition.ExpandValueOrUserVariable(engine); +// //int xPos; +// //if ((variableXPosition == engine.engineSettings.CurrentWindowPositionKeyword) || (variableXPosition == engine.engineSettings.CurrentWindowXPositionKeyword)) +// //{ +// // xPos = pos.left; +// //} +// //else if (variableXPosition == engine.engineSettings.CurrentWindowYPositionKeyword) +// //{ +// // xPos = pos.top; +// //} +// //else +// //{ +// // xPos = v_XPosition.ExpandValueOrUserVariableAsInteger("X Position", engine); +// //} + +// //var variableYPosition = v_YPosition.ExpandValueOrUserVariable(engine); +// //int yPos; +// //if ((variableYPosition == engine.engineSettings.CurrentWindowPositionKeyword) || (variableYPosition == engine.engineSettings.CurrentWindowYPositionKeyword)) +// //{ +// // yPos = pos.top; +// //} +// //else if (variableYPosition == engine.engineSettings.CurrentWindowXPositionKeyword) +// //{ +// // yPos = pos.left; +// //} +// //else +// //{ +// // yPos = v_YPosition.ExpandValueOrUserVariableAsInteger("Y Position", engine); +// //} + +// var whnd = win.Item1; + +// var xPos = this.ExpandValueOrVariableAsWindowXPosition(whnd, engine); +// var yPos = this.ExpandValueOrVariableAsWindowYPosition(whnd, engine); + +// WindowControls.SetWindowPosition(win.Item1, xPos, yPos); +// } +// }) +// ); +// } + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/ResizeWindowCommand.cs b/taskt/Core/Automation/Commands/_RemovedCommands/ResizeWindowCommand.cs new file mode 100644 index 000000000..e3b9193e1 --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/ResizeWindowCommand.cs @@ -0,0 +1,127 @@ +//using System; +//using System.Xml.Serialization; +//using System.Collections.Generic; +//using taskt.Core.Automation.Attributes.PropertyAttributes; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Window Actions")] +// [Attributes.ClassAttributes.CommandSettings("Resize Window")] +// [Attributes.ClassAttributes.Description("This command resizes a window to a specified size.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want to reize a window by name to a specific size on screen.")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class ResizeWindowCommand : AOneWindowNameCommands, IWindowResizeProperties +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// [XmlAttribute] +// //[PropertyDescription("Window Width (Pixcel)")] +// //[InputSpecification("Window Width", true)] +// //[PropertyDetailSampleUsage("**640**", PropertyDetailSampleUsage.ValueType.Value, "Width")] +// //[PropertyDetailSampleUsage("**{{{vWidth}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Width")] +// //[Remarks("")] +// //[PropertyShowSampleUsageInDescription(true)] +// //[PropertyTextBoxSetting(1, false)] +// //[PropertyValidationRule("Width", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] +// //[PropertyDisplayText(true, "Width")] +// //[PropertyAvailableSystemVariable(Engine.SystemVariables.LimitedSystemVariableNames.Window_Size)] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputWidth))] +// [PropertyParameterOrder(6500)] +// public string v_Width { get; set; } + +// [XmlAttribute] +// //[PropertyDescription("Window Height (Pixcel)")] +// //[InputSpecification("Window Height", true)] +// //[PropertyDetailSampleUsage("**480**", PropertyDetailSampleUsage.ValueType.Value, "Height")] +// //[PropertyDetailSampleUsage("**{{{vHeight}}}**", PropertyDetailSampleUsage.ValueType.VariableValue, "Height")] +// //[Remarks("")] +// //[PropertyShowSampleUsageInDescription(true)] +// //[PropertyTextBoxSetting(1, false)] +// //[PropertyValidationRule("Height", PropertyValidationRule.ValidationRuleFlags.Empty | PropertyValidationRule.ValidationRuleFlags.EqualsZero | PropertyValidationRule.ValidationRuleFlags.LessThanZero)] +// //[PropertyDisplayText(true, "Height")] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_InputHeight))] +// [PropertyParameterOrder(6500)] +// public string v_Height { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] +// //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] +// //public string v_MatchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] +// //public string v_NameResult { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] +// //public string v_HandleResult { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] +// [PropertyParameterOrder(9000)] +// public string v_WhenWindowIsMinimized { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(WindowControls), nameof(WindowControls.v_WhenWindowIsMinimizedForSet))] +// [PropertyParameterOrder(9001)] +// public string v_WhenWindowIsMaximized { get; set; } + +// public ResizeWindowCommand() +// { +// //this.CommandName = "ResizeWindowCommand"; +// //this.SelectionName = "Resize Window"; +// //this.CommandEnabled = true; +// //this.CustomRendering = true; +// } + +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction(this, engine, +// new Action>(wins => +// { +// //var width = this.ExpandValueOrUserVariableAsInteger(nameof(v_Width), engine); +// //var height = this.ExpandValueOrUserVariableAsInteger(nameof(v_Height), engine); + +// foreach (var win in wins) +// { +// var whnd = win.Item1; + +// var width = this.ExpandValueOrVariableAsWindowWidth(whnd, engine); +// var height = this.ExpandValueOrVariableAsWindowHeight(whnd, engine); + +// WindowControls.SetWindowSize(whnd, width, height); +// } +// }) +// ); +// } + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Commands/_RemovedCommands/SetWindowStateCommand.cs b/taskt/Core/Automation/Commands/_RemovedCommands/SetWindowStateCommand.cs new file mode 100644 index 000000000..6d4848c0d --- /dev/null +++ b/taskt/Core/Automation/Commands/_RemovedCommands/SetWindowStateCommand.cs @@ -0,0 +1,109 @@ +//using System; +//using System.Xml.Serialization; +//using System.Collections.Generic; +//using taskt.Core.Automation.Attributes.PropertyAttributes; + +//namespace taskt.Core.Automation.Commands +//{ +// [Serializable] +// [Attributes.ClassAttributes.Group("Window")] +// [Attributes.ClassAttributes.SubGruop("Window Actions")] +// [Attributes.ClassAttributes.CommandSettings("Set Window State")] +// [Attributes.ClassAttributes.Description("This command sets a target window's state.")] +// [Attributes.ClassAttributes.UsesDescription("Use this command when you want to change a window's state to minimized, maximized, or restored state")] +// [Attributes.ClassAttributes.ImplementationDescription("")] +// [Attributes.ClassAttributes.CommandIcon(nameof(Properties.Resources.command_window))] +// [Attributes.ClassAttributes.EnableAutomateRender(true)] +// [Attributes.ClassAttributes.EnableAutomateDisplayText(true)] +// public sealed class SetWindowStateCommand : AOneWindowNameCommands, IWindowStateProperties +// { +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowName))] +// //public string v_WindowName { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_CompareMethod))] +// //public string v_SearchMethod { get; set; } + +// [XmlAttribute] +// [PropertyVirtualProperty(nameof(GeneralPropertyControls), nameof(GeneralPropertyControls.v_ComboBox))] +// [PropertyDescription("State of the Window")] +// [PropertyUISelectionOption("Maximize")] +// [PropertyUISelectionOption("Minimize")] +// [PropertyUISelectionOption("Restore")] +// [InputSpecification("", true)] +// [PropertyValidationRule("Window State", PropertyValidationRule.ValidationRuleFlags.Empty)] +// [PropertyDisplayText(true, "State")] +// [PropertyParameterOrder(6500)] +// public string v_WindowState { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_MatchMethod))] +// //[PropertySelectionChangeEvent(nameof(MatchMethodComboBox_SelectionChangeCommitted))] +// //public string v_MatchMethod { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_TargetWindowIndex))] +// //public string v_TargetWindowIndex { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WaitTime))] +// //public string v_WaitTime { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_WindowNameResult))] +// //public string v_NameResult { get; set; } + +// //[XmlAttribute] +// //[PropertyVirtualProperty(nameof(WindowNameControls), nameof(WindowNameControls.v_OutputWindowHandle))] +// //public string v_HandleResult { get; set; } + +// public SetWindowStateCommand() +// { +// //this.CommandName = "SetWindowStateCommand"; +// //this.SelectionName = "Set Window State"; +// //this.CommandEnabled = true; +// //this.CustomRendering = true; +// } + +// public override void RunCommand(Engine.AutomationEngineInstance engine) +// { +// WindowControls.WindowAction(this, engine, +// new Action>(wins => +// { +// var windowState = this.ExpandValueOrUserVariableAsSelectionItem(nameof(v_WindowState), engine); +// var state = WindowControls.WindowState.SW_RESTORE; +// switch (windowState.ToLower()) +// { +// case "maximize": +// state = WindowControls.WindowState.SW_MAXIMIZE; +// break; +// case "minimize": +// state = WindowControls.WindowState.SW_MINIMIZE; +// break; +// } + +// foreach (var win in wins) +// { +// var whnd = win.Item1; +// if (WindowControls.IsIconic(whnd) && (state != WindowControls.WindowState.SW_MINIMIZE)) +// { +// WindowControls.ShowIconicWindow(whnd); +// } +// WindowControls.SetWindowState(whnd, state); +// } +// }) +// ); +// } + +// //private void MatchMethodComboBox_SelectionChangeCommitted(object sender, EventArgs e) +// //{ +// // WindowNameControls.MatchMethodComboBox_SelectionChangeCommitted(ControlsList, (ComboBox)sender, nameof(v_TargetWindowIndex)); +// //} + +// //public override void Refresh(UI.Forms.ScriptBuilder.CommandEditor.frmCommandEditor editor) +// //{ +// // ControlsList.GetPropertyControl(nameof(v_WindowName)).AddWindowNames(); +// //} +// } +//} \ No newline at end of file diff --git a/taskt/Core/Automation/Engine/AutomationEngineInstance.cs b/taskt/Core/Automation/Engine/AutomationEngineInstance.cs index 8f81f0200..b51a7ac82 100644 --- a/taskt/Core/Automation/Engine/AutomationEngineInstance.cs +++ b/taskt/Core/Automation/Engine/AutomationEngineInstance.cs @@ -5,10 +5,9 @@ using System.Data; using System.Linq; using System.Threading; -using System.Reflection; -using taskt.Core.Server; using taskt.Core.Automation.Commands; using taskt.Core.Script; +using taskt.Core.Server; namespace taskt.Core.Automation.Engine { @@ -35,7 +34,7 @@ public class AutomationEngineInstance : IAppInstancesProperties, IScriptVariable public Dictionary PreloadedTasks { get; set; } - + public ErrorHandlingCommand ErrorHandler; public WhenErrorOccurs WhenErrorOccursBehavior { get; set; } @@ -230,7 +229,7 @@ public void ExecuteScript(string data, bool dataIsFile) { this.AppInstances.Add(instance.Key, instance.Value); } - + // execute commands foreach (var executionCommand in automationScript.Commands) { @@ -522,8 +521,10 @@ public virtual void ScriptFinished(ScriptFinishedEventArgs.ScriptFinishedResult public virtual void LineNumberChanged(int lineNumber) { - LineNumberChangedEventArgs args = new LineNumberChangedEventArgs(); - args.CurrentLineNumber = lineNumber; + LineNumberChangedEventArgs args = new LineNumberChangedEventArgs + { + CurrentLineNumber = lineNumber + }; LineNumberChangedEvent?.Invoke(this, args); } @@ -532,15 +533,21 @@ public enum EngineStatus Loaded, Running, Paused, Finished } - public string GetEngineContext() + /// + /// get engine status as json text + /// + /// + public string GetEngineContextAsJSON() { // set json settings - JsonSerializerSettings settings = new JsonSerializerSettings(); - settings.Error = (serializer, err) => + JsonSerializerSettings settings = new JsonSerializerSettings { - err.ErrorContext.Handled = true; + Error = (serializer, err) => + { + err.ErrorContext.Handled = true; + }, + Formatting = Formatting.Indented }; - settings.Formatting = Formatting.Indented; return JsonConvert.SerializeObject(this, settings); } @@ -563,30 +570,6 @@ public SafeAutomationEngineInstanceEngineSettings GetAutomationEngineInstanceEng } } - public class ReportProgressEventArgs : EventArgs - { - public string ProgressUpdate { get; set; } - } - - public class ScriptFinishedEventArgs : EventArgs - { - public DateTime LoggedOn { get; set; } - public ScriptFinishedResult Result { get; set; } - public string Error { get; set; } - public TimeSpan ExecutionTime { get; set; } - public string FileName { get; set; } - public enum ScriptFinishedResult - { - Successful, Error, Cancelled - } - } - - public class LineNumberChangedEventArgs : EventArgs - { - public int CurrentLineNumber { get; set; } - } - - public class ScriptError { public int LineNumber { get; set; } diff --git a/taskt/Core/Automation/Engine/EM_AppInstancesPropertiesExtensionMethods.cs b/taskt/Core/Automation/Engine/EM_AppInstancesPropertiesExtensionMethods.cs index 2f0158f87..d0a5839c3 100644 --- a/taskt/Core/Automation/Engine/EM_AppInstancesPropertiesExtensionMethods.cs +++ b/taskt/Core/Automation/Engine/EM_AppInstancesPropertiesExtensionMethods.cs @@ -99,6 +99,34 @@ public static void RemoveAppInstance(this IAppInstancesProperties me, string ins } } + /// + /// get App Instance name + /// + /// + /// + /// + /// + public static string GetAppInstanceName(this IAppInstancesProperties me, object instance) + { + string name = string.Empty; + foreach(var kv in me.AppInstances) + { + if (kv.Value == instance) + { + name = kv.Key; + break; + } + } + if (!string.IsNullOrEmpty(name)) + { + return name; + } + else + { + throw new Exception("Instance not found."); + } + } + /// /// create new instance name (not dup) /// diff --git a/taskt/Core/Automation/Engine/LineNumberChangedEventArgs.cs b/taskt/Core/Automation/Engine/LineNumberChangedEventArgs.cs new file mode 100644 index 000000000..308361e02 --- /dev/null +++ b/taskt/Core/Automation/Engine/LineNumberChangedEventArgs.cs @@ -0,0 +1,15 @@ +using System; + +namespace taskt.Core.Automation.Engine +{ + /// + /// execute command line number changed event args + /// + public class LineNumberChangedEventArgs : EventArgs + { + /// + /// current line number + /// + public int CurrentLineNumber { get; set; } + } +} diff --git a/taskt/Core/Automation/Engine/ReportProgressEventArgs.cs b/taskt/Core/Automation/Engine/ReportProgressEventArgs.cs new file mode 100644 index 000000000..33ff22a2f --- /dev/null +++ b/taskt/Core/Automation/Engine/ReportProgressEventArgs.cs @@ -0,0 +1,9 @@ +using System; + +namespace taskt.Core.Automation.Engine +{ + public class ReportProgressEventArgs : EventArgs + { + public string ProgressUpdate { get; set; } + } +} diff --git a/taskt/Core/Automation/Engine/ScriptFinishedEventArgs.cs b/taskt/Core/Automation/Engine/ScriptFinishedEventArgs.cs new file mode 100644 index 000000000..678c4b5ea --- /dev/null +++ b/taskt/Core/Automation/Engine/ScriptFinishedEventArgs.cs @@ -0,0 +1,22 @@ +using System; + +namespace taskt.Core.Automation.Engine +{ + /// + /// script finished event args + /// + public class ScriptFinishedEventArgs : EventArgs + { + public DateTime LoggedOn { get; set; } + public ScriptFinishedResult Result { get; set; } + public string Error { get; set; } + public TimeSpan ExecutionTime { get; set; } + public string FileName { get; set; } + public enum ScriptFinishedResult + { + Successful, + Error, + Cancelled + } + } +} diff --git a/taskt/Core/Automation/Engine/SystemVariables.cs b/taskt/Core/Automation/Engine/SystemVariables.cs index b86695ea4..3be7a9196 100644 --- a/taskt/Core/Automation/Engine/SystemVariables.cs +++ b/taskt/Core/Automation/Engine/SystemVariables.cs @@ -232,10 +232,10 @@ private static void UpdateSystemVariables(AutomationEngineInstance engine) DateTime_Now_FileSafe.VariableValue = DateTime.Now.ToString("MM-dd-yy HH.mm.ss"); DateTime_Now_FileSafeLong.VariableValue = DateTime.Now.ToString("yyyy-MM-dd_HH.mm.ss"); - Env_ActiveWindowTitle.VariableValue = WindowControls.GetActiveWindowTitle(); + Env_ActiveWindowTitle.VariableValue = EM_CanHandleWindowNameExtensionMethods.GetActiveWindowName(); ; - Window_CurrentWindowName.VariableValue = WindowControls.GetActiveWindowTitle(); - Window_CurrentWindowHandle.VariableValue = WindowControls.GetActiveWindowHandle().ToString(); + Window_CurrentWindowName.VariableValue = EM_CanHandleWindowNameExtensionMethods.GetActiveWindowName(); + Window_CurrentWindowHandle.VariableValue = EM_CanHandleWindowHandleExtentionMethods.GetActiveWindowHandle().ToString(); // NOTE: Keep it commented out as this is where it slows down the script execution. //Taskt_EngineContext.VariableValue = engine.GetEngineContext(); diff --git a/taskt/Core/Automation/User32/User32Functionas.cs b/taskt/Core/Automation/User32/User32Functionas.cs index 2a3bf433f..7d5eec357 100644 --- a/taskt/Core/Automation/User32/User32Functionas.cs +++ b/taskt/Core/Automation/User32/User32Functionas.cs @@ -391,7 +391,7 @@ private static void BuildMouseCommand(IntPtr lParam, MouseMessages mouseMessage) //define new mouse command MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); - var mouseMove = new Core.Automation.Commands.MoveMouseCommand + var mouseMove = new MoveMouseCommand { v_XMousePosition = hookStruct.pt.x.ToString(), v_YMousePosition = hookStruct.pt.y.ToString(), @@ -444,12 +444,16 @@ private static void BuildWindowCommand(IntPtr hWinEventHook, SystemEvents @event //System.Threading.Thread.Sleep(250); windowName = _Buffer.ToString(); - Automation.Commands.ActivateWindowCommand activateWindowCommand = new ActivateWindowCommand + //Automation.Commands.ActivateWindowCommand activateWindowCommand = new ActivateWindowCommand + //{ + // v_WindowName = windowName, + // v_Comment = "Generated by Screen Recorder @ " + DateTime.Now.ToString() + //}; + var activateWindowCommand = new ActivateOneWindowCommand() { v_WindowName = windowName, v_Comment = "Generated by Screen Recorder @ " + DateTime.Now.ToString() }; - generatedCommands.Add(activateWindowCommand); //detect if tracking window open location or activate windows to top left @@ -457,8 +461,15 @@ private static void BuildWindowCommand(IntPtr hWinEventHook, SystemEvents @event { GetWindowRect(hwnd, out RECT windowRect); + //Automation.Commands.MoveWindowCommand moveWindowCommand = new MoveWindowCommand + //{ + // v_WindowName = windowName, + // v_XPosition = windowRect.left.ToString(), + // v_YPosition = windowRect.top.ToString(), + // v_Comment = "Generated by Screen Recorder @ " + DateTime.Now.ToString() - Automation.Commands.MoveWindowCommand moveWindowCommand = new MoveWindowCommand + //}; + var moveWindowCommand = new MoveOneWindowCommand() { v_WindowName = windowName, v_XPosition = windowRect.left.ToString(), @@ -466,14 +477,21 @@ private static void BuildWindowCommand(IntPtr hWinEventHook, SystemEvents @event v_Comment = "Generated by Screen Recorder @ " + DateTime.Now.ToString() }; - generatedCommands.Add(moveWindowCommand); } else if (activateWindowTopLeft) { //generate command to set window position - Automation.Commands.MoveWindowCommand moveWindowCommand = new MoveWindowCommand + //Automation.Commands.MoveWindowCommand moveWindowCommand = new MoveWindowCommand + //{ + // v_WindowName = windowName, + // v_XPosition = "0", + // v_YPosition = "0", + // v_Comment = "Generated by Screen Recorder @ " + DateTime.Now.ToString() + + //}; + var moveWindowCommand = new MoveOneWindowCommand() { v_WindowName = windowName, v_XPosition = "0", @@ -481,9 +499,7 @@ private static void BuildWindowCommand(IntPtr hWinEventHook, SystemEvents @event v_Comment = "Generated by Screen Recorder @ " + DateTime.Now.ToString() }; - SetWindowPosition(hwnd, 0, 0); - generatedCommands.Add(moveWindowCommand); } @@ -498,7 +514,15 @@ private static void BuildWindowCommand(IntPtr hWinEventHook, SystemEvents @event var height = windowRect.bottom - windowRect.top; //generate command to set window position - Automation.Commands.ResizeWindowCommand reszWindowCommand = new ResizeWindowCommand + //Automation.Commands.ResizeWindowCommand reszWindowCommand = new ResizeWindowCommand + //{ + // v_WindowName = windowName, + // v_Width = width.ToString(), + // v_Height = height.ToString(), + // v_Comment = "Generated by Screen Recorder @ " + DateTime.Now.ToString() + + //}; + var reszWindowCommand = new ResizeOneWindowCommand() { v_WindowName = windowName, v_Width = width.ToString(), @@ -506,7 +530,6 @@ private static void BuildWindowCommand(IntPtr hWinEventHook, SystemEvents @event v_Comment = "Generated by Screen Recorder @ " + DateTime.Now.ToString() }; - //add to list generatedCommands.Add(reszWindowCommand); } @@ -532,7 +555,7 @@ private static void BuildPauseCommand() private static IntPtr SetKeyboardHook(LowLevelKeyboardProc proc) { - using (Process curProcess = Process.GetCurrentProcess()) + using (System.Diagnostics.Process curProcess = System.Diagnostics.Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { @@ -543,7 +566,7 @@ private static IntPtr SetKeyboardHook(LowLevelKeyboardProc proc) } private static IntPtr SetMouseHook(LowLevelMouseProc proc) { - using (Process curProcess = Process.GetCurrentProcess()) + using (System.Diagnostics.Process curProcess = System.Diagnostics.Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { diff --git a/taskt/Core/ExtensionMethods.cs b/taskt/Core/ExtensionMethods.cs index 5c56e607a..f3020754e 100644 --- a/taskt/Core/ExtensionMethods.cs +++ b/taskt/Core/ExtensionMethods.cs @@ -475,7 +475,7 @@ private static bool ExpandVariableDotProperty(string variableName, List + /// taskt script file class + /// public class Script { /// /// Contains user-defined variables /// public List Variables { get; set; } + /// /// Contains user-selected commands /// public List Commands; + /// + /// script informations + /// public ScriptInformation Info; public Script() @@ -47,6 +55,7 @@ public Script() Commands = new List(); Info = new ScriptInformation(); } + /// /// Returns a new 'Top-Level' command. /// @@ -89,7 +98,7 @@ public static Script SerializeScript(ListView.ListViewItemCollection scriptComma { srcCommand.IsDontSavedCommand = false; } - + var command = srcCommand.Clone(); command.LineNumber = lineNumber; @@ -123,7 +132,7 @@ public static Script SerializeScript(ListView.ListViewItemCollection scriptComma // remove last command since loop is ending subCommands.RemoveAt(subCommands.Count - 1); } - else if (subCommands.Count == 0) + else if (subCommands.Count == 0) { // add command as a root item script.AddNewParentCommand(command); @@ -303,7 +312,7 @@ public static (string path, string timeStump) GetAutoSaveScriptFilePath() var savePath = IO.Folders.GetAutoSaveFolderPath(); var saveTime = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); - return (Path.Combine(savePath, "autosave-") + saveTime + ".xml", saveTime); + return (Path.Combine(savePath, $"autosave-{saveTime}.xml"), saveTime); } ///// @@ -335,7 +344,7 @@ public static string GetRunWithoutSavingScriptFilePath() //var runPath = GetRunWithoutSavingFolderPath(); var runPath = IO.Folders.GetRunWithoutSavingFolderPath(); var saveTime = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); - return Path.Combine(runPath, "run-") + saveTime + ".xml"; + return Path.Combine(runPath, $"run-{saveTime}.xml"); } /// @@ -343,7 +352,7 @@ public static string GetRunWithoutSavingScriptFilePath() /// public void ReGenerateCommandID() { - foreach(var command in this.Commands) + foreach (var command in this.Commands) { ReGenerateCommandIDProcess(command); } @@ -358,13 +367,24 @@ public static void ReGenerateCommandIDProcess(ScriptAction script) script.ScriptCommand.GenerateID(); if ((script.AdditionalScriptCommands?.Count ?? 0) > 0) { - foreach(var command in script.AdditionalScriptCommands) + foreach (var command in script.AdditionalScriptCommands) { ReGenerateCommandIDProcess(command); } } } + /// + /// check old version + /// + /// + /// + /// When a is older than b, return true + private static bool IsOldVersion(Version a, string b) + { + return a.CompareTo(new Version(b)) < 0; + } + /// /// script xml converter /// @@ -375,85 +395,373 @@ private static XDocument convertOldScript(XDocument doc, IEngineSettings engine) // very important! // ** DO NOT USE nameof to change command name ** + var versionText = doc.Element("Script").Element("Info")?.Element("TasktVersion")?.Value ?? "0.0.0.0"; + var myVersion = new Version(versionText); + fixDataTableSchemaPosition(doc); fixToSameCommandNames(doc); - convertTo3_5_0_45(doc); - convertTo3_5_0_46(doc); - convertTo3_5_0_47(doc); - convertTo3_5_0_50(doc); - convertTo3_5_0_51(doc); - convertTo3_5_0_52(doc); - convertTo3_5_0_57(doc); - convertTo3_5_0_67(doc); - fixUIAutomationCommandEnableParameterValue(doc); - convertTo3_5_0_73(doc); - convertTo3_5_0_74(doc); - convertTo3_5_0_78(doc); - fixUIAutomationSearchEnableParameterValue(doc); - convertTo3_5_0_83(doc); - convertTo3_5_1_16(doc); - convertTo3_5_1_30(doc); - convertTo3_5_1_31(doc); - convertTo3_5_1_33(doc); - convertTo3_5_1_34(doc); - convertTo3_5_1_35(doc); - convertTo3_5_1_36(doc); - convertTo3_5_1_38(doc); - convertTo3_5_1_39(doc); - fixUIAutomationSearchEnableParameterValue_3_5_1_39(doc); - convertTo3_5_1_40(doc); - convertTo3_5_1_41(doc); - convertTo3_5_1_42(doc); - convertTo3_5_1_44(doc); - convertTo3_5_1_45(doc); - convertTo3_5_1_46(doc); - convertTo3_5_1_48(doc); - convertTo3_5_1_49(doc); - convertTo3_5_1_50(doc); - convertTo3_5_1_51(doc); - convertTo3_5_1_52(doc); - convertTo3_5_1_54(doc); + if (IsOldVersion(myVersion, "3.5.0.45")) + { + convertTo3_5_0_45(doc); + } + if (IsOldVersion(myVersion, "3.5.0.46")) + { + convertTo3_5_0_46(doc); + } + if (IsOldVersion(myVersion, "3.5.0.47")) + { + convertTo3_5_0_47(doc); + } + if (IsOldVersion(myVersion, "3.5.0.50")) + { + convertTo3_5_0_50(doc); + } + if (IsOldVersion(myVersion, "3.5.0.51")) + { + convertTo3_5_0_51(doc); + } + if (IsOldVersion(myVersion, "3.5.0.52")) + { + convertTo3_5_0_52(doc); + } + if (IsOldVersion(myVersion, "3.5.0.57")) + { + convertTo3_5_0_57(doc); + } + if (IsOldVersion(myVersion, "3.5.0.67")) + { + convertTo3_5_0_67(doc); + } + fixUIAutomationCommandEnableColumnParameterValues(doc); + if (IsOldVersion(myVersion, "3.5.0.73")) + { + convertTo3_5_0_73(doc); + } + if (IsOldVersion(myVersion, "3.5.0.74")) + { + convertTo3_5_0_74(doc); + } + if (IsOldVersion(myVersion, "3.5.0.78")) + { + convertTo3_5_0_78(doc); + } + fixUIAutomationSearchEnableColumnParameterValues(doc); + if (IsOldVersion(myVersion, "3.5.0.83")) + { + convertTo3_5_0_83(doc); + } + if (IsOldVersion(myVersion, "3.5.1.16")) + { + convertTo3_5_1_16(doc); + } + if (IsOldVersion(myVersion, "3.5.1.30")) + { + convertTo3_5_1_30(doc); + } + if (IsOldVersion(myVersion, "3.5.1.31")) + { + convertTo3_5_1_31(doc); + } + if (IsOldVersion(myVersion, "3.5.1.33")) + { + convertTo3_5_1_33(doc); + } + if (IsOldVersion(myVersion, "3.5.1.34")) + { + convertTo3_5_1_34(doc); + } + if (IsOldVersion(myVersion, "3.5.1.35")) + { + convertTo3_5_1_35(doc); + } + if (IsOldVersion(myVersion, "3.5.1.36")) + { + convertTo3_5_1_36(doc); + } + if (IsOldVersion(myVersion, "3.5.1.38")) + { + + convertTo3_5_1_38(doc); + } + if (IsOldVersion(myVersion, "3.5.1.39")) + { + convertTo3_5_1_39(doc); + } + fixUIAutomationSearchEnableColumnParameterValues_3_5_1_39(doc); + if (IsOldVersion(myVersion, "3.5.1.40")) + { + convertTo3_5_1_40(doc); + } + if (IsOldVersion(myVersion, "3.5.1.41")) + { + convertTo3_5_1_41(doc); + } + if (IsOldVersion(myVersion, "3.5.1.42")) + { + convertTo3_5_1_42(doc); + } + if (IsOldVersion(myVersion, "3.5.1.44")) + { + convertTo3_5_1_44(doc); + } + if (IsOldVersion(myVersion, "3.5.1.45")) + { + convertTo3_5_1_45(doc); + } + if (IsOldVersion(myVersion, "3.5.1.46")) + { + convertTo3_5_1_46(doc); + } + if (IsOldVersion(myVersion, "3.5.1.48")) + { + convertTo3_5_1_48(doc); + } + if (IsOldVersion(myVersion, "3.5.1.49")) + { + convertTo3_5_1_49(doc); + } + if (IsOldVersion(myVersion, "3.5.1.50")) + { + convertTo3_5_1_50(doc); + } + if (IsOldVersion(myVersion, "3.5.1.51")) + { + convertTo3_5_1_51(doc); + } + if (IsOldVersion(myVersion, "3.5.1.52")) + { + convertTo3_5_1_52(doc); + } + if (IsOldVersion(myVersion, "3.5.1.54")) + { + convertTo3_5_1_54(doc); + } fixUIAutomationSearchEnableParameterValue_v3_5_1_56(doc); - convertTo3_5_1_56(doc); - convertTo3_5_1_58(doc); - convertTo3_5_1_62(doc); - convertTo3_5_1_72(doc); - convertTo3_5_1_74(doc); - convertTo3_5_1_75(doc, engine); - convertTo3_5_1_77(doc, engine); - convertTo3_5_1_79(doc, engine); - convertTo3_5_1_80(doc); - convertTo3_5_1_81(doc, engine); - convertTo3_5_1_83(doc); - convertTo3_5_1_84(doc); - convertTo3_5_1_86(doc); - convertTo3_5_1_87(doc); - convertTo3_5_1_88(doc); - convertTo3_5_1_89(doc); - convertTo3_5_1_91(doc); - convertTo3_5_1_92(doc); - convertTo3_5_1_93(doc); - convertTo3_5_1_96(doc); - convertTo3_5_1_98(doc); - convertTo3_5_2_0(doc); - convertTo3_5_2_1(doc); - convertTo3_5_2_6(doc); - convertTo3_5_2_11(doc); - convertTo3_5_2_13(doc); - convertTo3_5_2_14(doc); - convertTo3_5_2_15(doc); - convertTo3_5_2_16(doc); - convertTo3_5_2_17(doc); - convertTo3_5_2_18(doc); - convertTo3_5_2_19(doc); - convertTo3_5_2_20(doc); - convertTo3_5_2_21(doc); - convertTo3_5_2_22(doc); - convertTo3_5_2_23(doc); - convertTo3_5_2_24(doc); - convertTo3_5_2_25(doc); - convertTo3_5_2_31(doc); + if (IsOldVersion(myVersion, "3.5.1.56")) + { + convertTo3_5_1_56(doc); + } + if (IsOldVersion(myVersion, "3.5.1.58")) + { + convertTo3_5_1_58(doc); + } + if (IsOldVersion(myVersion, "3.5.1.62")) + { + convertTo3_5_1_62(doc); + } + if (IsOldVersion(myVersion, "3.5.1.72")) + { + convertTo3_5_1_72(doc); + } + if (IsOldVersion(myVersion, "3.5.1.74")) + { + convertTo3_5_1_74(doc); + } + if (IsOldVersion(myVersion, "3.5.1.75")) + { + convertTo3_5_1_75(doc, engine); + } + if (IsOldVersion(myVersion, "3.5.1.77")) + { + convertTo3_5_1_77(doc, engine); + } + if (IsOldVersion(myVersion, "3.5.1.79")) + { + convertTo3_5_1_79(doc, engine); + } + if (IsOldVersion(myVersion, "3.5.1.80")) + { + convertTo3_5_1_80(doc); + } + if (IsOldVersion(myVersion, "3.5.1.81")) + { + convertTo3_5_1_81(doc, engine); + } + if (IsOldVersion(myVersion, "3.5.1.83")) + { + convertTo3_5_1_83(doc); + } + if (IsOldVersion(myVersion, "3.5.1.84")) + { + convertTo3_5_1_84(doc); + } + if (IsOldVersion(myVersion, "3.5.1.86")) + { + convertTo3_5_1_86(doc); + } + if (IsOldVersion(myVersion, "3.5.1.87")) + { + convertTo3_5_1_87(doc); + } + if (IsOldVersion(myVersion, "3.5.1.88")) + { + convertTo3_5_1_88(doc); + } + if (IsOldVersion(myVersion, "3.5.1.89")) + { + convertTo3_5_1_89(doc); + } + if (IsOldVersion(myVersion, "3.5.1.91")) + { + convertTo3_5_1_91(doc); + } + if (IsOldVersion(myVersion, "3.5.1.92")) + { + convertTo3_5_1_92(doc); + } + if (IsOldVersion(myVersion, "3.5.1.93")) + { + convertTo3_5_1_93(doc); + } + if (IsOldVersion(myVersion, "3.5.1.96")) + { + convertTo3_5_1_96(doc); + } + if (IsOldVersion(myVersion, "3.5.1.98")) + { + convertTo3_5_1_98(doc); + } + if (IsOldVersion(myVersion, "3.5.2.0")) + { + convertTo3_5_2_0(doc); + } + if (IsOldVersion(myVersion, "3.5.2.1")) + { + convertTo3_5_2_1(doc); + } + if (IsOldVersion(myVersion, "3.5.2.6")) + { + convertTo3_5_2_6(doc); + } + if (IsOldVersion(myVersion, "3.5.2.11")) + { + convertTo3_5_2_11(doc); + } + if (IsOldVersion(myVersion, "3.5.2.13")) + { + convertTo3_5_2_13(doc); + } + if (IsOldVersion(myVersion, "3.5.2.14")) + { + convertTo3_5_2_14(doc); + } + if (IsOldVersion(myVersion, "3.5.2.15")) + { + convertTo3_5_2_15(doc); + } + if (IsOldVersion(myVersion, "3.5.2.16")) + { + convertTo3_5_2_16(doc); + } + if (IsOldVersion(myVersion, "3.5.2.17")) + { + convertTo3_5_2_17(doc); + } + if (IsOldVersion(myVersion, "3.5.2.18")) + { + convertTo3_5_2_18(doc); + } + if (IsOldVersion(myVersion, "3.5.2.19")) + { + convertTo3_5_2_19(doc); + } + if (IsOldVersion(myVersion, "3.5.2.20")) + { + convertTo3_5_2_20(doc); + } + if (IsOldVersion(myVersion, "3.5.2.21")) + { + convertTo3_5_2_21(doc); + } + if (IsOldVersion(myVersion, "3.5.2.22")) + { + convertTo3_5_2_22(doc); + } + if (IsOldVersion(myVersion, "3.5.2.23")) + { + convertTo3_5_2_23(doc); + } + if (IsOldVersion(myVersion, "3.5.2.24")) + { + convertTo3_5_2_24(doc); + } + if (IsOldVersion(myVersion, "3.5.2.25")) + { + convertTo3_5_2_25(doc); + } + if (IsOldVersion(myVersion, "3.5.2.31")) + { + convertTo3_5_2_31(doc); + } + if (IsOldVersion(myVersion, "3.5.2.38")) + { + convertTo3_5_2_38(doc); + } + if (IsOldVersion(myVersion, "3.5.2.39")) + { + convertTo3_5_2_39(doc); + } + if (IsOldVersion(myVersion, "3.5.2.42")) + { + convertTo3_5_2_42(doc); + } + if (IsOldVersion(myVersion, "3.5.2.43")) + { + convertTo3_5_2_43(doc); + } + if (IsOldVersion(myVersion, "3.5.2.44")) + { + convertTo3_5_2_44(doc); + } + if (IsOldVersion(myVersion, "3.5.2.45")) + { + convertTo3_5_2_45(doc); + } + if (IsOldVersion(myVersion, "3.5.2.46")) + { + convertTo3_5_2_46(doc); + } + if (IsOldVersion(myVersion, "3.5.2.47")) + { + convertTo3_5_2_47(doc); + } + if (IsOldVersion(myVersion, "3.5.2.51")) + { + convertTo3_5_2_51(doc); + } + if (IsOldVersion(myVersion, "3.5.2.53")) + { + convertTo3_5_2_53(doc); + } + if (IsOldVersion(myVersion, "3.5.2.55")) + { + convertTo3_5_2_55(doc); + } + if (IsOldVersion(myVersion, "3.5.2.56")) + { + convertTo3_5_2_56(doc); + } + if (IsOldVersion(myVersion, "3.5.2.57")) + { + convertTo3_5_2_57(doc); + } + if (IsOldVersion(myVersion, "3.5.2.59")) + { + convertTo3_5_2_59(doc); + } + if (IsOldVersion(myVersion, "3.5.2.61")) // this method use <= 3.5.2.60 + { + convertTo3_5_2_60(doc); + } + if (IsOldVersion(myVersion, "3.5.2.61")) + { + convertTo3_5_2_61(doc); + } + if (IsOldVersion(myVersion, "3.5.2.62")) + { + convertTo3_5_2_62(doc); + } return doc; } @@ -527,7 +835,7 @@ private static void fixToSameCommandNames(XDocument doc) XNamespace ns = "http://www.w3.org/2001/XMLSchema-instance"; var commands = doc.Descendants("ScriptCommand"); - foreach(var cmd in commands) + foreach (var cmd in commands) { var commandName = cmd.Attribute("CommandName"); var xsiType = cmd.Attribute(ns + "type"); @@ -541,7 +849,8 @@ private static void fixToSameCommandNames(XDocument doc) private static void convertTo3_5_0_45(XDocument doc) { // change "Start with" -> "Starts with", "End with" -> "Ends with" - ChangeAttributeValue(doc, new Func( el => { + ChangeAttributeValue(doc, new Func(el => + { switch (GetCommandName(el)) { case "ActivateWindowCommand": @@ -562,7 +871,8 @@ private static void convertTo3_5_0_45(XDocument doc) default: return false; } - }), "v_SearchMethod", new Action( attr => { + }), "v_SearchMethod", new Action(attr => + { switch (attr?.Value.ToLower() ?? "") { case "start with": @@ -624,7 +934,7 @@ private static void convertTo3_5_0_52(XDocument doc) // change "Start with" -> "Starts with", "End with" -> "Ends with" ChangeAttributeValue(doc, new Func(el => { - switch(GetCommandName(el)) + switch (GetCommandName(el)) { case "GetFilesCommand": case "GetFoldersCommand": @@ -633,7 +943,8 @@ private static void convertTo3_5_0_52(XDocument doc) default: return false; } - }), "v_SearchMethod", new Action(attr => { + }), "v_SearchMethod", new Action(attr => + { switch (attr?.Value.ToLower() ?? "") { case "start with": @@ -652,7 +963,7 @@ private static void convertTo3_5_0_57(XDocument doc) ChangeCommandName(doc, "CheckStringCommand", "CheckTextCommand", "Check Text"); // ModifyVariableCommand -> ModifyTextCommand - ChangeCommandName(doc, new Func( el => + ChangeCommandName(doc, new Func(el => { switch (GetCommandName(el)) { @@ -690,7 +1001,7 @@ private static void convertTo3_5_0_67(XDocument doc) ChangeCommandName(doc, "SeleniumBrowserGetAElementValuesAsDataTableCommand", "SeleniumBrowserGetAnElementValuesAsDataTableCommand", "Get An Element Values As DataTable"); } - private static void fixUIAutomationCommandEnableParameterValue(XDocument doc) + private static void fixUIAutomationCommandEnableColumnParameterValues(XDocument doc) { // UI Automation Boolean Fix ChangeTableCellValue(doc, "UIAutomationCommand", "v_UIASearchParameters", "Enabled", new Action(c => @@ -816,7 +1127,7 @@ private static void convertTo3_5_0_78(XDocument doc) }), "v_LoopActionParameterTable", modFunc); } - private static void fixUIAutomationSearchEnableParameterValue(XDocument doc) + private static void fixUIAutomationSearchEnableColumnParameterValues(XDocument doc) { // UI Automation Boolean Fix ChangeTableCellValue(doc, new Func(el => @@ -1053,7 +1364,7 @@ private static void convertTo3_5_1_39(XDocument doc) ChangeCommandName(doc, "Format Folder PathCommand", "FormatFolderPathCommand", "Format Folder Path"); } - private static void fixUIAutomationSearchEnableParameterValue_3_5_1_39(XDocument doc) + private static void fixUIAutomationSearchEnableColumnParameterValues_3_5_1_39(XDocument doc) { ChangeTableCellValue(doc, new Func(el => { @@ -1173,7 +1484,7 @@ private static void convertTo3_5_1_44(XDocument doc) var copyCommands = commands.Where(el => (el.Attribute("v_OperationType").Value.ToLower() == "copy file")).ToList(); ChangeCommandNameProcess(moveCommands, "MoveFileCommand", "Move File"); ChangeCommandNameProcess(copyCommands, "CopyFileCommand", "Copy File"); - foreach(var cmd in commands) + foreach (var cmd in commands) { cmd.Attribute("v_OperationType").Remove(); } @@ -1312,7 +1623,7 @@ private static void convertTo3_5_1_49(XDocument doc) // change new SeleniumBrowserWebElementActionCommand var commands = GetCommands(doc, "SeleniumBrowserWebElementActionCommand"); - foreach(var cmd in commands) + foreach (var cmd in commands) { var elementAction = cmd.Element("v_SeleniumElementAction"); string act = ""; @@ -1453,14 +1764,14 @@ private static void convertTo3_5_1_49(XDocument doc) } } - private static void convertTo3_5_1_50(XDocument doc) + private static void convertTo3_5_1_50(XDocument doc) { // WebElement Action: Wait For WebElement To Exists // WebElement Action: fix parameter table var commands = GetCommands(doc, "SeleniumBrowserWebElementActionCommand"); foreach (var cmd in commands) { - var act = cmd.Attribute("v_SeleniumElementAction").Value; + var act = cmd.Attribute("v_SeleniumElementAction")?.Value ?? string.Empty; if (act.ToLower() == "wait for webelement to exist") { cmd.SetAttributeValue("v_SeleniumElementAction", "Wait For WebElement To Exists"); @@ -1555,7 +1866,7 @@ private static void convertTo3_5_1_51(XDocument doc) // UIAutomationUIElementActionCommand : UIElement Action name, v_WindowName to Attribute var cmds = GetCommands(doc, "UIAutomationUIElementActionCommand"); - foreach(var cmd in cmds) + foreach (var cmd in cmds) { var act = cmd.Attribute("v_AutomationType").Value.ToLower(); string newAct = act.ToLower(); @@ -1614,16 +1925,18 @@ private static void convertTo3_5_1_51(XDocument doc) // WebElementAction: Set Text (Encrypted Text param) cmds = GetCommands(doc, new Func((el) => { + var elemAction = el.Attribute("v_SeleniumElementAction")?.Value.ToLower() ?? string.Empty; + return (GetCommandName(el) == "SeleniumBrowserWebElementActionCommand") && - (el.Attribute("v_SeleniumElementAction").Value.ToLower() == "set text"); + (elemAction == "set text"); })); - foreach(var cmd in cmds) + foreach (var cmd in cmds) { (var table, _, _, _, _) = GetTable(cmd, "v_WebActionParameterTable"); var rows = table?.Elements()?.ToList() ?? new List(); //var beforeRows = before?.Elements()?.ToList() ?? new List(); - foreach(var row in rows) + foreach (var row in rows) { if (row.Element("Parameter_x0020_Name").Value == "Encrypted Text") { @@ -2026,7 +2339,7 @@ private static void convertTo3_5_1_75(XDocument doc, IEngineSettings engine) // SendAdvancedKeyStrokesCommand strange element "v_KeyUpDefault" var cmds = GetCommands(doc, "SendAdvancedKeyStrokesCommand"); - foreach(var cmd in cmds) + foreach (var cmd in cmds) { var elem = cmd.Element("v_KeyUpDefault"); var attr = cmd.Attribute("v_KeyUpDefault"); @@ -2474,8 +2787,9 @@ private static void convertTo3_5_1_81(XDocument doc, IEngineSettings engine) private static void convertTo3_5_1_83(XDocument doc) { // ExcelSetRowValuesFromDataTableCommand, ExcelSetColumnValuesFromDataTableCommand v_WhenItemNotEnough - ChangeAttributeName(doc, - new Func(el => { + ChangeAttributeName(doc, + new Func(el => + { switch (GetCommandName(el)) { case "ExcelSetRowValuesFromDataTableCommand": @@ -2484,12 +2798,13 @@ private static void convertTo3_5_1_83(XDocument doc) default: return false; } - + }), "v_IfDataTableNotEnough", "v_WhenItemNotEnough"); // ExcelSetRowValuesFromDictionaryCommand, ExcelSetColumnValuesFromDictionaryCommand v_WhenItemNotEnough - ChangeAttributeName(doc, - new Func(el => { + ChangeAttributeName(doc, + new Func(el => + { switch (GetCommandName(el)) { case "ExcelSetRowValuesFromDictionaryCommand": @@ -2501,8 +2816,9 @@ private static void convertTo3_5_1_83(XDocument doc) }), "v_IfDictionaryNotEnough", "v_WhenItemNotEnough"); // ExcelSetRowValuesFromListCommand, ExcelSetColumnValuesFromListCommand v_WhenItemNotEnough - ChangeAttributeName(doc, - new Func(el => { + ChangeAttributeName(doc, + new Func(el => + { switch (GetCommandName(el)) { case "ExcelSetRowValuesFromListCommand": @@ -2570,7 +2886,7 @@ private static void convertTo3_5_1_84(XDocument doc) new List<(string, Action)>() { ( - "v_Option", + "v_Option", new Action(attr => { if (attr.Value.ToLower() == "column name") @@ -2725,7 +3041,7 @@ private static void convertTo3_5_1_87(XDocument doc) }), "v_InputData", "v_Dictionary"); // AddDictionaryItemCommand, CreateDictionaryCommand v_DictionaryName -> v_Dictionary - ChangeAttributeName(doc, + ChangeAttributeName(doc, new Func(el => { switch (GetCommandName(el)) @@ -3240,7 +3556,7 @@ private static void convertTo3_5_1_92(XDocument doc) ChangeAttributeName(doc, "ReplaceDataTableValueCommand", "v_TargetType", "v_ValueType"); // ReplaceDictionaryCommand, ReplaceListCommand v_NewValue - ChangeAttributeName(doc, + ChangeAttributeName(doc, new Func(el => { switch (GetCommandName(el)) @@ -3372,7 +3688,7 @@ private static void convertTo3_5_1_98(XDocument doc) // separate JSONPath var rmv = GetCommands(doc, "RemoveJSONObjectPropertyCommand"); - foreach(var c in rmv) + foreach (var c in rmv) { var attrPath = c.Attribute("v_JsonExtractor"); var attrProp = c.Attribute("v_PropertyName"); @@ -3384,7 +3700,7 @@ private static void convertTo3_5_1_98(XDocument doc) var idx = path.LastIndexOf('.'); var newProp = path.Substring(idx + 1); var newPath = path.Substring(0, idx); - + if (attrProp != null) { attrProp.SetValue(newProp); @@ -3408,7 +3724,7 @@ private static void convertTo3_5_1_98(XDocument doc) private static void convertTo3_5_2_0(XDocument doc) { var htmlCommands = GetCommands(doc, "ShowHTMLInputDialogCommand"); - foreach(var cmd in htmlCommands) + foreach (var cmd in htmlCommands) { var html = cmd.Attribute("v_InputHTML").Value; html = html.Replace("window.external.Ok()", "chrome.webview.hostObjects.fm.OK()") @@ -3536,8 +3852,8 @@ private static void convertTo3_5_2_15(XDocument doc) default: return false; } - }), new List<(string, string)>() - { + }), new List<(string, string)>() + { ("v_SearchMethod", "v_CompareMethod"), ("v_UserVariableName", "v_Result"), } @@ -3590,7 +3906,7 @@ private static void convertTo3_5_2_15(XDocument doc) // TextGetIndexOf, TextGetLastIndexOf v_SearchStartIndex var idxCmds = GetCommands(doc, new Func(el => { - switch (GetCommandName(el)) + switch (GetCommandName(el)) { case "TextGetIndexOfCommand": case "TextGetLastIndexOfCommand": @@ -3599,7 +3915,7 @@ private static void convertTo3_5_2_15(XDocument doc) return false; } })); - foreach(var cmd in idxCmds) + foreach (var cmd in idxCmds) { if (cmd.Attribute("v_SearchStartPosition") == null) { @@ -3639,16 +3955,17 @@ private static void convertTo3_5_2_15(XDocument doc) private static void convertTo3_5_2_16(XDocument doc) { XNamespace xs = "http://www.w3.org/2001/XMLSchema"; - int GetColumnsCount(XElement elem) + int GetColumnsCount(XElement elem) { return elem.Element(xs + "schema").Element(xs + "element").Element(xs + "complexType") .Element(xs + "choice").Element(xs + "element").Element(xs + "complexType") .Element(xs + "sequence").Elements(xs + "element").Count(); - }; + } + ; // Execute REAT API v_RESTParameters <-> v_AdvancedParameters var rest = GetCommands(doc, "HTTPExecuteRESTAPICommand"); - + foreach (var cmd in rest) { var advParams = cmd.Element("v_AdvancedParameters"); @@ -3721,25 +4038,25 @@ private static void convertTo3_5_2_17(XDocument doc) private static void convertTo3_5_2_18(XDocument doc) { - // SeleniumBrowserGetWebBrowserInformationCommand Handles JSON Array -> SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand - ChangeToOtherCommand(doc, new Func(elem => - { - if ((GetCommandName(elem) == "SeleniumBrowserGetWebBrowserInformationCommand") && - (elem.Attribute("v_InfoType").Value.ToLower() == "handles json array")) - { - return true; - } - else - { - return false; - } - }), - "SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand", "Get Window And Tab Handles As JSON", - new List<(string, string)>() - { - ("v_applyToVariableName", "v_Result"), - } - ); + //// SeleniumBrowserGetWebBrowserInformationCommand Handles JSON Array -> SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand + //ChangeToOtherCommand(doc, new Func(elem => + // { + // if ((GetCommandName(elem) == "SeleniumBrowserGetWebBrowserInformationCommand") && + // (elem.Attribute("v_InfoType").Value.ToLower() == "handles json array")) + // { + // return true; + // } + // else + // { + // return false; + // } + // }), + // "SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand", "Get Window And Tab Handles As JSON", + // new List<(string, string)>() + // { + // ("v_applyToVariableName", "v_Result"), + // } + //); // File Commands v_SourceFilePath -> v_TargetFilePath ChangeAttributeName(doc, new Func(elem => @@ -3862,7 +4179,7 @@ private static void convertTo3_5_2_18(XDocument doc) // Folder/GetFilesPathAsListCommand commands v_WaitForFolder -> v_WaitTimeForFolder ChangeAttributeName(doc, new Func(elem => { - switch(GetCommandName(elem)) + switch (GetCommandName(elem)) { case "CheckFolderExistsCommand": case "CreateFolderCommand": @@ -4045,7 +4362,7 @@ private static void convertTo3_5_2_22(XDocument doc) } }) ); - foreach (var cmd in copyMove) + foreach (var cmd in copyMove) { var attrDel = cmd.Attribute("v_DeleteExisting"); if (attrDel != null) @@ -4153,7 +4470,7 @@ void AddCommentProcess(XElement cmd) } } - foreach(var cmd in fmts) + foreach (var cmd in fmts) { var attrType = cmd.Attribute("v_FormatType"); if (attrType != null) @@ -4368,23 +4685,1028 @@ private static void convertTo3_5_2_31(XDocument doc) }), "v_applyToVariableName", "v_Result"); } - /// - /// get old, new current window keyword - /// - /// - /// - private static (string oldKeyword, string newKeyword) GetOldNewCurrentWindow(IEngineSettings engine) + private static void convertTo3_5_2_38(XDocument doc) { - return GetOldNewKeyword("%kwd_current_window%", engine.CurrentWindowKeyword, SystemVariables.Window_CurrentWindowName, engine); - } - - /// - /// get old new keyword - /// - /// - /// - /// - /// + // ShowHTMLInputDialog v_WhenCancel + var commands = GetCommands(doc, "ShowHTMLInputDialogCommand"); + foreach (var command in commands) + { + var wc = command.Attribute("v_WhenCancel"); + if (wc == null) + { + var er = command.Attribute("v_ErrorOnClose"); + var erv = er?.Value ?? ""; + string newValue; + switch (erv.ToLower()) + { + case "error on close": + newValue = "Error"; + break; + case "do not error on close": + newValue = "Ignore"; + break; + default: + newValue = ""; + break; + } + command.SetAttributeValue("v_WhenCancel", newValue); + if (er != null) + { + er.Remove(); + } + } + } + + // ShowUserInputDialogCommand v_InputHeader -> v_DialogTitle, v_InputDirections -> v_Message + ChangeMultiAttributeNames(doc, "ShowUserInputDialogCommand", + new List<(string, string)>() + { + ("v_InputHeader", "v_DialogTitle"), + ("v_InputDirections", "v_Message"), + } + ); + } + + private static void convertTo3_5_2_39(XDocument doc) + { + void SeparateOneAll(XDocument x, string currentCommandName, string oneCommandName, string oneSelectionName, string allCommandName, string allSelectionName) + { + var cmds = GetCommands(x, currentCommandName); + var one = new List(); + var all = new List(); + foreach (var cmd in cmds) + { + var matchAttr = cmd.Attribute("v_MatchMethod"); + switch (matchAttr?.Value.ToLower() ?? "") + { + case "all": + matchAttr?.Remove(); + all.Add(cmd); + break; + default: + one.Add(cmd); + break; + } + } + ChangeCommandNameProcess(one, oneCommandName, oneSelectionName); + ChangeCommandNameProcess(all, allCommandName, allSelectionName); + } + + // ActivateWindowCommand -> ActivateOneWindowCommand, ActivateWindowsCommand + SeparateOneAll(doc, "ActivateWindowCommand", "ActivateOneWindowCommand", "Activate One Window", "ActivateWindowsCommand", "Activate Windows"); + + // CloseWindowCommand -> CloseOneWindowCommand, CloseWindowsCommand + SeparateOneAll(doc, "CloseWindowCommand", "CloseOneWindowCommand", "Close One Window", "CloseWindowsCommand", "Close Windows"); + + // MoveWindowCommand -> MoveOneWindowCommand, MoveWindowsCommand + SeparateOneAll(doc, "MoveWindowCommand", "MoveOneWindowCommand", "Move One Window", "MoveWindowsCommand", "Move Windows"); + + // ResizeWindowCommand -> ResizeOneWindowCommand, ResizeWindowsCommand + SeparateOneAll(doc, "ResizeWindowCommand", "ResizeOneWindowCommand", "Resize One Window", "ResizeWindowsCommand", "Resize Windows"); + + // SetWindowStateCommand -> SetOneWindowStateCommand, SetWindowsStateCommand + SeparateOneAll(doc, "SetWindowStateCommand", "SetOneWindowStateCommand", "Set One Window State", "SetWindowsStateCommand", "Set Windows State"); + + // GetProcessNameFromWindowNameCommand -> GetOneProcessNameFromOneWindowNameCommand + ChangeCommandName(doc, "GetProcessNameFromWindowNameCommand", "GetOneProcessNameFromOneWindowNameCommand", "Get One Process Name From One Window Name"); + + // GetWindowHandleFromWindowNameCommand -> GetOneWindowHandleFromOneWindowNameCommand + //ChangeCommandName(doc, "GetWindowHandleFromWindowNameCommand", "GetOneWindowHandleFromOneWindowNameCommand", "Get One Window Handle From One Window Name"); + ChangeToOtherCommand(doc, "GetWindowHandleFromWindowNameCommand", "GetOneWindowHandleFromOneWindowNameCommand", "Get One Window Handle From One Window Name", + new List<(string, string)>() + { + ("v_HandleResult", "v_Result"), + } + ); + + // GetWindowPositionCommand -> GetOneWindowPositionCommand + ChangeCommandName(doc, "GetWindowPositionCommand", "GetOneWindowPositionCommand", "Get One Window Position"); + + // GetWindowSizeCommand -> GetOneWindowSizeCommand + ChangeCommandName(doc, "GetWindowSizeCommand", "GetOneWindowSizeCommand", "Get One Window Size"); + + // GetWindowStateCommand -> GetOneWindowStateCommand + ChangeCommandName(doc, "GetWindowStateCommand", "GetOneWindowStateCommand", "Get One Window State"); + } + + private static void convertTo3_5_2_42(XDocument doc) + { + // TakeScreenshot v_ActivateWindowBeforeCapture -> v_ActivateBeforeAction + // v_WaitTimeBeforeCapture -> v_WaitTimeBetweenFindAndAction + var takes = GetCommands(doc, "TakeScreenshotCommand").ToList(); + ChangeAttributeNameProcess(takes, "v_ActivateWindowBeforeCapture", "v_ActivateBeforeAction"); + foreach (var cmd in takes) + { + var attr_wbc = cmd.Attribute("v_WaitTimeBeforeCapture"); + if (attr_wbc != null) + { + if (int.TryParse(attr_wbc.Value, out int wbc)) + { + cmd.SetAttributeValue("v_WaitTimeBetweenFindAndAction", ((wbc / 1000.0)).ToString()); + } + else + { + cmd.SetAttributeValue("v_WaitTimeBetweenFindAndAction", attr_wbc.Value); + } + attr_wbc.Remove(); + } + } + + // EnterKeys v_WaitTime -> v_WaitTimeAfterKeyEnter + ChangeAttributeName(doc, "EnterKeysCommand", "v_WaitTime", "v_WaitTimeAfterKeyEnter"); + + // SendAdvancedKeyStrokes, EnterShotcutKey v_WaitAfterKeyEnter -> v_WaitTimeAfterKeyEnter + ChangeAttributeName(doc, + new Func((el) => + { + switch (GetCommandName(el)) + { + case "SendAdvancedKeyStrokesCommand": + case "EnterShortcutKeyCommand": + return true; + default: + return false; + } + }), "v_WaitAfterKeyEnter", "v_WaitTimeAfterKeyEnter"); + + // EnterKeys v_EncryptionOption values -> Yes/No + ChangeAttributeValue(doc, "EnterKeysCommand", "v_EncryptionOption", new Action(attr => + { + switch (attr.Value.ToLower()) + { + case "encrypted": + attr.SetValue("Yes"); + break; + case "not encrypted": + attr.SetValue("No"); + break; + } + })); + } + + private static void convertTo3_5_2_43(XDocument doc) + { + // CheckTextCommand, GetFilesPathAsListCommand, GetFoldersPathAsListCommand + // v_CompareMethod -> v_CheckMethod, v_TrimBeforeCompare -> v_TrimBeforeCheck + ChangeMultiAttributeNames(doc, + new Func(el => + { + switch (GetCommandName(el)) + { + case "CheckTextCommand": + case "GetFilesPathAsListCommand": + case "GetFoldersPathAsListCommand": + return true; + default: + return false; + } + }), + new List<(string, string)>() + { + ("v_CompareMethod", "v_CheckMethod"), + ("v_TrimBeforeCompare", "v_TrimBeforeCheck"), + } + ); + + // CheckTextCommand v_userVariableName -> v_Text, v_applyToVariableName -> v_Result + ChangeMultiAttributeNames(doc, "CheckTextCommand", + new List<(string, string)>() + { + ("v_userVariableName", "v_Text"), + ("v_applyToVariableName", "v_Result"), + } + ); + + // many window commands, uiautomation commands, key commands, image command + // v_CompareMethod -> v_CheckMethod, v_MatchMethod -> v_SelectionMethod + ChangeMultiAttributeNames(doc, + new Func(el => + { + switch (GetCommandName(el)) + { + // image + case "TakeScreenshotCommand": + // key + case "EnterKeysCommand": + case "EnterShortcutKeyCommand": + case "SendAdvancedKeyStrokesCommand": + // uiautomation (uielement) + case "UIAutomationSearchUIElementAndWindowByXPathCommand": + case "UIAutomationSearchUIElementAndWindowCommand": + case "UIAutomationSearchUIElementFromWindowCommand": + case "UIAutomationUIElementActionByXPathCommand": + case "UIAutomationUIElementActionCommand": + // get from window name + case "GetOneProcessNameFromOneWindowNameCommand": + case "GetOneWindowHandleFromOneWindowNameCommand": + case "GetOneWindowPositionCommand": + case "GetOneWindowSizeCommand": + case "GetOneWindowStateCommand": + // one window action + case "ActivateOneWindowCommand": + case "CloseOneWindowCommand": + case "MoveOneWindowCommand": + case "ResizeOneWindowCommand": + case "SetOneWindowStateCommand": + return true; + default: + return false; + } + }), + new List<(string, string)>() + { + ("v_CompareMethod", "v_CheckMethod"), + ("v_MatchMethod", "v_SelectionMethod"), + } + ); + + // many window commands + // v_CompareMethod -> v_CheckMethod + ChangeMultiAttributeNames(doc, + new Func(el => + { + switch (GetCommandName(el)) + { + // get from window name + case "CheckWindowNameExistsCommand": + case "GetProcessNamesFromWindowNamesAsDataTableCommand": + case "GetProcessNamesFromWindowNamesAsListCommand": + case "GetWindowHandlesFromWindowNamesAsDataTableCommand": + case "GetWindowHandlesFromWindowNamesAsListCommand": + case "GetWindowNamesCommand": + case "GetWindowPositionsFromWindowNamesAsDataTableCommand": + case "GetWindowPositionsFromWindowNamesAsListCommand": + case "GetWindowSizesFromWindowNamesAsDataTableCommand": + case "GetWindowSizesFromWindowNamesAsListCommand": + case "GetWindowStatesFromWindowNamesAsDataTableCommand": + case "GetWindowStatesFromWindowNamesAsListCommand": + // multi window actions + case "ActivateWindowsCommand": + case "CloseWindowsCommand": + case "MoveWindowsCommand": + case "ResizeWindowsCommand": + case "SetWindowsStateCommand": + // one window name actions + case "WaitForWindowToExistsCommand": + return true; + + default: + return false; + } + }), + new List<(string, string)>() + { + ("v_CompareMethod", "v_CheckMethod"), + } + ); + + // CheckWindowNameExistsCommand, GetWindowNamesCommand + // v_UserVariableName -> v_Result + ChangeAttributeName(doc, + new Func(el => + { + switch (GetCommandName(el)) + { + case "CheckWindowNameExistsCommand": + case "GetWindowNamesCommand": + return true; + default: + return false; + } + }), "v_UserVariableName", "v_Result"); + } + + private static void convertTo3_5_2_44(XDocument doc) + { + // ClickUIElement v_ActivateWindow -> v_ActivateWindowBeforeAction + ChangeAttributeName(doc, "UIAutomationClickUIElementCommand", "v_ActivateWindow", "v_ActivateWindowBeforeAction"); + + // UIAutomationSetTextToUIElementCommand v_TextVariable -> v_TextToSet + ChangeAttributeName(doc, "UIAutomationSetTextToUIElementCommand", "v_TextVariable", "v_TextToSet"); + + // UIAutomationGetSelectedStateFromUIElementCommand, UIAutomationGetChildrenUIElementsInformationCommand v_ResultVariable -> v_Result + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "UIAutomationGetSelectedStateFromUIElementCommand": + case "UIAutomationGetChildrenUIElementsInformationCommand": + return true; + default: + return false; + } + }), "v_ResultVariable", "v_Result"); + + // UIAutomationGetSelectionItemsFromUIElementCommand v_ListVariable -> v_Result + ChangeAttributeName(doc, "UIAutomationGetSelectionItemsFromUIElementCommand", "v_ListVariable", "v_Result"); + + // UIAutomationGetTextFromTableUIElementCommand, UIAutomationGetTextFromUIElementCommand v_TextVariable -> v_Result + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "UIAutomationGetTextFromTableUIElementCommand": + case "UIAutomationGetTextFromUIElementCommand": + return true; + default: + return false; + } + }), "v_TextVariable", "v_Result"); + + // UIAutomationGetUIElementTreeXMLFromUIElementCommand v_XMLVariable -> v_Result + ChangeAttributeName(doc, "UIAutomationGetUIElementTreeXMLFromUIElementCommand", "v_XMLVariable", "v_Result"); + + // UIAutomationSearchUIElementFromTableUIElementCommand -> UIAutomationGetUIElementFromTableUIElementCommand + ChangeCommandName(doc, "UIAutomationSearchUIElementFromTableUIElementCommand", "UIAutomationGetUIElementFromTableUIElementCommand", "Get UIElement From Table UIElement"); + // UIAutomationSearchParentUIElementCommand -> UIAutomationGetParentUIElementCommand + ChangeCommandName(doc, "UIAutomationSearchParentUIElementCommand", "UIAutomationGetParentUIElementCommand", "Get Parent UIElement"); + // UIAutomationSearchUIElementFromWindowCommand -> UIAutomationGetWindowUIElementCommand + ChangeCommandName(doc, "UIAutomationSearchUIElementFromWindowCommand", "UIAutomationGetWindowUIElementCommand", "Get Window UIElement"); + + // UIAutomationGetUIElementFromTableUIElementCommand, UIAutomationGetParentUIElementCommand, UIAutomationGetWindowUIElementCommand + // v_AutomationElementVariable -> v_Result + ChangeAttributeName(doc, new Func((el) => + { + switch (GetCommandName(el)) + { + case "UIAutomationGetUIElementFromTableUIElementCommand": + case "UIAutomationGetParentUIElementCommand": + case "UIAutomationGetWindowUIElementCommand": + return true; + default: + return false; + } + }), "v_AutomationElementVariable", "v_Result"); + + // UIAutomationGetSelectionItemsFromUIElementCommand -> UIAutomationGetSelectionItemsValueFromUIElementCommand + ChangeCommandName(doc, "UIAutomationGetSelectionItemsFromUIElementCommand", "UIAutomationGetSelectionItemsValueFromUIElementCommand", "Get Selection Items Value From UIElement"); + } + + private static void convertTo3_5_2_45(XDocument doc) + { + // UIAutomationSearchChildUIElementCommand, UIAutomationGetChildrenUIElementsInformationCommand + // v_RootElement -> v_TargetElement + ChangeAttributeName(doc, new Func((el) => + { + switch (GetCommandName(el)) + { + case "UIAutomationSearchChildUIElementCommand": + case "UIAutomationGetChildrenUIElementsInformationCommand": + return true; + default: + return false; + } + }), "v_RootElement", "v_TargetElement"); + + // UIAutomationSearchChildUIElementCommand v_AutomationElementVariable -> v_Result + ChangeAttributeName(doc, "UIAutomationSearchChildUIElementCommand", "v_AutomationElementVariable", "v_Result"); + + // UIAutomationGetChildrenUIElementsInformationCommand -> UIAutomationSearchChildrenUIElementsInformationCommand + ChangeCommandName(doc, "UIAutomationGetChildrenUIElementsInformationCommand", "UIAutomationSearchChildrenUIElementsInformationCommand", "Search Children UIElements Information"); + + // UIAutomationSetSelectionStateToUIElementCommand -> UIAutomationSetSelectedStateToUIElementCommand + ChangeCommandName(doc, "UIAutomationSetSelectionStateToUIElementCommand", "UIAutomationSetSelectedStateToUIElementCommand", "Set Selected State To UIElement"); + } + + private static void convertTo3_5_2_46(XDocument doc) + { + // UIAutomationCheckUIElementExistsByXPathCommand, UIAutomationCheckUIElementExistsCommand, + // UIAutomationSearchUIElementFromUIElementByXPathCommand, UIAutomationSearchUIElementFromUIElementCommand, + // UIAutomationWaitForUIElementToExistsByXPathCommand, UIAutomationWaitForUIElementToExistsCommand + // v_WaitTime -> v_WaitTimeForUIElement + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "UIAutomationCheckUIElementExistsByXPathCommand": + case "UIAutomationCheckUIElementExistsCommand": + case "UIAutomationSearchUIElementFromUIElementByXPathCommand": + case "UIAutomationSearchUIElementFromUIElementCommand": + case "UIAutomationWaitForUIElementToExistsByXPathCommand": + case "UIAutomationWaitForUIElementToExistsCommand": + return true; + default: + return false; + } + }), "v_WaitTime", "v_WaitTimeForUIElement"); + + // UIAutomationSearchUIElementAndWindowByXPathCommand, UIAutomationSearchUIElementAndWindowCommand, + // UIAutomationUIElementActionByXPathCommand, UIAutomationUIElementActionCommand + // v_ElementWaitTime -> v_WaitTimeForUIElement + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "UIAutomationSearchUIElementAndWindowByXPathCommand": + case "UIAutomationSearchUIElementAndWindowCommand": + case "UIAutomationUIElementActionByXPathCommand": + case "UIAutomationUIElementActionCommand": + return true; + default: + return false; + } + }), "v_ElementWaitTime", "v_WaitTimeForUIElement"); + + // UIAutomationSearchChildUIElementCommand v_Index -> v_TargetUIElementIndex + ChangeAttributeName(doc, "UIAutomationSearchChildUIElementCommand", "v_Index", "v_TargetUIElementIndex"); + + // UIAutomationSearchUIElementAndWindowByXPathCommand, UIAutomationSearchUIElementAndWindowCommand, + // UIAutomationSearchUIElementFromUIElementByXPathCommand, UIAutomationSearchUIElementFromUIElementCommand + // v_AutomationElementVariable -> v_Result + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "UIAutomationSearchUIElementAndWindowByXPathCommand": + case "UIAutomationSearchUIElementAndWindowCommand": + case "UIAutomationSearchUIElementFromUIElementByXPathCommand": + case "UIAutomationSearchUIElementFromUIElementCommand": + return true; + default: + return false; + } + }), "v_AutomationElementVariable", "v_Result"); + + // ActivateOneWindowCommand, ActivateWindowsCommand, + // CheckWindowNameExistsCommand, + // CloseOneWindowCommand, CloseWindowsCommand, + // GetOneProcessNameFromOneWindowNameCommand, GetOneWindowHandleFromOneWindowNameCommand, + // GetOneWindowPositionCommand, GetOneWindowSizeCommand, GetOneWindowStateCommand, + // GetProcessNamesFromWindowNamesAsDataTableCommand, GetProcessNamesFromWindowNamesAsListCommand, + // GetWindowHandlesFromWindowNamesAsDataTableCommand, GetWindowHandlesFromWindowNamesAsListCommand, + // GetWindowNamesCommand, + // GetWindowPositionsFromWindowNamesAsDataTableCommand, GetWindowPositionsFromWindowNamesAsListCommand, + // GetWindowSizesFromWindowNamesAsDataTableCommand, GetWindowSizesFromWindowNamesAsListCommand, + // GetWindowStatesFromWindowNamesAsDataTableCommand, GetWindowStatesFromWindowNamesAsListCommand, + // MoveOneWindowCommand, MoveWindowsCommand, + // ResizeOneWindowCommand, ResizeWindowsCommand, + // SetOneWindowStateCommand, SetWindowsStateCommand, + // WaitForWindowToExistsCommand, + // UIAutomationSearchUIElementAndWindowByXPathCommand, UIAutomationSearchUIElementAndWindowCommand, + // UIAutomationUIElementActionByXPathCommand, UIAutomationUIElementActionCommand + // v_NameResult -> v_WindowNameResult, v_HandleResult -> v_WindowHandleResult + ChangeMultiAttributeNames(doc, new Func(el => + { + switch (GetCommandName(el)) + { + // window commands + case "ActivateOneWindowCommand": + case "ActivateWindowsCommand": + case "CheckWindowNameExistsCommand": + case "CloseOneWindowCommand": + case "CloseWindowsCommand": + case "GetOneProcessNameFromOneWindowNameCommand": + case "GetOneWindowHandleFromOneWindowNameCommand": + case "GetOneWindowPositionCommand": + case "GetOneWindowSizeCommand": + case "GetOneWindowStateCommand": + case "GetProcessNamesFromWindowNamesAsDataTableCommand": + case "GetProcessNamesFromWindowNamesAsListCommand": + case "GetWindowHandlesFromWindowNamesAsDataTableCommand": + case "GetWindowHandlesFromWindowNamesAsListCommand": + case "GetWindowNamesCommand": + case "GetWindowPositionsFromWindowNamesAsDataTableCommand": + case "GetWindowPositionsFromWindowNamesAsListCommand": + case "GetWindowSizesFromWindowNamesAsDataTableCommand": + case "GetWindowSizesFromWindowNamesAsListCommand": + case "GetWindowStatesFromWindowNamesAsDataTableCommand": + case "GetWindowStatesFromWindowNamesAsListCommand": + case "MoveOneWindowCommand": + case "MoveWindowsCommand": + case "ResizeOneWindowCommand": + case "ResizeWindowsCommand": + case "SetOneWindowStateCommand": + case "SetWindowsStateCommand": + case "WaitForWindowToExistsCommand": + // UIElement command + case "UIAutomationSearchUIElementAndWindowByXPathCommand": + case "UIAutomationSearchUIElementAndWindowCommand": + case "UIAutomationUIElementActionByXPathCommand": + case "UIAutomationUIElementActionCommand": + return true; + default: + return false; + } + }), new List<(string, string)>() + { + ("v_NameResult", "v_WindowNameResult"), + ("v_HandleResult", "v_WindowHandleResult"), + }); + + // UIAutomationUIElementActionCommand v_UIASearchParameters -> v_SearchParameters + ChangeInnerTagName(doc, "UIAutomationUIElementActionCommand", "v_UIASearchParameters", "v_SearchParameters"); + + // UIAutomationSearchUIElementAndWindowByXPathCommand -> UIAutomationSearchUIElementFromWindowNameByXPathCommand + ChangeCommandName(doc, "UIAutomationSearchUIElementAndWindowByXPathCommand", "UIAutomationSearchUIElementFromWindowNameByXPathCommand", "Search UIElement From Window Name By XPath"); + + // UIAutomationSearchUIElementAndWindowCommand -> UIAutomationSearchUIElementFromWindowCommand + ChangeCommandName(doc, "UIAutomationSearchUIElementAndWindowCommand", "UIAutomationSearchUIElementFromWindowNameCommand", "Search UIElement From Window Name"); + + // GetOneWindowHandleFromOneWindowNameCommand, GetWindowHandlesFromWindowNamesAsListCommand + // v_Result -> v_WindowHandleResult + OverwriteAttributeValue(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "GetOneWindowHandleFromOneWindowNameCommand": + case "GetWindowHandlesFromWindowNamesAsListCommand": + return true; + default: + return false; + } + }), "v_Result", "v_WindowHandleResult"); + + // GetWindowNameFromWindowHandleCommand, GetWindowNamesCommand + // v_Result -> v_WindowNameResult + OverwriteAttributeValue(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "GetWindowNameFromWindowHandleCommand": + case "GetWindowNamesCommand": + return true; + default: + return false; + } + }), "v_Result", "v_WindowNameResult"); + } + + private static void convertTo3_5_2_47(XDocument doc) + { + // UIAutomationUIElementActionByXPathCommand v_UIASearchParameters -> v_SearchXPath + ChangeAttributeName(doc, "UIAutomationUIElementActionByXPathCommand", "v_UIASearchParameters", "v_SearchXPath"); + + // UIAutomationGetUIElementTreeXMLFromUIElementCommand -> UIAutomationGetUIElementsTreeXMLFromUIElementCommand + ChangeCommandName(doc, "UIAutomationGetUIElementTreeXMLFromUIElementCommand", "UIAutomationSearchUIElementsTreeXMLFromUIElementCommand", "Search UIElements Tree XML From UIElement"); + + // UIAutomationCheckUIElementExistsByXPathCommand, UIAutomationSearchUIElementFromUIElementByXPathCommand, + // UIAutomationWaitForUIElementToExistsByXPathCommand + // v_SearchXPath element to attribute + var checkUIElemXPath = GetCommands(doc, new Func(elem => + { + switch (GetCommandName(elem)) + { + case "UIAutomationCheckUIElementExistsByXPathCommand": + case "UIAutomationSearchUIElementFromUIElementByXPathCommand": + case "UIAutomationWaitForUIElementToExistsByXPathCommand": + return true; + default: + return false; + } + })); + foreach (var command in checkUIElemXPath) + { + var xpathElem = command.Element("v_SearchXPath"); + if (xpathElem != null) + { + command.SetAttributeValue("v_SearchXPath", xpathElem.Value); + xpathElem.Remove(); + } + } + } + + private static void convertTo3_5_2_51(XDocument doc) + { + // UIAutomationUIElementActionCommand -> UIAutomationUIElementActionAfterSearchUIElementFromWindowNameCommand + ChangeCommandName(doc, "UIAutomationUIElementActionCommand", "UIAutomationUIElementActionAfterSearchUIElementFromWindowNameCommand", "UIElement Action After Search UIElement From Window Name"); + + // UIAutomationUIElementActionByXPathCommand -> UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowNameCommand + ChangeCommandName(doc, "UIAutomationUIElementActionByXPathCommand", "UIAutomationUIElementActionAfterSearchUIElementByXPathFromWindowNameCommand", "UIElement Action After Search UIElement By XPath From Window Name"); + } + + private static void convertTo3_5_2_53(XDocument doc) + { + // UIAutomationGetWindowUIElementCommand -> UIAutomationGetWindowUIElementFromWindowNameCommand + ChangeCommandName(doc, "UIAutomationGetWindowUIElementCommand", "UIAutomationGetWindowUIElementFromWindowNameCommand", "Get Window UIElement From Window Name"); + } + + private static void convertTo3_5_2_55(XDocument doc) + { + // ExtractionFolderPathCommand + var exFolder = GetCommands(doc, "ExtractionFolderPathCommand"); + foreach (var cmd in exFolder) + { + var attr = cmd.Attribute("v_Format"); + var format = attr.Value.ToLower(); + switch (format) + { + case "folder": + cmd.Attribute("v_Format").SetValue("Parent Folder"); + break; + case "drivename": + cmd.Attribute("v_Format").SetValue("Drive Name"); + break; + } + } + } + + private static void convertTo3_5_2_56(XDocument doc) + { + // change attribute name + // SeleniumBrowserScrollToWebElementCommand v_WhenFailScroll -> v_WhenFailAction + ChangeAttributeName(doc, "SeleniumBrowserScrollToWebElementCommand", "v_WhenFailScroll", "v_WhenFailAction"); + + // SeleniumBrowserClearTextInWebElementCommand + ChangeMultiAttributeNames(doc, "SeleniumBrowserClearTextInWebElementCommand", new List<(string, string)>() + { + ("v_ScrollToElement", "v_ScrollToWebElement"), + ("v_WhenClearNotSupported", "v_WhenFailAction"), + }); + + // SeleniumBrowserClickWebElementCommand + ChangeMultiAttributeNames(doc, "SeleniumBrowserClickWebElementCommand", new List<(string, string)>() + { + ("v_ScrollToElement", "v_ScrollToWebElement"), + ("v_WhenFailClick", "v_WhenFailAction"), + }); + + // SeleniumBrowserSelectOptionForWebElementCommand + ChangeMultiAttributeNames(doc, "SeleniumBrowserSelectOptionForWebElementCommand", new List<(string, string)>() + { + ("v_ScrollToElement", "v_ScrollToWebElement"), + ("v_WhenFailSelectAction", "v_WhenFailAction"), + }); + + //// SeleniumBrowserSendSpecialKeystrokesToWebElementCommand + //ChangeMultiAttributeNames(doc, "SeleniumBrowserSendSpecialKeystrokesToWebElementCommand", new List<(string, string)>() + //{ + // ("v_ScrollToElement", "v_ScrollToWebElement"), + // ("v_WhenSetNotSupported", "v_WhenFailAction"), + //}); + + //// SeleniumBrowserSetTextToWebElementCommand + //ChangeMultiAttributeNames(doc, "SeleniumBrowserSetTextToWebElementCommand", new List<(string, string)>() + //{ + // ("v_ScrollToElement", "v_ScrollToWebElement"), + // ("v_WhenSetNotSupported", "v_WhenFailAction"), + //}); + + // SeleniumBrowserSendSpecialKeystrokesToWebElementCommand + // SeleniumBrowserSetTextToWebElementCommand + ChangeMultiAttributeNames(doc, + new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserSendSpecialKeystrokesToWebElementCommand": + case "SeleniumBrowserSetTextToWebElementCommand": + return true; + default: + return false; + } + }), + new List<(string, string)>() + { + ("v_ScrollToElement", "v_ScrollToWebElement"), + ("v_WhenSetNotSupported", "v_WhenFailAction"), + } + ); + + // SeleniumBrowserSwitchFrameToWebElementCommand + ChangeMultiAttributeNames(doc, "SeleniumBrowserSwitchFrameToWebElementCommand", new List<(string, string)>() + { + ("v_ScrollToElement", "v_ScrollToWebElement"), + ("v_WhenFailSwitch", "v_WhenFailAction"), + }); + // SeleniumBrowserSwitchFrameToWebElementCommand -> SeleniumBrowserSwitchToFrameWebElementCommand + ChangeCommandName(doc, "SeleniumBrowserSwitchFrameToWebElementCommand", "SeleniumBrowserSwitchToFrameWebElementCommand", "Switch To Frame WebElement"); + } + + private static void convertTo3_5_2_57(XDocument doc) + { + // SeleniumBrowserCreateWebBrowserInstanceCommand v_EngineType -> v_BrowserType + ChangeAttributeName(doc, "SeleniumBrowserCreateWebBrowserInstanceCommand", "v_EngineType", "v_BrowserType"); + + // SeleniumBrowserCheckBrowserInstanceExistsCommand, SeleniumBrowserGetWebBrowserInformationCommand + // v_applyToVariableName -> v_Result + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserCheckBrowserInstanceExistsCommand": + case "SeleniumBrowserGetWebBrowserInformationCommand": + return true; + default: + return false; + } + }), "v_applyToVariableName", "v_Result"); + + // SeleniumBrowserSearchWebElementCommand, SeleniumBrowserSearchWebElementFromWebEelementCommand, + // SeleniumBrowserCheckWebElementExistsCommand, SeleniumBrowserWaitForWebElementToExistsCommand, + // SeleniumBrowserGetAWebElementValuesAsDataTableCommand, SeleniumBrowserGetAWebElementValuesAsDictionaryCommand, + // SeleniumBrowserGetAWebElementValuesAsListCommand, SeleniumBrowserGetTableValueAsDataTableCommand, + ChangeMultiAttributeNames(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserSearchWebElementCommand": + case "SeleniumBrowserSearchWebElementFromWebElementCommand": + case "SeleniumBrowserCheckWebElementExistsCommand": + case "SeleniumBrowserWaitForWebElementToExistsCommand": + case "SeleniumBrowserGetAWebElementValuesAsDataTableCommand": + case "SeleniumBrowserGetAWebElementValuesAsDictionaryCommand": + case "SeleniumBrowserGetAWebElementValuesAsListCommand": + case "SeleniumBrowserGetTableValueAsDataTableCommand": + return true; + default: + return false; + } + }), new List<(string, string)>() + { + ("v_SeleniumSearchType", "v_SearchMethod"), + ("v_SeleniumSearchParameter", "v_SearchParameter"), + ("v_ElementIndex", "v_WebElementIndex"), + ("v_WaitTime", "v_WaitTimeForWebElement"), + }); + + // SeleniumBrowserWebElementActionCommand + // v_SeleniumSearchType -> v_SearchMethod, v_SeleniumSearchParameter -> v_SearchParameter + // v_SeleniumElementIndex -> v_WebElementIndex, v_SeleniumElementAction -> v_WebElementAction + // v_SeleniumElementAction -> v_WebElementAction, v_ScrollToElement -> v_ScrollToWebElement + ChangeMultiAttributeNames(doc, "SeleniumBrowserWebElementActionCommand", + new List<(string, string)>() + { + ("v_SeleniumSearchType", "v_SearchMethod"), + ("v_SeleniumSearchParameter", "v_SearchParameter"), + ("v_SeleniumElementIndex", "v_WebElementIndex"), + ("v_SeleniumElementAction", "v_WebElementAction"), + ("v_ScrollToElement", "v_ScrollToWebElement"), + ("v_WaitTime", "v_WaitTimeForWebElement"), + } + ); + + // SeleniumBrowserGetAttributeFromWebElementCommand, SeleniumBrowserGetOptionsFromWebElementCommand + ChangeMultiAttributeNames(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserGetAttributeFromWebElementCommand": + case "SeleniumBrowserGetOptionsFromWebElementCommand": + return true; + default: + return false; + } + }), new List<(string, string)>() + { + ("v_WhenNoAttribute", "v_WhenValueCanNotRetrieved"), + ("v_ScrollToElement", "v_ScrollToWebElement"), + }); + + // SeleniumBrowserGetHTMLFromWebElementCommand, SeleniumBrowserGetTextFromWebElementCommand + // v_ScrollToElement -> v_ScrollToWebElement + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserGetHTMLFromWebElementCommand": + case "SeleniumBrowserGetTextFromWebElementCommand": + return true; + default: + return false; + } + }), "v_ScrollToElement", "v_ScrollToWebElement"); + + // SeleniumBrowserGetMatchedWebElementsCommand, SeleniumBrowserGetWebElementsCountCommand, + // SeleniumBrowserGetWebElementsValueAsDictionaryCommand, SeleniumBrowserGetWebElementsValueAsListCommand, + // SeleniumBrowserGetWebElementsValuesAsDataTableCommand, SeleniumBrowserGetWebElementsValueAsDataTableCommand + ChangeMultiAttributeNames(doc, + new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserGetMatchedWebElementsCommand": + case "SeleniumBrowserGetWebElementsCountCommand": + case "SeleniumBrowserGetWebElementsValueAsDictionaryCommand": + case "SeleniumBrowserGetWebElementsValueAsListCommand": + case "SeleniumBrowserGetWebElementsValuesAsDataTableCommand": + case "SeleniumBrowserGetWebElementsValueAsDataTableCommand": + return true; + default: + return false; + } + }), + new List<(string, string)>() + { + ("v_SeleniumSearchType", "v_SearchMethod"), + ("v_SeleniumSearchParameter", "v_SearchParameter"), + ("v_WaitTime", "v_WaitTimeForWebElement"), + } + ); + + // SeleniumBrowserGetAWebElementValuesAsDataTableCommand, SeleniumBrowserGetTableValueAsDataTableCommand, + // SeleniumBrowserGetWebElementsValueAsDataTableCommand, SeleniumBrowserGetWebElementsValuesAsDataTableCommand + // v_DataTableVariableName -> v_Result + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserGetAWebElementValuesAsDataTableCommand": + case "SeleniumBrowserGetTableValueAsDataTableCommand": + case "SeleniumBrowserGetWebElementsValueAsDataTableCommand": + case "SeleniumBrowserGetWebElementsValuesAsDataTableCommand": + return true; + default: + return false; + } + }), "v_DataTableVariableName", "v_Result"); + + // SeleniumBrowserGetAWebElementValuesAsDictionaryCommand, SeleniumBrowserGetWebElementsValueAsDictionaryCommand + // v_DictionaryVariableName -> v_Result + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserGetAWebElementValuesAsDictionaryCommand": + case "SeleniumBrowserGetWebElementsValueAsDictionaryCommand": + return true; + default: + return false; + } + }), "v_DictionaryVariableName", "v_Result"); + + // SeleniumBrowserGetAWebElementValuesAsListCommand, SeleniumBrowserGetWebElementsValueAsListCommand + // v_ListVariableName -> v_Result + ChangeAttributeName(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserGetAWebElementValuesAsListCommand": + case "SeleniumBrowserGetWebElementsValueAsListCommand": + return true; + default: + return false; + } + }), "v_ListVariableName", "v_Result"); + } + + private static void convertTo3_5_2_59(XDocument doc) + { + // SeleniumAttachCreateWebBrowserInstanceCommand v_EngineType -> v_BrowserType + ChangeAttributeName(doc, "SeleniumAttachCreateWebBrowserInstanceCommand", "v_EngineType", "v_BrowserType"); + // SeleniumAttachCreateWebBrowserInstanceCommand -> SeleniumBrowserAttachCreateWebBrowserInstanceCommand + ChangeCommandName(doc, "SeleniumAttachCreateWebBrowserInstanceCommand", "SeleniumBrowserAttachCreateWebBrowserInstanceCommand", "Attach Web Browser Instance"); + + // SeleniumBrowserCreateWebBrowserInstanceCommand v_Handle -> v_WindowHandleResult + ChangeAttributeName(doc, "SeleniumBrowserCreateWebBrowserInstanceCommand", "v_Handle", "v_WindowHandleResult"); + + // SeleniumBrowserExecuteScriptCommand v_userVariableName -> v_Result + ChangeAttributeName(doc, "SeleniumBrowserExecuteScriptCommand", "v_userVariableName", "v_Result"); + + // SeleniumBrowserExecuteScriptCommand -> SeleniumBrowserExecuteJavaScriptCommand + ChangeCommandName(doc, "SeleniumBrowserExecuteScriptCommand", "SeleniumBrowserExecuteJavaScriptCommand", "Execute JavaScript"); + } + + private static void convertTo3_5_2_60(XDocument doc) + { + // SeleniumBrowserExecuteJavaScriptCommand v_Args -> v_Arguments + ChangeAttributeName(doc, "SeleniumBrowserExecuteJavaScriptCommand", "v_Args", "v_Arguments"); + + // SeleniumBrowserExecuteJavaScriptCommand -> SeleniumBrowserExecuteJavaScriptFromFileCommand + ChangeToOtherCommand(doc, new Func(el => + { + switch (GetCommandName(el)) + { + case "SeleniumBrowserExecuteJavaScriptCommand": + var typeAttr = el.Attribute("v_CodeType"); + if (typeAttr != null) + { + var v = typeAttr.Value.ToLower(); + return (v == "file"); + } + else + { + return false; + } + + default: + return false; + } + }), "SeleniumBrowserExecuteJavaScriptFromFileCommand", "Execute JavaScript From File", + new List<(string, string)>() + { + ("v_ScriptCode", "v_FilePath"), + } + ); + + // SeleniumBrowserRefreshCommand -> SeleniumBrowserRefreshWebBrowserCommand + ChangeCommandName(doc, "SeleniumBrowserRefreshCommand", "SeleniumBrowserRefreshWebBrowserCommand", "Refresh Web Browser"); + + // SeleniumBrowserTakeScreenshotCommand -> SeleniumBrowserTakeScreenshotOfWebBrowserCommand + ChangeCommandName(doc, "SeleniumBrowserTakeScreenshotCommand", "SeleniumBrowserTakeScreenshotOfWebBrowserCommand", "Take Screenshot Of Web Browser"); + } + + private static void convertTo3_5_2_61(XDocument doc) + { + // SeleniumBrowserExecuteJavaScriptCommand -> SeleniumBrowserExecuteJavaScriptFromCodeCommand + ChangeCommandName(doc, "SeleniumBrowserExecuteJavaScriptCommand", "SeleniumBrowserExecuteJavaScriptFromCodeCommand", "Execute JavaScript From Code"); + + // SeleniumWebElementPositionCommand -> SeleniumBrowserGetWebElementPositionCommand + ChangeCommandName(doc, "SeleniumWebElementPositionCommand", "SeleniumBrowserGetWebElementPositionCommand", "Get WebElement Position"); + + // SeleniumWebElementSizeCommand -> SeleniumBrowserGetWebElementSizeCommand + ChangeCommandName(doc, "SeleniumWebElementSizeCommand", "SeleniumBrowserGetWebElementSizeCommand", "Get WebElement Size"); + + // SeleniumBrowserGetMatchedWebElementsCommand -> SeleniumBrowserGetMatchedWebElementsHTMLAsListCommand + ChangeCommandName(doc, "SeleniumBrowserGetMatchedWebElementsCommand", "SeleniumBrowserGetMatchedWebElementsHTMLAsListCommand", "Get Matched WebElements HTML As List"); + + // SeleniumBrowserGetTableValueAsDataTableCommand -> SeleniumBrowserGetTableValuesAsDataTableCommand + ChangeCommandName(doc, "SeleniumBrowserGetTableValueAsDataTableCommand", "SeleniumBrowserGetTableValuesAsDataTableCommand", "Get Table Values As DataTable"); + + // SeleniumBrowserGetAWebElementValuesAsDictionaryCommand -> SeleniumBrowserGetOneWebElementValuesAsDictionaryCommand + ChangeCommandName(doc, "SeleniumBrowserGetAWebElementValuesAsDictionaryCommand", "SeleniumBrowserGetOneWebElementValuesAsDictionaryCommand", "Get One WebElement Values As Dictionary"); + + // SeleniumBrowserGetAWebElementValuesAsListCommand -> SeleniumBrowserGetOneWebElementValuesAsListCommand + ChangeCommandName(doc, "SeleniumBrowserGetAWebElementValuesAsListCommand", "SeleniumBrowserGetOneWebElementValuesAsListCommand", "Get One WebElement Values As List"); + + // SeleniumBrowserGetAWebElementValuesAsDataTableCommand -> SeleniumBrowserGetOneWebElementValuesAsDataTableCommand + ChangeCommandName(doc, "SeleniumBrowserGetAWebElementValuesAsDataTableCommand", "SeleniumBrowserGetOneWebElementValuesAsDataTableCommand", "Get One WebElement Values As DataTable"); + + // SeleniumBrowserGetWebBrowserInformationCommand -> new commands + var getBrowserInfo = GetCommands(doc, "SeleniumBrowserGetWebBrowserInformationCommand"); + var getHTML = new List(); + var getJSONHandle = new List(); + foreach(var cmd in getBrowserInfo) + { + var attr = cmd.Attribute("v_InfoType"); + if (attr != null) + { + switch (attr.Value.ToLower()) + { + case "html page source": + getHTML.Add(cmd); + break; + case "handles json array": + getJSONHandle.Add(cmd); + break; + } + } + } + // SeleniumBrowserGetWebBrowserInformationCommand -> SeleniumBrowserGetWebBrowserHTMLSourceCommand + ChangeToOtherCommandProcess(getHTML, "SeleniumBrowserGetWebBrowserHTMLSourceCommand", "Get Web Browser HTML Source", new List<(string, string)>()); + // SeleniumBrowserGetWebBrowserInformationCommand -> SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand + ChangeToOtherCommandProcess(getJSONHandle, "SeleniumBrowserGetWindowAndTabHandlesAsJSONCommand", "Get Window And Tab Handles As JSON", new List<(string, string)>()); + } + + private static void convertTo3_5_2_62(XDocument doc) + { + // SeleniumBrowserSwitchWebBrowserWindowAndTabCommand paremeters + ChangeMultiAttributeNames(doc, "SeleniumBrowserSwitchWebBrowserWindowAndTabCommand", + new List<(string, string)>() + { + ("v_WindowMatchType", "v_CheckTarget"), + ("v_MatchSpecification", "v_CheckMethod"), + ("v_CaseSensitiveMatch", "v_CaseSensitive"), + ("v_MatchParameter", "v_CheckText"), + } + ); + + // SeleniumBrowserSwitchWebBrowserWindowAndTabCommand v_CheckTarget value + ChangeAttributeValue(doc, "SeleniumBrowserSwitchWebBrowserWindowAndTabCommand", "v_CheckTarget", + new Action(attr => + { + switch (attr.Value.ToLower()) + { + case "window url": + attr.SetValue("URL"); + break; + case "window title": + attr.SetValue("Page Title"); + break; + } + }) + ); + + // SeleniumBrowserSwitchWebBrowserWindowAndTabCommand v_CheckMethod value + ChangeAttributeValue(doc, "SeleniumBrowserSwitchWebBrowserWindowAndTabCommand", "v_CheckMethod", + new Action(attr => + { + switch (attr.Value.ToLower()) + { + case "contains match": + attr.SetValue("Contains"); + break; + } + }) + ); + } + + /// + /// get old, new current window keyword + /// + /// + /// + private static (string oldKeyword, string newKeyword) GetOldNewCurrentWindow(IEngineSettings engine) + { + return GetOldNewKeyword("%kwd_current_window%", engine.CurrentWindowKeyword, SystemVariables.Window_CurrentWindowName, engine); + } + + /// + /// get old new keyword + /// + /// + /// + /// + /// /// private static (string oldKeyword, string newKeyword) GetOldNewKeyword(string intermediateKeyword, string rawKeyword, ScriptVariable systemVariable, IEngineSettings engine) { @@ -4559,7 +5881,7 @@ private static XDocument ChangeTableCellValue(XDocument doc, Func(); foreach (XElement row in table) { @@ -4604,6 +5926,12 @@ private static (XElement, XElement, string, XElement, List) GetTable(X XNamespace nsMsdata = "urn:schemas-microsoft-com:xml-msdata"; var el = elem.Element(tableParameterName); + if (el == null) + { + // table not found + return (null, null, "", null, null); + } + var elel = el.Element(nsXs + "schema").Element(nsXs + "element"); // table name @@ -4612,7 +5940,7 @@ private static (XElement, XElement, string, XElement, List) GetTable(X { rowName = elel.Attribute(nsMsdata + "MainDataTable")?.Value; } - + // xs:sequence var seq = elel.Element(nsXs + "complexType").Element(nsXs + "choice").Element(nsXs + "element").Element(nsXs + "complexType").Element(nsXs + "sequence"); @@ -4759,9 +6087,13 @@ private static void CreateTable(XElement diffgram) private static void ChangeTableColumnNames(XDocument doc, string commandName, string tableParameterName, List<(string currentColumnName, string newColumnName)> changes) { var cmds = GetCommands(doc, commandName); - foreach(var cmd in cmds) + foreach (var cmd in cmds) { (var table, var before, _, _, var seq) = GetTable(cmd, tableParameterName); + if ((table == null) || (before == null)) + { + continue; + } foreach (var e in seq) { @@ -4869,7 +6201,7 @@ private static XDocument ChangeAttributeName(XDocument doc, string targetCommand /// (targetAttributeName, newAttributeName) private static void ChangeMultiAttributeNamesProcess(List commands, List<(string, string)> attributePairs) { - foreach((var targetAttribute, var newAttribute) in attributePairs) + foreach ((var targetAttribute, var newAttribute) in attributePairs) { ChangeAttributeNameProcess(commands, targetAttribute, newAttribute); } @@ -4915,7 +6247,7 @@ private static void ChangeToOtherCommandProcess(List commands, string // attribute values if (preAttributeFunc != null) { - foreach((var attr, var func) in preAttributeFunc) + foreach ((var attr, var func) in preAttributeFunc) { ChangeAttributeValueProcess(commands, attr, func); } @@ -4958,5 +6290,115 @@ private static XDocument ChangeToOtherCommand(XDocument doc, string targetComman { return ChangeToOtherCommand(doc, GetSearchCommandsFunc(targetCommand), newCommand, newSelectionName, attributePairs, preAttributeFunc); } + + /// + /// change tag name in commands + /// + /// + /// + /// + private static void ChangeInnerTagNameProcess(List commands, string currentTagName, string newTagName) + { + foreach (var cmd in commands) + { + var targetElement = cmd.Element(currentTagName); + if (targetElement != null) + { + var newElement = new XElement(newTagName, targetElement.Attributes(), targetElement.Nodes()); + targetElement.ReplaceWith(newElement); + } + } + } + + /// + /// Change inner tag name in Commands + /// + /// + /// + /// + /// + /// + private static XDocument ChangeInnerTagName(XDocument doc, Func searchFunc, string currentTagName, string newTagName) + { + var commands = doc.Descendants("ScriptCommand") + .Where(searchFunc).ToList(); + ChangeInnerTagNameProcess(commands, currentTagName, newTagName); + return doc; + } + + /// + /// change inner tag name in commands + /// + /// + /// + /// + /// + /// + private static XDocument ChangeInnerTagName(XDocument doc, string targetCommand, string currentTagName, string newTagName) + { + return ChangeInnerTagName(doc, GetSearchCommandsFunc(targetCommand), currentTagName, newTagName); + } + + /// + /// overwrite attribute value with another existing attribute process + /// + /// + /// + /// + /// + private static void OverwriteAttributeValueProcess(List commands, string targetAttr, string overwriteAttr, bool removeTargetAttr) + { + foreach (var cmd in commands) + { + var tAttr = cmd.Attribute(targetAttr); + if (tAttr != null) + { + var oAttr = cmd.Attribute(overwriteAttr); + if (oAttr != null) + { + oAttr.SetValue(tAttr.Value); + } + else + { + cmd.SetAttributeValue(overwriteAttr, tAttr.Value); + } + if (removeTargetAttr) + { + tAttr.Remove(); + } + } + } + } + + /// + /// overwrite attribute value with anothre existing attribute + /// + /// + /// + /// + /// + /// + /// + private static XDocument OverwriteAttributeValue(XDocument doc, Func searchFunc, string targetAttribute, string overwriteAttribute, bool removeTargetAttribute = true) + { + var commands = doc.Descendants("ScriptCommand") + .Where(searchFunc).ToList(); + OverwriteAttributeValueProcess(commands, targetAttribute, overwriteAttribute, removeTargetAttribute); + return doc; + } + + /// + /// overwrite attribute value with anothre existing attribute + /// + /// + /// + /// + /// + /// + /// + private static XDocument OverwriteAttributeValue(XDocument doc, string targetCommand, string targetAttribute, string overwriteAttribute, bool removeTargetAttribute = true) + { + return OverwriteAttributeValue(doc, GetSearchCommandsFunc(targetCommand), targetAttribute, overwriteAttribute, removeTargetAttribute); + } } } \ No newline at end of file diff --git a/taskt/Core/Script/ScriptVariable.cs b/taskt/Core/Script/ScriptVariable.cs index b2dda77cc..a65d827fc 100644 --- a/taskt/Core/Script/ScriptVariable.cs +++ b/taskt/Core/Script/ScriptVariable.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Xml.Serialization; using OpenQA.Selenium; +using taskt.Core.Automation.Commands.UIAutomationGroup; namespace taskt.Core.Script { @@ -107,7 +108,7 @@ private string GetDisplayValue(DataTable myDT, string requiredProperty = "") case "INDEX": return CurrentPosition.ToString(); default: - if (requiredProperty == "") + if (requiredProperty == string.Empty) { var dataRow = myDT.Rows[CurrentPosition]; return Newtonsoft.Json.JsonConvert.SerializeObject(dataRow.ItemArray); @@ -145,7 +146,7 @@ private string GetDisplayValue(Dictionary myDic, string required case "INDEX": return CurrentPosition.ToString(); default: - if (requiredProperty == "") + if (requiredProperty == string.Empty) { return (trgDic.Values.ToArray())[CurrentPosition]; } @@ -210,7 +211,7 @@ private string GetDisplayValue(System.Windows.Automation.AutomationElement eleme case "TYPE": return "AUTOMATIONELEMENT"; default: - return "Name: " + element.Current.Name + ", LocalizedControlType: " + element.Current.LocalizedControlType + ", ControlType: " + taskt.Core.Automation.Commands.UIElementControls.GetControlTypeText(element.Current.ControlType); + return $"Name: {element.Current.Name}, LocalizedControlType: {element.Current.LocalizedControlType}, ControlType: {EM_CanHandleUIElementExtentionMethods.GetControlTypeText(element)}"; } } private string GetDisplayValue(DateTime dt, string requiredProperty) @@ -296,7 +297,7 @@ private string GetDisplayValue(MimeKit.MimeMessage mail, string requiredProperty case "ID": return mail.MessageId; default: - string mes = ""; + string mes = string.Empty; if (mail.TextBody != null) { mes = mail.TextBody; @@ -305,7 +306,7 @@ private string GetDisplayValue(MimeKit.MimeMessage mail, string requiredProperty { mes = mail.HtmlBody; } - return "Subject: " + mail.Subject + ", Message: " + ((mes.Length > 100) ? mes.Substring(0, 100) : mes); + return $"Subject: {mail.Subject}, Message: {((mes.Length > 100) ? mes.Substring(0, 100) : mes)}"; } } private string GetDisplayValue(List mails, string requiredProperty) @@ -325,7 +326,7 @@ private string GetDisplayValue(List mails, string requiredP case "TYPE": return "MAILKIT_EMAILLIST"; default: - return "Index: " + CurrentPosition + ", " + GetDisplayValue(mails[CurrentPosition], ""); + return $"Index: {CurrentPosition}, " + GetDisplayValue(mails[CurrentPosition], ""); } } diff --git a/taskt/Program.cs b/taskt/Program.cs index 9bfff0e6c..c0dac83ab 100644 --- a/taskt/Program.cs +++ b/taskt/Program.cs @@ -52,6 +52,9 @@ static void Main(string[] args) Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + // DBG + //var a = App.AllCommandsInfo; + //if the exe was passed a filename argument then run the script if (args.Length > 0) { diff --git a/taskt/Properties/AssemblyInfo.cs b/taskt/Properties/AssemblyInfo.cs index da986da60..3ca3338a1 100644 --- a/taskt/Properties/AssemblyInfo.cs +++ b/taskt/Properties/AssemblyInfo.cs @@ -22,7 +22,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("taskt")] -[assembly: AssemblyCopyright("Copyright ©2025")] +[assembly: AssemblyCopyright("Copyright ©2026")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -44,6 +44,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("0.0.*")] -[assembly: AssemblyFileVersion("3.6.0.0")] +[assembly: AssemblyFileVersion("3.5.2.61")] //[assembly: AssemblyVersion("0.0.0.2")] //[assembly: AssemblyFileVersion("0.0.0.2")] diff --git a/taskt/Resources/chromedriver.exe b/taskt/Resources/chromedriver.exe index f16796213..363ae4f28 100644 Binary files a/taskt/Resources/chromedriver.exe and b/taskt/Resources/chromedriver.exe differ diff --git a/taskt/Resources/msedgedriver.exe b/taskt/Resources/msedgedriver.exe index 739696a19..12264e153 100644 Binary files a/taskt/Resources/msedgedriver.exe and b/taskt/Resources/msedgedriver.exe differ diff --git a/taskt/Samples/Application_Script_Commands/Open_File.xml b/taskt/Samples/Application_Script_Commands/Open_File.xml new file mode 100644 index 000000000..c73177820 --- /dev/null +++ b/taskt/Samples/Application_Script_Commands/Open_File.xml @@ -0,0 +1,24 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Application_Script_Commands/Open_Folder.xml b/taskt/Samples/Application_Script_Commands/Open_Folder.xml new file mode 100644 index 000000000..28a17ed2e --- /dev/null +++ b/taskt/Samples/Application_Script_Commands/Open_Folder.xml @@ -0,0 +1,24 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Excel_Commands/Attach_Excel_Instance.xml b/taskt/Samples/Excel_Commands/Attach_Excel_Instance.xml new file mode 100644 index 000000000..d3e9858a2 --- /dev/null +++ b/taskt/Samples/Excel_Commands/Attach_Excel_Instance.xml @@ -0,0 +1,36 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Excel_Commands/Set_Column_Width.xml b/taskt/Samples/Excel_Commands/Set_Column_Width.xml new file mode 100644 index 000000000..27c248776 --- /dev/null +++ b/taskt/Samples/Excel_Commands/Set_Column_Width.xml @@ -0,0 +1,42 @@ + + \ No newline at end of file diff --git a/taskt/Samples/File_Operation_Commands/Get_Files_Path_As_List.xml b/taskt/Samples/File_Operation_Commands/Get_Files_Path_As_List.xml index ab3559004..971149d42 100644 --- a/taskt/Samples/File_Operation_Commands/Get_Files_Path_As_List.xml +++ b/taskt/Samples/File_Operation_Commands/Get_Files_Path_As_List.xml @@ -8,7 +8,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -42,11 +42,11 @@ - 3.5.2.22 + 3.5.2.43 2024-09-15T21:40:06.6233843+09:00 3 - 7 + 8 0.0.0 diff --git a/taskt/Samples/Folder_Operation_Commands/Get_Folders_Path_As_List.xml b/taskt/Samples/Folder_Operation_Commands/Get_Folders_Path_As_List.xml index abc40f5e7..de09a4c13 100644 --- a/taskt/Samples/Folder_Operation_Commands/Get_Folders_Path_As_List.xml +++ b/taskt/Samples/Folder_Operation_Commands/Get_Folders_Path_As_List.xml @@ -8,7 +8,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -30,11 +30,11 @@ - 3.5.2.22 + 3.5.2.43 2024-09-16T09:56:42.6221992+09:00 4 - 7 + 8 0.0.0 diff --git a/taskt/Samples/Image_Commands/TakeScreenshot_FileCounter.xml b/taskt/Samples/Image_Commands/TakeScreenshot_FileCounter.xml index e3a0a32a7..f6464ef11 100644 --- a/taskt/Samples/Image_Commands/TakeScreenshot_FileCounter.xml +++ b/taskt/Samples/Image_Commands/TakeScreenshot_FileCounter.xml @@ -27,11 +27,11 @@ - 3.5.2.4 + 3.5.2.43 2024-09-16T10:22:49.4600103+09:00 4 - 3 + 4 0.0.0 diff --git a/taskt/Samples/Image_Commands/Take_Screenshot.xml b/taskt/Samples/Image_Commands/Take_Screenshot.xml index dbf43f0e7..6bb0d657d 100644 --- a/taskt/Samples/Image_Commands/Take_Screenshot.xml +++ b/taskt/Samples/Image_Commands/Take_Screenshot.xml @@ -18,11 +18,11 @@ - 3.5.2.4 + 3.5.2.43 2024-09-16T10:21:49.9244075+09:00 3 - 3 + 4 0.0.0 diff --git a/taskt/Samples/Key_Mouse_Commands/Enter_Keys.xml b/taskt/Samples/Key_Mouse_Commands/Enter_Keys.xml index bc1584e78..3aee07a64 100644 --- a/taskt/Samples/Key_Mouse_Commands/Enter_Keys.xml +++ b/taskt/Samples/Key_Mouse_Commands/Enter_Keys.xml @@ -8,31 +8,31 @@ - + - + - + - + - + @@ -41,18 +41,18 @@ - + - 3.5.2.4 + 3.5.2.43 2024-09-16T10:45:44.8519845+09:00 1 - 4 + 5 0.0.0 diff --git a/taskt/Samples/Key_Mouse_Commands/Enter_Keys_From_Window_Handle.xml b/taskt/Samples/Key_Mouse_Commands/Enter_Keys_From_Window_Handle.xml new file mode 100644 index 000000000..5c8027dab --- /dev/null +++ b/taskt/Samples/Key_Mouse_Commands/Enter_Keys_From_Window_Handle.xml @@ -0,0 +1,48 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Key_Mouse_Commands/Enter_Keys_Use_Clipboard.xml b/taskt/Samples/Key_Mouse_Commands/Enter_Keys_Use_Clipboard.xml index e0d2d9553..4368dcff1 100644 --- a/taskt/Samples/Key_Mouse_Commands/Enter_Keys_Use_Clipboard.xml +++ b/taskt/Samples/Key_Mouse_Commands/Enter_Keys_Use_Clipboard.xml @@ -8,19 +8,19 @@ - + - + - + @@ -30,11 +30,11 @@ - 3.5.2.15 + 3.5.2.43 2024-12-01T17:35:25.796111+09:00 2 - 4 + 5 0.0.0 diff --git a/taskt/Samples/Key_Mouse_Commands/Enter_Shortcut_Key.xml b/taskt/Samples/Key_Mouse_Commands/Enter_Shortcut_Key.xml index 69dfbbfa4..db910c57f 100644 --- a/taskt/Samples/Key_Mouse_Commands/Enter_Shortcut_Key.xml +++ b/taskt/Samples/Key_Mouse_Commands/Enter_Shortcut_Key.xml @@ -8,19 +8,19 @@ - + - + - + @@ -29,18 +29,18 @@ - + - 3.5.2.4 + 3.5.2.43 2024-09-16T10:56:47.9119389+09:00 2 - 6 + 7 0.0.0 diff --git a/taskt/Samples/Key_Mouse_Commands/Enter_Shortcut_Key_From_Window_Handle.xml b/taskt/Samples/Key_Mouse_Commands/Enter_Shortcut_Key_From_Window_Handle.xml new file mode 100644 index 000000000..dfd7b423a --- /dev/null +++ b/taskt/Samples/Key_Mouse_Commands/Enter_Shortcut_Key_From_Window_Handle.xml @@ -0,0 +1,48 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes.xml b/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes.xml index ce6275415..92c1a4e60 100644 --- a/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes.xml +++ b/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes.xml @@ -8,19 +8,19 @@ - + - + - + @@ -70,7 +70,7 @@ - + @@ -110,11 +110,11 @@ - 3.5.2.4 + 3.5.2.43 2024-09-16T11:00:49.8696915+09:00 4 - 10 + 11 0.0.0 diff --git a/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes_Alt_Tab.xml b/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes_Alt_Tab.xml index a3e5ddbd8..44bc40484 100644 --- a/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes_Alt_Tab.xml +++ b/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes_Alt_Tab.xml @@ -8,13 +8,13 @@ - + - + - + @@ -23,7 +23,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -109,7 +109,7 @@ - + @@ -146,11 +146,11 @@ - 3.5.2.4 + 3.5.2.43 2024-09-16T11:06:07.053004+09:00 2 - 4 + 5 0.0.0 diff --git a/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes_From_Window_Handle.xml b/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes_From_Window_Handle.xml new file mode 100644 index 000000000..3f9f4d320 --- /dev/null +++ b/taskt/Samples/Key_Mouse_Commands/Send_Advanced_Keystrokes_From_Window_Handle.xml @@ -0,0 +1,122 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Text_Commands/Check_Text.xml b/taskt/Samples/Text_Commands/Check_Text.xml index c18475799..3dde2c425 100644 --- a/taskt/Samples/Text_Commands/Check_Text.xml +++ b/taskt/Samples/Text_Commands/Check_Text.xml @@ -11,7 +11,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -29,10 +29,10 @@ - + - + @@ -41,10 +41,10 @@ - + - + @@ -53,21 +53,21 @@ - + - + - 3.5.2.15 + 3.5.2.43 2024-12-01T11:00:43.7504395+09:00 8 - 13 + 14 0.0.0 diff --git a/taskt/Samples/Text_Commands/Check_Text_2.xml b/taskt/Samples/Text_Commands/Check_Text_2.xml index 6c483bd2b..81c81fb87 100644 --- a/taskt/Samples/Text_Commands/Check_Text_2.xml +++ b/taskt/Samples/Text_Commands/Check_Text_2.xml @@ -8,10 +8,10 @@ - + - + @@ -20,10 +20,10 @@ - + - + @@ -35,10 +35,10 @@ - + - + @@ -50,21 +50,21 @@ - + - + - 3.5.2.25 + 3.5.2.43 2024-12-01T11:43:29.163279+09:00 6 - 9 + 10 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Check_UIElement_Exists.xml b/taskt/Samples/UIAutomation_Commands/Check_UIElement_Exists.xml index 39e73e8da..b665dc0ea 100644 --- a/taskt/Samples/UIAutomation_Commands/Check_UIElement_Exists.xml +++ b/taskt/Samples/UIAutomation_Commands/Check_UIElement_Exists.xml @@ -8,19 +8,19 @@ - + - + - + @@ -265,7 +265,7 @@ - + @@ -508,11 +508,11 @@ - 3.5.2.10 + 3.5.2.47 2024-10-06T11:09:35.9513238+09:00 7 - 13 + 14 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Check_UIElement_Exists_By_XPath.xml b/taskt/Samples/UIAutomation_Commands/Check_UIElement_Exists_By_XPath.xml index 5a101ffaa..3c9e3f2b0 100644 --- a/taskt/Samples/UIAutomation_Commands/Check_UIElement_Exists_By_XPath.xml +++ b/taskt/Samples/UIAutomation_Commands/Check_UIElement_Exists_By_XPath.xml @@ -8,21 +8,19 @@ - + - + - - //CheckBox[@Name="checkBox1"] - + @@ -31,20 +29,18 @@ - - //CheckBox[@Name="checkBox4"] - + - 3.5.2.10 + 3.5.2.48 2024-10-06T11:11:14.5340852+09:00 8 - 15 + 16 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Checkbox.xml b/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Checkbox.xml index 68023bd09..f1dc7c4a1 100644 --- a/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Checkbox.xml +++ b/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Checkbox.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,18 +259,18 @@ - + - 3.5.2.6 + 3.5.2.48 2024-10-03T22:39:40.1240002+09:00 6 - 4 + 5 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Radiobutton.xml b/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Radiobutton.xml index 042570f79..041a3a5ea 100644 --- a/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Radiobutton.xml +++ b/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Radiobutton.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,18 +259,18 @@ - + - 3.5.2.6 + 3.5.2.48 2024-10-03T22:40:33.611184+09:00 7 - 3 + 4 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Tab.xml b/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Tab.xml index 34034f93d..e788c2ab8 100644 --- a/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Tab.xml +++ b/taskt/Samples/UIAutomation_Commands/Click_UIElement_Click_Tab.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,18 +259,18 @@ - + - 3.5.2.6 + 3.5.2.48 2024-10-03T22:41:18.6198189+09:00 8 - 2 + 3 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Expand_Collapse_Items_In_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Expand_Collapse_Items_In_UIElement.xml index 6d6ae9452..613813060 100644 --- a/taskt/Samples/UIAutomation_Commands/Expand_Collapse_Items_In_UIElement.xml +++ b/taskt/Samples/UIAutomation_Commands/Expand_Collapse_Items_In_UIElement.xml @@ -5,19 +5,19 @@ - + - + - + @@ -275,11 +275,11 @@ - 3.5.2.6 + 3.5.2.48 2024-10-03T22:41:49.7558038+09:00 8 - 3 + 5 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Search_Parent_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Get_Parent_UIElement.xml similarity index 92% rename from taskt/Samples/UIAutomation_Commands/Search_Parent_UIElement.xml rename to taskt/Samples/UIAutomation_Commands/Get_Parent_UIElement.xml index 25e5e7c59..ee045eebe 100644 --- a/taskt/Samples/UIAutomation_Commands/Search_Parent_UIElement.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_Parent_UIElement.xml @@ -2,25 +2,25 @@ \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Checkbox_State.xml b/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Checkbox_State.xml index 2a2eb9e81..40136c75a 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Checkbox_State.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Checkbox_State.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,7 +259,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -510,7 +510,7 @@ - + @@ -520,11 +520,11 @@ - 3.5.2.6 + 3.5.2.47 2024-10-05T10:24:18.0668273+09:00 7 - 4 + 5 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Radiobutton_State.xml b/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Radiobutton_State.xml index e857d6ee9..b19b7ea66 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Radiobutton_State.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Radiobutton_State.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,7 +259,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -510,7 +510,7 @@ - + @@ -520,11 +520,11 @@ - 3.5.2.6 + 3.5.2.47 2024-10-05T10:25:15.9301748+09:00 8 - 3 + 4 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Tab_State.xml b/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Tab_State.xml index cabc3c1fe..3d37a5782 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Tab_State.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_Selected_State_From_UIElement_Get_Tab_State.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,7 +259,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -510,7 +510,7 @@ - + @@ -520,11 +520,11 @@ - 3.5.2.6 + 3.5.2.47 2024-10-05T10:25:37.3296752+09:00 9 - 4 + 5 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Get_Selection Items_Value_From_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Get_Selection Items_Value_From_UIElement.xml new file mode 100644 index 000000000..6cb4b7c37 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_Selection Items_Value_From_UIElement.xml @@ -0,0 +1,310 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_Selection_Items_From_UIElement_Get_Combobox_Items.xml b/taskt/Samples/UIAutomation_Commands/Get_Selection_Items_Value_From_UIElement_Get_Combobox_Items.xml similarity index 94% rename from taskt/Samples/UIAutomation_Commands/Get_Selection_Items_From_UIElement_Get_Combobox_Items.xml rename to taskt/Samples/UIAutomation_Commands/Get_Selection_Items_Value_From_UIElement_Get_Combobox_Items.xml index adae24e1a..2fddf68ce 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_Selection_Items_From_UIElement_Get_Combobox_Items.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_Selection_Items_Value_From_UIElement_Get_Combobox_Items.xml @@ -2,25 +2,25 @@ \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIEelement_Get_DataGridView_Text.xml b/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIEelement_Get_DataGridView_Text.xml index 2f3a46c68..34583aa35 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIEelement_Get_DataGridView_Text.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIEelement_Get_DataGridView_Text.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,7 +259,7 @@ - + @@ -269,11 +269,11 @@ - 3.5.2.6 + 3.5.2.47 2024-10-05T10:29:37.2271302+09:00 18 - 4 + 5 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIEelement_Get_ListView_Text.xml b/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIEelement_Get_ListView_Text.xml index d2349c646..66c040fee 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIEelement_Get_ListView_Text.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIEelement_Get_ListView_Text.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,7 +259,7 @@ - + @@ -269,11 +269,11 @@ - 3.5.2.6 + 3.5.2.47 2024-10-05T10:24:54.3059023+09:00 8 - 4 + 6 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIElement.xml new file mode 100644 index 000000000..ff1c27c9c --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_Text_From_Table_UIElement.xml @@ -0,0 +1,297 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_Text_From_UIElement_Get_Button_Text.xml b/taskt/Samples/UIAutomation_Commands/Get_Text_From_UIElement_Get_Button_Text.xml index 325a13e3c..7dab979bc 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_Text_From_UIElement_Get_Button_Text.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_Text_From_UIElement_Get_Button_Text.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,7 +259,7 @@ - + @@ -269,11 +269,11 @@ - 3.5.2.6 + 3.5.2.47 2024-10-05T10:23:58.7629722+09:00 8 - 4 + 5 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Get_Text_From_UIElement_Get_Label_Text.xml b/taskt/Samples/UIAutomation_Commands/Get_Text_From_UIElement_Get_Label_Text.xml index ae650f7df..5692018dd 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_Text_From_UIElement_Get_Label_Text.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_Text_From_UIElement_Get_Label_Text.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,7 +259,7 @@ - + @@ -269,11 +269,11 @@ - 3.5.2.6 + 3.5.2.47 2024-10-05T10:24:36.1781039+09:00 6 - 4 + 5 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Get_Texts_From_Table_UIElement_As_DataTable.xml b/taskt/Samples/UIAutomation_Commands/Get_Texts_From_Table_UIElement_As_DataTable.xml new file mode 100644 index 000000000..78921a36b --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_Texts_From_Table_UIElement_As_DataTable.xml @@ -0,0 +1,304 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_UIElement_From_Table_UIEelement.xml b/taskt/Samples/UIAutomation_Commands/Get_UIElement_From_Table_UIEelement.xml new file mode 100644 index 000000000..cf75a1775 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_UIElement_From_Table_UIEelement.xml @@ -0,0 +1,301 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_UIElement_From_Table_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Get_UIElement_From_Table_UIElement.xml new file mode 100644 index 000000000..7fd898a25 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_UIElement_From_Table_UIElement.xml @@ -0,0 +1,307 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_UIElement_Position.xml b/taskt/Samples/UIAutomation_Commands/Get_UIElement_Position.xml index f45241963..8b0e1dd39 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_UIElement_Position.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_UIElement_Position.xml @@ -8,19 +8,19 @@ - + - + - + @@ -269,11 +269,11 @@ - 3.5.2.7 + 3.5.2.47 2024-10-06T21:08:06.4397375+09:00 7 - 10 + 11 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Get_UIElement_Size.xml b/taskt/Samples/UIAutomation_Commands/Get_UIElement_Size.xml index 99404f7a8..fc044515c 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_UIElement_Size.xml +++ b/taskt/Samples/UIAutomation_Commands/Get_UIElement_Size.xml @@ -8,19 +8,19 @@ - + - + - + @@ -266,11 +266,11 @@ - 3.5.2.7 + 3.5.2.47 2024-10-06T21:11:08.8877531+09:00 6 - 9 + 10 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Get_Window_Handle_From_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Get_Window_Handle_From_UIElement.xml new file mode 100644 index 000000000..532fae94a --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_Window_Handle_From_UIElement.xml @@ -0,0 +1,298 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_Window_Name_From_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Get_Window_Name_From_UIElement.xml new file mode 100644 index 000000000..0abd5109a --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_Window_Name_From_UIElement.xml @@ -0,0 +1,298 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_Window_UIElement_From_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Get_Window_UIElement_From_UIElement.xml new file mode 100644 index 000000000..11606d08b --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_Window_UIElement_From_UIElement.xml @@ -0,0 +1,294 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_Window_UIElement_From_Window_Handle.xml b/taskt/Samples/UIAutomation_Commands/Get_Window_UIElement_From_Window_Handle.xml new file mode 100644 index 000000000..5cfb95ca1 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_Window_UIElement_From_Window_Handle.xml @@ -0,0 +1,58 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_Window_UIElement_From_Window_Name.xml b/taskt/Samples/UIAutomation_Commands/Get_Window_UIElement_From_Window_Name.xml new file mode 100644 index 000000000..2b7f5dfa8 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Get_Window_UIElement_From_Window_Name.xml @@ -0,0 +1,48 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Search_UIElement_From_UIElement_Click_Button.xml b/taskt/Samples/UIAutomation_Commands/Scroll_Percent_UIElement.xml similarity index 83% rename from taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Search_UIElement_From_UIElement_Click_Button.xml rename to taskt/Samples/UIAutomation_Commands/Scroll_Percent_UIElement.xml index b51e0c2fc..934db8761 100644 --- a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Search_UIElement_From_UIElement_Click_Button.xml +++ b/taskt/Samples/UIAutomation_Commands/Scroll_Percent_UIElement.xml @@ -2,25 +2,22 @@ \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Get_Children_Elements_Information.xml b/taskt/Samples/UIAutomation_Commands/Search_Children_UIElements_Information.xml similarity index 91% rename from taskt/Samples/UIAutomation_Commands/Get_Children_Elements_Information.xml rename to taskt/Samples/UIAutomation_Commands/Search_Children_UIElements_Information.xml index a9edd48d7..94a4bc78e 100644 --- a/taskt/Samples/UIAutomation_Commands/Get_Children_Elements_Information.xml +++ b/taskt/Samples/UIAutomation_Commands/Search_Children_UIElements_Information.xml @@ -2,25 +2,25 @@ \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_And_Window_By_XPath_Click_Button.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElement_And_Window_By_XPath_Click_Button.xml index 652bd8aae..192e8361a 100644 --- a/taskt/Samples/UIAutomation_Commands/Search_UIElement_And_Window_By_XPath_Click_Button.xml +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElement_And_Window_By_XPath_Click_Button.xml @@ -8,13 +8,13 @@ - + - + @@ -27,11 +27,11 @@ - 3.5.2.6 + 3.5.2.43 2024-10-03T22:36:38.7553231+09:00 7 - 4 + 5 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_And_Window_Click_Button.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElement_And_Window_Click_Button.xml index f9cb607e6..03fe15966 100644 --- a/taskt/Samples/UIAutomation_Commands/Search_UIElement_And_Window_Click_Button.xml +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElement_And_Window_Click_Button.xml @@ -8,13 +8,13 @@ - + - + @@ -263,11 +263,11 @@ - 3.5.2.6 + 3.5.2.43 2024-10-03T22:35:57.9073638+09:00 6 - 6 + 7 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement.xml new file mode 100644 index 000000000..dc373b15c --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement.xml @@ -0,0 +1,291 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement_By_XPath.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement_By_XPath.xml new file mode 100644 index 000000000..0f03b3fad --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement_By_XPath.xml @@ -0,0 +1,55 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement_By_XPath_Click_Button.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement_By_XPath_Click_Button.xml index 3cb3e590a..bf2a4d17f 100644 --- a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement_By_XPath_Click_Button.xml +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_UIElement_By_XPath_Click_Button.xml @@ -8,38 +8,36 @@ - + - + - - /Button[@AutomationId="button1"] - + - + - 3.5.2.6 + 3.5.2.48 2024-10-03T22:37:40.9871213+09:00 6 - 5 + 7 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Handle.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Handle.xml new file mode 100644 index 000000000..04d371039 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Handle.xml @@ -0,0 +1,284 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Handle_By_XPath.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Handle_By_XPath.xml new file mode 100644 index 000000000..e48c5313b --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Handle_By_XPath.xml @@ -0,0 +1,48 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Name.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Name.xml new file mode 100644 index 000000000..1c428c669 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Name.xml @@ -0,0 +1,277 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Name_By_XPath.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Name_By_XPath.xml new file mode 100644 index 000000000..d0eec2f09 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElement_From_Window_Name_By_XPath.xml @@ -0,0 +1,48 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElements_Information_From_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Information_From_UIElement.xml new file mode 100644 index 000000000..fcf7aaf56 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Information_From_UIElement.xml @@ -0,0 +1,533 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElements_Information_From_Window_Handle.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Information_From_Window_Handle.xml new file mode 100644 index 000000000..511ddc3fc --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Information_From_Window_Handle.xml @@ -0,0 +1,284 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElements_Information_From_Window_Name.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Information_From_Window_Name.xml new file mode 100644 index 000000000..535e0441d --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Information_From_Window_Name.xml @@ -0,0 +1,277 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElements_Tree_XML_From_UIElement.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Tree_XML_From_UIElement.xml new file mode 100644 index 000000000..c55301021 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Tree_XML_From_UIElement.xml @@ -0,0 +1,57 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElements_Tree_XML_From_Window_Handle.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Tree_XML_From_Window_Handle.xml new file mode 100644 index 000000000..7d002a64f --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Tree_XML_From_Window_Handle.xml @@ -0,0 +1,48 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Search_UIElements_Tree_XML_From_Window_Name.xml b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Tree_XML_From_Window_Name.xml new file mode 100644 index 000000000..35facfe3c --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Search_UIElements_Tree_XML_From_Window_Name.xml @@ -0,0 +1,41 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Select_Item_In_UIElement_Select_Combobox_Item.xml b/taskt/Samples/UIAutomation_Commands/Select_Item_In_UIElement_Select_Combobox_Item.xml index 69e671249..bfc6eeba0 100644 --- a/taskt/Samples/UIAutomation_Commands/Select_Item_In_UIElement_Select_Combobox_Item.xml +++ b/taskt/Samples/UIAutomation_Commands/Select_Item_In_UIElement_Select_Combobox_Item.xml @@ -5,19 +5,19 @@ - + - + - + @@ -262,24 +262,21 @@ - + - + - - - - + - 3.5.2.6 + 3.5.2.55 - 2024-10-05T11:29:02.6490142+09:00 - 30 - 3 + 2026-01-18T13:06:55.5979597+09:00 + 31 + 6 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Select_UIElement_Select_Checkbox.xml b/taskt/Samples/UIAutomation_Commands/Select_UIElement_Select_Checkbox.xml index 0f94ff0cb..e0dc7a460 100644 --- a/taskt/Samples/UIAutomation_Commands/Select_UIElement_Select_Checkbox.xml +++ b/taskt/Samples/UIAutomation_Commands/Select_UIElement_Select_Checkbox.xml @@ -8,19 +8,19 @@ - + - + - + @@ -265,7 +265,7 @@ - + @@ -508,11 +508,11 @@ - 3.5.2.6 + 3.5.2.48 2024-10-06T11:03:11.6404798+09:00 11 - 15 + 17 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Set_Selected_State_To_UIElement_Checkbox.xml b/taskt/Samples/UIAutomation_Commands/Set_Selected_State_To_UIElement_Checkbox.xml new file mode 100644 index 000000000..ab1334adc --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/Set_Selected_State_To_UIElement_Checkbox.xml @@ -0,0 +1,296 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/Set_Text_To_UIElement_Set_Combobox_Text.xml b/taskt/Samples/UIAutomation_Commands/Set_Text_To_UIElement_Set_Combobox_Text.xml index 21ae9c6fc..1e07022b8 100644 --- a/taskt/Samples/UIAutomation_Commands/Set_Text_To_UIElement_Set_Combobox_Text.xml +++ b/taskt/Samples/UIAutomation_Commands/Set_Text_To_UIElement_Set_Combobox_Text.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,18 +259,18 @@ - + - 3.5.2.6 + 3.5.2.48 2024-10-05T11:29:34.1375817+09:00 9 - 3 + 4 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/Set_Text_To_UIElement_Set_Textbox_Text.xml b/taskt/Samples/UIAutomation_Commands/Set_Text_To_UIElement_Set_Textbox_Text.xml index cdecc294f..ec89b187f 100644 --- a/taskt/Samples/UIAutomation_Commands/Set_Text_To_UIElement_Set_Textbox_Text.xml +++ b/taskt/Samples/UIAutomation_Commands/Set_Text_To_UIElement_Set_Textbox_Text.xml @@ -5,19 +5,19 @@ - + - + - + @@ -259,18 +259,18 @@ - + - 3.5.2.6 + 3.5.2.48 2024-10-05T11:30:10.6016938+09:00 9 - 4 + 5 0.0.0 diff --git a/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_By_XPath_From_Window_Handle_Click_Button.xml b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_By_XPath_From_Window_Handle_Click_Button.xml new file mode 100644 index 000000000..85b7a31ca --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_By_XPath_From_Window_Handle_Click_Button.xml @@ -0,0 +1,90 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/UIElement_Action_By_XPath_Click_Button.xml b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_By_XPath_From_Window_Name_Click_Button.xml similarity index 84% rename from taskt/Samples/UIAutomation_Commands/UIElement_Action_By_XPath_Click_Button.xml rename to taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_By_XPath_From_Window_Name_Click_Button.xml index 2a3cf2a11..c17144967 100644 --- a/taskt/Samples/UIAutomation_Commands/UIElement_Action_By_XPath_Click_Button.xml +++ b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_By_XPath_From_Window_Name_Click_Button.xml @@ -2,19 +2,19 @@ \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_From_Window_Handle_Click_Button.xml b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_From_Window_Handle_Click_Button.xml new file mode 100644 index 000000000..b11380845 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_From_Window_Handle_Click_Button.xml @@ -0,0 +1,325 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_From_Window_Name.xml b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_From_Window_Name.xml new file mode 100644 index 000000000..6a97e68d6 --- /dev/null +++ b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_From_Window_Name.xml @@ -0,0 +1,41 @@ + + \ No newline at end of file diff --git a/taskt/Samples/UIAutomation_Commands/UIElement_Action_Click_Button.xml b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_From_Window_Name_Click_Button.xml similarity index 95% rename from taskt/Samples/UIAutomation_Commands/UIElement_Action_Click_Button.xml rename to taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_From_Window_Name_Click_Button.xml index 12c29901a..3fee38c21 100644 --- a/taskt/Samples/UIAutomation_Commands/UIElement_Action_Click_Button.xml +++ b/taskt/Samples/UIAutomation_Commands/UIElement_Action_After_Search_UIElement_From_Window_Name_Click_Button.xml @@ -2,20 +2,68 @@ \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Attach_Web_Browser_Instance_Edge.xml b/taskt/Samples/Web_Browser_Commands/Attach_Web_Browser_Instance_Edge.xml new file mode 100644 index 000000000..136048d10 --- /dev/null +++ b/taskt/Samples/Web_Browser_Commands/Attach_Web_Browser_Instance_Edge.xml @@ -0,0 +1,39 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Attach_Web_Browser_Instance_Firefox.xml b/taskt/Samples/Web_Browser_Commands/Attach_Web_Browser_Instance_Firefox.xml new file mode 100644 index 000000000..99be41d56 --- /dev/null +++ b/taskt/Samples/Web_Browser_Commands/Attach_Web_Browser_Instance_Firefox.xml @@ -0,0 +1,39 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Click_WebElement.xml b/taskt/Samples/Web_Browser_Commands/Click_WebElement.xml new file mode 100644 index 000000000..ca6d8f796 --- /dev/null +++ b/taskt/Samples/Web_Browser_Commands/Click_WebElement.xml @@ -0,0 +1,60 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Click_WebElement_Right_Click.xml b/taskt/Samples/Web_Browser_Commands/Click_WebElement_Right_Click.xml new file mode 100644 index 000000000..574d36ad9 --- /dev/null +++ b/taskt/Samples/Web_Browser_Commands/Click_WebElement_Right_Click.xml @@ -0,0 +1,60 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Execute_Script_Code.xml b/taskt/Samples/Web_Browser_Commands/Execute_JavaScript_From_Code.xml similarity index 71% rename from taskt/Samples/Web_Browser_Commands/Execute_Script_Code.xml rename to taskt/Samples/Web_Browser_Commands/Execute_JavaScript_From_Code.xml index 944a5d41b..0e819daef 100644 --- a/taskt/Samples/Web_Browser_Commands/Execute_Script_Code.xml +++ b/taskt/Samples/Web_Browser_Commands/Execute_JavaScript_From_Code.xml @@ -2,25 +2,25 @@ \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Execute_Script_File.xml b/taskt/Samples/Web_Browser_Commands/Execute_JavaScript_From_File.xml similarity index 71% rename from taskt/Samples/Web_Browser_Commands/Execute_Script_File.xml rename to taskt/Samples/Web_Browser_Commands/Execute_JavaScript_From_File.xml index 6aea7c7eb..d9d8f5eb6 100644 --- a/taskt/Samples/Web_Browser_Commands/Execute_Script_File.xml +++ b/taskt/Samples/Web_Browser_Commands/Execute_JavaScript_From_File.xml @@ -2,25 +2,25 @@ \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Get_Table_Value_As_DataTable.xml b/taskt/Samples/Web_Browser_Commands/Get_Table_Values_As_DataTable.xml similarity index 74% rename from taskt/Samples/Web_Browser_Commands/Get_Table_Value_As_DataTable.xml rename to taskt/Samples/Web_Browser_Commands/Get_Table_Values_As_DataTable.xml index 129ba1e03..ad9a43c58 100644 --- a/taskt/Samples/Web_Browser_Commands/Get_Table_Value_As_DataTable.xml +++ b/taskt/Samples/Web_Browser_Commands/Get_Table_Values_As_DataTable.xml @@ -2,25 +2,25 @@ \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Information.xml b/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Information.xml index feee1fae3..1c58f766d 100644 --- a/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Information.xml +++ b/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Information.xml @@ -8,45 +8,39 @@ - + - + - + - + - + - + - - - - - - - + - 3.5.2.10 + 3.5.2.61 2024-10-13T18:56:48.7031393+09:00 3 - 7 + 9 0.0.0 @@ -59,9 +53,5 @@ vURL - - vSource - - \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Position.xml b/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Position.xml new file mode 100644 index 000000000..c789c3435 --- /dev/null +++ b/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Position.xml @@ -0,0 +1,57 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Size.xml b/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Size.xml new file mode 100644 index 000000000..4e95f0f7f --- /dev/null +++ b/taskt/Samples/Web_Browser_Commands/Get_Web_Browser_Size.xml @@ -0,0 +1,57 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_Handles_As_JSON.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Handles_As_JSON.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_Handles_As_JSON.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Handles_As_JSON.xml diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_Handles_As_List.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Handles_As_List.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_Handles_As_List.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Handles_As_List.xml diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_Informations_As_DataTable.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Informations_As_DataTable.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_Informations_As_DataTable.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Informations_As_DataTable.xml diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_Informations_As_JSON.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Informations_As_JSON.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_Informations_As_JSON.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Informations_As_JSON.xml diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_Titles_As_Dictionary.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Titles_As_Dictionary.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_Titles_As_Dictionary.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Titles_As_Dictionary.xml diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_Titles_As_JSON.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Titles_As_JSON.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_Titles_As_JSON.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Titles_As_JSON.xml diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_Titles_As_List.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Titles_As_List.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_Titles_As_List.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_Titles_As_List.xml diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_URLs_As_Dictionary.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_URLs_As_Dictionary.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_URLs_As_Dictionary.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_URLs_As_Dictionary.xml diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_URLs_As_JSON.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_URLs_As_JSON.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_URLs_As_JSON.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_URLs_As_JSON.xml diff --git a/taskt/Samples/Web_Browser_Commands/Get_Window_And_URLs_As_List.xml b/taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_URLs_As_List.xml similarity index 100% rename from taskt/Samples/Web_Browser_Commands/Get_Window_And_URLs_As_List.xml rename to taskt/Samples/Web_Browser_Commands/Get_Window_And_Tab_URLs_As_List.xml diff --git a/taskt/Samples/Web_Browser_Commands/Refresh.xml b/taskt/Samples/Web_Browser_Commands/Refresh_Web_Browser.xml similarity index 77% rename from taskt/Samples/Web_Browser_Commands/Refresh.xml rename to taskt/Samples/Web_Browser_Commands/Refresh_Web_Browser.xml index 54aaa6451..deb8b0fa9 100644 --- a/taskt/Samples/Web_Browser_Commands/Refresh.xml +++ b/taskt/Samples/Web_Browser_Commands/Refresh_Web_Browser.xml @@ -2,13 +2,13 @@ \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Check_Window_Name_Exists.xml b/taskt/Samples/Window_Commands/Check_Window_Name_Exists.xml index c648b7b56..f79eae41d 100644 --- a/taskt/Samples/Window_Commands/Check_Window_Name_Exists.xml +++ b/taskt/Samples/Window_Commands/Check_Window_Name_Exists.xml @@ -8,13 +8,13 @@ - + - + @@ -23,18 +23,18 @@ - + - 3.5.2.4 + 3.5.2.43 2024-09-22T09:54:53.228269+09:00 7 - 17 + 18 0.0.0 diff --git a/taskt/Samples/Window_Commands/Close_Window.xml b/taskt/Samples/Window_Commands/Close_One_Window.xml similarity index 73% rename from taskt/Samples/Window_Commands/Close_Window.xml rename to taskt/Samples/Window_Commands/Close_One_Window.xml index d0675d7e3..644e529e3 100644 --- a/taskt/Samples/Window_Commands/Close_Window.xml +++ b/taskt/Samples/Window_Commands/Close_One_Window.xml @@ -2,19 +2,19 @@ \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_One_Process_Name_From_One_Window_Name.xml b/taskt/Samples/Window_Commands/Get_One_Process_Name_From_One_Window_Name.xml new file mode 100644 index 000000000..439c0f543 --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_One_Process_Name_From_One_Window_Name.xml @@ -0,0 +1,41 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_One_Window_Handle_From_One_Window_Name.xml b/taskt/Samples/Window_Commands/Get_One_Window_Handle_From_One_Window_Name.xml new file mode 100644 index 000000000..5f0536456 --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_One_Window_Handle_From_One_Window_Name.xml @@ -0,0 +1,41 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Window_Position.xml b/taskt/Samples/Window_Commands/Get_One_Window_Position.xml similarity index 72% rename from taskt/Samples/Window_Commands/Get_Window_Position.xml rename to taskt/Samples/Window_Commands/Get_One_Window_Position.xml index 87147f14b..47337524e 100644 --- a/taskt/Samples/Window_Commands/Get_Window_Position.xml +++ b/taskt/Samples/Window_Commands/Get_One_Window_Position.xml @@ -2,19 +2,19 @@ \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Windowe_State.xml b/taskt/Samples/Window_Commands/Get_One_Window_State.xml similarity index 67% rename from taskt/Samples/Window_Commands/Get_Windowe_State.xml rename to taskt/Samples/Window_Commands/Get_One_Window_State.xml index ba3038b70..4ef0ccb83 100644 --- a/taskt/Samples/Window_Commands/Get_Windowe_State.xml +++ b/taskt/Samples/Window_Commands/Get_One_Window_State.xml @@ -2,22 +2,22 @@ \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Process_Name_From_Window_Name.xml b/taskt/Samples/Window_Commands/Get_Process_Name_From_Window_Name.xml deleted file mode 100644 index bab806fbe..000000000 --- a/taskt/Samples/Window_Commands/Get_Process_Name_From_Window_Name.xml +++ /dev/null @@ -1,47 +0,0 @@ - - \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Process_Names_From_Window_Names_As_DataTable.xml b/taskt/Samples/Window_Commands/Get_Process_Names_From_Window_Names_As_DataTable.xml new file mode 100644 index 000000000..6afc52713 --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_Process_Names_From_Window_Names_As_DataTable.xml @@ -0,0 +1,51 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Process_Names_From_Window_Names_As_List.xml b/taskt/Samples/Window_Commands/Get_Process_Names_From_Window_Names_As_List.xml new file mode 100644 index 000000000..6744aa5fe --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_Process_Names_From_Window_Names_As_List.xml @@ -0,0 +1,51 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Window_Handle_From_Window_Name.xml b/taskt/Samples/Window_Commands/Get_Window_Handle_From_Window_Name.xml index 3947b9045..cc14d1c55 100644 --- a/taskt/Samples/Window_Commands/Get_Window_Handle_From_Window_Name.xml +++ b/taskt/Samples/Window_Commands/Get_Window_Handle_From_Window_Name.xml @@ -8,13 +8,13 @@ - + - + @@ -30,11 +30,11 @@ - 3.5.2.4 + 3.5.2.43 2024-09-21T21:58:01.1352629+09:00 5 - 13 + 14 0.0.0 diff --git a/taskt/Samples/Window_Commands/Get_Window_Handles_From_Window_Names_As_List.xml b/taskt/Samples/Window_Commands/Get_Window_Handles_From_Window_Names_As_List.xml new file mode 100644 index 000000000..16da49e03 --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_Window_Handles_From_Window_Names_As_List.xml @@ -0,0 +1,51 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Window_Name_From_Window_Handle.xml b/taskt/Samples/Window_Commands/Get_Window_Name_From_Window_Handle.xml index 7a8f47f6c..6e753c4e4 100644 --- a/taskt/Samples/Window_Commands/Get_Window_Name_From_Window_Handle.xml +++ b/taskt/Samples/Window_Commands/Get_Window_Name_From_Window_Handle.xml @@ -8,7 +8,7 @@ - + @@ -27,11 +27,11 @@ - 3.5.2.4 + 3.5.2.43 2024-09-22T15:22:27.5296629+09:00 5 - 8 + 9 0.0.0 diff --git a/taskt/Samples/Window_Commands/Get_Window_Names.xml b/taskt/Samples/Window_Commands/Get_Window_Names.xml index 2c01f2106..236dbd7bf 100644 --- a/taskt/Samples/Window_Commands/Get_Window_Names.xml +++ b/taskt/Samples/Window_Commands/Get_Window_Names.xml @@ -8,16 +8,16 @@ - + - + - + @@ -30,11 +30,11 @@ - 3.5.2.4 + 3.5.2.43 2024-09-22T10:03:11.5079685+09:00 2 - 4 + 5 0.0.0 diff --git a/taskt/Samples/Window_Commands/Get_Window_Names_Get_All_Window_Names.xml b/taskt/Samples/Window_Commands/Get_Window_Names_Get_All_Window_Names.xml index 35f0b0208..a13e59e69 100644 --- a/taskt/Samples/Window_Commands/Get_Window_Names_Get_All_Window_Names.xml +++ b/taskt/Samples/Window_Commands/Get_Window_Names_Get_All_Window_Names.xml @@ -8,19 +8,19 @@ - + - + - + - + @@ -33,11 +33,11 @@ - 3.5.2.4 + 3.5.2.43 2024-09-22T09:59:25.1846391+09:00 1 - 3 + 4 0.0.0 diff --git a/taskt/Samples/Window_Commands/Get_Window_Posision_From_Window_Handle.xml b/taskt/Samples/Window_Commands/Get_Window_Position_From_Window_Handle.xml similarity index 94% rename from taskt/Samples/Window_Commands/Get_Window_Posision_From_Window_Handle.xml rename to taskt/Samples/Window_Commands/Get_Window_Position_From_Window_Handle.xml index c8e3640f8..9979d549f 100644 --- a/taskt/Samples/Window_Commands/Get_Window_Posision_From_Window_Handle.xml +++ b/taskt/Samples/Window_Commands/Get_Window_Position_From_Window_Handle.xml @@ -8,7 +8,7 @@ - + @@ -39,11 +39,11 @@ - 3.5.2.4 + 3.5.2.43 2024-09-22T15:28:27.6472879+09:00 5 - 9 + 10 0.0.0 diff --git a/taskt/Samples/Window_Commands/Get_Window_Positions_From_Window_Names_As_DataTable.xml b/taskt/Samples/Window_Commands/Get_Window_Positions_From_Window_Names_As_DataTable.xml new file mode 100644 index 000000000..f6589b9a0 --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_Window_Positions_From_Window_Names_As_DataTable.xml @@ -0,0 +1,57 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Window_Positions_From_Window_Names_As_List.xml b/taskt/Samples/Window_Commands/Get_Window_Positions_From_Window_Names_As_List.xml new file mode 100644 index 000000000..d8e519022 --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_Window_Positions_From_Window_Names_As_List.xml @@ -0,0 +1,67 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Window_Size.xml b/taskt/Samples/Window_Commands/Get_Window_Size.xml index adf8f201b..b18a7db2c 100644 --- a/taskt/Samples/Window_Commands/Get_Window_Size.xml +++ b/taskt/Samples/Window_Commands/Get_Window_Size.xml @@ -2,19 +2,19 @@ \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Window_Sizes_From_Window_Names_As_List.xml b/taskt/Samples/Window_Commands/Get_Window_Sizes_From_Window_Names_As_List.xml new file mode 100644 index 000000000..e6a4e882f --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_Window_Sizes_From_Window_Names_As_List.xml @@ -0,0 +1,67 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Window_State_From_Window_Handle.xml b/taskt/Samples/Window_Commands/Get_Window_State_From_Window_Handle.xml index bed7b8f70..c0660cecc 100644 --- a/taskt/Samples/Window_Commands/Get_Window_State_From_Window_Handle.xml +++ b/taskt/Samples/Window_Commands/Get_Window_State_From_Window_Handle.xml @@ -8,7 +8,7 @@ - + @@ -17,10 +17,10 @@ - + - + @@ -32,10 +32,10 @@ - + - + @@ -48,11 +48,11 @@ - 3.5.2.4 + 3.5.2.40 - 2024-09-22T15:54:04.8264685+09:00 - 6 - 10 + 2025-09-14T10:33:38.8682757+09:00 + 7 + 12 0.0.0 @@ -65,5 +65,9 @@ vState + + vStateText + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Window_States_From_Window_Names_As_DataTable.xml b/taskt/Samples/Window_Commands/Get_Window_States_From_Window_Names_As_DataTable.xml new file mode 100644 index 000000000..8ea8ea12f --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_Window_States_From_Window_Names_As_DataTable.xml @@ -0,0 +1,57 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Get_Window_States_From_Window_Names_As_List.xml b/taskt/Samples/Window_Commands/Get_Window_States_From_Window_Names_As_List.xml new file mode 100644 index 000000000..f39a45bee --- /dev/null +++ b/taskt/Samples/Window_Commands/Get_Window_States_From_Window_Names_As_List.xml @@ -0,0 +1,67 @@ + + \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Move_Window.xml b/taskt/Samples/Window_Commands/Move_One_Window.xml similarity index 63% rename from taskt/Samples/Window_Commands/Move_Window.xml rename to taskt/Samples/Window_Commands/Move_One_Window.xml index 983440502..0f2815abd 100644 --- a/taskt/Samples/Window_Commands/Move_Window.xml +++ b/taskt/Samples/Window_Commands/Move_One_Window.xml @@ -2,19 +2,19 @@ \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Resize_Window.xml b/taskt/Samples/Window_Commands/Resize_One_Window.xml similarity index 63% rename from taskt/Samples/Window_Commands/Resize_Window.xml rename to taskt/Samples/Window_Commands/Resize_One_Window.xml index 250ec3a47..a792eb7c9 100644 --- a/taskt/Samples/Window_Commands/Resize_Window.xml +++ b/taskt/Samples/Window_Commands/Resize_One_Window.xml @@ -2,19 +2,19 @@ \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Set_Window_State.xml b/taskt/Samples/Window_Commands/Set_One_Window_State.xml similarity index 61% rename from taskt/Samples/Window_Commands/Set_Window_State.xml rename to taskt/Samples/Window_Commands/Set_One_Window_State.xml index 93403fe51..6ea4bff72 100644 --- a/taskt/Samples/Window_Commands/Set_Window_State.xml +++ b/taskt/Samples/Window_Commands/Set_One_Window_State.xml @@ -2,19 +2,19 @@ \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Wait_For_Window_Exists.xml b/taskt/Samples/Window_Commands/Wait_For_Window_Exists.xml deleted file mode 100644 index 5da3c883e..000000000 --- a/taskt/Samples/Window_Commands/Wait_For_Window_Exists.xml +++ /dev/null @@ -1,47 +0,0 @@ - - \ No newline at end of file diff --git a/taskt/Samples/Window_Commands/Wait_For_Window_To_Exists.xml b/taskt/Samples/Window_Commands/Wait_For_Window_To_Exists.xml index 3e1ec1501..8c8a63fcf 100644 --- a/taskt/Samples/Window_Commands/Wait_For_Window_To_Exists.xml +++ b/taskt/Samples/Window_Commands/Wait_For_Window_To_Exists.xml @@ -2,32 +2,36 @@