Open gingerbeardman opened 2 years ago
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
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
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'
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