110,587
社区成员
发帖
与我相关
我的任务
分享
private bool EnumChildWindowsCallback(IntPtr handle, IntPtr lparam)
{
StringBuilder className = new StringBuilder(100);
GetClassName(handle, className, className.Capacity);
MessageBox.Show(className.ToString());
string cn = className.ToString();
if (className.ToString() == "MacromediaFlashPlayerActiveX")
{
Point point = GetFlashPointFromHandle(handle);
if (point.X == ((webBrowser1.Document.DomDocument) as HTMLDocument).getElementById("obj1").offsetLeft && point.Y == ((webBrowser1.Document.DomDocument) as HTMLDocument).getElementById("obj1").offsetTop)
{
webBrowser1.Document.Body.ScrollTop = point.Y;
int x = Convert.ToInt32(textBox1.Text); // X coordinate of the click
int y = Convert.ToInt32(textBox2.Text); // Y coordinate of the click
IntPtr lParam = (IntPtr)((y << 16) | x); // The coordinates
IntPtr wParam = IntPtr.Zero; // Additional parameters for the click (e.g. Ctrl)
const uint downCode = 0x201; // Left click down code
const uint upCode = 0x202; // Left click up code
SendMessage(handle, downCode, wParam, lParam); // Mouse button down
SendMessage(handle, upCode, wParam, lParam); // Mouse button up
}
}
return true;
}
EnumChildWindows(webBrowser1.Handle, new EnumChildrenCallback(EnumChildWindowsCallback), IntPtr.Zero);//调用