Flipsos Posted August 26, 2015 Share Posted August 26, 2015 Is this possible? Basically I'm trying to invoke the keyboard shortcut alt shift left-arrow to select the word to the left of the cursor key. Then I want to start Alfred with the keyword "spell" and the just selected word. That would make a nice and simple spell checker (I hate the automated one). I could assign the whole workflow to a shortcut. Is this somehow possible? Link to comment
deanishe Posted August 28, 2015 Share Posted August 28, 2015 If you add a Hotkey Trigger to a workflow, you'll see it has an Argument option. You can set this to "Selection in OS X". Add such a Hotkey Trigger and connect it to a Run Script Action. Set Language to "/usr/bin/osascript" and paste the following into the Script box: tell application "Alfred 2" to search "spell {query}" Combining both actions (selecting text and running Alfred) would be relatively complex with Alfred, and less flexible (it would only work with the word just before the cursor). I'd recommend Keyboard Maestro for something like that. Link to comment
Flipsos Posted August 28, 2015 Author Share Posted August 28, 2015 (edited) Thanks for your message deanishe. I posted a screenshot of a version that actually does what I want. Only downside is that when I invoke the shortcut I get a pop sound, that you would get when you try to do a shortcut that is not available. This is because when I invoke the shortcut nothing is selected and I try to push the selection into the Script. I'm aware that I'm not using it but else the workflow won't work. It's a hacky implementation but maybe somebody has an idea how to fix it? Edited August 28, 2015 by Flipsos Link to comment
deanishe Posted August 28, 2015 Share Posted August 28, 2015 You could try adding short delays between the simulated keypresses. Such actions in AppleScript are asynchronous, so it's possible your script is proceeding before the intended action has been carried out. You can also access the keyboard contents directly from AppleScript without having to simulate CMD+V to send the text to Alfred. Link to comment
Flipsos Posted August 29, 2015 Author Share Posted August 29, 2015 I finally got it to work as expected. Thanks deanishe for your help! http://www.alfredforum.com/topic/7294-spelll-check-spelling-of-last-typed-word/ 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