This directory contains the source of the example programs. These are described in further detail below. More details are explained in the program source.

If you want to create your own command line program, simply copy one of the sample directories and use it as a template. If you're wondering how to work out the coordinates of mouse clicks, the demo program PuppetDemo can assist. Under Preferences there is a switch which will turn on logging of all mouse clicks. Thereafter, each time you use PuppetDemo to click in a remote application's window, the event will be logged on the console with the window height and width and the x and y coordinates of the click relative to the bottom left corner of the window (ie the same coordinates as are used in Puppeteer's mouse event methods). It's advisable to use the mouse down coordinates rather than mouse up (see below).

One tip to bear in mind if the button you are trying to click is a fixed distance from the top of the window, but the window size varies: make a note of the distance from the top of the window and then prior to posting the mouse event, ask for the window's frame rectangle. The y coordinate is just the window height minus the offset from the top.

PuppetDemo

This demonstration program is provided just for fun. You enter the name of the application you want to control and then press "Attach Strings". An image of the application's key window appears in the scroll view below. Clicking on this image will result in the mouse click being relayed by the Puppeteer object to the remote application. Similarly, typing in the text field above will also be forwarded to the application.

Occasionally after mousing in the lower scroll view you will see the mouse cursor in the wrong place (and the log of mouse up will report incorrectly). This is unavoidable (I think) because it is impossible to flush the remote application's postscript setting of the mouse position. It's not a bug in Puppeteer!

When you've finished playing with the remote application, press "Release Strings" (or just quit). Until you do, the application will not respond to real user events.

preferencesPuppet

This command line program toggles the Public Window Server switch in Preferences. Call it as follows:

		./preferencesPuppet -P
		
The x coordinates of the mouse clicks assume that there are no extra preferences modules loaded.

previewPuppet

Asks Preview to print an eps file. It is called as follows:

		./previewPuppet [-l] file1.eps [file2.eps ...]
		
The -l option specifies that the file is to be printed in Landscape mode. The program will bring up the Page Layout panel and then click either the Portrait or Landscape button accordingly. Then it will bring up the Print panel with a cmd-p, followed by a return to print the file.

The files must be of type eps because otherwise the Page Layout menu item is not enabled.

terminalPuppet

Outputs a file of text to a given application (default Terminal), pausing after every line. It is called as follows:

		./terminalPuppet  [-a application] [-d delay] [-f file]
		
application specifies the application to which the file will be sent, delay specifies the amount of time in milliseconds to wait after each line has been sent and file gives the name of the file to be read (default is to read from standard input).

websterPuppet

Returns the definition of a word from the Webster application. Use as follows:

		./websterPuppet word
		
Where word is the word whose definition is required. The definition is written to standard output.