如何使用WScript.Shell的SendKeys发送数字键盘击键? [英] How do I use WScript.Shell SendKeys to send Number Pad key strokes?
问题描述
我想使用WScript.Shell SendKeys方法来模拟发送从数字键盘一键preSS。
I am trying to use WScript.Shell SendKeys method to emulate sending a key press from the Number Pad.
我有我写的自动化测试使用QTP的应用程序。它是一个基于Web浏览器应用程序和输入到Java应用程序的网页中。输入只接受来自数字键盘和Enter键键presses。
I have an application that I am writing automated testing for using QTP. It is a Web Browser based application and the input is into a Java App within the web page. The input only accepts key presses from the Number Pad and the Enter key.
到目前为止,我用这code:
So far I am using this code:
Dim strInputKey
strInputKey = "{ENTER}"
Set objWsh = CreateObject("WScript.Shell")
Browser("Launch Browser").Page("Test Application").WebElement("Item ID").Click
objWsh.SendKeys strInputKey
这工作正常发送回车键,但我不能完全弄清楚是否有发送数字键的方式。任何帮助将大大AP preciated。
This works fine for sending the Enter key, but I can't quite figure out if there is a way to send Number Keys. Any help would be greatly appreciated.
我不知道是否有实现这一目标的任何公开的方式。我已阅读 http://msdn.microsoft.com/en -us /库/ 8c6yea83(VS.85)的.aspx 但它并没有详谈了。
I am not sure if there are any undocumented ways of achieving this. I have read http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx but it doesn't go into great detail.
由于提前,
- 布伦特
推荐答案
您需要使用的关键codeS的数字键盘。
You'll need to use the keycodes for the number pad.
下面是它们的列表:
的http://www.empirisoft.com/directrt/help/_helpcontents.htm?directrt_key_$c$cs.htm
因此,要发送123,你需要做的:
So to send "123", you would need to do:
objWsh.SendKeys chr(79) & chr(80) & chr(81)
这篇关于如何使用WScript.Shell的SendKeys发送数字键盘击键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!