Jump to content
GuiB

Cardhop Workflow

Recommended Posts

I played around with Cardhop and here is a workflow that I made. I wanted to get more time before sending some workflows to the forum to setup a repository and with an auto-update to the workflow, but I didn't have the time yet for that. And since some people mentioned that they would like a workflow for Cardhop, here is one!

 

Features:

  • Keyword "chc" : Search a contact in Alfred and open it in Cardhop
  • Keyword "chs" or hotkey : Send the query to Cardhop. If the query is empty, it tries to get the selection from the front application and send it to Carhop (In short, you can select the contact information on it's website or email and call "chs" from Alfred and the selection should be sent directly to Cardhop). You can use this action to send the selection or pass a string to your Favorites list (alternative to keyword: chf) or to the Cardhop's Actions (alternative to keyword: cha).
  • Keyword "chf" : Send a string from your Favorites list directly to Cardhop (could be used as a Snippets/Bookmarks list to rapidly write a query to Cardhop that you know gives you the right information in it without the need to write it all). Write your list in the Workflow Environment Variables "Favorites" and separated by semicolon (";"). Ex: Call mom home;Mail boss work;facetime Complicated Name;website businessName;/MyTag;Direction dentist... A variable "{q}" could be used to have a placeholder for a string that you want to set just before sending to Cardhop (ex: "Email {q} work" where {q} could be changed to any name at the time that you invoke the workflow). Tip: To directly activate an action in Cardhop, it seems to delay the input until it has done parsing the query, so you can rapidly press Enter a second time when you select an item from your Favorites list in Alfred and it should run the first action that Cardhop returns.
  • Keyword "cha" : Show a list of possible Carhop actions. If arriving to this function using the Send feature (chs), then the selection or query would be appended to the Cardhop action before sending it.
  • Hotkey to Send selection to Cardhop : If you prefer to send the selection directly to Cardhop with a hotkey instead of a keyword
  • Fallback search to send the query to Cardhop : If you want to write the information directly in Alfred without any keyword before. To make it works, you would need to add the Fallback search into the Alfred Preferences at: "Features/Default Results/Setup fallback results/+/Workflow Trigger/Send to Cardhop"
  • External trigger to send a string to Cardhop from an external script. Other external triggers are set if you want to pop the Favorites list or Actions list from an external script.
  • Append/Prepend string : Add a string before or after the main string before sending using a predefined list or any string if the query doesn't match an item in the list (Could be useful to have a list of predefined group/tags) (See "Workflow Environment Variables" and "Navigation" lists below)


Workflow Environment Variables:

  • Favorites List: See keyword "chf" above
  • AppendToSend : Set a predefined list of string to append using the Append feature (ALT key)
  • PrependToSend : Set a predefined list of string to prepend using the Prepend feature (CTRL key)


Navigation:

  • CMD key : Go to the Send feature Actions List (chs)
  • ALT key : Activate the selected item and append extra string (using the AppendToSend list)
  • CTRL key : Activate the selected item and prepend extra string (using the PrependToSend list)

 

Tip: If you want to use Cardhop as the application to open from Alfred when you are viewing a contact with the Alfred Contact Viewer and press CMD+O: Insert "x-cardhop://show?id={uid}" into the Alfred Preferences at "Features/Contacts/Advanced/URL Handler" instead of using "addressbook://{uid}". This should do the same as the keyword "chc" but without the need to write the keyword before searching for a contact and use directly the built-in contact search of Alfred

 

Download Link (latest version): https://d.pr/f/rQTPtu

 

Have fun!

Edited by GuiB
Updated the download link to version 1.2.5

Share this post


Link to post

Update Version 1.1.0

 

New Feature:

  • Keyword "chf" : Send a string from your Favorites list directly to Cardhop (could be used as a Snippets/Bookmarks list to rapidly write a query to Cardhop that you know gives you the right information in it without the need to write it all). Write your list in the Workflow Environment Variables "Favorites" and separated by semicolon (";").

 

Example on how to insert items in the Workflow Environment Variable "Favorites":

Call mom home;Mail boss work;facetime Complicated Name;website businessName;/MyTag;Direction dentist

 

Tip: To directly activate an action in Cardhop: it seems to delay the input until it has done parsing the query, so you can rapidly press Enter a second time when you select an item from your Favorites list in Alfred and it should run the first action that Cardhop returns.

 

Download link: https://nofile.io/f/vkgor7xxgvn/gbCardhop.alfredworkflow

 

Edited by GuiB

Share this post


Link to post

Wow, GuiB, this workflow is a DREAM. Exactly what I hoped would happen with Alfred, and enough to push me over into buying Cardhop after the trial. Thank you for making it!

Share this post


Link to post

@able, thanks for your kind word! And yes, Cardhop input field is already nice to work with, but I think this workflow gives just enough little extras to make it more convenient and faster :)

Share this post


Link to post

Update Version 1.2.0

 

Big update, many more features and faster...

 

New Features:

  • Keyword "chs" or Hotkey: Added items to go to the Favorites or Actions list
  • Keyword "cha" : Show a list of possible Carhop actions. If arriving to this function using the Send feature (chs), then the selection or query would be appended to the Cardhop action before sending it. (Could be used as an easy way to remember possible actions that can be done with Cardhop)
  • Favorites List : A new variable "{q}" could be used to have a placeholder for a string that you want to set just before sending to Cardhop (ex: "Email {q} work" where {q} could be changed to any name at the time that you invoke the workflow).
  • Append/Prepend string : Add a string before or after the main string before sending using a predefined list or any string if the query doesn't match an item in the list (Could be useful to have a list of predefined group/tags: /Business;/Friends...)

New Workflow Environment Variables:

  • AppendToSend : Set a predefined list of string (separated by semicolon ";") to append using the Append feature (ALT key)
  • PrependToSend : Set a predefined list of string (separated by semicolon ";")  to prepend using the Prepend feature (CTRL key)

Navigation:

  • CMD key : Go to the Send feature Actions List (chs)
  • ALT key : Activate the selected item and append extra string (using the AppendToSend list)
  • CTRL key : Activate the selected item and prepend extra string (using the PrependToSend list)

 

Download link: https://nofile.io/f/A5joYTcGU88/gbCardhop.alfredworkflow

Edited by GuiB

Share this post


Link to post

Me: "I don't think that learning how to set up workflows and scripts is going to be that difficult."

5ac4f23c3c9aa_ScreenShot2018-04-04at10_41_17AM.png.70c4ae5c18ccb8b30b4c581da7e5cd4d.png

Also me: [spits out coffee]

 

Thanks for making this! 

Share this post


Link to post

This workflow is great! I have one issue though: Cardhop crashes when sending a command including any Swedish characters (å, ä, and ö), e.g. 'chs text jönsson'. Cardhop works fine if I write the same command ('text jönsson') directly into the application, so I figure that the crash is related to how the workflow treats international characters. I guess users working in other languages may be affected, too, so it would be great if this can be fixed (I'm using version 1.2.1 of the workflow with Alfred 3.6.1 on macOS 10.13.4).

Share this post


Link to post
31 minutes ago, cands said:

I guess users working in other languages may be affected, too

 

English, too, tbh. The workflow is failing because it’s trying to use encoded strings, but Python’s json module is Unicode. So it dies in flames when given non-ASCII input.

 

At minimum, every query variable needs decoding. Ideally, all Python strings should be converted to Unicode strings, not encoded strings.

Share this post


Link to post

@cands , yes this was a problem with unicode encoding. Here is a new version that should fix the issue (it's working on my side, let me know if you get any other issues!)

 

https://nofile.io/f/RtSBb1n8st5/gbCardhop.alfredworkflow

 

@deanishe, it didn't seem to cause problems with the json output, but more to Cardhop since I tried normalizing the output that sends to Cardhop and it was working as well, but I now normalize the inputs to make sure and it's working also. The problem seemed more that Cardhop want NFC type of unicode or crash

Share this post


Link to post

@Eukaryote, haha thanks :) Actually, you can make a workflow for Cardhop with just a simple Open URL object and a Keyword object to set a string to send, but I wanted to add more features than simply passing the string to Cardhop ;) Also, I'm sure there could be a method with less connections, but I've been using this kind of message passing with filtering and find it's working quite well.

 

Best wishes in trying to learn how to make workflows! :)

Share this post


Link to post
38 minutes ago, GuiB said:

 

@deanishe, it didn't seem to cause problems with the json output, but more to Cardhop since I tried normalizing the output that sends to Cardhop and it was working as well, but I now normalize the inputs to make sure and it's working also. The problem seemed more that Cardhop want NFC type of unicode or crash

 

I’m sure you’re right. I was just looking at the code in info.plist on my iPad, so I didn’t have any real context. I also can’t remember whether Andrew added PYTHONIOENCODING to Alfred, which would affect the behaviour.

 

Weird that it would want NFC considering macOS prefers NFD.

Share this post


Link to post
2 hours ago, GuiB said:

@cands , yes this was a problem with unicode encoding. Here is a new version that should fix the issue (it's working on my side, let me know if you get any other issues!)

 

https://nofile.io/f/RtSBb1n8st5/gbCardhop.alfredworkflow

 

I did some brief tests and can confirm that it seems to be working fine now with Swedish characters, thanks very much for the quick update!

Share this post


Link to post

There's a minor bug in your workflow. You need to import unicodedata into your cha script filter. This is stopping the actions list from working.

Thanks for the workflow though - awesome.

Share this post


Link to post

@Mightymuke , you are right, I did this node too fast while adding the unicode normalization this week...

 

Here is a new update with this bug fix: https://nofile.io/f/TocAqvK7JJJ/gbCardhop.alfredworkflow

 

However, now I have a bigger problem since Cardhop 1.1 added localization and English actions doesn't work when you are in another localization. So, I'll see what could be changed to make it works for everyone (extract all the localized strings from Carhop or maybe ask the Cardhop team if it would be possible to keep the English actions word working in other language (as I think I would prefer this since I'm used to write those kind of actions in English than in French: I'm used to write "mail personName" than "écrire personName", but not sure they would want this))

 

@cands, you should update to this one to have this bug fix

 

Share this post


Link to post

@michaelwills sorry for the long delay! I got too much work on my side with no free time. Things are starting to settle down

 

Sorry that the nofile.io link is not working anymore. Actually, I had a small update on my side that I needed to push here ;)

 

So here it is:

 

Update Version 1.2.5

 

What’s new:

  • Cardhop Actions list should be in your own language (I’m getting the localization from the Cardhop application directly, so you should get the same thing as in the application)
  • Some bugs fix

Download link: https://d.pr/f/rQTPtu

 

@michaelwills regarding the coffee, actually, I like pretty much all kind of coffee :) I’m not very difficult

 

All the best!

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...