VBScript Sendkeys Shortcuts

During my day to day duties as a support technician I use the same commands over and over again. Whether it be updating a call on our helpdesk system to say “called and left a message – awaiting customer callback” or restarting hung processes on a server.

To streamline my workflow I have created several VBScript based files that I have positioned on my Quick Launch bar at the bottom of my screen. These shortcuts contain the most commonly used commands and text strings which, when clicked on, pipe those commands or text to the relevant window or application.

Heres an example of one of the script files.

Dim oShell
Set oShell = CreateObject("Wscript.Shell")
oShell.AppActivate "Progress"
oShell.SendKeys "Left a message for the user to call me back."

The file is saved as callback.vbs and is located in my My Documents folder. I have then created a shortcut to the file and dragged and dropped that shortcut to the Quick Launch bar.

In basic terms, this script will activate the window called “Progress” which in this example is the name of the editing window in our helpdesk system and send the following text to it as if I had typed it in:

Left a message for the user to call me back.

It’s simple, quick and easy to get to from the Quick Launch bar too. I could also right click the shortcut, choose properties from the pop-up menu and assign a shortcut key. So all I would have to do would be to press that key combination to get the script to activate.

You can also use codes within the sendkeys to represent other keys such as {ENTER} for Enter or the {F1} for the F keys.

Other shortcuts I use do the following:

  • Stop / Start Services.
  • Pipe complex passwords to remote control sessions.
  • Enter my email signature to our email client.

The example file above can be applied to work with any application. Copy and paste the code to a notepad window and change the text after the AppActivate command to point at your chosen application eg: “Microsoft Word” or “Command Prompt”. You can then change the text after the SendKeys command to what ever you need. Save the file with a .VBS extension and you can then either double click the file to launch it or create a shortcut as I do.

You may come across issues where there are two versions of the application open and the text goes to the wrong one. It seems that the script sends the text to the most recently opened window with that name. I do not really see this as a major issue as it forces me to close un-needed applications which keeps my machine fast.

One Response to “VBScript Sendkeys Shortcuts”

Leave a Reply