Replace characters in chat text

I was written a small applescript to replace some characters in chat message. Here is my code.
property searchList : {"live"}
property replaceList : {"love"}
to switchText of t from s to r
   set text item delimiters to s
   set t to t's text items
   set text item delimiters to r
   tell t to set t to beginning & ({""} & rest)
   t
end switchText
to convertText(t)
   set d to text item delimiters
   considering case
       repeat with n from 1 to count searchList
           set t to switchText of t from my searchList's item n to my replaceList's item n
       end repeat
   end considering
   set text item delimiters to d
   t
end convertText
using terms from application "Messages"
   on message sent theMessage for theChat
       try
           return convertText(theMessage)
       end try
   end message sent
   on message received theMessage from theBuddy for theChat
       return convertText(theMessage)
   end message received
   on chat room message received theMessage from theBuddy for theChat
       return convertText(theMessage)
   end chat room message received
end using terms from
This code worked fine for Yahoo account, but it dont work when i received messages from iMessage and Jabber account. I tried to look into Alerts event and i found "Message received in active chat" ,maybe iMessage and Jabber account use this event to alert received message, but the problem is this object not defined in applescript. How can i define it, or make this code work with  iMessage and Jabber account.

after long long times for google and test myseft, i found yahoo account have problem too, because active chat why is apple dont define this object ""Message received in active chat"'

Similar Messages

  • Replace Characters in a Text Field

    Hello,
    I have a script to replace a carriage return in a text box.
    The script is not working when run from the console.
    Can any one please advise how the script can be revised to find/replace a carriage return in a multiline text box?
    var t = this.getField("ActionAgenda").value;
    t = t.replace("\r","") // delete carriage return
    Any assistance would be most appreciated.

    Thank you for your help, George.
    The script works perfectly to replace carriage returns in a text field.
    Can you please advise how to modify the same script to remove a blank line instead of a carriage return?
    Thanks again, George.
    Regards
    Jo

  • UDF to replace characters in free text?

    Hi experts,
    If I have dates such as "2009.11.12" in a free text I need to change those to "2009-11-12".
    Basically I have to replace dots with a hyphen.
    I am thinking of a UDF but could not find one in the forum. Does anyone have an idea how to achieve that?
    Thank you very much for your help!
    Best regards,
    Peter

    YOu can make use of replaceString function.
    Find its documentation here: http://help.sap.com/saphelp_erp2004/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    Or you can make use of DateTrans function and specify the delimiter of your choice.
    Regards,
    ravi

  • Reading characters from a text file into a multidimensional array?

    I have an array, maze[][] that is to be filled with characters from a text file. I've got most of the program worked out (i think) but can't test it because I am reading my file incorrectly. However, I'm running into major headaches with this part of the program.
    The text file looks like this: (It is meant to be a maze, 19 is the size of the maze(assumed to be square). is free space, # is block, s is start, x is finish)
    This didn't paste evenly, but thats not a big deal. Just giving an idea.
    19
    5..................
    And my constructor looks like follows, I've tried zillions of things with the input.hasNext() and hasNextLine() to no avail.
    Code:
    //Scanner to read file
    Scanner input = null;
    try{
    input = new Scanner(fileName);
    }catch(RuntimeException e) {
    System.err.println("Couldn't find the file");
    System.exit(0);
    //Set the size of the maze
    while(input.hasNextInt())
    size = input.nextInt();
    //Set Limits on coordinates
    Coordinates.setLimits(size);
    //Set the maze[][] array equal to this size
    maze = new char[size][size];
    //Fill the Array with maze values
    for(int i = 0; i < maze.length; i++)
    for(int x = 0; x < maze.length; x++)
    if(input.hasNextLine())
    String insert = input.nextLine();
    maze[i][x] = insert.charAt(x);
    Any advice would be loved =D

    Code-tags sometimes cause wonders, I replaced # with *, as the code tags interprets # as comment, which looks odd:
    ******...*.........To your code: Did you test it step by step, to find out about what is read? You could either use a debugger (e.g., if you have an IDE) or system outs to get a clue. First thing to check would be, if the maze size is read correctly. Further, the following loops look odd:for(int i = 0; i < maze.length; i++) {
        for(int x = 0; x < maze.length; x++) {
            if (input.hasNextLine()) {
                String insert = input.nextLine();
                maze[x] = insert.charAt(x);
    }Shouldn't the nextLine test and assignment be in the outer loop? And assignment be to each maze's inner array? Like so:for(int i = 0; i < maze.length; i++) {
        if (input.hasNextLine()) {
            String insert = input.nextLine();
            for(int x = 0; x < insert.size(); x++) {
                maze[i][x] = insert.charAt(x);
    }Otherwise, only one character per line is read and storing a character actually should fail.

  • Replacing multiple lines of text in a file

    Hello
    I have an interesting problem
    I have a scheduling software which outputs a iCalendar file - this iCalendar file can be read by Kontact but all the events have NO alarm
    I Checked the file and what I need to add is :
    BEGIN:VALARM
    DESCRIPTION:
    ACTION:DISPLAY
    TRIGGER;VALUE=DURATION:-PT15M
    END:VALARM
    before
    END:VEVENT
    problem is that
    1) the scheduling software exports the file often - so any modification would be overwritten - which means I have to have the script run periodically
    2) the script shouldn't run more than once on the file otherwise I would get multiple alarm tags...
    what I though of doing is
    check for
    TZID:America/Toronto
    END:VEVENT
    and replace it with
    TZID:America/Toronto
    BEGIN:VALARM
    DESCRIPTION:
    ACTION:DISPLAY
    TRIGGER;VALUE=DURATION:-PT15M
    END:VALARM
    END:VEVENT
    which should prevent all problems.
    Now the big problem is that I have not found a single way around to have a script doing this for me.
    I have tried sed but it doesn't support multiple lines
    I have tried awk which is able to insert multile lines but somehow cannot search for multiple lines
    The added complication is that I have a lot of special characters in the text to search and replace
    any of you good souls can help me with this???
    Cippa

    This should work:
    #!/bin/bash
    INSERT='BEGIN:VALARM\nDESCRIPTION:\nACTION:DISPLAY\nTRIGGER;VALUE=DURATION:-PT15M\nEND:VALARM'
    sed -e "/TZID:America\/Toronto$/N;s/\(TZID:America\/Toronto\)\n\(END:VEVENT\)/\1\n$INSERT\n\2/" $1
    I just learned from http://www.shell-fu.org/lister.php?id=539

  • Removing the Control Characters from a text file

    Hi,
    I am using the java.util.regex.* package to removing the control characters from a text file. I got below programming from the java.sun site.
    I am able to successfully compile the file and the when I try to run the file I got the error as
    ------------------------------------------------------------------------D:\Debi\datamigration>java Control
    Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repet
    ition
    {cntrl}
    at java.util.regex.Pattern.error(Pattern.java:1472)
    at java.util.regex.Pattern.closure(Pattern.java:2473)
    at java.util.regex.Pattern.sequence(Pattern.java:1597)
    at java.util.regex.Pattern.expr(Pattern.java:1489)
    at java.util.regex.Pattern.compile(Pattern.java:1257)
    at java.util.regex.Pattern.<init>(Pattern.java:1013)
    at java.util.regex.Pattern.compile(Pattern.java:760)
    at Control.main(Control.java:24)
    Please help me on this issue.
    Thanks&Regards
    Debi
    import java.util.regex.*;
    import java.io.*;
    public class Control {
    public static void main(String[] args)
    throws Exception {
    //Create a file object with the file name
    //in the argument:
    File fin = new File("fileName1");
    File fout = new File("fileName2");
    //Open and input and output stream
    FileInputStream fis =
    new FileInputStream(fin);
    FileOutputStream fos =
    new FileOutputStream(fout);
    BufferedReader in = new BufferedReader(
    new InputStreamReader(fis));
    BufferedWriter out = new BufferedWriter(
    new OutputStreamWriter(fos));
         // The pattern matches control characters
    Pattern p = Pattern.compile("{cntrl}");
    Matcher m = p.matcher("");
    String aLine = null;
    while((aLine = in.readLine()) != null) {
    m.reset(aLine);
    //Replaces control characters with an empty
    //string.
    String result = m.replaceAll("");
    out.write(result);
    out.newLine();
    in.close();
    out.close();

    Hi,
    I used the code below with the \p, but I didn't able to complie the file. It gave me an
    D:\Debi\datamigration>javac Control.java
    Control.java:24: illegal escape character
    Pattern p = Pattern.compile("\p{cntrl}");
    ^
    1 error
    Please help me on this issue.
    Thanks&Regards
    Debi
    // The pattern matches control characters
    Pattern p = Pattern.compile("\p{cntrl}");
    Matcher m = p.matcher("");
    String aLine = null;

  • How to put more than 1200 characters in a text form within a pdf created in Adobe Acrobat

    I need to know how to put more than 1200 characters in a text form within a pdf created in Adobe Acrobat. I have a request from a customer to do so and after googling I have came up with nothing. Also the customer would like it if they could convert said pdf form to a microsoft word document with the text form.

    There's no limit on the number of characters you can enter into a text
    field, unless you set it as such.

  • Minimim characters in a text box

    It seems silly that it is so easy to set the maximum number of characters in a text box (ie. Properties>Options>Limit of X characters) but that there is no easy equaivalent for minimum characters? At least not in Acrobat 9 anyway, don't know about the never versions!
    Does anyone know if the minimum number of characters can be set with Javascript?

    That was intended to be a rhetorical question. So what you really want is if the field is not blank, that there should at least be some minimum number of characters. What is the minimum number that you want to enforce? Youd probably want to use a custom validation script for this, but what exactly do you want to happen if the user only enters three characters but the minimum you want is four? Should the three characters that were entered be rejected altogether, or should the focus just be set back to the field so the user can enter more, or something else?
    Here's what a script that rejects the entry might look like:
    // Custom validate script for text field
    (function () {
        // Allow nothing
        if (!event.value) return;
        // Set the minimum number of characters
        var min_chars = 4;
        // Reject the entry and alert user if fewer than the minimum
        if (event.value.length < min_chars) {
            event.rc = false;
            app.alert("Please enter at least " + min_chars + "characters.\r\rYou entered " + event.value.length + " characters.", 1);

  • Non printable characters in a text file..

    hi,
    How to get blank lines and non-printable characters
    and remove those characters from the text file being uploaded from application server .
    thanks,
    Anil.

    Take a look at the constants in cl_abap_char_utilities. A simpler solution would be to ask for a file without such characters...

  • Address book: Find and replace characters?

    Hi all,
    I just imported VCF file from Outlook to Address book. I am in Iceland and the Icelandic characters came wrong. Is there any way to batch find and replace characters in Address book? That is in individual cards.
    Thanks,
    Hilmar

    I believe the only way would be to write an AppleScript.

  • Problem in replacing characters of a string ?

    Hello everybody,
    I want to replace a few characters with their corresponding unicode codepoint values.
    I have a userdefined method that gets the unicode codepoint value for a character.
    1. I want to know how to replace the characters and have the replaced string after the comparision is over in the for loop in my main.
    Currently , i am able to replace , but i am not able to have the replacements done in a single variable.
    The output of the code is
    e\u3006ame
    ena\u3005e
    But i want the output i require is,
    e\u3006a\u3005e
    Please offer some help in this regard
    import java.io.*;
    class Read1
         public static void main(String s[])
             String rp,snd;
             String tmp="ename";
             for(int i=0;i<tmp.length();i++)
                 snd=getCodepoint(tmp.charAt(i));
                 if(snd!=null)
                    rp=replace(tmp,String.valueOf(tmp.charAt(i)),"\\u"+snd);
                    System.out.println(rp);
    public static String replace(String source, String pattern, String replace)
         if (source!=null)
             final int len = pattern.length();
             StringBuffer sb = new StringBuffer();
             int found = -1;
             int start = 0;
             while( (found = source.indexOf(pattern, start) ) != -1)
                 sb.append(source.substring(start, found));
                 sb.append(replace);
                 start = found + len;
             sb.append(source.substring(start));
             return sb.toString();
         else return "";
    ...,Any help in this regard would be useful
    Thanks
    khurram

    This manual replacement thingy reminds me of quite an old technique, when
    64KB of memory was considered enough for 20 users (at the same time that is!)
    Suppose you have a buffer of, say, n characters. Starting at location i, a region
    of chars have to be swapped with bytes starting at location j >= i+l_i; the lengths
    of the two regions are l_i and l_j respectively.
    Suppose the following method is available:public void reverse(char[] buffer, int f, int l_f) {
       for (int t= f+l_f; --t > f; f++) {
          char tmp=buffer[f]; buffer[f]= buffer[t]; buffer[t]= tmp;
    }i.e. the above method reverses a region of characters, starting at position f
    with length l_f. Given this simple method, the original problem can be solved
    using the following simple sequence:reverse(buffer, i, j+l_j);
    reverse(buffer, i, l_j);
    reverse(buffer, i+l_j, j-i-l_i);
    reverse(buffer, j+l_j-l_i, l_i);Of course, when replacing characters we don't need the last reversal.
    kind regards,
    Jos (dinosaurus)

  • Why can I not activate chat/text by clicking "Available?"

    I am not able to initiate Chat/Text by clicking "available." At&T and Yahoo believe it has something to do with mal-functioning flash drive. I reloaded lastest Adobe flash drive but problem persists. Any thoughts?? I use Windows XP 32 bit with Internet Explorer.

    "Flash drive"?  You mean Flash Player?
    Can you see the Flash animation at http://helpx.adobe.com/flash-player/kb/find-version-flash-player.html ?
    What is your Flash Player version?

  • Can I Animate Individual Characters in a Text Block Using the Wiggle Expression?

    I'm new to After Express and just diving in to expressions. I was trying to figure out if there was a simple way to use the wiggle expression in a way that it would wiggle individual characters in a text block independently of each other.
    Definitely appreciate any help.

    Did you try the Wiggly Selector? Alternatively, you could add an Expression Selector and add and Amount expression like this:
    seedRandom(textIndex,true);
    wiggle(1,100)
    Dan

  • I need a query that returns the average amount of characters for a text colum in MS SQL.

    I need a query that returns the average amount of characters
    for a text colum in MS SQL.
    Could someone show me how?

    Sorted, i need the
    DATALENGTH
    function

  • Limit the amount of characters of a text field based on first digit

    Hello and thanks in advance for your help!
    I would like to limit the amount of characters of the text field based on the first digit of the number (the text field is only limited to a number format...no decimals, no commas).
    For example, if the number begins with a 3, I would like to limit the text field to allow only ten characters. I have three scenarios but if I could get started with some code and what is the best place to add it (keystroke or validation?) I can take it from there. Thanks again for your help!!

    I've written this code for you that does that. Use it as the field's custom Keystroke code:
    // Validate that only digits are entered
    if (event.change) {
        event.rc = /^\d+$/.test(event.change);
    // Validate string length if it starts with 3
    if (/^3/.test(AFMergeChange(event))) {
        event.rc = AFMergeChange(event).length <= 10;
        if (!event.rc) app.alert("If the number starts with \"3\" it may not be longer than 10 digits.",1); // optional error message
    You can duplicate the second part of it for additional conditions, but keep in mind that this code won't even let you remove the first character in the field if the result is an invalid one.
    For example, if you enter "234567890123456" then you can't remove the "2" at the start because that would result in an invalid number. You can remove any of the other digits, though, and when it's 10 digits or less then you could remove the starting "2" as well.

Maybe you are looking for

  • TDMS: is it possible to use sender and receiver client within the same SID

    Hi all I have a general question about TDMS: i always read that it is possible to refresh data from a productive system/client to a test system/client, e.g. PRD100 => DEV100. But is it also possible to refresh data from one sender-client to the recei

  • Syncing Suffle after installing Windows 7 error message not allowed

    Installed Windows 7 on the computer-- wiped out previous I-tunes library. What do I have to do to be able to sync library on Shuffle with computer. Getting a message that the files can't be transferred because the computer isn't the authorized cmpute

  • Homesharing iPad mini

    Can somebody give me some suggestions? My problem is with homesharing on the ipad mini.  This mini pretty new.  It has done this since I purchased it.  I turn on homesharing on the mini and only a few select artists show up.  All of them won't show u

  • How to translate dashboard prompt year/period into literal date range

    I am using OBIEE 10g. I have a dashboard that prompts for a fiscal year and fiscal period (both are numeric data types). I need to use these values in the date filter for my answers request - however, to fully utilize the indexes and partitioning tha

  • Error loading 'ModelCom.dll': Missing export 'GetModuleHandleW' from 'KERNEL32

    Hallo zusammen, wir Arbeiten hier mit LV-RT (8.5) und ProveTech TA, von der Firma MBtech. Die Frima MBtech liefert dazu eine dll dür den Datenaustausch zwischen beiden Systemen. Seit dem Update der dll auf eine neuere Version bekommen wir immer folge