我需要在遠端發送一個指令以執行.VBS檔案,內容是執行一個組合鍵
請問 .VBS應該怎麼寫?
我搜尋結果有看到+特定字符
特殊控制键 特殊字符
Shift +
Ctrl ^
Alt %
我現在需要的是以下4個 .vbs:
煩請協助,感恩
可以透過Windows Script Shell物件的SendKeys去送出鍵盤上按鍵
例如:
<pre class="c" name="code">
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("cmd")
WScript.Sleep 10000
WshShell.SendKeys "dir"
WshShell.SendKeys "{Enter}"
WScript.Quit
數字鍵?
0-->96
1-->97
2-->98
以下都失敗
<pre class="c" name="code">WshShell.SendKeys "^%" & CHR(96)
WshShell.SendKeys "^%" & chr(96)
WshShell.SendKeys "^%" & "chr(96)"
應該是
WshShell.SendKeys "^%{0}"
WshShell.SendKeys "^%{1}"
WshShell.SendKeys "^%{2}"
這樣才對
以下失敗~
WshShell.SendKeys "^%" & {chr98}...不正確字元
WshShell.SendKeys "^%" &{chr98}....不正確字元
WshShell.SendKeys "^%" & "{chr98}"..引數不正確
WshShell.SendKeys "^%" & chr{98}...不正確字元
WshShell.SendKeys "^%" & (chr98)
[/code]
...糖叔叔會錯意了
請照抄~
WshShell.SendKeys "^%{0}"
WshShell.SendKeys "^%{1}"
WshShell.SendKeys "^%{2}"
wiselou提到:
WshShell.SendKeys "^%{2}"
這樣沒錯誤,但是沒動靜耶.....
都寫成一個了,麻煩 bigcandy 大大自己切分囉~
<pre class="c" name="code">Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "^%H"
WshShell.SendKeys "^%0"
WshShell.SendKeys "^%1"
WshShell.SendKeys "^%2"
<pre class="c" name="code">
1. WshShell.SendKeys "^%H"
2. WshShell.SendKeys "^%" & CHR(96)
3. WshShell.SendKeys "^%" & CHR(97)
4. WshShell.SendKeys "^%" & CHR(98)
<pre class="c" name="code">Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "^%h"
以上是wiseguy兄提供出來正常可用的
請問數字碼部份?
<pre class="c" name="code">Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "^%" & CHR(96)
這樣不行耶
CHR(96) 改小寫 chr(96)也沒動靜
糖叔叔:試試SendKeys "^%{0}"
把數字用大括弧括起來