Slider in Applescript?

I'm trying to have a slider in a cocoa-based applescript app I'm doing adjust the rate at which a song is played. The slider is called "slider1". What's wrong with this code?


on action theObject
set my_track to choose file
tell application "QuickTime Player"
close every window
open my_track
set my_movie to first document
set ts to time scale of my_movie
set current time of my_movie to 0 * ts
set rate of my_movie to the value of the slider "slider"
end tell
end action

MacBook (Black 2.4 GHz), G4 (Digital Audio 867 MHz), iMac (Lime 266 MHz), Mac OS X (10.5.6), G4 dual boots OS X Server 10.4.11 and Mac OS 9.2.2

Posted on May 13, 2009 8:28 PM

Reply
5 replies

May 14, 2009 2:32 PM in response to Jrtechn

By hierarchy, I mean the levels of objects that make up the various parts of the user interface. For example, the Finder describes a file item as file "x" of folder "y" of disk "z". An application may have a window, and that window may have tab groups, and one of the tab groups may contain a text field, and...

When you access an item, you need to fully describe what it is so that AppleScript can pass the message on to the appropriate object. If your slider is a part of another item (such as a window), you will need to include that item in the path to your object.

May 14, 2009 6:00 PM in response to Jrtechn

The messages in the build results will tell you the line where your script is failing - if everything is named and linked, my guess would be that the use of your application terms inside of the Quicktime tell statement is confusing things. Typically, to avoid terminology conflicts inside of tell statements, you should try to avoid putting anything into an application tell statement that isn't directly related to that application. Try breaking the item(s) out, for example:

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Xcode AppleScript Editor">
on action theObject
tell window of theObject
set slider_value to contents of slider "slider"
end tell
set my_track to choose file
tell application "QuickTime Player"
close every window
open my_track
set my_movie to first document
set ts to time scale of my_movie
set current time of my_movie to 0 * ts
set rate of my_movie to slider_value
end tell
end action
</pre>

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Slider in Applescript?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.