Create a New Contact with Keyboard Maestro and AppleScript

Ah, interesting. And I see they have a companion app for the Calendar too... "BusyCal + BusyContacts"

You can get a 30-day trial of each app at https://www.busymac.com

Also, both are available in Setapp.

1 Like

Thanks, yes. I am trying them out.

1 Like

Likewise, the handy app Interact Contact Scratchpad by the developer of Drafts is no longer for sale either.

That being said, I’ll say again that I think Cardhop is well worth the $20 to solve this problem if you want to add contacts easily.


¿Pro? Tip:

I assume everyone knows this, but just in case… if you are trying to add a business to your Contacts, use Apple Maps.

  1. Search for the business.

  2. Click on the result you want from the search results in the left sidebar.

  3. Scroll all the way down to the bottom and you will see “Create New Contact”.

Very handy, especially if you need to have it in your contacts for getting driving directions later.

4 Likes

Yes, Cardhop does it very nicely - even with some cool animation as it populates the correct fields. So, that is the way I will go. I did manage to put together an AppleScript workflow based on all the ideas above. It is here for @ccstone to look at and tell me what I could have done better :smiling_face:︎ (It does give a single dialog box where the whole address can just be pasted in - but I have to admit Cardhop is easy to use and quicker).

set varFirst to text returned of (display dialog "Enter the first name:" default answer "")
set varLast to text returned of (display dialog "Enter the last name:" default answer "")
set varCompany to text returned of (display dialog "Enter the company:" default answer "")

set {varStreet, varCity, varState, varZip, varCountry} to (inputItems for {"• Street", "• Town", "• State", "• Zip", "• Country"} with title given prompt:"Enter the following items separated by a carriage return:")

to inputItems for someItems given title:theTitle, prompt:thePrompt
 
 if thePrompt is in {true, false} then -- "with" or "without" prompt
   if thePrompt then
     set thePrompt to "Input the following items:" & return & return -- default
   else
     set thePrompt to ""
   end if
 else -- fix up the prompt a bit
   set thePrompt to thePrompt & return & return
 end if
 
 if theTitle is in {true, false} then if theTitle then -- "with" or "without" title
   set theTitle to "Multiple Input Dialog" -- default
 else
   set theTitle to ""
 end if
 
 if class of someItems is integer then -- no item list
   set {theCount, someItems} to {someItems, ""}
   if thePrompt is not "" then set thePrompt to text 1 thru -2 of thePrompt
 else
   set theCount to (count someItems)
 end if
 if theCount is less than 1 then error "inputItems handler:  empty input list"
 set {theItems, theInput} to {{}, {}}
 
 repeat theCount times -- set the number of lines in the input
   set the end of theInput to ""
 end repeat
 set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
 set {someItems, theInput} to {someItems as text, theInput as text}
 set AppleScript's text item delimiters to tempTID
 
 set theInput to paragraphs of text returned of (display dialog thePrompt & someItems with title theTitle default answer theInput)
 
 repeat with anItem from 1 to theCount -- pad/truncate entered items
   try
     set the end of theItems to (item anItem of theInput)
   on error
     set the end of theItems to ""
   end try
 end repeat
 return theItems
end inputItems

set varPhoneLabel to text returned of (display dialog "Phone Label:" default answer "mobile")
set varPhone to text returned of (display dialog "Enter the phone number:" default answer "(408) 606-5775")
set varEmailLabel to text returned of (display dialog "email Label:" default answer "email")
set varEmail to text returned of (display dialog "Enter the e-mail address:" default answer "")
set varNote to text returned of (display dialog "Enter notes:" default answer (the clipboard as text))

tell application "Contacts"
 set varContact to make new person with properties {first name:varFirst, last name:varLast, organization:varCompany}
 tell varContact
   make new address at end of addresses with properties {street:varStreet, city:varCity, state:varState, zip:varZip, country:varCountry}
   make new phone at end of phones with properties {label:varPhoneLabel, value:varPhone}
   make new email at end of emails with properties {label:varEmailLabel, value:varEmail}
   
   set note of varContact to varNote
 end tell
 save
end tell
tell application "Contacts"
 activate
 set selection to varContact
end tell

I've owned a Cardhop license for iOS for years now.  :sunglasses:

I only recently bought a copy for the Mac.

-Chris

1 Like

Hey @Zabobon,

I don't see anything to fuss about, except:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

These statements should be reserved for AppleScripts that employ AppleScriptObjC. They are not needed for vanilla scripts, and impose unnecessary restrictions.

Script Debugger's templates automatically insert them, so you either have to create your own template, edit SD's, or delete them manually.

Most user's either don't know about this or forget to do it. Personally I find it annoying to open a script which shows at the top it's an AppleScriptObjC script but doesn't have any AppleScriptObjC content.

-Chris

1 Like

Deleted :smiling_face:
Thanks Chris. Yes, it must be because I used Script Debugger to edit the AppleScript together.

1 Like

Just relooked at Cardhop and they now charge $3.33/mo if paid annually for the premium features, which include parsing from the clipboard.

I've been unhappy with FlexBits, since they moved to a subscription model...