Hi everybody!
This a beginner Question! But please help me
anyway. The thing I want to “create” is a script that tells me when a buddy in ichat is been online. When the buddy is online a script should run wich opens a text edit document and places the message the the buddy (name) was logged into iChat at time and date. It should be opend always the same document and the text should be added to the document.
What I managed to do is, that apple script is openen a new text edit ducument.
So please help me!
Greetings from switzerland to everybody!
Thanks Stephan
Hi Stephan,
I created a small script snippet for you that shows how to log the iChat data to a RTF file using TextEdit. Of course, you could also just read and write to a plain text file using AppleScript only (without using TexdtEdit).
I have not so much experience with scripting iChat, but I guess someone will add this missing part soon 
-- simultated iChat buddy and log date
set ichatbuddy to "My iChat buddy"
set logdate to (current date) as Unicode text
-- file path to log file
set logfilepath to ((path to desktop) as Unicode text) & "ichatlog.rtf"
-- does the log file already exist?
try
set logfilealias to logfilepath as alias
set logfileexists to true
on error
set logfileexists to false
end try
-- is TextEdit currently running?
tell application "System Events"
set allprocnames to name of every process
if "TextEdit" is in allprocnames then
set quittextedit to false
else
set quittextedit to true
end if
end tell
-- creating and saving the log data using text edit
tell application "TextEdit"
if logfileexists then
set logdoc to open (logfilepath as alias)
else
set logdoc to make new document
end if
set logtext to text of logdoc
set logtext to logtext & return & logdate & ": " & ichatbuddy
set text of logdoc to logtext
close logdoc saving in logfilepath
if quittextedit is true then
quit
end if
end tell
WOW!
Thanks a lot! It works right away! PERFECT! Thank you VERY much. The one thing is, there is coming an error -1708 (it says: “there is an error running apple script event handler”) but after I click “ignore error” it is written in the rtf file. What do you think is the cause of this error?
Thanks again, GREAT help!
Stephan
Hallo Martin, Hoi Stephan,
the iChat part depends on the system version.
Leopard has an event handler to manage this very easy,
in Tiger you must create a stay open script.
If you’re using Leopard, you’ll find a sample script with the adequate event handler in /Library/Scripts/
Then you have to enable the event in iChat.
Sorry for the common description,
I’m somewhere having my Tiger running PowerBook with me 