Jump to content

Recommended Posts

Posted (edited)

I'd like to make a spell check helper.  Basically a keyboard shortcut driven auto-correct spell checker.  

 

1.) User selects text

2.) Issue a keyboard shortcut or some simple trigger

3.) Take the highlighted text and make an API call to some service (maybe this or something similar) and get the suggested correct spelling

4.) Parse the response of the API call 

5.) Paste that new text overtop of the selected text

It's like a spell check that will work anywhere on the computer.  Has anyone done anything like this?  It seems like it could be possible.  The trick part I think would be making the API call and parsing the response.  I've built many work flows in Alfred before, but I haven't tried this one yet. 

What's the best way to do this?  I'm thinking to either trigger a script, apple script, or just a terminal command.  I didn't see any built in API related features in Alfred.  


This makes me wonder.  Is there a timeout for an action?  I haven't ever used Alfred to trigger a script.  What happens if the API call takes 30 seconds.  I could assume it failed and change screens only to have the text paste somewhere else undesirable.  

Edited by 2Pants

Share this post


Link to post
Posted (edited)
4 hours ago, 2Pants said:

Is there a timeout for an action?

 

No. I believe Alfred will only ever kill your workflow process if you've configured it to do so.

 

4 hours ago, 2Pants said:

I didn't see any built in API related features in Alfred.

 

There aren't any. Alfred allows you to write workflows in basically any programming language. Pick one with a good HTTP library.

 

4 hours ago, 2Pants said:

What happens if the API call takes 30 seconds.  I could assume it failed and change screens only to have the text paste somewhere else undesirable.

 

That's up to you to figure out, tbh. You might, for example, check that the same application is still active before you paste content.

 

Personally, I'd use a locally-installed spellchecker, not an API. Either something like hunspell (which you can install via Homebrew) or Apple's own spellcheck API. There's no point uploading stuff to the cloud when it isn't necessary, and local is almost always faster. And free.

Edited by deanishe

Share this post


Link to post
7 hours ago, deanishe said:

There aren't any. Alfred allows you to write workflows in basically any programming language. Pick one with a good HTTP library.

 

Great idea!  I prefer python.  

 

 

Quote

Personally, I'd use a locally-installed spellchecker, not an API. Either something like hunspell (which you can install via Homebrew) or Apple's own spellcheck API. There's no point uploading stuff to the cloud when it isn't necessary, and local is almost always faster. And free.

 

Great idea!  Didn't think of that one.  That would save a lot of delays.  

Share this post


Link to post
20 hours ago, 2Pants said:

Has anyone done anything like this?

 

Yes, you’ve described exactly how CheckSpelling works. Though the API hasn’t been working for a bit, despite the service looking like it’s still up. As a Workflow, it’s dirt simple: a few lines of bash with a curl command is most of what you need.

 

16 hours ago, deanishe said:

Personally, I'd use a locally-installed spellchecker, not an API.

 

I should do that instead for the next version. Who knows why I went the API route seven years ago. Though I remember I chose that one specifically because it did not require signing up for an API key.

 

16 hours ago, deanishe said:

or Apple's own spellcheck API

 

That requires diving into their frameworks (Appkit), does it not? I’m guessing they don’t provide a CLI tool for it.

Share this post


Link to post
1 hour ago, vitor said:

That requires diving into their frameworks (Appkit), does it not?

 

Yup. I've only glanced at the spelling API, but it looks like it might be for GUI apps only.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...