0

Im currently working on a Program which does alot of Key Inputs which is for a Game. Now i want that the Buttons are only working when a Window called "Diablo III" is in Focus so it doesnt do the Actions in other Windows when you Tab Out.

Code Example for one of the Buttons:

            InputSimulator sim = new InputSimulator();
        SetCursorPos(105, 640);
        System.Threading.Thread.Sleep(30);
        sim.Mouse.LeftButtonClick();
        System.Threading.Thread.Sleep(30);
        SetCursorPos(274, 547);
        System.Threading.Thread.Sleep(30);
        sim.Mouse.LeftButtonClick();
        System.Threading.Thread.Sleep(1560);
        sim.Keyboard.KeyPress(VirtualKeyCode.VK_T);
        System.Threading.Thread.Sleep(50);
        SetCursorPos(274, 547);
        sim.Mouse.LeftButtonClick();
        System.Threading.Thread.Sleep(1610);
        SetCursorPos(274, 547);
        sim.Mouse.LeftButtonClick();
        System.Threading.Thread.Sleep(1610);
        SetCursorPos(274, 547);
        sim.Mouse.LeftButtonClick();
        SetCursorPos(960, 540);

Does somebody know a way how i can do it ?

Godly
  • 19
  • 5
  • [GetForegroundWindow()](https://learn.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getforegroundwindow) API? – Idle_Mind Apr 13 '19 at 22:22
  • Possible duplicate of [How do I get the title of the current active window using c#?](https://stackoverflow.com/questions/115868/how-do-i-get-the-title-of-the-current-active-window-using-c) – sticky bit Apr 13 '19 at 22:23

0 Answers0