Applescript works in Automator but not as Application workflow

I have a pretty simple Application workflow in automator that runs this applescript:
set front_app to (path to frontmost application as Unicode text)
tell application front_app
activate
set bounds of window 1 to {0, 0, 1280, 800}
end tell
as you can see all it does is it maximizes the current window. it works when I run the script from within automator, but when i save it as an application and run that it says the applescript errored.
Why is my simple automator not working as an application?
Message was edited by: Pyrolistical

When you run that script as an application it comes to the front and is therefore the frontmost application: it doesn't have a window to be maximised.
You would need to specify the actual application to have its window maximised:
tell application "Safari"
activate
set bounds of window 1 to {0, 0, 1280, 800}
end tell
Trying to find out which was the frontmost application before you launched the AppleScript application is going to to be difficult.

Similar Messages

  • Applescript works in Automator, but not when app is opened - running all if statements at once?

    Good evening,
    I am new to applescript and have a newbie question regarding the following code. I am making a simple automator program to pull songs from iTunes to practice dancing to. I've started the program with a script that lets the user choose which dances (s)he wants to be played. Then I use applescript to run if statements for each dance, checking whether the dance was selected (and is therefore in "danceList"). If so, I call a separate app to handle finding and playing that dance. The whole thing runs perfectly once opened in automator.
    The problem is when I try to open the app for the first time, whether in finder or in automator -- it calls every single one of the if-statement applications, all at once, before anything else has happened, and thus crashes itself. I have no idea why. I have searched various help sites, tried multiple variations of the if statement code (waltz is an example, below) and making the sub-applications into workflows, but that didn't help.
    Any advice or pointers in the right direction/to appropriate resources would be greatly appreciated.
    Here is a snippet from the relevant code: (didn't include it all, it's the same thing with more if statements)
    on run {danceList}
              if danceList is not null then
                        if danceList contains "Waltz" then
                                       tell application "waltz"
                                                      run
                                       end tell
                                       delay 110
                        else
                                       tell application "waltz"
                                                      quit
                                       end tell
                        end if
                        if danceList contains "Tango" then
                                       tell application "tango"
                                                      run
                                       end tell
                                       delay 110
                        end if
                        if danceList contains "Viennese Waltz" then
                                       tell application "viennese"
                                                      run
                                       end tell
                                       delay 110
                        end if
    ... and so forth ...
        end if
        return danceList
    end run

    Ok, let me try to do a better job explaining.
    I am making this app to simulate the rounds used in competitive ballroom dancing. It lets the user select the dances they will participate in, and then, for each dance, the program reads out the dance title, chooses all songs in iTunes with that genre, selects one at random, starts playing it, waits ninety seconds, and then stops the music. Then a twenty second pause before the next dance. I have made eleven apps for this; one is the main app that calls the others; the others are identical and handle the individual dances.
    Here is all the code I have:
    1. Ask for confirmation - dialogue box explaining app
    2. Get specified text - list of all dances, passed to first section of applescript
    3. First section of script - found on internet, altered for multiple selection; lets user choose multiple dances from a list (code is below pic)
    on run {input, parameters}
    choose item(s) from text
    input: text - items are delimited by paragraphs (returns/newlines)
    output: a list of paragraphs selected
              set output to {}
              set NameList to {}
              set NameList to paragraphs of (input as text)
      activate me
              set TheChoice to (choose from list NameList with title "Choose Dances" with empty selection allowed and multiple selections allowed)
              if TheChoice is false then
                        error number -128 -- cancel
              else
                        set output to TheChoice
              end if
              return the output -- pass the result to the next action
    end run
    4. Store value of variable as "danceList" - probably unnecessary but gave it a name
    5. Second section of applescript - what's been discussed previously, here's the full code:
    on run {danceList}
              if danceList is not "" then
                        if danceList contains "Waltz" then
                                  tell application "waltz"
                                            run
                                  end tell
                                  delay 110
                        end if
                        if danceList contains "Tango" then
                                  tell application "tango"
                                            run
                                  end tell
                                  delay 110
                        end if
                        if danceList contains "Viennese Waltz" then
                                  tell application "viennese"
                                            run
                                  end tell
                                  delay 110
                        end if
                        if danceList contains "Foxtrot" then
                                  tell application "foxtrot"
                                            run
                                  end tell
                                  delay 110
                        end if
                        if danceList contains "Quickstep" then
                                  tell application "quickstep"
                                            run
                                  end tell
                                  delay 110
                        end if
                        if danceList contains "Samba" then
                                  tell application "samba"
                                            run
                                  end tell
                                  delay 110
                        end if
                        if danceList contains "Cha cha" then
                                  tell application "chacha"
                                            run
                                  end tell
                                  delay 110
                        end if
                        if danceList contains "Rumba" then
                                  tell application "rumba"
                                            run
                                  end tell
                                  delay 110
                        end if
                        if danceList contains "Paso Doble" then
                                  tell application "paso"
                                            run
                                  end tell
                                  delay 110
                        end if
                        if danceList contains "Jive" then
                                  tell application "jive"
                                            run
                                  end tell
                                  delay 110
                        end if
              end if
              return danceList
    end run
    Here is the code for the waltz app. All the other dance apps are identical; they just search for different terms and have a different introduction spoken.
    1. Get specified text - "Next Round is the Waltz, etc."
    2. Speak text - reads text out loud so people know what's next
    3. Find iTunes tracks where genre is "Waltz" or "waltz"
    4. select these tracks
    5. store all these in variable "tracks"
    6. applescript to pick a random track from "tracks":
    on run {tracks}
              set maxNumber to count of tracks
              set randy to random number from 1 to maxNumber
              set chosenTrack to item randy of tracks
              return chosenTrack
    end run
    7. 3 second pause between speech and music
    8. Start playing the chosen track
    9. 90 second wait while track plays
    10. pause itunes (stop music)
    11. end app
    Again, my concern here is why the program runs fine once it has already been opened in automator (say second or third time running it there) but when run from finder, or first opened in automator, it calls all the dance apps at once. Then they give error messages because the speech section is first, and this can't be done simultaneously:
    Also, not sure if this is relevant, but I have a spinning gear in the corner of my mac that I believe is automator launcher, and it's showing all the apps as running even after I've ok'd their error messages and they have disappeared from the dock. I can exit waltz and danceApp, which are the two actually running, but the others won't stop until I've ended automator launcher in activity monitor.
    Hopefully this is more helpful. Thanks again.

  • Bluetooth issue when working with Safari but not other applications

    I have tried two new bluetooth headsets (Motorola 9HD and Sony DR-BT100cx) that both can Pair with and work just fine with the local itunes application and any DVD I use. But these devices do not work with Safari. I tried going to Hulu, YouTube, etc and i can tell the bluetooth device is 'listening' because I can hear it click or wait for a signal. But I never hear anything. If i switch over to DVD or my Podcasts that are local, it works fine. If I go to bluetooth settings and select 'stop using headset' the MacBook speakers pick up right away.
    Note: I am a brand new Mac user, so please disregard my OS version I have selected. I have no idea how to find my OS version, nor do I know how to install Firefox to see if it is simply a browser issue.
    Thanks,
    Jay

    I have the same issue. I've tried 3 different btooth headsets, and they all react the same:
    - music: ok
    - skype: ok
    - webcasts / video (safari or firefox): no sound, and video stops
    HOWEVER: same system, same headset, using Internet Explorer in my windows xp VM: everything works.
    Anyone know how to contact Apple and log this issue?

  • Flash Movie works when testing, but not in application

    My flash movie works when I "Test Movie" within Flash 8 or
    when I press F12 and open it in the browser, but it only show the
    dynamic text, not the pictures when I place it within my page. The
    dynamic text changes properly but no images are displayed.

    I suspect this is where my issue lies, but I am not sure how
    to fix it. I have attached some code that defines the image
    location. I am able to successfully retrieve documents with the
    following, is this the same type of scenerio,
    http://www.skytitleagency.com/documents/Land_Contract.doc,
    except in the images folder ?

  • Custom F4 help in a BSP application working in Mozilla but not in IE

    Hi,
    I have created a custom F4 help in a BSP application.
    It is working in Mozilla but not in IE. I tried enabling javascript as well but still it is not working.
    Can someone please suggest a possible solution for this?

    Hi,
    See simmilar discussion in thread /thread/1883519 [original link is broken]
    I think this may be helpful for you.
    Thanks,
    Chandra

  • Password works for login but not for the Adobe CC Desktop application

    Password works for login but not for the Adobe CC Desktop application

    Please refer to http://helpx.adobe.com/creative-cloud/kb/troubleshoot-cc-installation-download.html
    ou can try deleting OPM.DB from steps below and try again.
    Mac OS: You can locate the OPM.db file in the \User\\Library\Application Support\Adobe\OOBE folder. To access the hidden user Library folder, see Access hidden user library files | Mac OS 10.7 Lion. - http://helpx.adobe.com/x-productkb/global/access-hidden-user-library-f iles.html
    Windows: You can locate the OPM.db file in the :\Users\\AppData\Local\Adobe\OOBE folder.  To view the hidden AppData folder, see Show hidden files, folders, filename extensions | Windows XP, Vista, Windows 7. -http://helpx.adobe.com/x-productkb/global/show-hidden-files-folders-ex tensions.html
    3) update to the latest version of the Creative Cloud app.
    Also we would like few more details:
    When has this issue started occurring, was this after installation of any specific adobe product.
    On which platform are you seeing this.
    Also we would like to know if after above steps this issue occurs ever again in future.
    You can refer to http://forums.adobe.com/thread/1239510
    Regards,
    Rajshree

  • Java works on chrome but not on firefox

    Java works on Chrome but not Firefox. I've uninstalled and reinstalled Firefox. Chacked all appropriate boxes in Control Panel. Deleted JavaReg.Dat. Enabled plugin. Uninstalled all Java from my computer and reinstalled. Cleared Firefox Cache. No luck.

    Do you see the Java plugin in Tools > Add-ons > Plugins ?
    Firefox is a 32 bit application, so you need to install the 32 bit Java version.
    See Java Platform > Java SE 7U5 or Java 6U33 (Downoad JRE)
    *http://www.oracle.com/technetwork/java/javase/downloads/index.html

  • Flash 10 works in FF but not Safari, OS X 10.5

    About a week ago flash stopped working in Safari and both firefox and safari started bugging me to install a newer version.  Muttering, I went to the download page and downloaded the latest, which claims to be for Safari, Opera, and firefox.
    Installation completes fine with no errors.  Firefox works.  But in Safari, I just get the usual 'no flash installed, would you like to download it?'
    I've downloaded and installed multiple times, no dice.  Plug-ins are enabled on Safari.  I do not have settings folders to delete--/Library/Application Supprt/Adobe has no flash player folder, only Acrobat, Updater6, and Help.
    This whole thing is a black box and I don't see what else to do.  Installation completes and there's no way to verify anything.  Any ideas would be welcome.

    Thanks! BTW I'm also having trouble updating Adobe Reader. I have 9.4.0 and want to update to the new Adobe Reader X. I keep getting Error 1402 which refers to the registry keys. I am unable to completely uninstall the old version. After receiving the error message it reloades the older version. I read about how to modify the registry to accept it but I believe this is a very wierd way to have to get an update loaded. Any suggestions?
    Date: Mon, 27 Dec 2010 10:34:22 -0700
    From: [email protected]
    To: [email protected]
    Subject: Flash Player works in IE8 but not Safari
    Hi Bruce, Adobe Flash Player is Installed separately into IE, since Windows uses the ActiveX Control. Firefox and other non-IE
    browsers must use the plugin Installer.
    This is the Adobe site :
    http://www.adobe.com/products/flashplayer/fp_distribution3.html
    Hope that explains it.
    Thanks,
    eidnolb
    >

  • Flash shockwave 11.5 works for youtube but not amazon instant video

    Shockwave 11.5 r502 works for Youtube but not for Amazon Instant Video.

    Hi,
    It asked me if I wanted to install something to make the videos load faster -
    Check Safari / Preferences - Extensions. Might be lurking there. If so, select the plugin then click Uninstall.
    Check:
    ~/Library/Internet Plug-Ins (~) Tilde character represents your Home folder
    Check:
    /Library/Internet Plug-Ins
    /Library/Application Support
    /Library/Input Managers
    And check your Safari downloads folder. If the file is still there, double click to open. Might be an uninstaller you can use.
    Help here for troubleshooting Flash
    Carolyn
    Message was edited by: Carolyn

  • Why does the counter work in MAX, but not Labview?

    Please help, I have been away from Labview for over 3 months, and I am quite rusty....
    Last year, I successfully configured NI9401 to measure period (seconds) by counting the rising edges of my sensor signal.  Since then, I have aquired a new PC, and loaded all my software into it, including the Labview VI's that successfully worked on the old computer.
    I can see the digital signal using MAX and the test panel for the NI9401, so, I know my wiring and my TTL signal is OK, but, when I try to run the attached VI, nothing happens except the error below..  How do I tell this VI to look for the signal on MOD3/CTR0 and channel 14?
    Thanks. I am sure it is a small adjustment...this worked fine a few months ago...not sure what is wrong now.
    Thanks,
    Dave
    Solved!
    Go to Solution.
    Attachments:
    continuously measure period buffered_singlechannel_forum_feb_23_2012.vi ‏20 KB

    OK, now.  Resolved the issue. The vi is fine, but, some shaky wires were identified...worked in MAX but not in the vi.  Now that the connections have been tightened up, it works for both.  Sorry for the inconvenience.
    Dave

  • HT1911 I just verified my Apple user ID and password but certain updates won't download (gives me the signal that I'm incorrect).  I keep changing it, verifying but not all applications let me proceed.

    I just verified my Apple user ID and password but certain updates won't download (gives me the signal that I'm incorrect).  I keep changing it, verifying but not all applications let me proceed.  So I can't download itunes software updates or update my iphone even though I have just verified my info.  I know others that have this problem but can't get support to resolve it.

    Hi mpellichero,
    Thanks for visiting Apple Support Communities.
    The steps in this article can help if you are being asked for the password to your previous Apple ID:
    iOS 7: If you're asked for the password to your previous Apple ID when signing out of iCloud
    http://support.apple.com/kb/TS5223
    Best Regards,
    Jeremy

  • Works on emulators but not on mobile devices

    Hello,
    My project works on emulators but not on mobile devices (no image and on Samsung it says "unsupported file").
    Please help, I don't know what to do. My configurations: MIDP 2.1, CLDC 1.1.
    Thanks in advance.
    Edited by: Vitali.pom on Oct 27, 2011 12:01 PM

    Edit: I succeeded to solve it accidentally. I did the following: Sign the jar in Netbeans, clean and build, the jar didn't work, I wiped out the .ks from the jar and clean and build again. Now it worked.
    Edited by: Vitali.pom on Oct 30, 2011 1:28 AM

  • Wifi works at home but not when away from home

    My Wifi works at home but not when away from home, what is wrong?  I thought with a phone plan I didn't need to have a wifi connection.

    You either need WiFi or Cellular (or both). If you have neither, you can't connect to the internet.
    Most people use WiFi at home and Cellular while away from home, or connect to public WiFi networks where there are some.

  • Can't FaceTime anymore?  iPad states wifi connected and iPhone 4 states not connected?  I have wireless in my home? Not sure what happened.  Password works for iPad but not on phone?

    iPhone won't connect to wifi.  iPad is connected.  Password working on iPad but not on phone.  Can't upload software update of IOS 7.1 because phone not connecting to wifi?

    Connect iPhone to computer and open iTunes.  You will be prompted to update to iOS 7.0.  Keep your phone connected until the update is finished.

  • My apple id works on itunes but not on my ipod touch, what gives ?

    my apple id works on itunes but not on my ipod touch, what gives ?

    What are you trying to do on the iPod?
    Have you went to Settings>Store and sign out and then sign back in?

Maybe you are looking for

  • Syncing Issues: album art, cut-off songs

    I have a 16GB iPod Touch that I've been syncing with my Windows Vista PC, seemingly without complications. It has only recently come to my attention that somewhere between my computer's library and my library on my iPod, something is messing up at ra

  • Field symbols and data extract

    hi frenz, Can anybody please give me details about <b><i>field symbols</i></b> and <b><i>data extracts</i></b> what is the purpose of  using them and regarding the performance issues for the two..... if some one explains with an example its going to

  • Questions re: Bridge CS3

    I am new into using Bridge even though I have it for a while. I am trying to solve these problems: 1. How come some files do not have thumb nail previews, but when I play them in the monitor windows, they play fine. Just no thumb nail preview? 2. Is

  • Adobe Flash player, shockwave just doesn't work.

    For flash player, I'm using chrome and firefox, somehow flash player just won't work I checked the flash player is installed, and can see the animation at no. 5 https://helpx.adobe.com/flash-player.html But when I tries to view a video from cbs site,

  • Freehand keeps crashing!

    I need some help! I've been using Freehand v 11.0.2 for some time now, but recently I was having issues with my copies of Windows and installed Windows 7 Home Premium, 64-bit and reinstalled the same Freehand disc. The program opens fine but when I c