Created
June 1, 2019 17:11
-
-
Save AhiyaHiya/2a111a1f28b376544b6bb20839b743e3 to your computer and use it in GitHub Desktop.
Older code, showing how to send keystrokes to FileMaker Pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGPoint curpos; | |
CGEventRef evntRef; | |
ProcessSerialNumber procSerialNo; | |
ProcessInfoRec procInfoStruc; | |
OSStatus err; | |
procSerialNo.highLongOfPSN = 0; | |
procSerialNo.lowLongOfPSN = kNoProcess; | |
procInfoStruc.processInfoLength = sizeof(ProcessInfoRec); | |
procInfoStruc.processName = NULL; | |
procInfoStruc.processAppSpec = NULL; | |
procInfoStruc.processLocation = NULL; | |
// we are going to switch to filemaker and click on the first box | |
curpos.x = _mouseCrd[0].x; | |
curpos.y = _mouseCrd[0].y; | |
// get filemaker process serial number | |
_ready = 0; | |
do { | |
err = GetNextProcess(&procSerialNo); | |
if (err == noErr) { | |
err = GetProcessInformation(&procSerialNo, &procInfoStruc); | |
if (procInfoStruc.processSignature == 'ARPZ') { | |
_ready = 1; | |
} | |
} | |
} while (_ready == 0); | |
// switch to filemaker | |
CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)55, TRUE); // cmd | |
CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)48, TRUE); // Tab | |
CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)48, FALSE); | |
CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)55, FALSE); | |
// mouse double click | |
evntRef = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, curpos, kCGMouseButtonLeft); | |
CGEventPostToPSN(&procSerialNo, evntRef); | |
evntRef = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseUp, curpos, kCGMouseButtonLeft); | |
CGEventPostToPSN(&procSerialNo, evntRef); | |
evntRef = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, curpos, kCGMouseButtonLeft); | |
CGEventPostToPSN(&procSerialNo, evntRef); | |
evntRef = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseUp, curpos, kCGMouseButtonLeft); | |
CGEventPostToPSN(&procSerialNo, evntRef); | |
CFRelease(evntRef); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment