コード例 #1
0
 protected void OnClick0(EventArgs e)
 {
     if (IsRunMode)
     {
         if (!string.IsNullOrEmpty(_keysToSend))
         {
             KeyPair kp = null;
             if (_keyPairList != null && _keyPairList.Count > 0)
             {
                 kp = _keyPairList.GetCombinedKey();                        //get key-pair based on keyboard recording
                 if (kp != null)
                 {
                     int len = kp.PreviousKey.Length;                             //key-companiation
                     //remove the key-combination and then send the result keys
                     string s = "{BS " + len.ToString(System.Globalization.CultureInfo.InvariantCulture) + "}" + kp.Value;
                     System.Windows.Forms.SendKeys.Send(s);
                     //replace used key-companiation with the result keys
                     KeyPairList.ReplaceKey(len, kp.Value);
                     KeyPairList.PushKeyBuffer(_keysToSend);
                 }
             }
             if (kp == null)
             {
                 System.Windows.Forms.SendKeys.Send(_keysToSend);
                 //record keyboard
                 if (string.Compare(_keysToSend, "{BACKSPACE}", StringComparison.OrdinalIgnoreCase) == 0 ||
                     string.Compare(_keysToSend, "{BS}", StringComparison.OrdinalIgnoreCase) == 0 ||
                     string.Compare(_keysToSend, "{BKSP}", StringComparison.OrdinalIgnoreCase) == 0)
                 {
                     KeyPairList.PopKeyBuffer();
                 }
                 else if (string.Compare(_keysToSend, "{DELETE}", StringComparison.OrdinalIgnoreCase) == 0 ||
                          string.Compare(_keysToSend, "{DEL}", StringComparison.OrdinalIgnoreCase) == 0)
                 {
                 }
                 else if (_keysToSend.StartsWith("{", StringComparison.OrdinalIgnoreCase))
                 {
                 }
                 else
                 {
                     KeyPairList.PushKey(_keysToSend);
                 }
             }
         }
     }
     base.OnClick(e);
 }