JGC Posted August 1, 2018 Share Posted August 1, 2018 (edited) Is it possible to create a workflow in Alfred that does the following? - Copy selected text to clipboard - Switch to last used app - Paste text from clipboard - Switch back to the first app This is an action I've realised I do lots of times a day. If it isn't possible, and I suspect it isn't in Alfred, has anyone come across a different app that can do this? Many thanks. Edited August 1, 2018 by vitor Moved title to post content Link to comment
vitor Posted August 1, 2018 Share Posted August 1, 2018 When making a post, please always make a descriptive title. What you wish to accomplish can be boiled down to a series of keyboard shortcuts: ⌘C, ⌘⇥, ⌘V, ⌘⇥. While it’d be better do to it programatically, I’m not certain if Apple gives us easy access to the order of open apps. If you always do this operation with the same two apps, then that’d be helpful information and we could do something better. Otherwise, check Hotkey Triggers to start the Workflow with the selection, the Dispatch Key Combo Output to press the keys, the Delay Utility so things don’t fire too quickly (an unfortunate effect of GUI scripting) and the Copy to Clipboard Output to paste. It’ll also work if you just chain a bunch of Dispatch Key Combo Output and Delay Utility, though. Link to comment
JGC Posted August 3, 2018 Author Share Posted August 3, 2018 Thanks, @vitor. The problem is that ⌘⇥ can't be issued by the 'Key Combo' action. I can't see an action that can do this, but perhaps there's a 'System Command' or AppleScript that can do it? Link to comment
vitor Posted August 3, 2018 Share Posted August 3, 2018 21 minutes ago, JGC said: or AppleScript that can do it? tell application "System Events" to key code 48 using {command down} Link to comment
JGC Posted August 3, 2018 Author Share Posted August 3, 2018 Thanks so much, @vitor. I've implemented that, including one second delays, and it works on my laptop (though for some reason not on my MacMini yet). Posting screenshot of it here in case others can use it. Link to comment
CJK Posted August 8, 2018 Share Posted August 8, 2018 @JGC, is there a specific reason you've used Run NSAppleScript actions instead of Run Script ? If not, the latter is the one you want. Link to comment
JGC Posted August 11, 2018 Author Share Posted August 11, 2018 No reason, other than someone else suggested it. What's the reason for favouring 'Run Script'? Link to comment
dfay Posted August 12, 2018 Share Posted August 12, 2018 It runs on a separate thread in the background. 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