after a long and party frustating search i came up with an answer when i found a python script to control the Mouse here on Stackoverflow:
The Python Script is:
from Quartz.CoreGraphics import CGEventCreateMouseEvent
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import kCGEventMouseMoved
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseUp
from Quartz.CoreGraphics import kCGMouseButtonLeft
from Quartz.CoreGraphics import kCGHIDEventTap
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(
None,
type,
(posx,posy),
kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
# uncomment this line if you want to force the mouse
# to MOVE to the click location first (I found it was not necessary).
#mouseEvent(kCGEventMouseMoved, posx,posy);
mouseEvent(kCGEventLeftMouseDown, posx,posy);
mouseEvent(kCGEventLeftMouseUp, posx,posy);
mouseclick(200,200)
I then call this script via the NativeProcess.
The Class generates the python file in the application storage directory and runs it.
I run it on the onFullscreenEvent handler.
Works like a charm here using MacOS 10.10.3
cheers!
package {
import flash.events.IOErrorEvent;
import flash.filesystem.FileStream;
import flash.filesystem.FileMode;
import flash.events.Event;
import flash.desktop.NativeProcess
import flash.events.NativeProcessExitEvent
import flash.desktop.NativeProcessStartupInfo
import flash.events.ProgressEvent;
import flash.filesystem.File;
public class MouseClick extends Object {
private static var process:NativeProcess
private static var _pythonfilepath:String
private static var _pythonfilename:String="MouseClick.py"
private static var _pythonfile:File
private static var _pythonstring:String="from Quartz.CoreGraphics import CGEventCreateMouseEvent\nfrom Quartz.CoreGraphics import CGEventPost\nfrom Quartz.CoreGraphics import kCGEventMouseMoved\nfrom Quartz.CoreGraphics import kCGEventLeftMouseDown\nfrom Quartz.CoreGraphics import kCGEventLeftMouseDown\nfrom Quartz.CoreGraphics import kCGEventLeftMouseUp\nfrom Quartz.CoreGraphics import kCGMouseButtonLeft\nfrom Quartz.CoreGraphics import kCGHIDEventTap\n\ndef mouseEvent(type, posx, posy):\n theEvent = CGEventCreateMouseEvent(\n None, \n type, \n (posx,posy), \n kCGMouseButtonLeft)\n CGEventPost(kCGHIDEventTap, theEvent)\n\ndef mousemove(posx,posy):\n mouseEvent(kCGEventMouseMoved, posx,posy);\n\ndef mouseclick(posx,posy):\n # uncomment this line if you want to force the mouse \n # to MOVE to the click location first (I found it was not necessary).\n #mouseEvent(kCGEventMouseMoved, posx,posy);\n mouseEvent(kCGEventLeftMouseDown, posx,posy);\n mouseEvent(kCGEventLeftMouseUp, posx,posy);\nmouseclick(200,200)";
public function MouseClick(){
super();
};
public static function click(): void {
_pythonfile=File.applicationStorageDirectory.resolvePath(_pythonfilename)
_pythonfilepath=_pythonfile.nativePath;
//
if(!_pythonfile.exists){
_pythonfile = new File(_pythonfilepath);
var fileStream:FileStream = new FileStream();
fileStream.open(_pythonfile, FileMode.WRITE);
fileStream.writeUTFBytes(_pythonstring);
fileStream.close();
}
var nativeProcessStartupInfo: NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = File.applicationDirectory.resolvePath("/usr/bin/python");
nativeProcessStartupInfo.executable = file;
var link =File.applicationDirectory.resolvePath("MouseClick.py").nativePath
var processArgs: Vector.<String> = new Vector.<String> ();
processArgs[0] = _pythonfilepath;
nativeProcessStartupInfo.arguments = processArgs;
process = new NativeProcess();
process.start(nativeProcessStartupInfo);
addNativeProcessListeners();
}
private static function removeNativeProcessListeners():void{
process.removeEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
process.removeEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
process.removeEventListener(NativeProcessExitEvent.EXIT, onExit);
process.removeEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);
process.removeEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, onIOError);
};
private static function addNativeProcessListeners():void{
process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
process.addEventListener(NativeProcessExitEvent.EXIT, onExit);
process.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);
process.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, onIOError);
};
public static function onOutputData(event: ProgressEvent): void {
removeNativeProcessListeners()
}
public static function onErrorData(event: ProgressEvent): void {
trace("could not send video successfully error: "+process.standardError.readUTFBytes(process.standardError.bytesAvailable),"err")
removeNativeProcessListeners()
}
public static function onExit(event: NativeProcessExitEvent): void {
removeNativeProcessListeners()
}
public static function onIOError(event: IOErrorEvent): void {
trace("could not send video successfully error onIOError: "+event.toString(),"err");
}
}
}