Skip to content

Instantly share code, notes, and snippets.

@motoishmz
Last active November 24, 2024 19:27
Show Gist options
  • Save motoishmz/52553c1c3ac0e6bff31202a577be6cd6 to your computer and use it in GitHub Desktop.
Save motoishmz/52553c1c3ac0e6bff31202a577be6cd6 to your computer and use it in GitHub Desktop.
AppleScript + Keynote
tell application "Keynote"
activate
if not (exists document 1) then error number -128
try
if playing is false then start the front document
end try
tell the front document -- or "tell document 1"
-- my console_log("slide number of current slide: " & slide number of current slide, "my_log")
-- my console_log("slide number of last slide: " & slide number of last slide, "my_log")
if slide number of current slide is less than slide number of last slide then
show next
end if
end tell
end tell
to console_log(log_string, log_file)
do shell script ¬
"echo `date '+%Y-%m-%d %T: '`\"" & log_string & ¬
"\" >> $HOME/Desktop/" & log_file & ".txt"
end console_log
tell application "Keynote"
activate
if not (exists document 1) then error number -128
try
if playing is false then start the front document
end try
tell the front document -- or "tell document 1"
-- my console_log("slide number of current slide: " & slide number of current slide, "my_log")
-- my console_log("slide number of last slide: " & slide number of last slide, "my_log")
if slide number of current slide is not equal to slide number of first slide then
show previous
end if
end tell
end tell
to console_log(log_string, log_file)
do shell script ¬
"echo `date '+%Y-%m-%d %T: '`\"" & log_string & ¬
"\" >> $HOME/Desktop/" & log_file & ".txt"
end console_log
-- usage
-- $ osascript move_to_specific_slide.scpt 2 # SlideNumber
on run argv
tell application "Keynote"
activate
if not (exists document 1) then error number -128
stop document 1 -- fuck
tell document 1
-- set sliderNumber to 2
set sliderNumber to (item 1 of argv) as integer
if sliderNumber is greater than 0 and sliderNumber is less than ((slide number of last slide) + 1) then
start from slide sliderNumber
end if
end tell
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment