Vous pouvez utiliser Automate / Apple script pour cela avec Outils de la souris en ligne de commande.
Vous pouvez obtenir Outils de la souris de ici . Il s'agit d'un petit outil permettant de déplacer le pointeur de la souris et d'effectuer des clics.
[-h] return this help text
[-b] coordinates are measured from bottom-left corner of the screen
[-location] return the current mouse location
[-x "xValue" -y "yValue"] move the mouse to the {xValue, yValue} location
[-mouseSteps numSteps] move mouse in number-of-steps to the location
[-leftClick] perform a mouse left-click at the current mouse location
[-doubleLeftClick] perform a mouse double-click with the left mouse button
[-rightClick] perform a mouse right-click at the current mouse location
[-shiftKey] shift key down, useful when performing a left-click event
[-commandKey] command key down, useful when performing a left-click event
[-optionKey] option key down, useful when performing a left-click event
[-controlKey] control key down, useful when performing a left-click event
[-leftClickNoRelease] perform a mouse click and do not release the mouse click
[-releaseMouse] release the mouse after using -leftClickNoRelease
Créez ensuite un Automate Le flux de travail en tant que service. Définissez "No input" comme entrée et "Preview" comme application. Ajoutez ceci Apple script là :
on run {input, parameters}
tell application "Preview" to activate
delay 1
set mouseToolsPath to (path to home folder as text) & "Downloads:MouseTools"
tell application "Preview"
set _b to bounds of the front window
set _x to item 1 of _b
set _y to item 2 of _b
set _width to item 3 of _b
end tell
set xpos to _x + (_width / 2)
set ypos to _y + 10
do shell script quoted form of POSIX path of mouseToolsPath & " -x " & (xpos as text) & " -y " & (ypos as text)
do shell script quoted form of POSIX path of mouseToolsPath & " -leftClick"
return input
end run
Dans ce cas, mon MouseTools binaire est en Downloads
répertoire. Enregistrez-le et donnez-lui un nom dont vous vous souviendrez. Attribuez un raccourci clavier à ce service dans Preferences.app sous Clavier -> Raccourcis .
J'ai testé cela et cela fonctionne pour moi.