![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
C# Stimulation mouse / keyboard!
Hello!
1. I have problem! How i can stimulate keyboard and mouse on No-Active window? On active window i use this code: Code: // Get a handle to an application window. [DllImport("USER32.DLL", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); // Activate an application window. [DllImport("USER32.DLL")] public static extern bool SetForegroundWindow(IntPtr hWnd); && Code:
IntPtr calculatorHandle = FindWindow(null, "MyGame");
// Verify that game is a running process.
if (calculatorHandle == IntPtr.Zero)
{
MessageBox.Show("Your game is not running!");
return;
}
// Make game the foreground application and send it
// a set of calculations.
SetForegroundWindow(calculatorHandle);
System.Threading.Thread.Sleep(500);
SendKeys.SendWait("Hello!");
System.Threading.Thread.Sleep(500);
SendKeys.SendWait(" How are");
System.Threading.Thread.Sleep(1000);
SendKeys.SendWait(" You");
System.Threading.Thread.Sleep(200);
SendKeys.SendWait("?");
2. How i can stimulate clicked mouse on XYZ position, on Active && no-active window? |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
|
||||||||||||||||||||||||||||||