/// <summary>
        /// Sends the specified string to the application as keystrokes.
        /// </summary>
        /// <returns></returns>
        public OpResult Execute(string param)
        {
            OpResult opResult = new OpResult();
            ushort key = 0;
            try
            {
                param = param.ToUpper();
                foreach (char c in param.ToCharArray(0, param.Length))
                {
                    key = (ushort)NativeMethods.VkKeyScan(c);
                    bool shift = ((NativeMethods.VkKeyScan(c) & 0x0100) > 0);

                    SendKeyCmd skc = new SendKeyCmd(key, shift, false, false);
                    opResult = skc.Execute("");
                    if (debug)
                    {
                        MsgBoxCmd mbc = new MsgBoxCmd();
                        string s = String.Format("\"Just sent a character!\" \"Character sent: '{0}', vk: {1}\" 1", c, key);
                        mbc.Execute(s);
                    }
                    if (opResult.StatusCode != OpStatusCode.Success) break;
                }
                if (debug)
                {
                    MsgBoxCmd mbc = new MsgBoxCmd();
                    mbc.Execute("\"Length: " + param.Length + "\" \"Sent: '" + param + "'\" 5");
                }
            }
            catch (Exception ex)
            {
                opResult.StatusCode = OpStatusCode.Exception;
                opResult.StatusText = ex.Message;
            }
            return opResult;
        }
Exemple #2
0
        /// <summary>
        /// Sends the specified string to the application as keystrokes.
        /// </summary>
        /// <returns></returns>
        public OpResult Execute(string param)
        {
            OpResult opResult = new OpResult();
            ushort   key      = 0;

            try
            {
                param = param.ToUpper();
                foreach (char c in param.ToCharArray(0, param.Length))
                {
                    key = (ushort)NativeMethods.VkKeyScan(c);
                    bool shift = ((NativeMethods.VkKeyScan(c) & 0x0100) > 0);

                    SendKeyCmd skc = new SendKeyCmd(key, shift, false, false);
                    opResult = skc.Execute("");
                    if (debug)
                    {
                        MsgBoxCmd mbc = new MsgBoxCmd();
                        string    s   = String.Format("\"Just sent a character!\" \"Character sent: '{0}', vk: {1}\" 1", c, key);
                        mbc.Execute(s);
                    }
                    if (opResult.StatusCode != OpStatusCode.Success)
                    {
                        break;
                    }
                }
                if (debug)
                {
                    MsgBoxCmd mbc = new MsgBoxCmd();
                    mbc.Execute("\"Length: " + param.Length + "\" \"Sent: '" + param + "'\" 5");
                }
            }
            catch (Exception ex)
            {
                opResult.StatusCode = OpStatusCode.Exception;
                opResult.StatusText = ex.Message;
            }
            return(opResult);
        }