Graphical Application Scripting Language
This application is a scripting language that allows you to manipulate a graphically application in Windows.
It loads a DLL into the target process' address space and then communicates with it via a socket. Sending
commands and receiving responses. The best way to understand the language and what it can do is by example.
You will need to use the right build for the target application, Puppeteer32.exe for controlling 32bit apps, and
Puppeteer64.exe for 64bit apps. The best way to use it is assocaite .puppet files with Puppeteer and then double
click the script after editing it.
This basic example opens the Notepad application and puts some text in the window. Then opens the save as dialog.
// Find an existing process -or- start a new instance:
p = GetProcess(ProcessName);
// Ok, no existing one, start one:
p = RunProcess(ProcessName);
// Couldn't find or start the process so exit with error
// Find the main window by title:
w = p.GetWindowByName( "Notepad");
Print( "w.Len="+w.Length+ "\n"); // Check we got only one window back from GetWindowByName
// Potentially you might get multiple results back as an array
menus = w.EnumMenus();
Print( "Menus:\n" + menus); // Show all the available menus in the console
w.SendKeys( "Shift+A"); // Insert capital 'A' into the document
w.InvokeMenuItem(4); // "Save as"
I'll write some more when I get the chance.
Firstly there is some general reference documenation for the language itself here
The objects, field and methods specific to Puppeteer are as follows:
Process objects refer to a separate process that Puppeteer has connected to. It has the following
- Window EnumWindows()
This returns an array of all the windows in the process.
- Window GetWindowByName(
Name, optional ParentWnd)
This returns an array of all the windows matching the given name.
- Window GetWindowById(
CtrlId, optional ParentWnd)
This returns an array of all the windows matching the given control ID.
- Window GetWindow(
This returns a window relative to Wnd. Type can be:
- Parent: the owning parent of 'Wnd'
- Next: the window following 'Wnd'
- Prev: the window before 'Wnd' in the z-order
- Child: the first child window of 'Wnd'
A window object wraps a single HWND. It references a single top level or child window in the target
This field is the window handle.
- Bool Click(optional
X, optional Y)
Clicks a button. Optionally passing in a corrdinate.
- String Text()
Returns the text for a window.
- Bool Text(
Sets the text for a window.
- Bool WaitEnable(
Waits TimeoutMs milliseconds for a window to change to enabled.
- int ListLength()
Returns the number of list items in a list control.
- String EnumMenus()
Returns a description of all the menus attached to a window.
- String SendKeys(
Sends key presses to a window. Keys can be a combination of:
Keys can be combined with a plus sign:
- Alt: Add the 'alt' key
- Shift: Add the 'shift' key
- Ctrl: Add the 'ctrl' key.
- F1, F2 etc
- Up, Down, Left, Right: the arrow keys
- Delete, Insert, Home etc.
- Numbers: 0, 1, 2 etc
- Letters: A, B, C etc (not case sensitive, use Shift+A to send a capital)
- Ctrl+C: Copy
- Ctrl+V: Paste
- Shift+A: Select all
- String InvokeMenuItem(
Activates a menu item. The MenuId will need to be discoved via EnumMenus.
There are some top level functions, that don't need an object to reference from:
- Process GetProcess(
Searches running processes for PathToExe.
- Process RunProcess(
Starts a new proces with PathToExe.
- void Exit()
Exits the whole application.