public override void RunCommand(object sender) { var engine = (AutomationEngineInstance)sender; if (v_WindowName != "Current Window") { ActivateWindowCommand activateWindow = new ActivateWindowCommand { v_WindowName = v_WindowName }; activateWindow.RunCommand(sender); } string textToSend = v_TextToSend.ConvertUserVariableToString(engine); if (v_EncryptionOption == "Encrypted") { textToSend = EncryptionServices.DecryptString(textToSend, "TASKT"); } if (textToSend == "{WIN_KEY}") { User32Functions.KeyDown(System.Windows.Forms.Keys.LWin); User32Functions.KeyUp(System.Windows.Forms.Keys.LWin); } else if (textToSend.Contains("{WIN_KEY+")) { User32Functions.KeyDown(System.Windows.Forms.Keys.LWin); var remainingText = textToSend.Replace("{WIN_KEY+", "").Replace("}", ""); foreach (var c in remainingText) { System.Windows.Forms.Keys key = (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), c.ToString()); User32Functions.KeyDown(key); } User32Functions.KeyUp(System.Windows.Forms.Keys.LWin); foreach (var c in remainingText) { System.Windows.Forms.Keys key = (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), c.ToString()); User32Functions.KeyUp(key); } } else { System.Windows.Forms.SendKeys.SendWait(textToSend); } System.Threading.Thread.Sleep(500); }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var variableWindowName = v_WindowName.ConvertUserVariableToString(engine); if (variableWindowName != "Current Window") { User32Functions.ActivateWindow(variableWindowName); } string textToSend = v_TextToSend.ConvertUserVariableToString(engine); if (v_EncryptionOption == "Encrypted") { textToSend = EncryptionServices.DecryptString(textToSend, "OPENBOTS"); } if (textToSend == "{WIN_KEY}") { User32Functions.KeyDown(Keys.LWin); User32Functions.KeyUp(Keys.LWin); } else if (textToSend.Contains("{WIN_KEY+")) { User32Functions.KeyDown(Keys.LWin); var remainingText = textToSend.Replace("{WIN_KEY+", "").Replace("}", ""); foreach (var c in remainingText) { Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); User32Functions.KeyDown(key); } User32Functions.KeyUp(Keys.LWin); foreach (var c in remainingText) { Keys key = (Keys)Enum.Parse(typeof(Keys), c.ToString()); User32Functions.KeyUp(key); } } else { SendKeys.SendWait(textToSend); } Thread.Sleep(500); }
public override void RunCommand(object sender) { if (v_WindowName != "Current Window") { ActivateWindowCommand activateWindow = new ActivateWindowCommand { v_WindowName = v_WindowName }; activateWindow.RunCommand(sender); } string textToSend = v_TextToSend.ConvertToUserVariable(sender); if (textToSend == "{WIN_KEY}") { User32Functions.KeyDown(System.Windows.Forms.Keys.LWin); User32Functions.KeyUp(System.Windows.Forms.Keys.LWin); } else if (textToSend.Contains("{WIN_KEY+")) { User32Functions.KeyDown(System.Windows.Forms.Keys.LWin); var remainingText = textToSend.Replace("{WIN_KEY+", "").Replace("}", ""); foreach (var c in remainingText) { System.Windows.Forms.Keys key = (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), c.ToString()); User32Functions.KeyDown(key); } User32Functions.KeyUp(System.Windows.Forms.Keys.LWin); foreach (var c in remainingText) { System.Windows.Forms.Keys key = (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), c.ToString()); User32Functions.KeyUp(key); } } else { System.Windows.Forms.SendKeys.SendWait(textToSend); } System.Threading.Thread.Sleep(500); }
public override void RunCommand(object sender) { //activate anything except current window if (v_WindowName != "Current Window") { ActivateWindowCommand_cn activateWindow = new ActivateWindowCommand_cn { v_WindowName = v_WindowName }; activateWindow.RunCommand(sender); } //track all keys down var keysDown = new List <System.Windows.Forms.Keys>(); //run each selected item foreach (DataRow rw in v_KeyActions.Rows) { //get key name var keyName = rw.Field <string>("Key"); //get key action var action = rw.Field <string>("Action"); //parse OEM key name string oemKeyString = keyName.Split('[', ']')[1]; var oemKeyName = (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), oemKeyString); //"Key Press (Down + Up)", "Key Down", "Key Up" switch (action) { case "Key Press (Down + Up)": //simulate press User32Functions.KeyDown(oemKeyName); User32Functions.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 User32Functions.KeyDown(oemKeyName); //track via keys down list if (!keysDown.Contains(oemKeyName)) { keysDown.Add(oemKeyName); } break; case "Key Up": //simulate up User32Functions.KeyUp(oemKeyName); //remove from key down if (keysDown.Contains(oemKeyName)) { keysDown.Remove(oemKeyName); } break; default: break; } } //return key to up position if requested if (v_KeyUpDefault.ConvertToUserVariable(sender) == "Yes") { foreach (var key in keysDown) { User32Functions.KeyUp(key); } } }
public async override Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; var variableWindowName = (string)await v_WindowName.EvaluateCode(engine); //activate anything except current window if (variableWindowName != "Current Window") { User32Functions.ActivateWindow(variableWindowName); } //track all keys down var keysDown = new List <Keys>(); //run each selected item foreach (DataRow rw in v_KeyActions.Rows) { //get key name var keyName = rw.Field <string>("Key"); //get key action var action = rw.Field <string>("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 User32Functions.KeyDown(oemKeyName); User32Functions.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 User32Functions.KeyDown(oemKeyName); //track via keys down list if (!keysDown.Contains(oemKeyName)) { keysDown.Add(oemKeyName); } break; case "Key Up": //simulate up User32Functions.KeyUp(oemKeyName); //remove from key down if (keysDown.Contains(oemKeyName)) { keysDown.Remove(oemKeyName); } break; default: break; } } //return key to up position if requested if (v_KeyUpDefault == "Yes") { foreach (var key in keysDown) { User32Functions.KeyUp(key); } } }