I developed application that use PostMessage to simulate mouse click in another app. I have screenshots of second app, i have coordinates for mouse click and i am simulate mouse click for second app. That all work fine on windows 7, but when i run it on windows 8 i am so confused: screenshots of second app on win8 and win7 are the same, but when i emulate click by PostMessage, click occurred in different area. And i have two questions: 1) Why PostMessage work different on win8? 2) How it can be fixed?
EDIT: For PostMessage lParam = ((HiWord << 16) | (LoWord & 0xffff)), where LoWord is Left and HiWord is Top coordinates
EDIT2: More code
Step1
var hW = Win32.User32.FindWindow(null, "AppName");
Step2
MouseEngine.Click(hW, 100, 100);
where
public void Click(IntPtr hWnd, int left, int top)
{
// send mouse down
User32.PostMessage(
hWnd,
User32.Message.WM_LBUTTONDOWN,
0,
User32.MakeLParam(left, top));
// send mouse up
User32.PostMessage(
hWnd,
User32.Message.WM_LBUTTONUP,
0,
User32.MakeLParam(left, top));
}
where
public static int MakeLParam(int LoWord, int HiWord)
{
return ((HiWord << 16) | (LoWord & 0xffff));
}