Ejemplo n.º 1
0
 void gkh_KeyUp(object sender, KeyEventArgs e)
 {
     if (!Form1.running)
     {
         if (Form1.recording)
         {
             PressedKeyEvent keyInfo = getLastOccurance(Form1.writingChars, (byte)e.KeyValue);
             if (keyInfo != null)
             {
                 keyInfo.duration = Form1.sw.ElapsedMilliseconds - keyInfo.startTime;
             }
         }
         else//To start the macro
         {
             // check if we need to handle the print screen in taking image
             if (e.KeyCode == Keys.PrintScreen && TextDialog.isInScreenshot && !TextDialog.takingScreenshot)
             {
                 TextDialog.takePic();
             }
             else
             {
                 string currentProgram = GetFocusedProcessName();
                 if (!currentProgram.Equals("RecordNplay"))
                 {
                     if (isCombination(0) && Form1.writingChars != null)
                     {
                         new Thread(() =>
                         {
                             form1.runMacro(Form1.writingChars, form1.currentLoop.Text, form1.currentWait.Text);
                         }).Start();
                     }
                     else if (isCombination(1) && Form1.slot1 != null)
                     {
                         new Thread(() =>
                         {
                             form1.runMacro(Form1.slot1, form1.macro1Loop.Text, form1.macro1Wait.Text);
                         }).Start();
                     }
                     else if (isCombination(2) && Form1.slot2 != null)
                     {
                         new Thread(() =>
                         {
                             form1.runMacro(Form1.slot2, form1.macro2Loop.Text, form1.randomMeanTextbox.Text);
                         }).Start();
                     }
                     else if (isCombination(3) && Form1.slot3 != null)
                     {
                         new Thread(() =>
                         {
                             form1.runMacro(Form1.slot3, form1.macro3Loop.Text, form1.macro3Wait.Text);
                         }).Start();
                     }
                 }
             }
         }
     }
     else
     {
         if ((byte)e.KeyValue == 27)           //it means we need to stop the macro
         {
             if (KeysClicker.clickEscape <= 0) // checking if the computer is pressing or human
             {
                 releaseAllKeys();
                 Form1.running = false;
             }
             KeysClicker.clickEscape--; //true when pc is clicking so we turn it to false right after so we know a human is pressing after
         }
     }
     keysHolding.Remove(e.KeyCode);
     //Console.WriteLine("Up\t" + e.KeyCode.ToString());
     //e.Handled = true;
 }
Ejemplo n.º 2
0
 public PressedKeyEvent(PressedKeyEvent pressedInfo)
 {
     keyCode   = pressedInfo.keyCode;
     duration  = pressedInfo.duration;
     startTime = pressedInfo.startTime;
 }