Skip to content

Instantly share code, notes, and snippets.

@mlhaufe
Created January 9, 2012 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlhaufe/1580376 to your computer and use it in GitHub Desktop.
Save mlhaufe/1580376 to your computer and use it in GitHub Desktop.
SendKeys + Sleep + VBScript
<!doctype html>
<html>
<!--Reference <http://www.visualbasicscript.com/tm.aspx?high=&m=95682&mpage=1#95682> -->
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Send Keys</title>
<script type="text/vbscript">
Sub Sleep(intTimeWait)
Dim Shell : Set Shell = CreateObject("WScript.Shell")
Shell.Run "%comspec% /c ping.exe 127.0.0.1 -w 1000 -n " & _
intTimeWait + 1, 0, True
End Sub
Sub BtnRun_OnClick()
Dim WShell : Set WShell = CreateObject("WScript.Shell")
With WShell
.Run "notepad"
Sleep 1
.AppActivate "notepad"
.SendKeys "Hello World!"
Sleep 3
.SendKeys "{ENTER}Hola Mundo!"
End With
End Sub
</script>
</head>
<body>
<button id="BtnRun">Do It</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment