Sending Keystrokes to Programs

 

 

Next Topic

 

The WIL Tutorial

§         Topic by Topic

§         The Tutorial Course

§         The Complete WIL Tutorial

Getting started

Using WIL

Reference

Notes

 

Here we come to one of the most useful and powerful features of WIL: the ability to send keystrokes to your programs, just as if you were typing them directly from the keyboard.

 

SendKeysTo (parent-windowname, sendkey string)

Activates the specified window and sends keystrokes to it.

This is an ideal way to make the computer automatically type the keystrokes that you enter every time you start a certain program. For example, to start up Notepad and have it prompt you for a file to open, you would use:

 

Run("notepad.exe", "")

SendKeysTo("~Notepad", "!fo")

 

The parameters you specify for SendKeysTo are the window-name (or at least the first unique part of it), and the string that you want sent to the program. This string consists of standard characters, as well as some special characters which you will find listed under the entry for SendKey in the WIL Function Reference (see SendKey). In the example above, the exclamation mark (!) stands for the Alt key, so !f is the equivalent of pressing and holding down the Alt key while simultaneously pressing the F key. The o in the example above is simply the letter O, and is the same as pressing the O key by itself:

 

image\tutbut15_shg.gif