Last active
October 24, 2024 02:32
-
-
Save scateu/0c196b5a86c0f5c31f28fc150a29056d to your computer and use it in GitHub Desktop.
pbpaste2keynote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- credit: ChatGPT. | |
-- This script fetch text from pasteboard and append to the end of opened Keynote. | |
-- If multiple Keynote opened, the most front will be selected. | |
-- Usage: Open it in Script Editor.app, export it as an Applcation. Then drag it into Dock. | |
-- KNOWN BUG: "shortcuts not allowed to sent keystroke, system events blahblah', just kill "System Events" from Activity Monitor. | |
-- tell application "System Events" to keystroke "c" using command down | |
tell application "System Events" | |
if not (exists (processes where name is "Keynote")) then | |
display dialog "Keynote is not running." buttons {"OK"} default button "OK" | |
return | |
end if | |
end tell | |
-- set clipboardInfo to clipboard info | |
-- set theClipboard to the clipboard as record | |
-- if clipboardInfo contains {"«class utf8»", "string"} then | |
-- set myText to make new text item at end of text items with properties {object text:theClipboard} | |
-- set the position of myText to {100, 100} -- Adjust position as needed | |
-- else if clipboardInfo contains "TIFF" then | |
-- -- set myImage to make new image with properties {file type:clipboard} | |
-- tell application "System Events" to keystroke "v" using command down | |
-- end if | |
tell application "Keynote" | |
activate | |
if (count of documents) = 0 then | |
display dialog "No Keynote documents are open." buttons {"OK"} default button "OK" | |
return | |
end if | |
tell document 1 | |
set newSlide to make new slide with properties {base layout:slide layout "Blank"} at end of slides | |
tell newSlide | |
tell application "System Events" to keystroke "v" using command down | |
end tell | |
end tell | |
end tell | |
tell application "System Events" to keystroke (ASCII character 9) using command down -- Cmd-Tab |
Author
scateu
commented
Oct 23, 2024
- https://iworkautomation.com/keynote/slide-default-text.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment