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:
REM ***TITLE***
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
'QuikInfo:
' 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!!!******************
'***********************************************************
'Description:
'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
Loop
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 File(s)
-
AutomateCodeDocumentation.zip (7.97K)
Number of downloads: 155



Help
Back to top









