When i play Age of empires or and other strategy game i often need to sell some resource 100 times and then by another. It's annoying :(
I wrote a program which helps me by clicking the mouse using :
//This is the decleration
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private void ClickTheMouse()
{
int X = Cursor.Position.X;
int Y = Cursor.Position.Y;
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
}
and then by using a timer and the code above i can click 30 times.
It all works great in and window in windows (word, Firefox, etc..) and even in Age of empires, But unfortunately it doesn't work in "Stronghold crusader" and some other games i don't remember their names.
I assume this happens because the click simulated in high level, and if it will be simulated closer to driver level it will work.
I have 2 questions :
- is my assumption right?
- how can i simulate mouse click in a lower level which will work in this game?
I use c# , but any c++ code will help also (i'll just use PInvoke).
Thanks,