Professional Web Applications Themes

Problem With System Events Scripting--Can't "click at" - Mac Programming

I'm trying to write a script for iTunes that skips a song to the end, thus allowing its play count to increment when it ends. I'm trying the following script, but it's not working. Note that this is only going to run on my machine, and the coordiates are acurate for the end of the scrub bar as I have the window positioned. When I run this, the Script Editor says "System Events got an error: NSReceiversCantHandleCommandScriptError". Anyone know what's wrong? tell application "iTunes" activate tell application "System Events" click at {745, 75} end tell end tell -- Aaron Davies ...

  1. #1

    Default Problem With System Events Scripting--Can't "click at"

    I'm trying to write a script for iTunes that skips a song to the end,
    thus allowing its play count to increment when it ends. I'm trying the
    following script, but it's not working. Note that this is only going to
    run on my machine, and the coordiates are acurate for the end of the
    scrub bar as I have the window positioned. When I run this, the Script
    Editor says "System Events got an error:
    NSReceiversCantHandleCommandScriptError". Anyone know what's wrong?

    tell application "iTunes"
    activate
    tell application "System Events"
    click at {745, 75}
    end tell
    end tell
    --
    Aaron Davies
    Opinions expressed are solely those of a random number generator.
    "I don't know if it's real or not but it is a myth."
    -Jami JoAnne of alt.folklore.urban, showing her grasp on reality.

    Aaron Davies Guest

  2. #2

    Default Re: Problem With System Events Scripting--Can't "click at"

    In article <1fxuq0v.kyixr51x5rezuN%aaronavalon.pascal-central.com>,
    [email]aaronavalon.pascal-central.com[/email] (Aaron Davies) wrote:
    > Editor says "System Events got an error:
    > NSReceiversCantHandleCommandScriptError". Anyone know what's wrong?
    It means what it says: NSReceivers Can't Handle Command.

    Since "NS" stands for NextStep, the ancestor of Cocoa, and iTunes
    started as the Classic App: SoundJam, it isn't surprising.

    ITunes is extensively scriptable. Did you look at iTunes AppleScript
    dictionary, to see if you can do what you want more directly?
    David Phillip Oster Guest

  3. #3

    Default Re: Problem With System Events Scripting--Can't "click at"

    In <1fxwogl.1bqavff11xo91iN%aaronavalon.pascal-central.com> Aaron
    Davies wrote:
    > matt neuburg <matttidbits.com> wrote:
    >
    >> In <1fxuq0v.kyixr51x5rezuN%aaronavalon.pascal-central.com> Aaron
    >> Davies wrote:
    >> > the scrub bar as I have the window positioned. When I run this, the
    >> > Script Editor says "System Events got an error:
    >> > NSReceiversCantHandleCommandScriptError". Anyone know what's wrong?
    >> >
    >> > tell application "iTunes"
    >> > activate
    >> > tell application "System Events"
    >> > click at {745, 75}
    >> > end tell
    >> > end tell
    >>
    >> You need to tell application process "iTunes" within the "System
    >> Events" tell block.
    >
    > OK, I reversed the blocks
    That isn't what I said to do. m.

    --
    matt neuburg, phd = [email]matttidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
    REALbasic: The Definitive Guide! 2nd edition!
    [url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
    Subscribe to TidBITS. It's free and smart.
    matt neuburg Guest

  4. #4

    Default Re: Problem With System Events Scripting--Can't "click at"

    In article
    <Patrick.Stadelmann-42467E.10413012072003news.fu-berlin.de>, Patrick
    Stadelmann <Patrick.Stadelmannunine.ch> wrote:
    > In article <1fxy4w1.colbeyi658ghN%aaronavalon.pascal-central.com>,
    > [email]aaronavalon.pascal-central.com[/email] (Aaron Davies) wrote:
    >
    > > OK, that works, but if I uncomment the click at, iTunes just seems to
    > > ignore it. I don't get an error or anything, but nothing happens. Does
    > > "click at" work at all?
    >
    > click reference -- the object for the command
    > [at list] -- when sent to a "process" object, the { x, y }
    > location at which to click, in global coordinates
    >
    > The direct parameter is required.
    >
    > Patrick
    I apologize for leaving in the commented line as it seems to have
    caused a bit of confusion.

    Patrick is correct but doesn't take it far enough, a parameter is
    required but the location at which to click isn't required unless you
    specify "at". In this case the parameter is a menu item, an alternative
    is to use the "keystroke" command instead of "click". The use of the
    arrow key makes that a bit more complicated (since you need to know the
    ASCII number for the arrow key) so I choose the menu item.

    (* using keystroke *)
    tell application "iTunes" to activate
    tell application "System Events" to tell process "iTunes"
    keystroke (ASCII character 29) with command down
    end tell
    (* end *)

    Screen/Window coordinates can change or rather the location of the UI
    element within them can change just zoom or drag a window. It is
    probably a good idea to use coordinates only as a last resort when
    other methods aren't available.

    I suspect that "click" didn't work here because the click on the
    button is too fast for the app to recognize. I've run into that problem
    in other scripts and applications.

    John

    --
    Use ROT-13 on the email address for email replies
    John Stewart Guest

Similar Threads

  1. Drag and drop problem with "dragEnabled" and"allowMultipleSelection"
    By tata668@gmail.com in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: April 4th, 02:29 AM
  2. Replies: 2
    Last Post: June 28th, 12:20 PM
  3. Replies: 0
    Last Post: June 27th, 03:54 AM
  4. Lsass.exe System error "object name not found". System keeps rebooting
    By Deepak in forum Windows Setup, Administration & Security
    Replies: 0
    Last Post: July 14th, 04:10 PM
  5. Replies: 3
    Last Post: June 24th, 06:08 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139