I want to select using AppleScript a group of contacts in Entourage 2004 that have the category “test” already assigned to each contact.
Each of the 3 AppleScripts listed below works, but only the last AppleScript (which requires some smart mouse clicks by the user beforehand) completes in a reasonable amount of time. My Entourage contact database contains 2,687 records, and 3 of those contacts have the category “test” assigned to them. The first AppleScript takes 43 seconds to complete. The second AppleScript takes 28 seconds to complete. The third AppleScript takes less than 1 second to complete (excluding smart user mouse clicks).
Does anyone have better/faster AppleScript code that selects the contacts in a specific category (but does not require the user manually highlight the contacts beforehand)?
Script 1:
tell application "Microsoft Entourage"
set theCategory to category "test"
set theseContacts to {}
set allContacts to every contact
repeat with thisContact in allContacts
set assignedCategories to category of thisContact
repeat with i from 1 to (count of assignedCategories)
if item i of assignedCategories is theCategory then
set end of theseContacts to thisContact
end if
end repeat
end repeat
--do stuff to theseContacts
end tell
beep
Script 2:
tell application "Microsoft Entourage"
set theCategory to category "test"
set theseContacts to contacts where theCategory is in its category
--do stuff to theseContacts
end tell
beep
Script 3 (user clicks to Entourage Address Book window, filters contacts to “Categoy is” → “test”, highlights/selects all resultant records, then runs AppleScript):
tell application "Microsoft Entourage"
set theseContacts to selection
--do stuff to theseContacts
end tell
beep