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 = (AutomationEngineInstance)sender;

            //activate anything except current window
            if (v_WindowName != "Current Window")
            {
                ActivateWindowCommand activateWindow = new ActivateWindowCommand
                {
                    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.ConvertUserVariableToString(engine) == "Yes")
            {
                foreach (var key in keysDown)
                {
                    User32Functions.KeyUp(key);
                }
            }
        }