I have 2 windows, which can be different size / different position. The final goal is to be able to click on Window A at a certain position, and send a click on Window B on the same point relatively.
Here's a screen to explain what I'm trying to achieve :
For now I'm amble to retrieve :
- Window A Handle/Rect
- Window B Handle/Rect
- Cursor position on screen
I've heard about ScreenToClient/ClientToScreen and I understand that I need to find the relative mouse position when clicked on Window A, and send the click relatively to Window B
Also, to send my button click I use :
SendMessage(character.MainWindowHandle, 0x201, IntPtr.Zero, CreateParams(?,?);
SendMessage(character.MainWindowHandle, 0x202, IntPtr.Zero, CreateParams(?,?);
What i need to find the the two question marks
My code for now :
var windowAHandle = Win32Api.GetForegroundWindow();
var windowARect = Win32Api.GetWindowRectangle(windowAHandle);
var windowB = PersosEnLigne.First(w => w.Nom == "Character 2");
var windowBRect = Win32Api.GetWindowRectangle(windowB.Process.MainWindowHandle);
var ptTopLeft = new Win32Api.POINT();
var ptBottomRight = new Win32Api.POINT();
ptTopLeft.x = windowARect.Left;
ptTopLeft.y = windowARect.Top;
ptBottomRight.x = windowARect.Right;
ptBottomRight.y = windowARect.Bottom;
Win32Api.ScreenToClient(windowB.MainWindowHandle, ref ptTopLeft);
Win32Api.ScreenToClient(windowB.MainWindowHandle, ref ptBottomRight);
//I'm not even sure if I need to use ScreenToClient or ClientToScreen