-->

在华廷击键(Key strokes in watin)

2019-09-29 09:48发布

我试图让我的华廷应用推动键,但我不能看到如何做到这一点。 我已经看到它在以前的文章中,你应该使用:

System.Windows.Forms.SendKeys.SendWait("{DOWN}"); 

但是这不会对我使用Web浏览器,任何建议工作作为即时通讯?

Answer 1:

你需要告诉Windows设置它的重点在浏览器窗口,然后发送正确的键命令。

例如,这个代码片段将焦点设置为浏览器和发送“DOWN”键,浏览器窗口。

[DllImport("user32.dll")]
private static extern IntPtr SetFocus(IntPtr hWnd);

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);

private void SendDownKey(Browser browser)
{
    SetForegroundWindow(browser.document.DomContainer.hWnd);
    SetFocus(browser.document.DomContainer.hWnd);      

    SendKeys.SendWait("{DOWN}");
}


Answer 2:

System.Windows.Forms.SendKeys.SendWait( “{} DOWN”); 建议您靶向的Windows应用程序。 你可以尝试用网络取代的Windows?

希望能帮助到你。 让我知道,如果不工作,我会尽力挖掘更多的进入这个有点。



Answer 3:

这是由以下几个问题很好的答案回答:

通过击键(即Enter键)到使用华廷脚本应用



文章来源: Key strokes in watin
标签: watin