作成 2010.01.07
更新 2010.01.07
更新 2010.01.07
VBScript でキーボード入力のエミュレーション
コード
日本語を入力するには、クリップボードでコピー&ペーストします。
Option Explicit
Dim WshShell, appcount, clip
Set WshShell= CreateObject("WScript.Shell")
WshShell.Run "notepad"
appcount = 0
' アプリケーションのタイトルで調べる
Do While Not WshShell.AppActivate("メモ帳")
WScript.Sleep 100
appcount = appcount + 1
If appcount > 20 Then
WScript.Echo "noapp"
WScript.Quit
End If
Loop
WScript.Sleep 100
WshShell.SendKeys "{TAB}1{+}2=3"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "^v"
WScript.Sleep 500
WshShell.SendKeys "%f{DOWN 3}{ENTER}"
参考