private void BackgroundInputDispatch() { for (;;) { StringBuilder sb = new StringBuilder(256); IntPtr window = GetForegroundWindow(); GetWindowText(window, sb, sb.Capacity); if (sb.ToString().Equals("WARFRAME", StringComparison.CurrentCultureIgnoreCase)) { Text = TitleString + " [WARFRAME is foreground present]"; if (((VirtualInput.GetAsyncKeyState(FireImmediateKey) & 0x8000) == 0x8000)) { btImmediate.BackColor = Color.Green; } else { btImmediate.BackColor = Color.Red; } int selected = 0; if (rbAb1.Checked) { selected = 1; } else if (rbAb2.Checked) { selected = 2; } else if (rbAb3.Checked) { selected = 3; } else if (rbAb4.Checked) { selected = 4; } else if (rbMbL.Checked) { selected = 5; } else if (rbMelee.Checked) { selected = 6; } if (selected > 0 && (activated || ((VirtualInput.GetAsyncKeyState(FireImmediateKey) & 0x8000) == 0x8000))) { switch (selected) { case 1: VirtualInput.KeyDown('1', false); break; case 2: VirtualInput.KeyDown('2', false); break; case 3: VirtualInput.KeyDown('3', false); break; case 4: VirtualInput.KeyDown('4', false); break; case 5: VirtualInput.MouseDown(VirtualInput.MouseButton.Left); break; case 6: VirtualInput.KeyDown('E', false); break; } if (cbCharge.Checked) { Thread.Sleep(tbChargeTime.Value); } else { Thread.Sleep(25); } switch (selected) { case 1: VirtualInput.KeyUp('1', false); break; case 2: VirtualInput.KeyUp('2', false); break; case 3: VirtualInput.KeyUp('3', false); break; case 4: VirtualInput.KeyUp('4', false); break; case 5: VirtualInput.MouseUp(VirtualInput.MouseButton.Left); break; case 6: VirtualInput.KeyUp('E', false); break; } Thread.Sleep(tbInterval.Value - 50); } } else { Text = TitleString + " [WARFRAME is not foreground present]"; } Thread.Sleep(25); } }