110,545
社区成员
发帖
与我相关
我的任务
分享
private void timer1_Tick(object sender, EventArgs e)
{
CloseWin("来自网页的消息", "确定");
CloseWin("Message from webpage", "确定");
}
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, uint hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SendMessage(IntPtr hwnd, uint wMsg, IntPtr wParam, int lParam);
private void CloseWin(string winTitle, string buttonTitle)
{
IntPtr hwnd = FindWindow(null, winTitle);
if (hwnd != IntPtr.Zero)
{
IntPtr hwndText = FindWindowEx(hwnd, 0, null, "请设置浏览器的安全级别.启用activeX脚本!");
if (hwndText != IntPtr.Zero)
{
IntPtr hwndSure = FindWindowEx(hwnd, 0, "Button", buttonTitle);
if (hwnd != IntPtr.Zero)
SendMessage(hwndSure, 0xF5, (IntPtr)0, 0); //按她
}
}
}