2017-06-17 92 views
0

我基本上有一个工作场所计算机上的软件(我将其称为软件X),我想在上千行的框中打勾。最快速的手动方法是按(SPACE)然后按(DOWN)键。所以我试图用VBS的sendkeys自动化它。VBScript SendKeys - 从输入框循环

所以......我想要一个脚本来提示我循环我的空间(空间)然后(下),然后做这个次数的次数。

I.e.如果我在框中输入“100”,它将按(空格键),然后按(下)并执行此操作100次。

WshShell.AppActivate "Software X" 
WshShell.SendKeys " " 
WshShell.SendKeys "{DOWN}" 
+0

搜索Google for *“如何在VBScript中循环”* ..... – GTAVLover

回答

0

For...Next Loop将成为您的朋友。还需要使用Sleep方法才能让按键正确发送一段时间。

Dim WshShell: Set WshShell = WScript.CreateObject("WScript.Shell") 
Dim Value: Value = "" 

Value = InputBox("Enter the number of times you want to SendKeys", "SendKeys - Software X", "1") 

For iNum = 1 To CInt(Value) 

    WshShell.AppActivate "Software X" 
    WScript.Sleep 500 

    WshShell.SendKeys " " 
    WScript.Sleep 500 

    WshShell.SendKeys "{DOWN}" 
    WScript.Sleep 500 

Next 

查看更多有关在VBScript loops