Skip to content

Instantly share code, notes, and snippets.

@melmatsuoka
Last active July 10, 2023 14:23
Show Gist options
  • Save melmatsuoka/0006dee17000d1e032923798c8ae5836 to your computer and use it in GitHub Desktop.
Save melmatsuoka/0006dee17000d1e032923798c8ae5836 to your computer and use it in GitHub Desktop.
AppleScript that uses GUI Scripting to toggle the "Position Lock" button in the Edit page (as of Resolve 18.1.4, you can't map a keyboard shortcut to this in the native keyboard Shortcuts prefs). This also requires 'clicliclick' (available from Homebrew). Note that the checkbox index is unfortunately a moving target in Resolve. In Resolve 18.1.4…
(*
AppleScript example that uses GUI Scripting to toggle the "Position Lock" button in the Edit page
(as of Resolve 18.1.4, you can't map a keyboard shortcut to this in the native keyboard Shortcuts
prefs).
This also requires 'cliclick' (available from Homebrew).
Note that the checkbox index is unfortunately a moving target in Resolve. In Resolve 18.1.4,
"checkbox 21" will target the Position Lock button ONLY if the "Media Pool" and "Edit Index" panels
are open in the Edit Page. If any other panels are open, the checkbox index will change!
*)
global xPos
global yPos
activate application "DaVinci Resolve"
tell application "System Events"
tell process "DaVinci Resolve"
try
tell checkbox 21 of group 1 of window 1
set {xPosition, yPosition} to position
set {xSize, ySize} to size
end tell
-- modify offsets if hot spot is not centered:
set xPos to xPosition + (xSize div 2)
set yPos to yPosition + (ySize div 2)
end try
end tell
end tell
-- note this shell command must be outside of the try/tell block,
-- otherwise you'll get a -10004 error. S
-- See: https://discussions.apple.com/thread/4719415
-- I use "cliclick" (available via Homebrew) for the actual click action,
-- as the AppleScript "click at" command doesn't seem to work reliably
-- on new versions of macOS.
do shell script "/opt/homebrew/bin/cliclick m:" & xPos & "," & yPos
do shell script "/opt/homebrew/bin/cliclick c:."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment