Puppeteer Help
Graphical Application Scripting Language
Intro
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.
Example Script
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:
ProcessName = "C:\\Windows\\Notepad.exe";
p = GetProcess(ProcessName);
if (!p)
// Ok, no existing one, start one:
p = RunProcess(ProcessName);
if (!p)
// Couldn't find or start the process so exit with error
return -1;
// 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.
Reference
Firstly there is some general reference documenation for the language itself
here.
The objects, field and methods specific to Puppeteer are as follows:
Objects:
- Process
Process objects refer to a separate process that Puppeteer has connected to. It has the following
methods:
- 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(
Wnd, Type);
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'
- Window
A window object wraps a single HWND. It references a single top level or child window in the target
process.
- Handle
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(
NewText)
Sets the text for a window.
- Bool WaitEnable(
TimeoutMs)
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(
Keys)
Sends key presses to a window. Keys can be a combination of:
- 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)
Keys can be combined with a plus sign:
- Ctrl+C: Copy
- Ctrl+V: Paste
- Shift+A: Select all
- String InvokeMenuItem(
MenuId)
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(
PathToExe)
Searches running processes for PathToExe.
- Process RunProcess(
PathToExe)
Starts a new proces with PathToExe.
- void Exit()
Exits the whole application.