Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support coordinates from right and bottom #133

Open
gingerbeardman opened this issue Dec 9, 2021 · 3 comments
Open

Support coordinates from right and bottom #133

gingerbeardman opened this issue Dec 9, 2021 · 3 comments

Comments

@gingerbeardman
Copy link

gingerbeardman commented Dec 9, 2021

It would be great to be able to specify co-ordinates from the right and bottom of the screen as well as the top and left.

This way, I can make sure my script that clicks something in the top right corner works on monitors of all sizes.

Currently my options seem to be

  • hard-code the value from to left (which will vary on other monitors)
  • move the mouse an extreme distance so it get trapped by the right edge and then move negative (seems like an ugly hack)
@BlueM
Copy link
Owner

BlueM commented Dec 22, 2021

There is another option: ask the system for the screen size.

osascript -e 'tell application "Finder" to get bounds of window of desktop' 

… will return X1, Y1, X2, Y2. So the top right corner could be clicked (written as a one-line) using …

cliclick -e 200 c:$( osascript -e 'tell application "Finder" to get bounds of window of desktop' | awk '{ print $3 }')0

@gingerbeardman
Copy link
Author

gingerbeardman commented Dec 22, 2021

Love it!

For anybody else, this line:

osascript -e 'tell application "Finder" to get bounds of window of desktop' | awk '{ print $3 }'

returns: 1080, (for my display)

...so the line ends 0 rather than ,0

@BlueM
Copy link
Owner

BlueM commented Dec 23, 2021

Just for the record: the awk invocation is just one example of splitting the result. A “cleaner” one would be …

osascript -e 'tell app "Finder" to get bounds of window of desktop' | cut -d ',' -f3 | xargs echo -n

… which will result in a plain number without comma. Or the AppleScriptish way:

osascript -e 'tell app "Finder" to set d to bounds of window of desktop' -e 'item 3 of d'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants