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 ?