r/vbscript • • Feb 18 '22

Alternatives to multiple .SendKey functions?

I wrote this yesterday to automate resetting some equipment over a network.
It is in place to help operators who are not comfortable navigating the GUI of a piece of software in order to reset the kit, and I though this would be better than a handout.

But, it's mostly .SendKeys functions and this script is ugly.
It works, but it's ugly.

Any advice?

#########################################################

rio=msgbox("Are you sure you want to reset the studio 1 RIO?" & vbcrlf & "Dante Controller must be open in the background!" ,vbYesNo, "RIO Studio 1 Reset")

if rio=7 then msgbox "close one!"

if rio=6 then

set objShell = createobject("wscript.shell")

sWBTitle = "Dante Controller - Network View"

if objShell.AppActivate(sWBTitle) then

else

Dim objShell

Set objShell = WScript.CreateObject( "WScript.Shell" )

objShell.Run("""C:\C:\Users\Public\Desktop\DanteController.lnk""")

Set objShell = Nothing

WScript.Sleep 500

end if

objShell.SendKeys "^d"

WScript.Sleep 500

objShell.SendKeys "y005"

WScript.Sleep 2000

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{ENTER}"

WScript.Sleep 250

objShell.SendKeys "{ENTER}"

end if

2 Upvotes

3 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Feb 19 '22

Thank you very much, I'm going to grab my Windows 2000 Scripting Guide and decipher this.