模擬按鍵c#我想模擬F5在我的c#程序中按下鍵,當(dāng)IE打開時,我希望能夠自動刷新我的網(wǎng)站,我不知道從哪里開始。謝謝,丹妮。
3 回答

蕪湖不蕪
TA貢獻(xiàn)1796條經(jīng)驗 獲得超7個贊
static class Program { [DllImport("user32.dll")] public static extern int SetForegroundWindow(IntPtr hWnd); [STAThread] static void Main() { while(true) { Process [] processes = Process.GetProcessesByName("iexplore"); foreach(Process proc in processes) { SetForegroundWindow(proc.MainWindowHandle); SendKeys.SendWait("{F5}"); } Thread.Sleep(5000); } } }
static class Program { const UInt32 WM_KEYDOWN = 0x0100; const int VK_F5 = 0x74; [DllImport("user32.dll")] static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam); [STAThread] static void Main() { while(true) { Process [] processes = Process.GetProcessesByName("iexplore"); foreach(Process proc in processes) PostMessage(proc.MainWindowHandle, WM_KEYDOWN, VK_F5, 0); Thread.Sleep(5000); } } }
- 3 回答
- 0 關(guān)注
- 672 瀏覽
添加回答
舉報
0/150
提交
取消