Using NSEvent.h (mac key events) in Monkey?

Monkey Forums/Monkey Programming/Using NSEvent.h (mac key events) in Monkey?

Mamoruanime(Posted 2014) [#1]
NSEvent.h allows the application to send keyboard/mouse events to the system.

Before anyone asks it's not for a hacking tool or anything along those lines- I want to run a bot as an experiment that presses keys in another game to see how far it can get in a 24 hour period.

The problem isn't setting it up to press the keys at an interval or anything along those lines; I've used Blitz and Monkey for years now, but I've never considered actually controlling global keyboard presses (and I've never ventured too far outside of what Blitz does out-of-the-box, so externs and such are new to me), and I can't find any functions that do this. Any suggestions/directions to point me in to figure it out?

EDIT: NSEvent.h is apparently what I want to use, specifically the following function - CGEventCreateKeyboardEvent:CGEventRef(source:CGEventSourceRef, virtualKey:CGKeyCode, keyDown:bool)

I'm not entirely sure how to properly import NSEvent.h though. If I simply do "import NSEvent.h", Monkey won't throw an error (at least not until I try to use anything related to it). I figure if it's not actually able to import NSEvent.h it'd error the moment it tries, so I'm thinking it's making a connection there. I'm just not entirely sure how to properly use externs so I can use CGEventCreateKeyboardEvent. It throws a fit with anything referencing the CGEventRef, CGEventSourceRef, and CGKeyCode classes.