treluk
06-12-2011, 06:17 PM
So I've been putzing around with my C# bot application a lot lately. After a night out with geek friends and a few beers got my mind rolling on a few different topics to consider. The first one being realistic mouse and keyboard inputs to the active window.
So I decided that I didn't want to have the C# program load different macros to perform mouse and keyboard inputs and that I was going to programmatically make them in C#.
public void RelocateActiveWindow();
{
SetCursorPos(240, 110);
mouse_event(MouseEventType.LeftDown, Cursor.Position.X, Cursor.Position.Y, 240, 110);
System.Threading.Thread.Sleep(1000);
Cursor.Position = new System.Drawing.Point(41, 18);
mouse_event(MouseEventType.LeftUp, Cursor.Position.X, Cursor.Position.Y, 41, 18);
}
Is a generalization of how I can grab a window, and drag it to where i want it to go, but it moves SO fast. Anyone know a method to slow it down to the point it looks realistic? And if i can be done, does it send the appropriate IO sequences to the program window so that it looks realistic from a 3rd party standpoint? Like i'm assuming when you move the mouse, it actually inputs/outputs the exact pixel for the entire length of the mouse movement call, which would be impossible to replicate with my knowledge in C#.
Next, the way i input keyboard presses also worries me. I'm currently a method that I'm sure is not the most appropriate way to be doing this.
SendKeys.Send("testingtesting123");
Does anyone have any ideas or documentation outlining better ways of handling this within a C# program?
Thanks in advance for any suggestions.
So I decided that I didn't want to have the C# program load different macros to perform mouse and keyboard inputs and that I was going to programmatically make them in C#.
public void RelocateActiveWindow();
{
SetCursorPos(240, 110);
mouse_event(MouseEventType.LeftDown, Cursor.Position.X, Cursor.Position.Y, 240, 110);
System.Threading.Thread.Sleep(1000);
Cursor.Position = new System.Drawing.Point(41, 18);
mouse_event(MouseEventType.LeftUp, Cursor.Position.X, Cursor.Position.Y, 41, 18);
}
Is a generalization of how I can grab a window, and drag it to where i want it to go, but it moves SO fast. Anyone know a method to slow it down to the point it looks realistic? And if i can be done, does it send the appropriate IO sequences to the program window so that it looks realistic from a 3rd party standpoint? Like i'm assuming when you move the mouse, it actually inputs/outputs the exact pixel for the entire length of the mouse movement call, which would be impossible to replicate with my knowledge in C#.
Next, the way i input keyboard presses also worries me. I'm currently a method that I'm sure is not the most appropriate way to be doing this.
SendKeys.Send("testingtesting123");
Does anyone have any ideas or documentation outlining better ways of handling this within a C# program?
Thanks in advance for any suggestions.