For the impatient:
- determine the relative coordinates for the cropped screenshot
- determine the coordinates of the mouse click
- compile click.m using cc
- run the shell script
| // File: | |
| // click.m | |
| // | |
| // Compile with: | |
| // gcc -o click click.m -framework ApplicationServices -framework Foundation | |
| // | |
| // Usage: | |
| // ./click -x pixels -y pixels | |
| // At the given coordinates it will click and release. | |
| // | |
| // From http://hints.macworld.com/article.php?story=2008051406323031 | |
| // and | |
| // https://stackoverflow.com/a/26687223/1164295 | |
| #import <Foundation/Foundation.h> | |
| #import <ApplicationServices/ApplicationServices.h> | |
| int main(int argc, char *argv[]) { | |
| NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
| NSUserDefaults *args = [NSUserDefaults standardUserDefaults]; | |
| int x = [args integerForKey:@"x"]; | |
| int y = [args integerForKey:@"y"]; | |
| CGPoint pt; | |
| pt.x = x; | |
| pt.y = y; | |
| CGPostMouseEvent( pt, 1, 1, 1 ); | |
| CGPostMouseEvent( pt, 1, 1, 0 ); | |
| [pool release]; | |
| return 0; | |
| } |
| #!/usr/bin/env bash | |
| # move the mouse to the relevant window and location | |
| ./click -x 1212 -y 777 | |
| # how many screenshots to take | |
| for index in `seq -w 1 270`; do | |
| echo slide $index | |
| sleep 4 | |
| screencapture -x -R150,120,1130,700 slide_${index}.png | |
| ./click -x 1212 -y 777 | |
| done |