0
我正在使用Fiddler Core,當我按「t」作爲信任根證書時,它顯示「安全警告」對話框,按是或否。如何自動單擊從控制檯應用程序打開的對話框
我想自動化本節,當對話框打開時,我的控制檯應用程序自動點擊是的。
我正在使用Fiddler Core,當我按「t」作爲信任根證書時,它顯示「安全警告」對話框,按是或否。如何自動單擊從控制檯應用程序打開的對話框
我想自動化本節,當對話框打開時,我的控制檯應用程序自動點擊是的。
如果你想點擊另一個窗口中的按鈕 - 首先找到窗口的標題和類名。這可以通過Spy ++來完成,它位於開始菜單文件夾(Microsoft Visual Studio 2010/Visual Studio Tools/Spy ++)中。在間諜++中,只需按下搜索/查找窗口...,而不是指向期望的窗口。
現在你可以發送鍵「輸入」到你的窗口(或第一發送「選項卡」,如果[否]按鈕被激活)
這裏有一個鏈接How to: Simulate Mouse and Keyboard Events in Code
例如(偉大工程與我火狐):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Temp
{
class Program
{
static void Main(string[] args)
{
bool IsDone = false;
while (IsDone == false)
{
// Get a handle to the Firefox application. The window class
// and window name were obtained using the Spy++ tool.
IntPtr firefoxHandle = FindWindow("MozillaWindowClass", null);
// Verify that Firefox is a running process.
if (firefoxHandle == IntPtr.Zero)
{
// log of errors
Console.WriteLine("Firefox is not running.");
// wait 1 sec and retry
System.Threading.Thread.Sleep(1000);
continue;
}
// Make Firefox the foreground application and send it commands
SetForegroundWindow(firefoxHandle);
// send keys to window
System.Windows.Forms.SendKeys.SendWait("google.com");
System.Windows.Forms.SendKeys.SendWait("{tab}");
System.Windows.Forms.SendKeys.SendWait("{enter}");
// yeah ! job's done
IsDone = true;
}
}
// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
}
}
我看來,你需要的是這樣的:http://stackoverflow.com/questions/20269616/handle-popup-automatically-and-click-yes-with-findwindow-in-vb-淨 – vesan