Coordinates Question

Hi all! I just need to ask a simple question regarding the python positions for posx and posy.

Where is the starting point for these references? Is it the bottom left hand corner of the screen?

Would be nice if you share the used library with us. There is no standard rule because when using PyObjC it will be top left and when using math based libraries it is bottom left. Without example code it’s really hard to tell :expressionless:

Sorry. I should have included the script. I’m trying to adapt this widely used mouse click script to automate a video transition.

I have the following saved as a Service and then assigned to a function key.

on run {input, parameters}
	
	activate application "ATEM Software Control"
	tell application "System Events"
		tell process "switchergui"
			activate
		end tell
	end tell
	
	set x to 1259
	
	set y to 966
	
	
	
	do shell script "

/usr/bin/python <<END

import sys

import time

from Quartz.CoreGraphics import *

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):

          mouseEvent(kCGEventLeftMouseDown, posx,posy);

          mouseEvent(kCGEventLeftMouseUp, posx,posy);

ourEvent = CGEventCreate(None);

currentpos=CGEventGetLocation(ourEvent);             # Save current mouse position

mouseclick(" & x & "," & y & ");

mousemove(int(currentpos.x),int(currentpos.y));      # Restore mouse position

END"
	
	activate application "ProPresenter 5"
	
	
	return input
end run

I think you answered my question about the coordinates, which is great and thanks for that! Now I’m getting an error message like this.

sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `

/usr/bin/python <<END

import sys

import time

from Quartz.CoreGraphics import *

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):

          mouseEvent(kCGEventLeftMouseDown, posx,posy);

          mouseEvent(kCGEventLeftMouseUp, posx,posy);

ourEvent = CGEventCreate(None);

currentpos=CGEventGetLocation(ourEvent);             # Save current mouse position

mouseclick(1259,966);

mousemove(int(currentpos.x),int(currentpos.y));      # Restore mouse position

END'

I see that you have borrowed parts of my code from this post. The problem is that you have changed the markup and indentation of my original code. Python uses indentation for scope like other programming languages uses curly braces or an end keyword as in AppleScript.

Indeed I did sir. Thank you! You’ve written a great piece of code. I’m sure you’re aware that it’s been shared far and wide!