applescript + ichat

Discussion in 'Mac Programming' started by podium06, Nov 12, 2009.

  1. podium06 macrumors newbie

    Joined:
    Nov 12, 2009
    #1
    hi all,
    I'm new to apple script. i'm trying to write a simple script to get ichat to close a window that always open after i log in to Jabber.

    so far i managed to do this line that close the window

    tell application "iChat" to close window "msn.jabber.meta.net.nz"

    the problem is that the window opens some time after the login is finished so if i choose to run it when login finished i get an error from ichat.

    so i tried to do a loop with many variations but nothing helped.
    this is the latest version i come up with (it is probably wrong in so many ways as i'm not really used for the applescript syntax)

    tell application "iChat"
    if (login finished for "msn.jabber.meta.net.nz") then
    tell application "iChat" to close window "msn.jabber.meta.net.nz"
    end if

    end tell


    can someone help me and point me to the right direction??

    thanks in advance for your time.
     
  2. Caleb531 macrumors 6502

    Caleb531

    Joined:
    Oct 17, 2009
    #2
    Try playing around with this. If you were to attach a keyboard shortcut to run this script, any time the window opens, press the chosen hotkey.

    tell application "iChat"
    if window "msn.jabber.meta.net.nz" exists then
    close window "msn.jabber.meta.net.nz"
    else
    beep
    end if
    end tell
     
  3. podium06 thread starter macrumors newbie

    Joined:
    Nov 12, 2009
    #3
    thanks

    thanks for your replay,
    but i really want it to run automatically.
    otherwise i can just click the close button of that window.

    i made up this new script (which also works from applescript).
    this makes me think it might be a problem with ichat running the script...
    might be that you need to add a special command at the beginning....

    delay 5
    tell application "iChat"
    if window "msn.jabber.meta.net.nz" exists then
    close window "msn.jabber.meta.net.nz"
    else
    delay 10
    end if
    end tell
    tell application "iChat"
    if window "msn.jabber.meta.net.nz" exists then
    close window "msn.jabber.meta.net.nz"
    else
    beep
    end if
    end tell
     
  4. podium06 thread starter macrumors newbie

    Joined:
    Nov 12, 2009
    #4
    another thing

    well i might be a different problem altogether.
    i just now tried to run a scrip from apple that came with ichat and i recive the same error...

    strange...
     
  5. podium06 thread starter macrumors newbie

    Joined:
    Nov 12, 2009
    #5

Share This Page