Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Send Keystrokes for automation (RunOnceEx, VBScr)

- - - - -

  • Please log in to reply
5 replies to this topic




  • Member
  • 16 posts
  • Joined 04-January 04
Hi all,

Happy New Year everyone! I hope this is the right spot to post a script I created to automate sending key strokes to an application during unattended install... I created my first Multi-Boot DVD... its awesome!!! I'll post all my menu screens I created (using photoshop). I used EasyBoot for the menu creation and UltraISO for the bootable ISO. The DVD has all my Operating Systems from Windows 1.0 to Windows XP, **** Small Linux, FreeDOS and Recovery Utils :-). Check out my upcoming posts. Good luck on your un-attendables :)

The visual basic script below will send keystrokes to any window (after finding it and making it active). You can call it from your RunOnceEx.cmd file as follows:

This is an example using Ad-Aware Pro 6:

REG ADD %KEY%\9970 /VE /D "Lavasoft Ad-Aware Pro" /f

REM ***Install Ad-Aware Pro***
REG ADD %KEY%\9970 /V 1 /D "%systemdrive%\install\Ad-AwarePro.exe /s" /f

REM ***Send Password using the script***
REG ADD %KEY%\9970 /V 2 /D "%systemdrive%\install\SendKeys.vbs \"Password\" \"0000000{ENTER}\" 30 500" /f

Replace 0000000 with your Password!

Here is the text of the script, I will attach a zip file of the .vbs and some very good documentation on RunOnceEx with examples from Microsoft.

'Title   : SendKeys.vbs
'Author  : Jawad Shaik Mohammed (shaikjawad@yahoo.com)
'Date    : 4-Jan-2004
'          Waits & Looks for a Window by its title,
'          If found (in the allotted time), sends
'          any Key sequence to window and exit.
'***************HAPPY NEW YEAR EVERYONE!!!******************
'Waits for the window "WindowName" to appear and send "Keys"
'Script Calling Syntax:
'SendKeys.vbs "Window Title (Exact, First few, Last few)" "Keys to send"
'             "# of times to loop" "Wait time(milli) for each loop"
'Example for Ad-Aware Pro 6:
'SendKeys.vbs  "Password" "0000000{ENTER}" 30 500
'The above command line will start this script and run it until
'the window titled "Password" shows up OR until 30 cycles of
'0.5 seconds each (15 sec), which ever comes first. If successful,
'script will activate the window and send 0000000 and the ENTER key
'to it.

Option Explicit
'On Error Resume Next

Dim WshShell, Args, WindowName, Keys, LoopTimes, LoopWaitTime
Set WshShell = WScript.CreateObject("WScript.Shell")
Set Args = WScript.Arguments
If Args.Count <> 4 Then
  MsgBox "Wrong number of arguments supplied. " & Args.Count &_
         " Correct Syntax is : " & vbCrLf &_
         "SendKeys.vbs <Window Name> <Keys> <Times to loop> <Wait time for each loop>"
  WScript.Quit 999
End If

WindowName = Args(0)
Keys = Args(1)
LoopTimes = Args(2)
LoopWaitTime =  Args(3)
Call LookForWindow()
WshShell.SendKeys Keys
Set WshShell = Nothing

Sub LookForWindow()
  Do Until WshShell.AppActivate(WindowName)
    If LoopTimes < 1 Then
      WScript.Quit 999
    End If
    WScript.Sleep LoopWaitTime
    LoopTimes = LoopTimes - 1
End Sub


The attached zip file contains SendKeys.vbs, Reg.exe documentation, and RunOnceEx,cmd sample file with very helpful samples. Email me if you are having any trouble. Look for my menus and tricks I used for my boot DVD on my next post, hopefully sometime this week. Good luck all.

Attached Files


How to remove advertisement from MSFN




  • Member
  • 16 posts
  • Joined 04-January 04

check it out! my first post and its 1/4/04/ 4:44am lol :)




    Advanced Member

  • Member
  • PipPipPip
  • 368 posts
  • Joined 31-July 03
I think you will find there is already a guide to this and i believe it is in a sticky thread called threads of interest - b0r3rd & westi VBS Scripts




  • Member
  • 16 posts
  • Joined 04-January 04
You are right... the send keys script here (http://www.MSFN.org/...sti VBS Scripts) does just about the same thing, though mine is more generic and can be used for any key/any application with a time limit. Thanks for pointing it out dev.



    XL-DJK Recordings Inc.2010 All Rights Reserved

  • Member
  • PipPip
  • 249 posts
  • Joined 13-November 03
  • OS:Windows 7 x64
  • Country: Country Flag
:) That's very clever of you, and I can guarantee you that all of us here at MSFN are going to make great use of this.....keep up the excellent work! :rolleyes:
«====~XL-DJK Recordings Inc.2010~=====»
«========~All Rights Reserved~=======»



    MSFN Addict

  • MSFN Sponsor
  • 1,952 posts
  • Joined 12-January 04

Would you please post your menu screens?

Also, I want to use EasyBoot. Would you please give me some idea about that?

I have got version 5, now.
Posted Image

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users