Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.3: A script to copy iChat buddy icons to Address Book Apps
Your iChat buddies can set up their own picture icons in iChat, but unfortunately these icons do not appear in your Address Book. To solve this problem, I wrote an Applescript that copies the buddy pictures in iChat into their corresponding entries in Address Book. Here's the Applescript code:

tell application "iChat"
 set modifiedList to {}
 set modifiedListRef to a reference to modifiedList
 repeat with curAccount from 1 to number of items in accounts
   set nameVar to the name of account curAccount
   if exists image of account nameVar then
     set theImage to the image of account nameVar
     tell application "Address Book"
       -- don't overwrite my own picture
       if 
       (last name of my card is not equal to last name of person nameVar) 
       or 
       (first name of my card is not equal to first name of person nameVar) 
       then
         set image of person nameVar to theImage
         copy nameVar to end of modifiedListRef
       end if
     end tell
   end if
 end repeat
 -- output the list of modified entries
 set AppleScript's text item delimiters to {", "}
 display dialog "The following entries were modified: " & modifiedList
end tell
Cut and paste the above into Script Editor, and then run it to copy the iChat pictures into Address Book. The pictures will now appear in Mail.app too! Huge!

Note: The script won't copy your own buddy icon into Address Book.

    •    
  • Currently 1.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[29,414 views]  

10.3: A script to copy iChat buddy icons to Address Book | 15 comments | Create New Account
Click here to return to the '10.3: A script to copy iChat buddy icons to Address Book' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: A script to copy iChat buddy icons to Address Book
Authored by: the_webmaestro on Nov 05, '03 11:51:43AM

It didn't work for me. The picture was automatically added from his .mac account (possibly while I was logged into Fire--my primary IM client since it supports y!,m$n,japper,aim,icq, etc.). Anyway, I noticed his picture doesn't appear in the "Address Card" section. But it shows up as the icon in the Buddy List. It does, however show up in the "Accounts" section under (my-buddy)@mac.com... Ideas on how to improve this? I'd love to see my friends in Address Book & Mail!

Web Maestro Clay

---
Father of Jeremy Logan Leeds



[ Reply to This | # ]
10.3: A script to copy iChat buddy icons to Address Book
Authored by: sdresser on Nov 05, '03 01:36:51PM

I can't get it to work. I get an AppleScript Error that says:

Address Book got an error:
NSReceiverEvaluationScriptError: 4

What's the deal?



[ Reply to This | # ]
Didn't work for me neither
Authored by: acrappa on Nov 05, '03 03:15:22PM

Doh.



[ Reply to This | # ]
Didn't work for me neither
Authored by: azchipka on Nov 05, '03 03:36:56PM

I got the same error message



[ Reply to This | # ]
Didn't work for me neither
Authored by: davidcrickett on Nov 05, '03 03:50:23PM

Same here.

---
davidcrickett



[ Reply to This | # ]
10.3: A script to copy iChat buddy icons to Address Book
Authored by: customjake on Nov 05, '03 08:38:59PM

Add another to the DOES NOT WORK FOR ME scoreboard



[ Reply to This | # ]
Same error here
Authored by: locklin on Nov 06, '03 05:30:50AM

Same here...



[ Reply to This | # ]
10.3: A script to copy iChat buddy icons to Address Book
Authored by: mcmikemn on Nov 05, '03 02:14:28PM

Not only did this work great for me, but here is an additional Panther hint (albeit a weak one): Hilight the script above and select Services in the Safari menu, then select Script Editor, and then select Get Result of Applescript. No need to copy and paste and create a new script (unless you want to use it again in the future, of course).



[ Reply to This | # ]
10.3: A script to copy iChat buddy icons to Address Book
Authored by: MattHaffner on Nov 05, '03 04:17:33PM

Great add-on tip! Thanks!

The original script worked great for me too.



[ Reply to This | # ]
Animated Icons
Authored by: UltraNurd on Nov 05, '03 09:32:03PM

Some of my friends have animated buddy icons. In iChat, these have never been displayed - normally just the first frame is. I ran this script (which worked great, by the way), and now their Address Cards happily animate the images! What gives? iChat is the one place this should work properly! Still, good to know that Apple is working on it...



[ Reply to This | # ]
10.3: A script to copy iChat buddy icons to Address Book
Authored by: jstrope on Nov 05, '03 10:12:36PM
At first I was getting the same errors that others were getting, but I realized that it happens when you have iChat buddies that do not have correspnding address book cards. I had a bunch from Buddies that I had added years ago using AOL IM. To track it down I deleted the checking for myself code (since I wanted it to add my icon) and inserted a new line to display a dialog of what entry it was working on. My final edited code looked like this:

tell application "iChat"
	set modifiedList to {}
	set modifiedListRef to a reference to modifiedList
	repeat with curAccount from 1 to number of items in accounts
		set nameVar to the name of account curAccount
		if exists image of account nameVar then
			set theImage to the image of account nameVar
			tell application "Address Book"
				display dialog nameVar
				set image of person nameVar to theImage
				copy nameVar to end of modifiedListRef
				
			end tell
		end if
	end repeat
	-- output the list of modified entries
	set AppleScript's text item delimiters to {", "}
	display dialog "The following entries were modified: " & modifiedList
end tell
NOTE that I removed the code that checked for your own name/card, but it did not replace my image anyway... You will be prompted with a dialog box after every entry that it wants to make, so if you have a large buddy list it could take a while to click through them all :) But at least this way you will know which name the script is busting out on and can then create an address card for the offending name (by control or right-clicking on the buddy name in question, and Get Info. From there you can create a card and re-run the script. Of course, you could eliminate all of this just by making sure all of your buddies in iChat have an address card. Hopefully that helps some others who want to import their pics into Address Book.

[ Reply to This | # ]
10.3: A script to copy iChat buddy icons to Address Book
Authored by: antonichan on Nov 05, '03 10:52:12PM
You can also add an "if" clause at the beginning of the "tell application Address Book" block. It will look something like this:

...
tell application "Address Book"
	if person nameVar exists then
		...
	end if
end tell
...


[ Reply to This | # ]
10.3: A script to copy iChat buddy icons to Address Book
Authored by: k0fcc on Nov 10, '03 03:12:49PM
Ok, for those of you who don't like to guess, here's the updated script:

-- IChat to Address Book
-- Copies the iChat buddy icon of your contact to the address book
--
-- Original code by Antoni Chan
-- Tweak by jstrope of Mac OS X Hnts
--
-- Comments by Joey Stanford
tell application "iChat"
	set modifiedList to {}
	set modifiedListRef to a reference to modifiedList
	repeat with curAccount from 1 to number of items in accounts
		set nameVar to the name of account curAccount
		if exists image of account nameVar then
			set theImage to the image of account nameVar
			tell application "Address Book"
				if person nameVar exists then
					set image of person nameVar to theImage
					copy nameVar to end of modifiedListRef
				end if
			end tell
		end if
	end repeat
	-- output the list of modified entries
	set AppleScript's text item delimiters to {", "}
	display dialog "The following entries were modified: " & modifiedList
end tell


[ Reply to This | # ]
10.3: A script to copy iChat buddy icons to Address Book
Authored by: phillipc on Nov 17, '03 09:24:19PM

Any idea why I would get an NScannotCreateScriptCommand error?

---
PhillipC



[ Reply to This | # ]
10.3: A script to copy iChat buddy icons to Address Book
Authored by: argh128 on Dec 14, '03 07:46:04PM
-- Source macosxhints
-- modified by Nicholas Shanks
-- posted by Alex Eiser
-- Asks you if you want to skip a user
tell application "iChat"
	repeat with curAccount from 1 to number of items in accounts
		if exists image of account curAccount then
			set theName to the name of account curAccount
			set theImage to the image of account curAccount
			tell application "Address Book"
				if person theName exists then
					if exists image of person theName then
						set theReply to display dialog "Replace image of " & theName & " with their iChat buddy icon?" buttons {"Abort", "Skip", "Replace"} default button "Skip" with icon caution
					else
						set theReply to display dialog "Add image for " & theName & " to your address book?" buttons {"Abort", "Skip", "Add"} default button "Add" with icon 1
					end if
					if (button returned of theReply is "Replace") or (button returned of theReply is "Add") then
						set image of person theName to theImage
					else if button returned of theReply is "Abort" then
						exit repeat
					end if
				end if
			end tell
		end if
	end repeat
end tell
This amendment asks if you want to replace the photo in your address book.
It also intelligently sets the default button if the address book record already has an image.

---
--

A completely SANE Canadian.

[ Reply to This | # ]