Jake3231

Q: Applescript and interface won't run together

I am creating a Cocoa Applescript application, and I have an applescript to make speech recognition server listen for commands to use as input.  I also have a small window that should appear at the top.  When I run the application, the speech recognition window appears and works like it is supposed to.  Sometimes the window I created doesn't show up until I quit the applescript part of the program, or it is gray and unusable until I quit the applescript part.  I want them to run side-by-side.  I am aiming for the speech recognition window appearing like normal, and the other window appearing at the same time (or close to the same time) and both working.

MacBook Pro, OS X Mavericks (10.9)

Posted on Oct 26, 2013 12:57 PM

Close

Q: Applescript and interface won't run together

  • All replies
  • Helpful answers

first Previous Page 4 of 4
  • by Jake3231,

    Jake3231 Jake3231 Feb 14, 2014 4:59 PM in response to red_menace
    Level 1 (68 points)
    Feb 14, 2014 4:59 PM in response to red_menace

    Thanks!  I have tried your suggestions. Here is the code I have now.

    on setvoiceSamantha_(sender)

        set theFile to Cocoa's NSBundle's mainBundle's pathForResource:"Samantha.SpeechVoice"

        tell application "Finder"

        copy theFile to folder (path to voices from user domain)

        end tell

     

               end setvoiceSamantha_

    It hasn't worked either.  I also tried using "path to resource "Samantha.SpeechVoice", but it said that it got an unrecognized selector sent to ???????

  • by red_menace,

    red_menace red_menace Feb 14, 2014 6:29 PM in response to Jake3231
    Level 6 (15,546 points)
    Desktops
    Feb 14, 2014 6:29 PM in response to Jake3231

    Cocoa uses POSIX paths, which the FInder doesn't know about, so you need to use one or the other.  Also, the Finder's copy command (which isn't implemented) is for the clipboard - duplicate is the command to use.  You also need to use the added voice's bundle identifier and get the system to look for it, so the whole thing would be something like:

     

    property synthesizer : missing value # outlet for the voice synthesizer
    
      on setSamVoice() # load and set voice from bundle resource
        set voiceFileName to "Samantha.SpeechVoice"
        set voiceFile to path to resource voiceFileName
        set userFolder to (path to voices from user domain) # user library
        tell application "Finder"
          if not (folder ((userFolder & voiceFileName) as text) exists) then duplicate voiceFile to userFolder
        end tell
        current application's NSSpeechSynthesizer's availableVoices() # make the system look
        synthesizer's setVoice:"com.apple.speech.synthesis.voice.samantha.premium" # voice bundle identifier
      end setSamVoice
    
  • by Jake3231,

    Jake3231 Jake3231 Mar 13, 2014 5:04 PM in response to red_menace
    Level 1 (68 points)
    Mar 13, 2014 5:04 PM in response to red_menace

    Thanks!  This might sound stupid to ask, but I had a quick question.  I've noticed that my app's delegate isn't updating when I compile and run the application.  What it wierd is that the interface file updates.   If I move the application from the debug folder, it screws up the application so it wont run.  There is only one copy, and I can't update the script.  It makes it so that I cannot add new commands because it says there is not hanler, and I can't do anything to the script at all...  Do you know how to fix it?

  • by red_menace,

    red_menace red_menace Mar 13, 2014 5:46 PM in response to Jake3231
    Level 6 (15,546 points)
    Desktops
    Mar 13, 2014 5:46 PM in response to Jake3231

    I don't know how you lay out your projects, but Xcode puts the build stuff in your user's ~/Library/Developer/Xcode/DerivedData folder (the default location can be changed in the preferences), which should be different than wherever you keep your project source files (the build products haven's been placed in the main project folder for a while now).  It sounds like some files have not been added to the project, so they are not getting included when the product is built.  You can look at your project's Build Phases to see what is being copied into the bundle.

  • by Jake3231,

    Jake3231 Jake3231 Mar 14, 2014 3:44 PM in response to red_menace
    Level 1 (68 points)
    Mar 14, 2014 3:44 PM in response to red_menace

    Thanks!  I added the script and info.plist to the copy list.  The only problem is that now I got another error....  He is a part of it.

     

    2014-03-14 17:41:33.070 Alpha Assistant[12039:303] Unknown class 'AppDelegate', using 'NSObject' instead. Encountered in Interface Builder file at

     

     

    It's crazy what technology does when it won't work right...

  • by Jake3231,

    Jake3231 Jake3231 Mar 14, 2014 4:00 PM in response to Jake3231
    Level 1 (68 points)
    Mar 14, 2014 4:00 PM in response to Jake3231

    Sorry to bother you, but I was able to fix it on my own.  Now it just asks for my admin password to build the applicaation every time, and it is very annoying.  Do you by any chance know how to fix this?

  • by red_menace,

    red_menace red_menace Mar 14, 2014 4:45 PM in response to Jake3231
    Level 6 (15,546 points)
    Desktops
    Mar 14, 2014 4:45 PM in response to Jake3231

    If your user is a member of the _developer group it shouldn't ask.  You can add a user from an admin account by using the Terminal command (where username is the user's short account name):

    sudo dscl . append /Groups/_developer GroupMembership username
  • by Jake3231,

    Jake3231 Jake3231 Mar 26, 2014 4:01 PM in response to red_menace
    Level 1 (68 points)
    Mar 26, 2014 4:01 PM in response to red_menace

    Thanks!  I was able to sort out that problem.  Sorry to be asking so many queations, but I have been trying to validate my application, and I narrowed it down to two errors. One says I can't change the bundle identifier from it's current value, the other says I don't have the 512x512 and 512x512@2x icons.  I do have a good icon, I just don't know how to convert it to support retina display.  I also have no idea what the error with the bundle ID means...  Do you happen to know about all of this?  Thanks for helping me with everything too!

  • by red_menace,

    red_menace red_menace Mar 26, 2014 7:41 PM in response to Jake3231
    Level 6 (15,546 points)
    Desktops
    Mar 26, 2014 7:41 PM in response to Jake3231

    You will need to use your favorite image editor to edit your icon to provide some higher (2x) resolution versions - see Apple's High Resolution Guidelines.

     

    I'm not sure what is happening with the bundleID - are you editing the Info.plist in some way?

  • by Jake3231,

    Jake3231 Jake3231 Sep 27, 2014 5:50 AM in response to red_menace
    Level 1 (68 points)
    Sep 27, 2014 5:50 AM in response to red_menace

    Thanks! Sorry to bother you, but I was also wondering if you by any chance knew how to use NSTask in ASOC.  I found some code that will run a shell script, but I would like to tell it to run an applescript without having to make a file for everything I want to do.

first Previous Page 4 of 4