At previous post, we could click at certain coordinate on screen. Today, we do abit more complicated - Click at certain coordinate of specific window.
To do that, we have to find ID Process of that window by find its handle (identification of each window)
We can find handle by several ways:
1)
var handl = Process.GetProcessById(ID Process);
and then its handle:
After we got handle,
2) Use AutoControl in Kautohelper.dllvar handl = Process.GetProcessById(ID Process).MainWindowHandle;
IntPtr hWnd = IntPtr.Zero;
hWnd = AutoControl.FindWindowHandle()
public static IntPtr FindWindowHandle(string className, string windowName);className get by use Autoit Window Info or Spyxx
After we got handle,
var pointToClick = AutoControl.GetGlobalPoint(hWnd, x, y);
x, y represent coordinate of point needed to click in comparision with window.
x, y get by use Autoit Window Info (coordinate of control compared with window)
pointToClick here return a Point() which represent coodinate of point needed to click in comparision with screen.
Befor click, we need to Focus on that window
AutoControl.BringToFront(hWnd);
Finally,
AutoControl.MouseClick(pointToClick, mouseKey);

Không có nhận xét nào:
Đăng nhận xét