StackShot "Robot" for Controlling External Programs
As described on the parent page, Zerene Stacker's controller for the StackShot rail allows an external program to be executed whenever a shutter operation occurs. The example there used Apple's /usr/bin/osascript program to launch FlexColor (if necessary) and then send it a simulated keystroke.
Zerene Stacker can also be made to simulate keystrokes and mouse actions by itself, even on Windows systems. This is useful for driving third party applications that are not prepared to be launched or controlled by command line actions.
Simulated events are produced by a specially formatted “External trigger command” that starts with “robot:” and continues with a list of the events to be simulated. For example, the following command simulates moving the mouse to screen coordinate (500,200), pressing and releasing the left mouse button, then pressing and releasing the shift and “n” keys to type a capital “N”:
robot: MM 500 200 MP 16 MR 16 KP 16 KP 78 KR 78 KR 16
As illustrated by this example, the capability is powerful but cryptic. It relies on knowing “magic values” utilized by the Java class named java.awt.Robot. As used in this example, the first two 16's refer to mouse button 1, the second two 16's refer to the shift key, and the 78's refer to the “n” key. Commonly used values include:
|Mouse Button 1 mask||16|
|Mouse Button 2 mask||8|
|Mouse Button 3 mask||4|
Values for other keys are given in the list of Java constants for the KeyEvent class, HERE.
Supported events are:
|Long Form||Short Form||Parameters|
|KeyPress||KP||key number (from KeyEvent class)|
|KeyRelease||KR||key number (from KeyEvent class)|
|MouseMove||MM||pixel coordinates (X Y)|
|MousePress||MP||button mask value (from InputEvent class)|
|MouseRelease||MR||button mask value (from InputEvent class)|
|MouseWheel||MW||number of increments|
Caution: Be sure to use press and release events in matched pairs. If you tell the robot to press a key but not to release it, then the computer will continue to act as if the key is held down, even outside Zerene Stacker. The resulting behavior can be quite confusing, particularly if the key that's being “held down” is a modifier like Shift or Ctrl.
Note: The simplest way to determine screen coordinates is use your computer's screen capture facility to grab an image of the entire screen, then pull that image into Photoshop or some equivalent program. Pixel coordinates reported by Photoshop, with 0,0 at the upper left of the screen, are the same coordinates needed by Zerene Stacker's robot facility.