Page 1 of 1

New chat in current chat window with Applescript

Posted: Fri Aug 01, 2008 4:55 am
by Raimondi
The script from this blog ( with a slight modification) lets me send a message from Quicksilver. It works fine, except that it opens a new window for every new chat.

How do I open a new tab in the current window?

Here is the code:

Code: Select all

using terms from application "Quicksilver"
	on process text im_text
		repeat with im_delimiter_position from 1 to (length of im_text)
			if character im_delimiter_position of im_text = ":" then exit repeat
		end repeat
		set im_contact_name to characters 1 thru (im_delimiter_position - 1) of im_text as string
		set im_message to characters (im_delimiter_position + 2) thru (length of im_text) of im_text as string
		tell application "Adium"

			set user to first contact whose (status type is not offline and (display name starts with im_contact_name or name starts with im_contact_name))
			
			if not (exists (chats whose contacts contains user)) then

				tell account of user to (make new chat with contacts {user} with new chat window)

			end if
			
			send (first chat whose contacts contains user) message im_message
		end tell
		return nothing
	end process text
end using terms from
I tried this (inside a check for the presence of any chat):

Code: Select all

	tell account of user to (make new chat with contacts {user} in first chat window)
And many combinations of that idea, but I'm missing something because I couldn't get it working...