Batch-VBScript 发送特定密钥特定次数
Batch-VBScript Send specific key(s) specific number of times
正如我在问题标题中所问,当我必须多次发送密钥时,如何避免重复键入密钥。
下面是我的 Batch-VBScript 混合动力车,为了发送 {DOWN}
密钥 4 次,我尝试了下面的代码但没有成功?:
FINDSTR /E "'VbsCode" %~f0 > %temp%\~temp.vbs
CSCRIPT //NOLOGO %temp%\~temp.vbs
Sub TestAppAuto 'VbsCode
On Error Resume Next 'VbsCode
Set WshShell = WScript.CreateObject("WScript.shell") 'VbsCode
WshShell.Visible = False 'VbsCode
WshShell.Run "test.app",0 'VbsCode
WScript.Sleep 500 : WshShell.AppActivate "Test Window Title" 'VbsCode
WScript.Sleep 500 : WshShell.sendKeys "{DOWN}{4}" 'VbsCode
:: Instead of WScript.Sleep 500 : WshShell.sendKeys "{DOWN}{DOWN}{DOWN}{DOWN}" 'VbsCode
End Sub 'VbsCode
TestAppAuto 'VbsCode
WScript.Quit 0 'VbsCode
我怎样才能达到我想要的?
我在我的 VBS 脚本中实现了一个 for 循环,它需要多次按键才能提高 YouTube 音量。
For i = 0 to 20
WshShell.SendKeys ("{RIGHT}")
Next
它更干净,也更容易编辑。
来自帮助http://download.microsoft.com/download/winscript56/Install/5.6/W982KMeXP/EN-US/scrdoc56en.exe
You can use the SendKeys
method to send a pattern of keystrokes that
consists of a single keystroke pressed several times in a row. To do
this, create a compound string argument that specifies the keystroke
you want to repeat, followed by the number of times you want it
repeated. You do this using a compound string argument of the form
{keystroke number}. For example, to send the letter "x
" ten times,
you would send the string argument "{x 10}
". Be sure to include a
space between keystroke and number.
正如我在问题标题中所问,当我必须多次发送密钥时,如何避免重复键入密钥。
下面是我的 Batch-VBScript 混合动力车,为了发送 {DOWN}
密钥 4 次,我尝试了下面的代码但没有成功?:
FINDSTR /E "'VbsCode" %~f0 > %temp%\~temp.vbs
CSCRIPT //NOLOGO %temp%\~temp.vbs
Sub TestAppAuto 'VbsCode
On Error Resume Next 'VbsCode
Set WshShell = WScript.CreateObject("WScript.shell") 'VbsCode
WshShell.Visible = False 'VbsCode
WshShell.Run "test.app",0 'VbsCode
WScript.Sleep 500 : WshShell.AppActivate "Test Window Title" 'VbsCode
WScript.Sleep 500 : WshShell.sendKeys "{DOWN}{4}" 'VbsCode
:: Instead of WScript.Sleep 500 : WshShell.sendKeys "{DOWN}{DOWN}{DOWN}{DOWN}" 'VbsCode
End Sub 'VbsCode
TestAppAuto 'VbsCode
WScript.Quit 0 'VbsCode
我怎样才能达到我想要的?
我在我的 VBS 脚本中实现了一个 for 循环,它需要多次按键才能提高 YouTube 音量。
For i = 0 to 20
WshShell.SendKeys ("{RIGHT}")
Next
它更干净,也更容易编辑。
来自帮助http://download.microsoft.com/download/winscript56/Install/5.6/W982KMeXP/EN-US/scrdoc56en.exe
You can use the
SendKeys
method to send a pattern of keystrokes that consists of a single keystroke pressed several times in a row. To do this, create a compound string argument that specifies the keystroke you want to repeat, followed by the number of times you want it repeated. You do this using a compound string argument of the form {keystroke number}. For example, to send the letter "x
" ten times, you would send the string argument "{x 10}
". Be sure to include a space between keystroke and number.