I’m looking for a way to save and restore pre-existing clipboard data.
I have a few Studio projects that use UI scripting. Sending text to a non-scriptable control by pasting from the clipboard is significantly faster than using the Keystroke command. What I’d like to do is store the complete contents of pasteboard “general”, execute my UI stuff, then repopulate the pasteboard with the archived values.
Because my goal is to leave the clipboard data as I found it, this needs to work with any kind of clipboard data. The problems I’m having relate to complex data being dumbed down. For example, an image copied from Safari becomes a plain text URL after storing and retrieving. Conceptually, moving a big lump of data should be possible, regardless of supported formats.
One other related question: Is the list returned by types of pasteboard “general” prioritized? If I had to pick one of the returned types, how would I know which was best?
The problem is I want to essentially buffer whatever is in there, use the clipboard for a UI call, then restore the previous contents. I don’t need to use any of the existing pasteboard data, I just need to be sure I can reconstruct it when I’m done. The Safari image was just an example, the pasteboard contents could be any type of data, from any application.
I also played with basic AppleScript clipboard commands, but they’re more limited than Studio’s pasteboard commands.