Nooblet Posted June 20, 2020 Share Posted June 20, 2020 I would just like to know if the following would be possible within a workflow or if I would need to use some external program as well: I want to set up hotkeys that will paste clipboard item 1, 2, 3, etc.. the only difference is I would like the pasted content to be selected when it is pasted. Why? I would effectively be able to scroll through the recent clipboard history inline. I wouldn't matter if I accidentally paste clipboard item 3 when I wanted #2 because by clicking the hotkey for clipboard Item 2 that would take its place. Basically a 'soft' paste function. Default: Three key presses Hotkey1, Hotkey2, Hotkey3: CI #1 CI #2 CI #3 Pastes three items What I want: Three key presses Hotkey1, Hotkey2, Hotkey3: CI #1 CI #2 CI #3 Pastes last item only. Sorry if I'm being redundant just trying my best to be clear. Thank you! Link to comment
deanishe Posted June 20, 2020 Share Posted June 20, 2020 1 hour ago, Nooblet said: the only difference is I would like the pasted content to be selected when it is pasted That's going to be tricky to do because to select text, you'd have to simulate keyboard shortcuts, and you'd therefore need to know how long the text you're inserting is in order to simulate the right number of keypresses. Essentially, you're going to have to code that up yourself in AppleScript or JXA. Nooblet 1 Link to comment
Nooblet Posted June 20, 2020 Author Share Posted June 20, 2020 Ah, I was hoping there would be some magical select paste function that would solve all my problems. It sounds like I won't be able to tackle this for some time. But to make sure I've got the right idea: At minimum I would need to write something that reads the content of the clipboard before pasting and acts appropriately based on what it read. If it were python(Only language I'm familiar with atm) I would need to do the equivalent of grab the length of the clipboard contents about to be pasted, then simulate shift + left arrow presses for the number that the len() function returned, that about right? Link to comment
deanishe Posted June 20, 2020 Share Posted June 20, 2020 58 minutes ago, Nooblet said: At minimum I would need to write something that reads the content of the clipboard before pasting and acts appropriately based on what it read. If it were python(Only language I'm familiar with atm) I would need to do the equivalent of grab the length of the clipboard contents about to be pasted, then simulate shift + left arrow presses for the number that the len() function returned, that about right? You don't need to read the clipboard because you can have Alfred pass the clipboard contents to your script with its {clipboard:N} macro. But "yes" to the rest. Although you probably don't want to try simulating keypresses with Python, as it's much easier to do with AppleScript/JXA. It's also going to suck with long snippets because selecting the text that way is slow. Link to comment
Nooblet Posted June 20, 2020 Author Share Posted June 20, 2020 Thank you! I imagine that would be very slow. It might just be something I toggle on when I'm doing schoolwork since I often work with short snippets and images when making flashcards. Thanks again, you were very helpful. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now