在WebDriver中,如果我使用sendKeys,它会将我的字符串附加到字段中已存在的值.我无法通过使用clear()方法清除它,因为第二个我这样做,网页将抛出一个错误,说它必须介于10和100之间.所以我无法清除它或者之前会抛出错误我可以使用sendKeys输入新值,如果我sendKeys它只是将它附加到已存在的值.
WebDriver中有什么东西可以覆盖字段中的值吗?
我正在研究C#中的快捷方式.我成功使用SendKeys实现了Ctrl,Alt和Shift.
像这样;
Ctrl+ C:
System.Windows.Forms.SendKeys.SendWait("^c");
Run Code Online (Sandbox Code Playgroud)
或Alt+ F4:
System.Windows.Forms.SendKeys.SendWait("%{F4}");
Run Code Online (Sandbox Code Playgroud)
但是我不能用SendKeys发送"Windows Key".我试过ex:Win+ E:.SendWait("#e")但它没有用.我应该使用什么而不是"#"?
谢谢.
我已经创建了一个应用程序,它将命令发送到激活的窗口.我希望能够在我的进程运行时使用计算机,因为只要我将焦点切换到另一个窗口,通过发送键发送的击键将转到我刚切换到的窗口.
目前我使用Windows API中的FindWindow,IsIconic和ShowWindow.我必须检查窗口是否有FindWindow,并将我的对象设置为该调用返回的特定窗口,然后检查是否使用IsIconic最小化并调用ShowWindow,如果是,最后我必须调用Interaction.AppActivate将焦点设置到该窗口.所有这一切都在我发送击键之前完成.似乎应该有一种方法来发送击键而不必显示窗口并激活它.最重要的是,当我的应用程序运行按键时,我无法在计算机上执行任何操作.
我使用这块板作为键盘用于演示目的.
无论如何,长话短说一切都很好,除了很少的情况.我使用user32.dll中的SendInput函数发送击键.
所以我的程序看起来像:
static void Main(string[] args)
{
Console.Write("Press enter an on the next secont the key combination shift+end will be send");
Console.Read();
Thread.Sleep(1000);
SendKeyDown(KeyCode.SHIFT);
SendKeyPress(KeyCode.END);
SendKeyUp(KeyCode.SHIFT);
Console.Read();
Console.Read();
}
[DllImport("user32.dll", SetLastError = true)]
private static extern uint SendInput(uint numberOfInputs, INPUT[] inputs, int sizeOfInputStructure);
/// <summary>
/// simulate key press
/// </summary>
/// <param name="keyCode"></param>
public static void SendKeyPress(KeyCode keyCode)
{
INPUT input = new INPUT {
Type = 1
};
input.Data.Keyboard = new KEYBDINPUT() { …Run Code Online (Sandbox Code Playgroud) 我想将一个特定的密钥(例如k)发送到另一个名为notepad的程序,下面是我使用的代码:
void sendkey ()
{
[DllImport ("User32.dll")]
static extern int SetForegroundWindow(IntPtr point);
Process p = Process.GetProcessesByName("notepad")[0];
IntPtr pointer = p.Handle;
SetForegroundWindow(pointer);
SendKeys.Send("k");
}
Run Code Online (Sandbox Code Playgroud)
但代码不起作用,代码有什么问题?
编辑:如果没有记事本作为活动窗口,我可以将"K"发送到记事本吗?(例如,活动窗口="Google Chrome",记事本位于背景中,这意味着将密钥发送到后台应用程序)
我有一个应用程序通过SendKeys将键击注入应用程序.
不幸的是,当我通过远程桌面运行它时,应用程序将无法运行,因为众所周知的问题是SendKeys不能与远程桌面一起使用.
有没有人以前解决过这个问题,或者对如何解决这个问题有任何好的建议?
在Mac 10.6中,我想让活动应用程序变为非活动状态,或者通过Python最小化
我知道我可以在Windows中使用带有Python的sendKey,那么在Mac中呢?
我正在尝试发送CTRL A (在这个案例中选择所有应用程序,但尝试我可能它不起作用)我尝试了很多组合,但都无济于事,任何想法?
IntPtr appHandle = FindWindow(null, "Document1 - Microsoft Word");
if (appHandle == IntPtr.Zero)
{
MessageBox.Show("Specified app is not running.");
return;
}
SetForegroundWindow(appHandle);
System.Threading.Thread.Sleep(500);
//SendKeys.SendWait("111");
SendKeys.SendWait("^A");
//SendKeys.SendWait("^(A)"); //ctrl a
//SendKeys.SendWait("(^A)");
Run Code Online (Sandbox Code Playgroud) SendKeys是将键击发送到应用程序的方法.
我可以在Javascript中执行此操作,在浏览器中发送按键吗?
参考:http :
//msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx
我最近为客户开发了一个虚拟键盘应用程序.该程序几乎适用于所有程序,但某些命令与Citrix一起使用{ENTER}或未{DEL}使用Citrix.有解决方法还是替代方案SendKeys?
编辑1:我尝试了SendInput方法(Windows输入模拟器使用SendInput),DEL键和箭头键仍然无法正常工作.然而,ENTER键有效.
编辑2:解决了它.测试了两个不同版本的Citrix.这个问题给了我很多帮助.:
Citrix瘦客户机使用keybd_event的扫描码参数,即使MS表示它未使用且应为0.您还需要提供物理扫描码以供Citrix客户端使用.Citrix客户端也存在使用SendInput API生成的键盘输入的主要问题.
我修补了Windows输入模拟器中的代码:
// Function used to get the scan code
[DllImport("user32.dll")]
static extern uint MapVirtualKey(uint uCode, uint uMapType);
/// <summary>
/// Calls the Win32 SendInput method ...
/// </summary>
/// <param name="keyCode">The VirtualKeyCode to press</param>
public static void SimulateKeyPress(VirtualKeyCode keyCode)
{
var down = new INPUT();
down.Type = (UInt32)InputType.KEYBOARD;
down.Data.Keyboard = new KEYBDINPUT();
down.Data.Keyboard.Vk = (UInt16)keyCode;
// Scan Code here, was 0
down.Data.Keyboard.Scan = (ushort) MapVirtualKey((UInt16)keyCode, …Run Code Online (Sandbox Code Playgroud)