Help with Apple Script rewrite

I can't wrap my brain around applescript. I found this program mp3gain. It is written in applescript. I just need it to go to folder abc download and run, then save it to a folder names abc done. I can reset the db from the script. Any help would be great. All the itunes stuff can be deleted.
-- MacMP3Gain.applescript
-- MacMP3Gain
-- Created by Bery Rinaldo on Tue Jan 14 2003.
-- Copyright (c) 2003-2005 Bery Rinaldo. All rights reserved.
-- This AppleScript is used to wrap the command line version of mp3gain with a quaint GUI.
-- This program is free software; you can redistribute it and/or modify it under the terms
-- of the GNU General Public License as published by the Free Software Foundation; either
-- version 2 of the License, or (at your option) any later version.
-- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- See the GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License along with this program; if not,
-- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-- This program includes a binary version of aacgain downloaded from here
-- http://www.hydrogenaudio.org/forums/index.php?act=Attach&type=post&id=1461
-- aacgain version 1.4.0, derived from mp3gain version 1.4.6
-- copyright(c) 2001-2004 by Glen Sawyer
-- AAC support copyright(c) 2004 David Lasker, Altos Design, Inc.
-- uses mpglib, which can be found at http://www.mpg123.de
-- AAC support uses faad2 (http://www.audiocoding.com), and
-- mpeg4ip's mp4v2 (http://www.mpeg4ip.net)
-- Check out the MP3Gain/AACgain web sites:
-- http://mp3gain.sourceforge.net/
-- http://altosdesign.com/aacgain/
-- Version 1.0 - Initial release
-- Version 1.01 - Added status updates to display while mp3gain is running
-- Version 1.1 - 13-Feb-2003 - Added iTunes playlist support
-- Version 1.2 - 18-Feb-2003 - Added "Process Sub-folders" option to process all folders below the selected folder.
-- Version 1.3 - 20-Feb-2003 - Fixed program hang when "Allow Clipping" checkbox was unchecked.
-- Version 1.4 - 23-Feb-2003 - Added target MP3 Gain dB value, added preferences file support for all controls
-- Version 1.5 - 26-Feb-2003 - Integrate "Be Nice" feature from Michael Heinz. Added "Cancel" feature.
-- Version 1.6 - 28-Feb-2003 - Minor GUI tweaks to "Be Nice" an "Target" buttons to disable while running.
-- Version 1.7 - 01-Nov-2003 - Update to mp3gain 1.4.3, use -k (autoClip) option when "Allow Clipping" is unchecked
-- Version 1.8 - 09-Nov-2003 - Update run_mp3gain.pl to handle iTunes 4 playlists
-- Version 1.9 - 23-Aug-2005 - Update for Tiger & AAC
property ref_folder : ""
property ref_playlist : ""
property running : false
property mp3gain : ""
property run_mp3gain : ""
on clicked theObject
if name of theObject is "Start" then
if running is true then
set title of button "Start" of window "MainWindow" to "Start"
try
set pids to do shell script "ps -auxww | egrep \"" & run_mp3gain & "|" & aacgain & "\" | grep -v grep | awk '{ print $2 }' | xargs kill"
end try
set running to false
tell progress indicator "BusyBar" of window "MainWindow" to stop
set visible of progress indicator "BusyBar" of window "MainWindow" to false
tell window "MainWindow" to update
set contents of text field "StatusMessage" of window "MainWindow" to "Processing aborted."
set enabled of button "Start" of window "MainWindow" to false
set enabled of button "Choose Folder" of window "MainWindow" to true
set enabled of button "Choose Playlist" of window "MainWindow" to true
set enabled of button "Clip" of window "MainWindow" to true
set enabled of button "Sub" of window "MainWindow" to true
set enabled of button "Target" of window "MainWindow" to true
set enabled of button "Nice" of window "MainWindow" to true
set targetchecked to state of button "Target" of window "MainWindow" as integer
if targetchecked = 1 then
set enabled of text field "TargetValue" of window "MainWindow" to true
set targetvalue to 75
try
set targetvalue to contents of default entry "TargetValue" of user defaults as integer
end try
set contents of text field "TargetValue" of window "MainWindow" to targetvalue
else
set enabled of text field "TargetValue" of window "MainWindow" to false
set contents of text field "TargetValue" of window "MainWindow" to 89
end if
set enabled of matrix "ARmatrix" of window "MainWindow" to true
set ref_folder to ""
set contents of text field "FolderPath" of window "MainWindow" to "No folder selected"
set ref_playlist to ""
set contents of text field "PlaylistName" of window "MainWindow" to "No playlist selected"
tell window "MainWindow" to update
else
set clip to (state of button "Clip" of window "MainWindow") as integer
set albumradio to current row of matrix "ARmatrix" of window "MainWindow"
set options to " -q "
if clip = 1 then
set options to options & "-c "
else
set options to options & "-k "
end if
if albumradio = 1 then
set options to options & "-a "
else
set options to options & "-r "
end if
set nicechecked to state of button "Nice" of window "MainWindow" as integer
set targetchecked to state of button "Target" of window "MainWindow" as integer
if targetchecked = 1 then
set targetdb to integer value of text field "TargetValue" of window "MainWindow"
set targetparam to targetdb - 89
set options to options & "-m " & (targetparam as string) & " "
end if
set can_run to false
if ref_playlist is not equal to "" then
set the playlist_text to ""
tell application "iTunes"
set the track_count to the count of tracks of playlist ref_playlist
repeat with z from 1 to the track_count
tell track z of playlist ref_playlist
copy {database ID} to {dbid}
end tell
set the playlist_text to the playlist_text & (dbid as string) & ","
end repeat
end tell
activate
if track_count = 0 then
display dialog "The playlist is empty." buttons {"OK"}
else
set options to options & "-P " & playlist_text
set can_run to true
end if
else
set folder_path to POSIX path of ref_folder
set sub to (state of button "Sub" of window "MainWindow") as integer
if sub = 1 then
set options to options & "-S -F \"" & folder_path & "\""
set can_run to true
else
set command to "cd \"" & folder_path & "\" ; ls *.mp3 *.m4a 2> /dev/null"
set output to do shell script command
if output is equal to "" then
display dialog "No MP3/M4A files were found in the specified folder." buttons {"OK"}
else
set options to options & "-F \"" & folder_path & "\""
set can_run to true
end if
end if
end if
if can_run is equal to true then
set enabled of button "Start" of window "MainWindow" to false
set enabled of button "Choose Folder" of window "MainWindow" to false
set enabled of button "Choose Playlist" of window "MainWindow" to false
set enabled of button "Clip" of window "MainWindow" to false
set enabled of button "Sub" of window "MainWindow" to false
set enabled of button "Target" of window "MainWindow" to false
set enabled of button "Nice" of window "MainWindow" to false
set enabled of text field "TargetValue" of window "MainWindow" to false
set enabled of matrix "ARmatrix" of window "MainWindow" to false
set visible of progress indicator "BusyBar" of window "MainWindow" to true
set uses threaded animation of progress indicator "BusyBar" of window "MainWindow" to true
tell progress indicator "BusyBar" of window "MainWindow" to start
tell window "MainWindow" to update
if nicechecked = 1 then
set command to "nice -n 1 "
else
set command to ""
end if
set command to command & "\"" & run_mp3gain & "\" " & options & " > /tmp/.mp3gain_output 2>&1"
--display dialog command
try
ignoring application responses
do shell script command & "&"
end ignoring
end try
set running to true
set title of button "Start" of window "MainWindow" to "Cancel"
set enabled of button "Start" of window "MainWindow" to true
tell window "MainWindow" to update
end if
end if
else if name of theObject is "Choose Playlist" then
tell application "iTunes"
set allPlaylists to name of user playlists
end tell
activate
set playlist_choice to choose from list allPlaylists with prompt "Which playlist?" multiple selections allowed 0
if playlist_choice is false then --nothing selected, just stop
set ref_playlist to ""
set contents of text field "PlaylistName" of window "MainWindow" to "No playlist selected."
else
set ref_playlist to playlist_choice as string
set contents of text field "PlaylistName" of window "MainWindow" to ref_playlist
set ref_folder to ""
set contents of text field "FolderPath" of window "MainWindow" to ""
set state of button "Sub" of window "MainWindow" to false
set enabled of button "Sub" of window "MainWindow" to false
set enabled of button "Start" of window "MainWindow" to true
tell window "MainWindow" to update
end if
else if name of theObject is "Sub" then
set ischecked to state of button "Sub" of window "MainWindow" as integer
try
set contents of default entry "Sub" of user defaults to ischecked
end try
else if name of theObject is "Clip" then
set ischecked to state of button "Clip" of window "MainWindow" as integer
try
set contents of default entry "Clip" of user defaults to ischecked
end try
else if name of theObject is "Nice" then
set nicechecked to state of button "Nice" of window "MainWindow" as integer
try
set contents of default entry "Nice" of user defaults to nicechecked
end try
else if name of theObject is "Target" then
set targetchecked to state of button "Target" of window "MainWindow" as integer
try
set contents of default entry "Target" of user defaults to targetchecked
end try
if targetchecked = 1 then
set enabled of text field "TargetValue" of window "MainWindow" to true
set targetvalue to 89
try
set targetvalue to contents of default entry "TargetValue" of user defaults as integer
end try
set contents of text field "TargetValue" of window "MainWindow" to targetvalue
else
set enabled of text field "TargetValue" of window "MainWindow" to false
set contents of text field "TargetValue" of window "MainWindow" to 89
end if
else if name of theObject is "ARmatrix" then
set albumradio to current row of matrix "ARmatrix" of window "MainWindow" as integer
try
set contents of default entry "AlbumRadio" of user defaults to albumradio
end try
else if name of theObject is "Choose Folder" then
set ref_folder to choose folder with prompt "Choose the folder where the MP3/M4A files are stored"
set contents of text field "FolderPath" of window "MainWindow" to ref_folder as string
set ref_playlist to ""
set contents of text field "PlaylistName" of window "MainWindow" to ""
set state of button "Sub" of window "MainWindow" to true
set enabled of button "Sub" of window "MainWindow" to true
set enabled of button "Start" of window "MainWindow" to true
tell window "MainWindow" to update
end if
end clicked
on will finish launching theObject
-- display dialog "IN the will finish launching thing"
set running to false
set mypath to POSIX path of (path to me as string)
set aacgain to mypath & "Contents/Resources/aacgain"
set run_mp3gain to mypath & "Contents/Resources/run_mp3gain.pl"
try
make new default entry at end of default entries of user defaults with properties {name:"AlbumRadio", contents:1}
end try
set albumradio to 1
try
set albumradio to contents of default entry "AlbumRadio" of user defaults as integer
end try
set current row of matrix "ARmatrix" of window "MainWindow" to albumradio
my getpreferencebutton("Clip")
my getpreferencebutton("Sub")
my getpreferencebutton("Target")
my getpreferencebutton("Nice")
try
make new default entry at end of default entries of user defaults with properties {name:"TargetValue", contents:89}
end try
set targetvalue to 89
try
set targetvalue to contents of default entry "TargetValue" of user defaults as integer
end try
set contents of text field "TargetValue" of window "MainWindow" to targetvalue
set targetchecked to state of button "Target" of window "MainWindow" as integer
if targetchecked = 1 then
set enabled of text field "TargetValue" of window "MainWindow" to true
else
set enabled of text field "TargetValue" of window "MainWindow" to false
set contents of text field "TargetValue" of window "MainWindow" to 89
end if
set visible of progress indicator "BusyBar" of window "MainWindow" to false
tell window "MainWindow" to update
set visible of window "MainWindow" to true
end will finish launching
on will close theObject
quit
end will close
on changed theObject
set targetdb to integer value of text field "TargetValue" of window "MainWindow"
try
set contents of default entry "TargetValue" of user defaults to targetdb
end try
end changed
on idle
-- display dialog "idle " & running
if running is true then
set psout to ""
set stout to ""
try
set psout to do shell script "ps -auxww | grep \"" & run_mp3gain & "\" | grep -v grep"
set stout to do shell script "grep -a -v '^$' /tmp/.mp3gain_output | tail -1"
end try
if stout = "" then
if ref_playlist is not equal to "" then
set stout to "Processing iTunes playlist " & ref_playlist & " ..."
else
set stout to "Processing folder " & ref_folder & " ..."
end if
else
set stlen to length of stout
if stlen > 75 then
set firstpart to (characters 1 through 30 of stout) as string
set startlast to stlen - 30
set lastpart to (characters startlast through stlen of stout) as string
set stout to firstpart & "..." & lastpart
end if
end if
set contents of text field "StatusMessage" of window "MainWindow" to stout
tell window "MainWindow" to update
if psout is equal to "" then
set running to false
set title of button "Start" of window "MainWindow" to "Start"
tell progress indicator "BusyBar" of window "MainWindow" to stop
set visible of progress indicator "BusyBar" of window "MainWindow" to false
tell window "MainWindow" to update
set contents of text field "StatusMessage" of window "MainWindow" to "Processing complete."
set enabled of button "Start" of window "MainWindow" to false
set enabled of button "Choose Folder" of window "MainWindow" to true
set enabled of button "Choose Playlist" of window "MainWindow" to true
set enabled of button "Clip" of window "MainWindow" to true
set enabled of button "Sub" of window "MainWindow" to true
set enabled of button "Target" of window "MainWindow" to true
set enabled of button "Nice" of window "MainWindow" to true
set targetchecked to state of button "Target" of window "MainWindow" as integer
if targetchecked = 1 then
set enabled of text field "TargetValue" of window "MainWindow" to true
else
set enabled of text field "TargetValue" of window "MainWindow" to false
set contents of text field "TargetValue" of window "MainWindow" to 89
end if
set enabled of matrix "ARmatrix" of window "MainWindow" to true
set ref_folder to ""
set contents of text field "FolderPath" of window "MainWindow" to "No folder selected"
set ref_playlist to ""
set contents of text field "PlaylistName" of window "MainWindow" to "No playlist selected"
tell window "MainWindow" to update
end if
end if
return 1
end idle
on will quit theObject
if running is true then
try
set pids to do shell script "ps -auxww | egrep \"" & run_mp3gain & "|" & aacgain & "\" | grep -v grep | awk '{ print $2 }' | xargs kill"
end try
end if
end will quit
on getpreferencebutton(buttonname)
try
-- this is how to initialize the preferences mechanism...it will not reset the value if one exists already
make new default entry at end of default entries of user defaults with properties {name:buttonname, contents:0}
end try
set value to 0
try
set value to contents of default entry buttonname of user defaults as integer
end try
if value = 1 then
set state of button buttonname of window "MainWindow" to true
else
set state of button buttonname of window "MainWindow" to false
end if
end getpreferencebutton

hi riker123
it is written in applescript, but it is written for AppleScript Studio & Xcode which has now been superseded by AppleScriptObjC & Xcode, used under OSX 10.6
Looking at your Mac specs you could use AppleScript Studio & Xcode
to set this code up, you will find a copy of Xcode on your OSX installer disk.
Not to discourage you but Xcode needs a bit of work to get the hang off,
but that's part of the fun.
Budgie

Similar Messages

  • Help with Apple Script Code

    Hi,
    I found this Apple script online and here's how it works:
    tell application "QuickTime Player"
    activate
    try
    if not (exists document 1) then display dialog "Please open a QuickTime movie." buttons {"Cancel"} default button 1 with icon 1
    set thefile to (choose file name)
    save document 1 in thefile
    close document 1
    end try
    end tell
    +I run the Apple script+
    *1. It prompts me to open a movie file in Quicktime*
    +I open a movie in Quicktime+
    *2. It prompts me for an name and directory to save the new file in*
    +I enter a name and directory+
    *3. It saves a new reference movie in said directory with said name*
    This is useful if I want to customize every file, but unfortunately, I just want to mass create reference movies for a whole bunch of files.
    What I am looking for is for an Apple script that is a drag and drop application, so I can drop say 100 movie files or so, and have the Apple script create reference movie files with the same name and in the same directory automatically with no prompts.
    Since I am unfamiliar with Apple script I was wondering if someone would be able to edit my existing script to do what I want.
    Thanks so much for your help!

    Use Automator. It's great for repetitious tasks (like the one you've described), and it's very user-friendly. Open Automator, create a new workflow that executes the action you want, and you can apply that action to the resources you wish to edit.
    Good resource here:
    http://bit.ly/

  • Help with apple script for Chapter Markers (on each edit)

    Hi,
    My goal:
    Add for each edit in the sequence a chapter marker til the end of the sequence.
    (Bonus track would be: Name the marker like the current clipname )
    so far I could work it out, with a lot of googling.... but:
    Not working: character "a" is not typed, no idea why ?
    Not working: goto begin of sequnce at the beginning
    And: I need something like a loop til the end of the sequence
    help very appreciated !
    thanks
    P.S.: I work tith FCP 7
    Here's my code so far:
    tell application "Final Cut Pro"
      activate
              tell application "System Events"
                        delay 0.5
      key code 34 using {shift down} #Go to Begin
                        delay 0.5
      key code 125 # Arrow Down, next edit
                        delay 0.2
      key code 46 #Create a marker
                        delay 0.2
      key code 46 #Edit the marker title
                        delay 0.2
      key code 48 # TAB
                        delay 0.2
      key code 50 # <
                        delay 0.2
      key code 8 using {shift down} # C
                        delay 0.2
      key code 4 # h
                        delay 0.5
      key code 128 # a
                        delay 0.2
      key code 35 # p
                        delay 0.2
      key code 17 # t
                        delay 0.2
      key code 14 # e
                        delay 0.2
      key code 15 # r
                        delay 0.2
      key code 50 using {shift down} # >
                        delay 0.5
      key code 76 #Enter, Get out of marker window
                        delay 0.5
      key code 125 # Arrow Down
              end tell
    end tell

    Use Automator. It's great for repetitious tasks (like the one you've described), and it's very user-friendly. Open Automator, create a new workflow that executes the action you want, and you can apply that action to the resources you wish to edit.
    Good resource here:
    http://bit.ly/

  • Help with Apple Script

    Hi All,
    Every so often I have to delete an application from my mac. Since this involves opening 6 specific folders and trashing a file from within each I thought I could automate this.
    I've opened all the relevant windows in Finder, open AppleScript, hit "record" and then move each of the items into the trash (some require password entry to do this).  When I have finished, I hit "stop" but there's nothing there, it hasn't recorded anything.  Am I missing something (knowledge maybe?)
    Thanks
    G

    The Finder has a command to delete items (move them to the trash), and the command line has commands to remove items (although you need to be very careful), so it would just be a matter of making a list of the paths of the files you want to remove, for example:
    tell application "Finder"
      delete file "path:to:file"
      -- empty trash
    end tell

  • Help Needed with Apple Script

    I need a little help with Apple Script. I have been using a script for several months now, and all of a sudden it just stopped working. Here's the script"
    ============
    with timeout of 9999 seconds
    tell application "Finder"
    activate
    (* copy target file to another disk - to create a backup *)
    duplicate file "Daily.dmg" of folder "File Backups" of disk "HD Mirror" to folder "Data Backup-Daily" of disk "MacHD 1" replacing yes
    (* copy a 2nd target file to another disk - to create a backup *)
    duplicate file "Personal.dmg" of folder "File Backups" of disk "HD Mirror" to folder "Data Backup-Daily" of disk "MacHD 1" replacing yes
    (* now copy the 2nd target file to my iDisk *)
    duplicate file "Personal.dmg" of folder "Data Backup-Daily" of disk "MacHD 1" to folder "Documents" of disk "xxxxxx" replacing yes
    end tell
    end timeout
    ============
    In the above script, xxxxxx represents the name of my iDisk that is mounted in the Finder.
    Here's my issue - the above script worked fine until just recently. However, now the first two steps work fine, but I get this error message while trying to copy the file to my iDisk:
    "The operation could not be completed because some items had to be skipped. 'Personal.dmg'"
    Does anyone have any ideas on how I can fix this? I'm wondering if Mac OS 10.4.5 might be the culprit since this problem seems to have occurred shortly after I upgraded???
    Thanks,
    -AstraPoint

    Hi,
    Assumptions :-
    uuencode command exits
    mailx command exits
    File name is "vas.txt".
    Mail id is "[email protected]"
    # START OF SCRIPT
    #!/bin/ksh
    vasFileName="$1"
    vasRecordsDirFile=/etl/dev/work/wellness/enrl_rej/records/${vasFileName}
    vasMetatdataDirFile=/etl/dev/work/wellness/enrl_rej/metadata/${vasFileName}
    vasHeaderDirFile=/etl/dev/work/wellness/enrl_rej/header/${vasFileName}
    vasHeaderRejDirFile=/etl/dev/work/wellness/enrl_rej/hdrrej/${vasFileName}
    vasFieldsDirFile=/etl/dev/work/wellness/enrl_rej/fields/${vasFileName}
    if [[ -e ${vasRecordsDirFile} ]]
    then
    uuencode ${vasRecordsDirFile} ${vasRecordsDirFile} | mailx -s "process complete and attached are the rejected records" [email protected]
    elif [[ -e ${vasMetatdataDirFile} ]]
    then
    uuencode ${vasMetatdataDirFile} ${vasMetatdataDirFile} | mailx -s "Metadata Mismatch no of fields in detail didn't match" [email protected]
    elif [[ -e ${vasHeaderDirFile} ]]
    then
    uuencode ${vasHeaderDirFile} ${vasHeaderDirFile} | mailx -s "Problem with header file - File Rejected" [email protected]
    elif [[ -e ${vasHeaderRejDirFile} ]]
    then
    uuencode ${vasHeaderRejDirFile} ${vasHeaderRejDirFile} | mailx -s "the Percentage of rejects more than 3 percent File rejected" [email protected]
    elif [[ -e ${vasFieldsDirFile} ]]
    then
    uuencode ${vasFieldsDirFile} ${vasFieldsDirFile} | mailx -s "The header and detail count didn't match File rejected" [email protected]
    else
    echo "File doesn't exist in any of the directories mentioned."
    fi
    # END
    Vijay Bheemineni.

  • Open multi page pdf specific page in Illustrator CS4 with apple script

    I need to open multi page pdf specific page in Illustrator CS4 with apple script. Is it something like this:
    activate  (open file theTargetFolder as PDF with options …).
    Thank you.

    Carlos,
    Muchas Gracias por tu colaboración y excelente script, el que se abra el ESTK no tiene mayor importancia.
    El caso es que Adobe recomienda encarecidamente NO utilizar Illustrator para editar PDFs, por diversas razones, aunque cuando no hay otro remedio o herramienta disponible, o conocida ...
    Para llegar aquí, aparte de San Google, hay que ir a Adobe.es (en mi caso), pestaña de Ayuda,  ..... (hasta aqui bien),
    luego hay que bajar hasta el final y ver Comunidad y Foros...... (esto puede ser)
    al pulsar aparacen un montón de foros se supone de programas pero en inglés,
    y la última línea es de International Forums,  ya casi hemos llegado)
    pulsamos entonces, y por fin se abren cuatro palabras con idiomas, en una dice: español      (casi no me lo puede creer)
    pincho y llego por fin aquí.
    Muy poca gente sabe de la existencia de este pequeño refugio, si a esta dificultad añadimos la peculiar forma de ser de la gente, ....

  • Auto refresh with apple script- help please

    can any one help me please
    i use multiple windows in safari at one time and can any one help me to refresh these pages (two windows) automatically using apple script.
    also if I click manually to refresh these pages i get the following note"
    "To open this page again, Safari must resend the form you completed to open the page the first time. This may cause the website to repeat actions it took the first time you sent the form."
    and i have click send for this to happen
    any help from you all will be appreciated as this will help me a lot with the present work that i am doing

    Not sure about the "automatic" reload - Opera allows you to set a refresh time interval for each tab, but not Safari. Also, Safari Extender gives you a single click contextual menu option to "reload all tabs".
    here is an AppleScript for a one-page auto reload. You might be able to alter the script to auto reload all open tabs.
    Not sure about the "warning" message. Can you post a URL so I can have a look?

  • Selecting Different Printer With Apple Script.

    Hi,
    I am currently in the process of making a script to be able to print off labels without the need of much user input (read from a document or e-mail) and I want to be able to set the printer when it goes to the print screen.
    this is the final apple script step in the application cmd+p brings up the 1st print menu the return takes it to the second print menu cmd+v pastes predifind by the user the ammount of copys they want
    on run {input, parameters}
              tell application "Labels & Addresses"
      activate
                        tell application "System Events"
      keystroke "p" using command down
                                  delay 1
      keystroke return
                                  delay 1
      keystroke "v" using command down
                                  delay 1
                                  tell application "System Events"
                                            tell process "Labels & Addresses"
                                                      click (menu item whose description is "Printer")
                                                      click (menu item "Zebra Technologies ZTC GK420t" whose description is "Printer")
                                            end tell
                                  end tell
                                  return input
                        end tell
              end tell
    end run
    now there is chance to change the printer selection twice once in the 1st print screen and once in the 2nd print screen the only problem is im not sure how to apple script to select the right printer from the drop down menu, I got the code from a forum but I think it was old code as when I tested it it was returning errors so I modified it a bit and now it just struggles finding the menu item with description of printer.
    Does anyone know what I would have to use for it to select the right printer? (The Zebra Technologies ZTC GK420t)
    Help would be greatly appricited!
    Thanks,
    Bruce
    P.S. sorry the code is a bit messy!

    Im NOT sure if you have just made this a little over complicated… This works just fine for me. Tested with about a dozen psd layers…
    tell application "Adobe InDesign CS2"
    tell active document
    tell rectangle 1
    tell graphic 1
    tell graphic layer options
    set GLC to count of graphic layers
    repeat with i from 1 to GLC
    if name of graphic layer i ≠ "Blue" then
    set current visibility of graphic layer i to false
    else
    set current visibility of graphic layer i to true
    end if
    end repeat
    end tell
    end tell
    end tell
    end tell
    end tell
    This variant also works as I would have expected too… Retaining visibility from a list…
    tell application "Adobe InDesign CS2"
    tell active document
    tell rectangle 1
    tell graphic 1
    tell graphic layer options
    set On_List to {"Red", "Aqua", "Orange"}
    set GLC to count of graphic layers
    repeat with i from 1 to GLC
    if name of graphic layer i is not in On_List then
    set current visibility of graphic layer i to false
    else
    set current visibility of graphic layer i to true
    end if
    end repeat
    end tell
    end tell
    end tell
    end tell
    end tell

  • I need help with this script please ASAP

    So I need this to work properly, but when ran and the correct answer is chosen the app quits but when the wrong answer is chosen the app goes on to the next question. I need help with this ASAP, it is due tommorow. Thank you so much for the help if you can.
    The script (Sorry if it's a bit long):
    #------------Startup-------------
    display dialog "Social Studies Exchange Trviva Game by Justin Parzik" buttons {"Take the Quiz", "Cyaaaa"} default button 1
    set Lolz to (button returned of the result)
    if Lolz is "Cyaaaa" then
    killapp()
    else if Lolz is "Take the Quiz" then
              do shell script "say -v samantha Ok starting in 3…2…1…GO!"
    #------------Question 1-----------
              display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
              set A1 to (button returned of the result)
              if A1 is "Apprentices" then
                        do shell script "say -v samantha Correct Answer"
              else
                        do shell script "say -v samantha Wrong Answer"
      #----------Question 2--------
                        display dialog "Most children were taught
    to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
                        set A2 to (button returned of the result)
                        if A2 is "Bible" then
                                  do shell script "say -v samantha Correct Answer"
                        else
                                  do shell script "say -v samantha Wrong Answer"
      #------------Question 3---------
                                  display dialog "In the 1730s and 1740s, a religious movement called the_______swept through the colonies." buttons {"Glorius Revolution", "Great Awakening", "The Enlightenment"}
                                  set A3 to (button returned of the result)
                                  if A3 is "Great Awakening" then
                                            do shell script "say -v samantha Correct Answer"
                                  else
                                            do shell script "say -v samantha Wrong Answer"
      #-----------Question 4--------
                                            display dialog "_______ was
    a famous American Enlightenment figure." buttons {"Ben Franklin", "George Washington", "Jesus"}
                                            set A4 to (button returned of the result)
                                            if A4 is "Ben Franklin" then
                                                      do shell script "say -v samantha Correct Answer"
                                            else
                                                      do shell script "say -v samantha Wrong Answer"
      #----------Question 5-------
                                                      display dialog "______ ownership gave colonists political rights as well as prosperity." buttons {"Land", "Dog", "Slave"}
                                                      set A5 to (button returned of the result)
                                                      if A5 is "Land" then
                                                                do shell script "say -v samantha Correct Answer"
                                                      else
                                                                do shell script "say -v samantha Wrong Answer"
      #---------Question 6--------
                                                                display dialog "The first step toward guaranteeing these rights came in 1215. That
    year, a group of English noblemen forced King John to accept the…" buttons {"Declaration of Independence", "Magna Carta", "Constitution"}
                                                                set A6 to (button returned of the result)
                                                                if A6 is "Magna Carta" then
                                                                          do shell script "say -v samantha Correct Answer"
                                                                else
                                                                          do shell script "say -v samantha Wrong Answer"
      #----------Question 7--------
                                                                          display dialog "England's cheif lawmaking body was" buttons {"the Senate", "Parliament", "King George"}
                                                                          set A7 to (button returned of the result)
                                                                          if A7 is "Parliament" then
                                                                                    do shell script "say -v samantha Correct Answer"
                                                                          else
                                                                                    do shell script "say -v samantha Wrong Answer"
      #--------Question 8-----
                                                                                    display dialog "Pariliament decided to overthrow _______ for not respecting their rights" buttons {"King James II", "King George", "King Elizabeth"}
                                                                                    set A8 to (button returned of the result)
                                                                                    if A8 is "King James II" then
                                                                                              do shell script "say -v samantha Correct Answer"
                                                                                    else
                                                                                              do shell script "say -v samantha Wrong Answer"
      #--------Question 9------
                                                                                              display dialog "Parliament named ___ and ___ as England's new monarchs in something called ____." buttons {"William/Mary/Glorius Revolution", "Adam/Eve/Great Awakening", "Johhny/Mr.Laphalm/Burning of the hand ceremony"}
                                                                                              set A9 to (button returned of the result)
                                                                                              if A9 is "William/Mary/Glorius Revolution" then
                                                                                                        do shell script "say -v samantha Correct Answer"
                                                                                              else
                                                                                                        do shell script "say -v samantha Wrong Answer"
      #---------Question 10-----
                                                                                                        display dialog "After accepting the throne William and Mary agreed in 1689 to uphold the English Bill of _____." buttons {"Money", "Colonies", "Rights"}
                                                                                                        set A10 to (button returned of the result)
                                                                                                        if A10 is "Rights" then
                                                                                                                  do shell script "say -v samantha Correct Answer"
                                                                                                        else
                                                                                                                  do shell script "say -v samantha Wrong Answer"
      #---------Question 11------
                                                                                                                  display dialog "By the late 1600s French explorers had claimed the ___ River Valey" buttons {"Mississippi", "Ohio", "Hudson"}
                                                                                                                  set A11 to (button returned of the result)
                                                                                                                  if A11 is "Ohio" then
                                                                                                                            do shell script "say -v samantha Correct Answer"
                                                                                                                  else
                                                                                                                            do shell script "say -v samantha Wrong Answer"
      #------Question 12---------
                                                                                                                            display dialog "______ was sent to ask the French to leave 'English Land'." buttons {"Johhny Tremain", "George Washington", "Paul Revere"}
                                                                                                                            set A12 to (button returned of the result)
                                                                                                                            if A12 is "George Washington" then
                                                                                                                                      do shell script "say -v samantha Correct Answer"
                                                                                                                            else
                                                                                                                                      do shell script "say -v samantha Wrong Answer"
      #---------Question 13-------
                                                                                                                                      display dialog "_____ proposed the Albany Plan of Union" buttons {"George Washingon", "Ben Franklin", "John Hancock"}
                                                                                                                                      set A13 to (button returned of the result)
                                                                                                                                      if A13 is "Ben Franklin" then
                                                                                                                                                do shell script "say -v samantha Correct Answer"
                                                                                                                                      else
                                                                                                                                                do shell script "say -v samantha Wrong Answer"
      #--------Question 14------
                                                                                                                                                display dialog "The __________ declared that England owned all of North America east of the Mississippi" buttons {"Proclomation of England", "Treaty of Paris", "Pontiac Treaty"}
                                                                                                                                                set A14 to (button returned of the result)
                                                                                                                                                if A14 is "" then
                                                                                                                                                          do shell script "say -v samantha Correct Answer"
                                                                                                                                                else
                                                                                                                                                          do shell script "say -v samantha Wrong Answer"
      #-------Question 15-------
                                                                                                                                                          display dialog "Braddock was sent to New England so he could ______" buttons {"Command an attack against French", "Scalp the French", "Kill the colonists"}
                                                                                                                                                          set A15 to (button returned of the result)
                                                                                                                                                          if A15 is "Command an attack against French" then
                                                                                                                                                                    do shell script "say -v samantha Correct Answer"
                                                                                                                                                          else
                                                                                                                                                                    do shell script "say -v samantha Wrong Answer"
      #------TheLolQuestion-----
                                                                                                                                                                    display dialog "____ is the name of the teacher who runs this class." buttons {"Mr.White", "Mr.John", "Paul Revere"} default button 1
                                                                                                                                                                    set LOOL to (button returned of the result)
                                                                                                                                                                    if LOOL is "Mr.White" then
                                                                                                                                                                              do shell script "say -v samantha Congratulations…you…have…common…sense"
                                                                                                                                                                    else
                                                                                                                                                                              do shell script "say -v alex Do…you…have…eyes?"
                                                                                                                                                                              #------END------
                                                                                                                                                                              display dialog "I hope you enjoyed the quiz!" buttons {"I did!", "It was horrible"}
                                                                                                                                                                              set endmenu to (button returned of the result)
                                                                                                                                                                              if endmenu is "I did!" then
                                                                                                                                                                                        do shell script "say -v samantha Your awesome"
                                                                                                                                                                              else
                                                                                                                                                                                        do shell script "say -v alex Go outside and run a lap"
                                                                                                                                                                              end if
                                                                                                                                                                    end if
                                                                                                                                                          end if
                                                                                                                                                end if
                                                                                                                                      end if
                                                                                                                            end if
                                                                                                                  end if
                                                                                                        end if
                                                                                              end if
                                                                                    end if
                                                                          end if
                                                                end if
                                                      end if
                                            end if
                                  end if
                        end if
              end if
    end if

    Use code such as:
    display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
    set A1 to (button returned of the result)
    if A1 is "Apprentices" then
    do shell script "say -v samantha Correct Answer"
    else
    do shell script "say -v samantha Wrong Answer"
    return
    end if
    #----------Question 2--------
    display dialog "Most children were taught to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
    set A2 to (button returned of the result)
    if A2 is "Bible" then
    do shell script "say -v samantha Correct Answer"
    else
    do shell script "say -v samantha Wrong Answer"
    return
    end if
    (90444)

  • How can I get the size of a file with apple script

    I try to get the size of a file within an apple script. But I did not find information how to do this.

    There are two ways. I think Apple is moving toward using System Events, which is listed first.tell application "Finder"
    set myFile to selection as alias
    --this just gets a file for me to work with
    --coercing it into an alias is required for the other functions
    end tell
    tell application "System Events"
    get size of myFile
    end tell
    set myInfo to (info for myFile)
    get size of myInfo

  • Help creating apple script to create folder and set access levels

    I'm trying to create folders in FileMaker Pro using apple script and need some help in setting the access level for the folders.  I want to set both Staff and everyone to Read and Write access.   Secondly I would like to have a function key set on the desktop to create new folders and set that same access level.  The default access is Read and I can not find a way to change that.
    Thanks

    I'm trying to create folders in FileMaker Pro using apple script and need some help in setting the access level for the folders.  I want to set both Staff and everyone to Read and Write access.   Secondly I would like to have a function key set on the desktop to create new folders and set that same access level.  The default access is Read and I can not find a way to change that.
    Thanks

  • Move a mouse with Apple script

    Hello,
    I need some apple script code to move a mouse to a certain location and then click. If possible could it record the location of the mouse, move it to the pre-assigned coordinates, click, and them move it back to where it was.
    I am doing this so I can use multivid and Qlab to play different videos on different iOS devices. Multivid doesn't seem to let me have a cue list with different videos playing simultaneously.
    I will have my iMac set up with 2 displays, one with Qlab and the other with multivid in full screen.
    Thanks for the help

    Here's another code using rubycocoa you might try.
    _rb_click({|:position|:{30, 10}, |:click|:1, |:restore|:true, |:prep|:false})
    on _rb_click(desc)
            record desc : event descriptor record;
                full spec = {|:position|:pos, |:click|:k, |:button|:b, |:flags|:m, |:restore|:r, |:prep|:p}
                defaults   = {|:position|:{}, |:click|:0, |:button|:1, |:flags|:"", |:restore|:false, |:prep|:true}
                list pos : {x, y} or {}
                    number x, y = x, y global coordinate of position
                    {} denotes current location
                integer k : click count (0, 1, 2 or 3}; 0 denotes only to move mouse and exit
                integer b : button index (1 = left button, 2 = right button)
                string m : modifier flags; e.g. 'ck' = control + command
                    a = capslock
                    s = shift
                    c = control
                    o = option
                    k = command
                boolean r : true to restore original mouse location, false otherwise
                boolean p : true to post preparatory left 1-click event to change UI context, false otherwise
            return list : {x, y} = mouse location at exit
        considering numeric strings
            if (system info)'s system version < "10.9" then
                set ruby to "/usr/bin/ruby"
            else
                set ruby to "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby"
            end if
        end considering
        set defaults to {|:position|:{}, |:click|:0, |:button|:1, |:flags|:"", |:restore|:false, |:prep|:true}
        set {|:position|:pos, |:click|:k, |:button|:b, |:flags|:m, |:restore|:r, |:prep|:p} to desc & defaults
        if pos = {} then
            set {x, y} to {"%", "%"}
        else
            set {x, y} to pos
        end if
        if k is not in {0, 1, 2, 3} then error "invalid click count: " & k number 8000
        if b is not in {1, 2} then error "invalid button index: " & b number 8000
        if m = "" then set m to "%"
        do shell script ruby & " <<'EOF' - " & x & " " & y & " " & k & " " & b & " " & m & " " & r & " " & p & "
    require 'osx/cocoa'
    include OSX
    if ARGV[0..1] == ['%', '%']
        pt = CGEventGetLocation(CGEventCreate(nil))        # current mouse location
    else
        pt = CGPoint.new
        pt.x, pt.y = ARGV[0..1].map {|a| a.to_f}
    end
    clk, btn = ARGV[2..3].map {|a| a.to_i}
    flg = ARGV[4]
    res, prep = ARGV[5..6].map {|a| a == 'true'}
    etype, mbtn = case btn
        when 1 then [KCGEventLeftMouseDown, KCGMouseButtonLeft]        # [1, 0]
        when 2 then [KCGEventRightMouseDown, KCGMouseButtonRight]    # [3, 1]
        when 3 then [KCGEventOtherMouseDown, KCGMouseButtonCenter]    # [25, 2]
        else raise ArgumentError, %[invalid mouse button: #{btn}]
    end
    mtable = {
        'a'    => KCGEventFlagMaskAlphaShift,
        's'    => KCGEventFlagMaskShift,
        'c'    => KCGEventFlagMaskControl,
        'o'    => KCGEventFlagMaskAlternate,
        'k'    => KCGEventFlagMaskCommand,
    mf = flg.split(//).inject(0) { |mf, x| (m = mtable[x]) ? mf | m : mf }
    src = CGEventSourceCreate(KCGEventSourceStateHIDSystemState)
    tap = KCGHIDEventTap
    pt0 = CGEventGetLocation(CGEventCreate(src))                    # current mouse location
    # move mouse to target location
    ev0 = CGEventCreateMouseEvent(src, KCGEventMouseMoved, pt, 0)    # move mouse
    CGEventPost(tap, ev0)
    if clk == 0
        puts pt.x, pt.y
        exit
    end
    # post preparatory left mouse click to change UI context (optional)
    if prep
        ev1 = CGEventCreateMouseEvent(src, KCGEventLeftMouseDown, pt, KCGMouseButtonLeft)    # mouse left button down
        CGEventPost(tap, ev1)
        CGEventSetType(ev1, KCGEventLeftMouseUp)                    # mouse left button up
        CGEventPost(tap, ev1)
    end
    # post target mouse click(s) with given flags
    ev = CGEventCreateMouseEvent(src, etype, pt, mbtn)                # mouse button down
    CGEventSetFlags(ev, mf)                                            # set flags
    CGEventSetIntegerValueField(ev, KCGMouseEventClickState, clk)    # set click count
    CGEventPost(tap, ev)
    CGEventSetType(ev, etype + 1)                                    # mouse button up
    CGEventPost(tap, ev)
    # restore mouse location (optional)
    if res
        CGEventSetLocation(ev0, pt0)                                # restore mouse location
        CGEventPost(tap, ev0)
        puts pt0.x, pt0.y
        exit
    end
    puts pt.x, pt.y
    EOF"
        set rr to paragraphs of result
        repeat with r in rr
            set r's contents to r as number
        end repeat
        return rr
    end _rb_click

  • Removing BCC with Apple Script when automatically BCC myself is set in pref

    I have "Automatically Bcc myself" set in the Mail Composing preferences, which I like because I get a copy of email that I send. I also have an apple script that forwards messages to an email address. When I used this apple script on Tiger, the BCC option was never added (it might have been a bug with Mail in Tiger); however, now on Leopard, the BCC option is always added when I used the apple script.
    I've tried setting the BCC field to Null and Blank, but that doesn't seem to work. I suspect that the field is set upon send or the "make new" directive. Does anyone know a way to tell Mail to not Bcc automatically in an Apple Script?
    Here is the forward apple script program:
    (* Cf. http://www.macosxhints.com/article.php?story=20060219014940761 *)
    (* RS 31st July 2006 *)
    set theAuthority to "person AT here"
    tell application "Mail"
    set theMessages to the selection
    repeat with thisMessage in theMessages
    set newMessage to make new outgoing message at end of outgoing messages
    tell newMessage
    set visible to true (* comment out whole line to stop 'blinking' windows *)
    set content to thisMessage's source
    set subject to "Fwd: " & thisMessage's subject
    set bcc to null (* my attempt to set bcc to null or blank *)
    make new to recipient with properties {address:theAuthority}
    end tell
    send newMessage
    set read status of thisMessage to true
    set was forwarded of thisMessage to true
    set junk mail status of thisMessage to true
    end repeat
    end tell

    Thanks for that reply!
    After more google searching, I found this on http://www.macosxhints.com/article.php?story=20040425063255443
    One of the responses said that you can add the lines:
    delete bcc recipients
    delete cc recipients
    "in that order" to the new message tell and get rid of the recipients. I had tried the delete before, but I thought I had to get the recipients before I deleted them. I'm not a very good apple script person. Here is my final script
    (* Cf. http://www.macosxhints.com/article.php?story=20060219014940761 *)
    (* RS 31st July 2006 *)
    set theAuthority to "email address here"
    (* or your personal Knujon address *)
    tell application "Mail"
    set theMessages to the selection
    repeat with thisMessage in theMessages
    set newMessage to make new outgoing message at end of outgoing messages
    tell newMessage
    set visible to false (* comment out whole line to stop 'blinking' windows *)
    set content to thisMessage's source
    set subject to "Fwd: " & thisMessage's subject
    make new to recipient with properties {address:theAuthority}
    delete bcc recipients
    delete cc recipients
    end tell
    send newMessage
    set read status of thisMessage to true
    set was forwarded of thisMessage to true
    set junk mail status of thisMessage to true
    end repeat
    end tell

  • Help with simple script

    I was wondering if someone could help me with a simple bit of action script 3. I need to make a movie clip (single_mc) disappear when the user clicks on the mouse (stop_btn). Here’s what I have so far.
    function setProperty(event:MouseEvent):void
    single_mc.alpha=0;
    stop_btn.addEventListener(MouseEvent.CLICK, setProperty);
    Also I was wonder if you could recommend an Action script 3 book for me. I would like one that is not a training book, but has situations and then the script written out. For example: I click a button and a movie symbol disappears from the stage. I am a graphic artist, that from time to time, needs simple interaction in flash, but cant justify the time to learn the script.
    Thanks for your time

    use the snippets panel to help with you with sample code for basic tasks.
    function setProperty(event:MouseEvent):void
    single_mc.visible=false;
    stop_btn.addEventListener(MouseEvent.CLICK, setProperty);

  • Help with sizing script

    I found a script online that turns my images into a square (by extending the canvas size of the short side to match the length of the long side) which is awesome, but I would like to do an additional step and I have no scripting experience so hopefully someone can help.
    now that my images are square I want to set a maximum dimension of 2500x2500 px, i have found scripts to set a resolution to a specific size but what I want to make sure I avoid is upsampling, so I just want any image larger than 2500x2500 px to down sample to 2500x2500 px
    any knowledge on the code for this would be much appreciated.
    When I am at the machine with the script I currently use I will paste it here in the meantime if you know something about scaling images down but preventing scaling them up I could probably chimp with the code I have and make it work.

    Photoshop shipts with a plug-in script that will do that for you. its found under menu File>Automate>Fit Image. Set both width and height to 2500 and check do not resize images that fit so your small square images will not be resized up in size.  You could also just create an action that uses both scripts
    step 1 menu File>Scripts>Make canvas Square.
    setp 2 menu File>Automate>Fit Image.  The 2500 x 2500 no upsize option settings will be recorded into the step and when the action is used its dialog will be bypassed and the recorded settings will ne used.
    You can then batch the action using menu file>Automate>Batch or menu File>Scripts>Image Processor.

Maybe you are looking for

  • STOLEN MacBook Pro (13-inch, Mid 2012) Serial number: C1*******TY4

    Hello to everyone, My Macbook Pro was stolen while travelling in China on my way from Yangshuo to Guilin. I know its maybe just another post about a stolen computer for everybody but I have to try anyways ! The serial number is as stated above: C1***

  • Business Catalyst IDX Integration

    I am creating a real estate website for a client that needs IDX integration within their website. For any that are unfamiliar with IDX, it is basically a way of integrating the MLS database (that is, the database of US homes for sale) into websites.

  • Report to executed as soon as F110 is run

    Hi All, I have a requirement where in i need to run a report as soon as F110 transaction is run. The input to the report will the same payment run id and date as on the F110 transaction. How can i achieve this. Regards, Jayant

  • Where the hell do the system.out.println s go ??

    I am using 9ifs 9.0.1 in windows accessing ifsservers through jsps. I am wondering where will the SOP 's be printed whil accessing the ifsserver through jsps 's. I guessed it was at the apachev jserv log files. I turned the log on and also checked al

  • ORA-01002: fetch out of sequence error

    Hello friends, I m facing a prob using a cursor for update. here is a piece of code: DECLARE                CURSOR c_tot_inv_qty (p_prd_id tr_periods.period_id%TYPE) IS SELECT total_inv_qty, item_id, period_id, dc_id FROM inv_dc_tmp WHERE period_id =