Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use VBScript to open an application and perform actions in it

Tags:

vbscript

I've written the following vbs to open ciphergraph:

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""C:\Program Files (x86)\CipherGraph\LaunchStub.exe""")
Set objShell = Nothing
WScript.Sleep 250

I'd like to also select the 'Connect' button in the ciphergraph window - I can get to it by hitting 'TAB' twice and then 'RETURN' when the app launches

how do I do this? Sorry if it's a basic question, new to VBS, but can't find an answer??

cheers

like image 782
Ammar Akhtar Avatar asked Oct 01 '22 09:10

Ammar Akhtar


1 Answers

The WshShell object is the solution.

- Use its AppActivate() method to bring any running application into the foreground.

- Use its SendKeys() method to send keystrokes to whatever application currently has the focus.

This is so simple that I omit sample code (you're almost there yourself, after all).

like image 135
Tomalak Avatar answered Oct 04 '22 20:10

Tomalak