C# 如何在Internet Explorer中获取子窗口的句柄?
我的问题是无法在InternetExplorer中获得flash子控件,但我可以在webbrowser控件中实现。webbrowser控件与flash对象有缺陷,因此我需要通过Internet explorer完成这项工作,并自动化flash测试 下面是我试图在IE 11中复制的webbrowser控件的代码C# 如何在Internet Explorer中获取子窗口的句柄?,c#,C#,我的问题是无法在InternetExplorer中获得flash子控件,但我可以在webbrowser控件中实现。webbrowser控件与flash对象有缺陷,因此我需要通过Internet explorer完成这项工作,并自动化flash测试 下面是我试图在IE 11中复制的webbrowser控件的代码 private async Task<bool> clickCoorindate(Point point) { IntPtr handle = null; Pr
private async Task<bool> clickCoorindate(Point point)
{
IntPtr handle = null;
Process[] processes = Process.GetProcessesByName("iexplore");
foreach (Process p in processes)
{
handle = p.MainWindowHandle;
}
//webBrowser1.Focus();
int x = point.X;
int y = point.Y;
// IntPtr handle = webBrowser1.Handle;
StringBuilder className = new StringBuilder(100);
while (className.ToString() != "MacromediaFlashPlayerActiveX")
{
handle = GetWindow(handle, 5); // Get a handle to the child window
GetClassName(handle, className, className.Capacity);
}
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
const uint moveCode = 0x200;
SendMessage(handle, downCode, wParam, lParam); // Mouse button down
SendMessage(handle, upCode, wParam, lParam); // Mouse button up
Thread.Sleep(20);
SendMessage(handle, downCode, wParam, lParam); // Mouse button down
SendMessage(handle, upCode, wParam, lParam); // Mouse button up
return true;
}
专用异步任务clickCoorindate(点)
{
IntPtr handle=null;
Process[]processs=Process.GetProcessesByName(“iexplore”);
foreach(进程中的进程p)
{
句柄=p.MainWindowHandle;
}
//webBrowser1.Focus();
int x=点x;
int y=点y;
//IntPtr handle=webBrowser1.handle;
StringBuilder类名称=新StringBuilder(100);
while(className.ToString()!=“MacromediaFlashPlayerActiveX”)
{
handle=GetWindow(handle,5);//获取子窗口的句柄
GetClassName(句柄、类名、类名、容量);
}
IntPtr lParam=(IntPtr)((你可以忽略除最后一个外的所有Exporer实例。你也可以用它来代替所有的实例。我试过了,但它不起作用**进程[]进程=Process.getProcessByName(“iexplore”);IntPtr hWnd=FindWindow(IntPtr.Zero,“MyWeb-Internet Explorer”);IntPtr handle=IntPtr.Zero;foreach(进程中的进程p){IntPtr windowHandle=p.MainWindowHandle;if(windowHandle==hWnd)handle=FindWindowEx(windowHandle,IntPtr.Zero,“MacromediaFlashPlayerActiveX”,null);}**主窗口句柄已找到,但flashobject窗口不可用。您可以忽略除最后一个外的所有Exporer实例。您也可以使用它来代替所有实例。我尝试过,但它不起作用**进程[]进程=进程。GetProcessByName(“iexplore”);IntPtr hWnd=FindWindow(IntPtr.Zero,“MyWeb-Internet Explorer”);IntPtr handle=IntPtr.Zero;foreach(进程中的进程p){IntPtr windowHandle=p.MainWindowHandle;if(windowHandle==hWnd)handle=FindWindowEx(windowHandle,IntPtr.Zero,“MacromediaFlashPlayerActiveX”,null);}**找到了主窗口句柄,但未找到flashobject窗口