I would like to compare my application for handwritten mathematical symbols recognition with the Math Input Panel (MIP) contained in Windows 7. I have a library of recorded mouse strokes representing different mathematical formulas and I need to send them to the MIP to measure its performance.
I tried to simulate mouse move but it's not working.
Here are constants and imported methods that I use:
const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;
const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, UIntPtr dwExtraInfo);
And that's the code itself:
IntPtr windowHandle = FindWindow("MathInput_Window", "");
SetForegroundWindow(windowHandle);
Cursor.Position = new Point(600, 700);
mouse_event(MOUSEEVENTF_LEFTDOWN, 600, 700, 0, UIntPtr.Zero);
for (int x = 600; x <= 650; x++)
{
Cursor.Position = new Point(x, 700);
}
for (int y = 700; y <= 750; y++)
{
Cursor.Position = new Point(650, y);
}
mouse_event(MOUSEEVENTF_LEFTUP, 650, 750, 0, UIntPtr.Zero);
But the only thing i get is a single dot at the position [600,700]. The funny thing is that when I use MSPaint instead of MIP everything is working perfectly.
Does anyone have some idea how it could be solved?