Exemple #1
0
 private void KeyboardHook_KeyboardActionReleased(object sender, KeyEventArgs e)
 {
     if (!ev_Stop)
     {
         if (ev_delta != -1)
         {
             ev_delta = (DateTime.Now - ev_lastTime).TotalMilliseconds;
             if (ev_delta < Settings.KeyboardReleaseTimeout)
                 return;
         }
         else
             ev_delta = 0;
         ev_lastTime = DateTime.Now;
         WinEvent we = new WinEvent(e, ev_delta, WinEvent.ArgsEventType.Released);
         events.Add(we);
         listBox1.Items.Add(we.ToString());
         UpdateStatusStrip();
     }
 }
Exemple #2
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         events.Clear();
         listBox1.Items.Clear();
         string str = File.ReadAllText(openFileDialog1.FileName);
         string[] strev = str.Split('\n');
         for (int i = 0; i < strev.Length; i++)
         {
             if (strev[i] != String.Empty)
             {
                 string[] ev = strev[i].Split(';');
                 if (ev.Length != 3 && ev.Length != 4)
                     continue;
                 bool mouse = false;
                 string evtype = String.Empty;
                 Point evloc = new Point();
                 string evtype2 = String.Empty;
                 string evdelta = String.Empty;
                 try
                 {
                     if (Configurator.GetPropertyNameFromString(ev[0]) == "Mouse")
                     {
                         mouse = true;
                         evtype = Configurator.GetPropertyValueFromString(ev[0]);
                         string[] point = Configurator.GetPropertyValueFromString(ev[1]).Replace("{X=", "").Replace("Y=", "").Replace("}", "").Split(',');
                         evloc = new Point(int.Parse(point[0]), int.Parse(point[1]));
                         evtype2 = Configurator.GetPropertyValueFromString(ev[2]);
                         evdelta = Configurator.GetPropertyValueFromString(ev[3]);
                     }
                     else
                     {
                         if (Configurator.GetPropertyNameFromString(ev[0]) == "Keyboard")
                         {
                             evtype = Configurator.GetPropertyValueFromString(ev[0]);
                             evtype2 = Configurator.GetPropertyValueFromString(ev[1]);
                             evdelta = Configurator.GetPropertyValueFromString(ev[2]);
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     continue;
                 }
                 if (evtype != String.Empty && evtype2 != String.Empty && evdelta != String.Empty)
                 {
                     try
                     {
                         if (mouse)
                         {
                             if (Configurator.GetPropertyValueFromString(ev[0]) != "Move")
                             {
                                 WinEvent we = new WinEvent(
                                     new MouseEventArgs((MouseButtons)Enum.Parse(typeof(MouseButtons), Configurator.GetPropertyValueFromString(ev[0])),
                                         1, evloc.X, evloc.Y, 0),
                                     Convert.ToDouble(evdelta),
                                     (WinEvent.ArgsEventType)Enum.Parse(typeof(WinEvent.ArgsEventType), evtype2)
                                     );
                                 events.Add(we);
                                 listBox1.Items.Add(we.ToString());
                             }
                             else
                             {
                                 WinEvent we = new WinEvent(
                                     new MouseEventArgs(System.Windows.Forms.MouseButtons.None, 0, evloc.X, evloc.Y, 0),
                                     Convert.ToDouble(evdelta),
                                     (WinEvent.ArgsEventType)Enum.Parse(typeof(WinEvent.ArgsEventType), evtype2)
                                     );
                                 events.Add(we);
                                 listBox1.Items.Add(we.ToString());
                             }
                         }
                         else
                         {
                             WinEvent we = new WinEvent(
                                     new KeyEventArgs((Keys)Enum.Parse(typeof(Keys), Configurator.GetPropertyValueFromString(ev[0]))),
                                     Convert.ToDouble(evdelta),
                                     (WinEvent.ArgsEventType)Enum.Parse(typeof(WinEvent.ArgsEventType), evtype2)
                                     );
                             events.Add(we);
                             listBox1.Items.Add(we.ToString());
                         }
                     }
                     catch (Exception ex)
                     {
                         continue;
                     }
                 }
             }
         }
         UpdateStatusStrip();
     }
 }
Exemple #3
0
        private void MouseHook_MouseActionMoved(object sender, MouseEventArgs e)
        {
            if (!ev_Stop)
            {
                if (ev_delta != -1)
                {
                    ev_delta = (DateTime.Now - ev_lastTime).TotalMilliseconds;
                    if (ev_delta < Settings.MouseMoveTimeout)
                        return;
                }
                else
                    ev_delta = 0;

                ev_lastTime = DateTime.Now;
                WinEvent we = new WinEvent(e, ev_delta, WinEvent.ArgsEventType.None);
                events.Add(we);
                listBox1.Items.Add(we.ToString());
                UpdateStatusStrip();
            }
        }