|
|
Dial the phone from Entourage?
Dialing from Entourage...
Following is my quick hack version based in good part upon an old OS 9 applescript from Applescript Central (props to that initial author whose name I unfortunately don't know!) plus routines I added to address OS X, my own personal taste, and my specific area code situation in S. Fla. The area code handling routines can be removed, of course, (and I have commented that section for easy identification), but I left it in for this post on the off chance there are others like me living in a locale where certain area codes may or may not be long distance and others may or may not require 10-digit dialing.
Also, I tried to incorporate (append, actually) the initial tip for the sake of consistency. There is probably no reason to create a duplicate configuration called "Telephone", but it doesn't hurt (and you would otherwise have to change the configuration name to "Internal Modem" wherever it appears in the script.)
One last note -- I haven't actually tested this by calling anyone because it is currently post-2am here and I don't know many people who would appreciate a call right now just to find out if some random applescript works :) Feedback is appreciated. Stealing the script verbatim, without any reference to my contribution, is not appreciated -- you know who you are.
Finally... to use the script... paste into Script Editor and save in ~/Documents/Microsoft User Data/Entourage Menu Items. Then run Entourage, highlight a single entry in your Entourage address book, and choose this script from the Entourage Scripts Menu. It will (hopefully) walk you through the rest.
set phoneList to {}
set errString to "This script only works with one contact selected in a list view."
tell application "Microsoft Entourage"
try
set s to the selection
set t to item 1 of s
if the class of t is contact then set theContact to t
on error theErr
display dialog theErr & return & return & errString with icon 1 buttons {"OK"} default button "OK"
return
end try
set custList to address book 1's {custom phone number one name, custom phone number two name, custom phone number three name, custom phone number four name}
repeat with i from 1 to 4
set x to item i of custList
if x ends with ":" then set x to text 1 thru -2 of x
set item i of custList to x
end repeat
set {custName1, custName2, custName3, custName4} to custList
try
set homeNumber to home phone number of theContact
set workNumber to business phone number of theContact
set otherHomeNumber to other home phone number of theContact
set otherWorkNumber to other business phone number of theContact
set mobileNumber to mobile phone number of theContact
set mainNumber to main phone number of theContact
set assistantNumber to assistant phone number of theContact
set pagerNumber to pager phone number of theContact
set homeFaxNumber to home fax phone number of theContact
set workFaxNumber to business fax phone number of theContact
set custom1 to custom phone number one of theContact
set custom2 to custom phone number two of theContact
set custom3 to custom phone number three of theContact
set custom4 to custom phone number four of theContact
if homeNumber is not "" then set end of phoneList to ("Home: " & homeNumber)
if workNumber is not "" then set end of phoneList to ("Work: " & workNumber)
if otherHomeNumber is not "" then set end of phoneList to ("Home 2: " & otherHomeNumber)
if otherWorkNumber is not "" then set end of phoneList to ("Work 2: " & otherWorkNumber)
if mobileNumber is not "" then set end of phoneList to ("Mobile: " & mobileNumber)
if mainNumber is not "" then set end of phoneList to ("Main: " & mainNumber)
if assistantNumber is not "" then set end of phoneList to ("Assistant: " & assistantNumber)
if pagerNumber is not "" then set end of phoneList to ("Pager: " & pagerNumber)
if homeFaxNumber is not "" then set end of phoneList to ("Home Fax: " & homeFaxNumber)
if workFaxNumber is not "" then set end of phoneList to ("Work Fax: " & workFaxNumber)
if custom1 is not "" then set end of phoneList to (custName1 & ": " & custom1)
if custom2 is not "" then set end of phoneList to (custName2 & ": " & custom2)
if custom3 is not "" then set end of phoneList to (custName3 & ": " & custom3)
if custom4 is not "" then set end of phoneList to (custName4 & ": " & custom4)
set theName to name of theContact
if theName = "" then set theName to company of theContact
on error theErr
display dialog theErr & return & return & errString with icon 1 buttons {"OK"} default button "OK"
return
end try
end tell
if (count of phoneList) = 1 then
set theResult to phoneList
else
if (count of phoneList) is greater than 1 then
try
set theResult to choose from list phoneList with prompt "Choose a phone number to dial for " & theName & ¬
":" default items {(item 1 of phoneList)} without multiple selections allowed and empty selection allowed
on error
display dialog ¬
"This script requires a scripting addition that is not installed on your computer. " with icon 1 buttons {"OK"} default button "OK"
end try
else
display dialog "That contact has no phone numbers." with icon note buttons {"OK"} default button "OK"
return
end if
end if
if theResult = {} or theResult is false then return
set t to item 1 of theResult
set i to offset of ": " in t
set theNumber to text (i + 2) thru -1 of t
-- Begin Routine to Handle Unique Area Code Situations
set locCheck to offset of 954 in theNumber
if locCheck = 2 then
display dialog ¬
"Add Prefix?" & return buttons {"1", "No Prefix"} default button "No Prefix"
set prefReply to button returned of result
if prefReply is equal to "No Prefix" then
set theNumber to theNumber
else
copy "1 " & theNumber to theNumber
end if
else
set locCheck to offset of 561 in theNumber
if locCheck = 2 then
display dialog ¬
"Add Prefix?" & return buttons {"1", "No Prefix"} default button "No Prefix"
set prefReply to button returned of result
if prefReply is equal to "No Prefix" then
set theNumber to theNumber
else
copy "1 " & theNumber to theNumber
end if
else
copy "1 " & theNumber to theNumber
end if
end if
-- End Routine to Handle Unique Area Code Situations
tell application "Microsoft Entourage"
activate
ignoring application responses
tell application "Internet Connect" to connect ¬
configuration "Telephone" to telephone number theNumber
end ignoring
display dialog theNumber & return & ¬
"Dialing in Progress: Disconnect?" buttons {"Disconnect"} default button 1 giving up after 20
tell application "Internet Connect" to disconnect configuration "Telephone"
tell application "Internet Connect" to quit
end tell
Dial the phone from Entourage?
Hi maclaw, |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|