コード例 #1
0
ファイル: MainForm.cs プロジェクト: sdetoni/AutoType
        private void StartTimer_Tick(object sender, EventArgs e)
        {
            ProgTimer.Stop();
            StartTimer.Stop();

            this.Text = mTitle + ": Typing now...";

            // Load text into memory
            if (this.mIsClipboardAction)
            {
                mTextToSend = Clipboard.GetText(TextDataFormat.UnicodeText);
            }
            else
            {
                mTextToSend = TextBuffer.Text;
            }

            // remove unwanted chars and set start typing pos
            mTextToSend    = mTextToSend.Replace("\r", "");
            mTextToSendIdx = 0;

            // Set progress bar output
            ProgBar.Value   = 0;
            ProgBar.Minimum = 0;
            ProgBar.Maximum = mTextToSend.Length;

            // Start send of the text
            mStartTextSend    = true;
            TxtTimer.Interval = (int)DelayCharsSendNum.Value;
            TxtTimer.Start();
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: sdetoni/AutoType
        private void TxtTimer_Tick(object sender, EventArgs e)
        {
            mTextToSendIdx++;

            // If at the end of the text send stage ... clean up
            if ((!mStartTextSend) || (mTextToSendIdx > mTextToSend.Length))
            {
                this.Text      = mTitle;
                mStartTextSend = false;
                TxtTimer.Stop();

                // if action from double click on system tray, then reset window sizing ...
                if (mIsDoubleClickAction)
                {
                    Visible = false;
                    mIsDoubleClickAction = false;
                    Size s = this.MinimumSize;
                    s.Height         = mSavedWinHeight;
                    this.MinimumSize = s;
                    this.Height      = s.Height;
                    this.AutoSize    = false;
                }
                return;
            }

            // (+), caret(^), percent sign(%), tilde(~), and parentheses() { }
            Char[] specChar = new Char[8] {
                '{', '}', '+', '^', '%', '~', '(', ')'
            };

            if (TurboTypeChk.Checked)
            {
                String newSendString = "";
                for (int sci = 0; sci < mTextToSend.Length; sci++)
                {
                    bool matched = false;
                    for (int idx = 0; idx < specChar.Length; idx++)
                    {
                        if (mTextToSend[sci] == specChar[idx])
                        {
                            newSendString += "{" + mTextToSend[sci] + "}";
                            matched        = true;
                            break;
                        }
                    }
                    if (!matched)
                    {
                        newSendString += mTextToSend[sci];
                    }
                }

                SendKeys.Send(newSendString);
                mTextToSendIdx = mTextToSend.Length;
            }
            else
            {
                String sendString = "";
                for (int idx = 0; idx < specChar.Length; idx++)
                {
                    if (mTextToSend[mTextToSendIdx - 1] == specChar[idx])
                    {
                        sendString = "{" + mTextToSend[mTextToSendIdx - 1] + "}";
                        break;
                    }
                }
                if (sendString == "")
                {
                    sendString = mTextToSend[mTextToSendIdx - 1].ToString();
                }

                SendKeys.Send(sendString);

                // Update the progress bar
                ProgBar.Value = ProgBar.Value + 1;

                // this hack makes it display quicker! So it show real representation of progress.
                if (ProgBar.Value > 0)
                {
                    ProgBar.Value = ProgBar.Value - 1;
                    ProgBar.Value = ProgBar.Value + 1;
                }
            }
        }