Help applescript and xcode

hello community,
i am writing a program  in xcode with applescript.
the language itself causes no trouble to me, but
how can i write values to the info.plist or a plist i
created?
the purpose is, that i can log settings done in the
program itself.
thanks
DERand

Are you talking about preferences, such as the User Defaults System?  Most of the existing Cocoa documentation can be used for ASObjC, you just need to know how to convert the examples.

Similar Messages

  • Need help with applescript and Xcode 4.3.2

    I'm trying to write my first application that will involve a GUI. I can code applescript using script editor with a bit of effort, but I'm want to have users input more than one piece of information in the pop up. So, I download xcode, create my first applescript cocoa project go to MainMenu.xib and add a bunch of labels, text fields and buttons. Looks fairly nice... Go to start it and... nothing (well the window pops up, but it doesn't do anything). Unfortunately, I haven't figured out how to link the window to the applescript... So, how do I...
    * Have the applescript prepopulate data in the text fields and pulldowns
    * Once the user changes the data in the fields tell the applescript
    * Tell the window to close and pass the control back to the applescript once either the cancel or submit button is pressed.
    More detailed...
    * What's an outlet and how do I use it here? Which of the 18 outlet(s) do i use for this?
    * What's a property (referenced on one of the web pages I saw around applescript and cocoa) and do I need them here?
    Looking at the documentation with xcode, there isn't a lot about xcode and applescipt. Looking at the web, the top links are a few years old. So, links to good relevent documentation would be very nice as well as direct answers to the questions
    Thanks,
    Scott

    I'm not sure why you are closing it, but the NSApplication class is what keeps track of the windows.  If you don't want to connect the window to an outlet from the interface editor, you can use something like
    set theWindow to current application's NSApplication's sharedApplication's mainWindow()
    ...and from there you can use whatever NSWindow methods, for example
    theWindow's performClose_(me)

  • Applescript and Xcode Progress Bar

    Hopefully someone here can give me a hand.
    I have a very simple script that I would like to share with some of my coworkers who aren't so comfortable with the command line. So I would like to make a GUI with a progress bar using Interface Builder. I've searched high and low but can not find anything current that helps me. I think I might just be misunderstanding how outlets work and such, as I can get the script to run and the window shows, but the bar does not progress.
    As a note, I'm using Xcode 4. Any help is greatly appreciated. Thanks in advance.

    A couple of things...
    Your window and it's contents (including your progress indicator) normally do not redraw while you're within a handler. So chances are that the progress indicator is not getting redrawn until you exit the awakeFromNib handler... at which time your progress indicator has already been incremented to it's max value and so it would redraw as already full.
    So, one option is to insert calls to tell your window to redraw after each update. But progress indicators have the ability to update themselves on a background thread. So, in this case, an easier option might be to tell your progress indicator to use threaded animation. So try inserting this at the top of your routine:
    myProgressBar's setUsesThreadedAnimation_(true)
    Another thing is that the "do shell script..." calls that you're doing are probably happening very quickly since all you're doing is a call to "mkdir". So even after adding the above line of code you may not see much if any difference in how quickly the progress indicator fills up.
    You might try adding a small "sleep" to each do shell script call to slow things down a little. For example, for each of your shell script calls you could do something like this:
    Change this:
    do shell script "mkdir ~/Desktop/dir1"
    To this:
    do shell script "mkdir ~/Desktop/dir1 ; sleep 0.5"
    That will add a half second delay to each shell script call and possibly allow you to see the progress indicator fill up more slowly.
    Steve

  • Display dialog w/ applescript and xcode why so different

    Hi all
    Having an issue with a dialog box in xcode
    In AS editor I have a long dialog box but xcode only shows half the message
    display dialog "line 1
    line 2
    line 3
    line 4
    line 5
    line 6
    line 7"
    For some reason applescript shows the whole message where as xcode only shows the first 2 lines and cuts off the rest.
    Why is that?
    How can I fix this?
    I need to display no less then 7 lines in the dialog

    Never mind I figured it out
    tell app "finder"
    activate
    tell app "system events" to display dialog "1
    2
    3
    4
    5
    6
    7
    end tell
    ----

  • Applescript and automator

    I have studyed html for 3 days and wordpress for 3 days , word , excel for 5 days, and llustrator and photoshop 13 yeas ago for 6 months.
    and still now its so hard to understand some how.
    but I am in need of understading now with the printed documents from my computer.
    and I wonder , so there are many defferent way to communicate with anyone out side of the world, right?
    like I know email , fax, facetime,
    but there are other way now I think because of the documents I found.
    and also with applescript and automator can do anything possible like even the child can click one and start conecting etc..
    I have the copy from its ,
    does anyone have time to explain me what it is?
    It's not that of teenager who doesn't want paretns to know or else,
    but I am quite serious for my situations.
    Please Help !
    Mac OS snow leopard to lion to moutain lion,,,,,
    but I don't know when it started yet.

    Using JavaScript to script System Events wouldn't be any better, since it uses the same Apple Events mechanism (how well it uses it is another topic).  To hold down a key you would need to use something that has access to the deeper system APIs, most likely using Xcode.
    And yes, your code snippet will press the arrow key 5 times (I am guessing that the missing space in key code is a typo).  You can place the cursor in a bunch of text in another application such as TextEdit, and use your script to activate it before performing the key codes to get a better idea of what is happening (trying to reposition the cursor in the Script Editor will reveal a bug with the delay command).

  • Applescript and ditto

    Hey all at the moment I am using this script to invoke the ditto command
    I use this method because I can at least see the progress
    but I would like something a bit better
    like a display dialog at least that counts the amount of files and starts from 1 to what ever it is or some sort of percentage.
    the bottom script does not open terminal and I would like to use the display dialog in the bottom script. is this possible.
    I tried using 3rd party progress bars with no luck.
    I am not very smart on coding. I only no a bit of applescript and unix.
    Have been playing with xcode and interface builder but can never get the progress indicator to actually work for me.
    set source to (choose folder with prompt "Select the Source folder")
    set destination to (choose folder with prompt "Select the Destination folder")
    set source_unix to quoted form of POSIX path of source
    set destination_unix to quoted form of POSIX path of destination
    tell application "Terminal"
    activate
    delay 2
    do script ("ditto -V -rsrc " & (source_unix) & space & (destination_unix))
    end tell
    But.......
    I rather use
    set source to choose folder
    set destination to choose folder
    set source_unix to quoted form of POSIX path of source
    set destination_unix to quoted form of POSIX path of destination
    do shell script "ditto -V -rsrc " & source_unix & space & destination_unix
    any help on this would be great
    like I said I would like a loading bar but a display dialog giving me some indication on time -- percentage -- or file count would be great

    the bottom script does not open terminal and I would like to use the display dialog in the bottom script. is this possible.
    It can be done, but it takes a bit of extra work.
    The issue is that when you invoke do shell script, AppleScript hands control over to the script and does not do anything else until that script returns control back to AppleScript. Therefore there's no way to display your progress dialog - AppleScript doesn't get a look-in until the script completes.
    That's largely because in most cases you want your script to react to the results of the shell command and you can't do that if the command hasn't finished.
    The exception to this rule is that you can tell the shell command to return control immediately to your script. This will let you run other AppleScript commands while the shell command executes in the background.
    You do this by appending " > /dev/null 2>&1 &" to the end of the command. This redirects the output of the command to /dev/null and sends it to the background so that AppleScript can continue.
    The trick now is in getting AppleScript to know the shell command's status.
    For that the typical solution involves outputting the shell command's result to a temporary file (rather than /dev/null) which you can then read in via AppleScript. What you need now is knowing when the shell command is done which relies on another shell trick (hack?) that tells you the PID of the most recently launched command - you can use that to query if the process is still running.
    So your command should end up like:
    -- do your shell command:
    do shell script "ditto -V -rsrc " & source_unix & space & destination_unix & " > /var/tmp/my.log 2>&1 & echo $!"
      -- 'echo $!' allows you to capture the PID of that process
    set thePID to the result
    try
      repeat
        -- does the PID exist?
        do shell script "ps -p" & thePID
        -- so show progress
        display dialog (do shell script "tail -1 /var/tmp/my.log") giving up after 2
      end repeat
    on error
      -- we're done, so clean up
      do shell script "rm /var/tmp/my.log
    end try
    The revised do shell script command writes ditto's output to /var/tmp/my.log and returns the PID of that process. The repeat loop then repeatedly checks that PID's status (via ps -p). If the process is running that command succeeds so the script progresses to the 'display dialog' command where it shows you the last line of the log file (you can change this to show anything you like).
    If the ps -p command fails because the process is no longer running, that trips the on error clause in the try block which cleans up the temp file.

  • Applescript Studio/Xcode Tutorials

    I'm a big applescripter, and just recently i learned about applescript studio in xcode. I downloaded xcode 3.2.6 and started having fun, but immediately found i was limited by obj-C (i know precious little). So i've been searching for a good bunch of applescript studio/xcode tutorials, but everything i find is for an older version of xcode! If any of you have seen anything for xcode 3.2.6, it would be greatly appreciated!

    AppleScript Studio is the old framework, and is deprecated in Snow Leopard (you can still use it if you really want to, though).  AppleScriptObjC is the new framework, and although you don't need to know Objective-C, it helps a bit to be able to read it, since most of the Cocoa documentation uses it (since ASOC calls Cocoa methods directly, Apple expects you to just use the existing documentation).
    There is an AppleScriptObjC in Xcode tutorial at MacScripter, and Shane Stanley has an excellent e-book available at Mac OS X Automation that will get you up to speed fairly quickly - definitely worth the investment.
    I also have a few example projects and references on my AppleScriptObjC web page that have been gathered from my various wanderings (there are also a couple of conversion examples from AS Studio and Obj-C).

  • New Videos : Objective-C and Xcode Essential Training

    Disclaimer : I have no association, stand to gain from, etc. whatsoever.
    This is purely my opinion.
    For a couple of months I have searched for training videos, and have found the full spectrum, from the 3 minute very amateur YouTube, to the professional products listed below which have been excellent:
    ( 1 ) Objective-C and Xcode Essential Training
    Author : Craig Williams
    http://www.vtc.com/products/Objective-C-and-Xcode-Essential-Training-Tutorials.h tm
    ( 2 ) Bill Dudney from the Pragmatic Bookshelf
    http://www.pragprog.com/screencasts/v-mcxcode/becoming-productive-in-xcode
    http://www.pragprog.com/screencasts/v-bdobjc/coding-in-objective-c-2-0
    ( 3 ) John C Murphy
    http://www.johncmurphy.com/category.aspx?cid=97
    Before I started trying to learn Cocoa and Objective C, I had found some tutorials AppleScript ObjC
    at http://macscripter.net/viewforum.php?id=31
    As it turns out there is a fellow named "Craig Williams" from http://allancraig.net/ who had written some of the tutorials, and had always been most helpful. As it turns out, he has created a 6+ hour video course (68 lessons) on "Objective-C and Xcode Essential Training"
    Eventually I decided to try to pursue Cocoa and Objective C, and I have been trying to document and pass on what I have learned, and even if what I have learned is not much, at least it is a starting point for some people that may know a little less than me, if that is possible...
    Anyway, some feedback about :
    Objective-C and Xcode Essential Training
    Author : Craig Williams
    http://www.vtc.com/products/Objective-C-and-Xcode-Essential-Training-Tutorials.h tm
    I have gone through the "NSUserDefaults pt. 5", and it has been an awesome experience. I was going to wait until the DVD became available next month, but decided not to wait, and re-joined http://vtc.com so I could start watching the videos right away. I was already familiar with a lot of the stuff in the first few lessons, but very quickly I started learning a lot of things I didn't know. The lessons got really interesting, very quickly...
    Craig has a wonderful way of teaching, and I sincerely hope he will continue making more videos.
    I liked Bill Dudney's videos, John C. Murphy was excellent as well, but my favorite by far has been Craig Williams' videos. I am only half way through the course, and I can't wait to see the rest of the 68 lessons. He just explains stuff really well, and I am enjoying his style very much.
    Hopefully somebody else will benefit from this...
    Best Regards,
    Bill Hernandez
    Plano, Texas

    In my enthusiasm to let others know how happy I was with some of these videos, I praised Craig Williams, and rightfully deserved in my opinion.
    I was unfair in not praising the others enough. I felt badly about that, and the more I thought about it, I wanted to make it right...
    John C Murphy's videos are absolutely amazing, and he covers a lot of material. He is a really amazing individual.
    All of these wonderful contributors just have a slightly different style.
    Thank You...
    Bill Hernandez
    Plano, Texas

  • How to calculate the maximum session for Confernecing and Xcoder on VG

    Hi All
    Please help me to understand the logic and concept that how we can calculate the number of session that we can define for the Conferencing and Xcoder  Configuration on the VG.
    Regards
    Chaman

    Hi Jaime
    Thanks for Reply.
    I created the Dsp profile . According to ISR i configured the Sessions . But i want to know the exact concept how to calcluate and if suppose i want some modification in future according to the conference calls that i want to support how do i calculate??
    dspfarm profile 2 transcode 
    codec g729abr8
    codec g729ar8
    codec g711alaw
    codec g711ulaw
    codec g729r8
    codec g722-64
    maximum sessions 13
    associate application SCCP
    dspfarm profile 1 conference 
    codec g729br8
    codec g729r8
    codec g729abr8
    codec g729ar8
    codec g711alaw
    --More--                            codec g711ulaw
    maximum conference-participants 16
    maximum sessions 3
    associate application SCCP

  • Can any help with my Xcode download issue?

    Hi all,
    Can anyone help with my Xcode issue? I downloaded it the other day but it is currently stuck saying waiting. I found this advice online http://scheyeniam.blogspot.co.uk/2011/08/how-to-revive-mac-app-store-when-its.ht ml and it seemed simple enough. However it tells me to go into activity monitor and quite 'storeagent'. The issue is that there is no process called storeagent. I have tried quitting other processes but it doesn't seem to be working.
    Does anyone know of a solution to stop the download saying 'waiting' and to get it started?
    Thanks

    Most likely it is downloading, although the App Store doesn't show the download progress. I had the same problem yesterday when I did the upgrade. It eventually finished, and it's quite a large download, so it might take hours, depending on your internet connection.
    If you open the Launchpad, and locate the XCode application icon, it should show a download/install progress, if you want to verify that it's actually doing something. Otherwise, just leave the App Store running, and it should eventually finish.

  • Using Applescript and Automator to manage files and folders

    Hi all.
    I need to make a simple action via applescript and-or automator to take the file it's been applied to (via the services) create a folder around it with the same name as the file.
    So far, I've searched the web, found some solutions but none are really working.
    Here's the script I found :
    set myFolder to findFolder()
    tell application "Finder" to set myFiles to files of myFolder as alias list
    repeat with aFile in myFiles
      set bName to my baseName(aFile)
      tell application "Finder"
      set folderExists to exists folder bName of myFolder
      if not folderExists then make new folder at myFolder with properties {name:bName}
      move aFile to folder bName of myFolder
      end tell
    end repeat
    ---------------- HANDLERS ----------------
    on baseName(myFile)
      tell application "System Events" to set {fileName, fileExt} to {name, name extension} of myFile
      return text 1 thru ((get offset of "." & fileExt in fileName) - 1) of fileName
    end baseName
    on findFolder()
      activate application "SystemUIServer"
      -- Bug pointed out by Lauri Ranta http://www.openradar.me/9406282
      tell application "Finder"
      activate
      set mySelection to (get selection)
      if mySelection ≠ {} then
      set mySelection to first item of (get selection)
      if mySelection's class = folder then
      set currentFolder to mySelection
      else if mySelection's class = document file then
      set currentFolder to parent of mySelection
      else if mySelection's class = alias file then
      set currentFolder to original item of mySelection
      end if
      else
      set currentFolder to target of front Finder window
      end if
      end tell
      return (currentFolder as alias)
    end findFolder
    And here's a page where they explain how to use automator and the Services to do what I <allmost> want, with some adaptation.
    But it still doesn't work.
    http://hbase.net/2011/08/17/move-selected-files-into-a-new-folder-using-applescr ipt-and-automator/
    So if anybody has an idea n how I could do this ?
    It It could either be a folder action (I drag and drop the files into a folder and boom, they get their folder around them)that I would set on a folder on a network drive, or locally, it doesn't matter, or a service (right clic on the file and boom folder around it.
    So if anyone could help with this I'd be grateful...

    Hi,
    Make an Automator Service (Service receives selected "Files or Folders"  in the "Finder.app").
    Use this script in the "Run AppleScript" action:
    on run {input, parameters}
        tell application "Finder"
            repeat with aFile in input
                if class of (item aFile) is not folder then
                    set {tName, fileExt} to {name, name extension} of aFile
                    if fileExt is not missing value and fileExt is not "" then
                        set tName to text 1 thru -((count fileExt) + 2) of tName
                        tell (get container of aFile)
                            if not (exists folder tName) then make new folder at it with properties {name:tName}
                            move aFile to folder tName
                        end tell
                    end if
                end if
            end repeat
        end tell
    end run
    This script work on files with a name extension.

  • AppleScript in Xcode

    I just got my mac about two weeks ago. I am a programmer, and i am trying to write some programs in applescript. I have encoutered two issues. First, I can not find any information or doumentation for the applescript language, such as a list of commands and ways to call variables, or even a tutorial that doesn't just say "applescript is very intuitive" like your just suposed to figure it out. Also, I have made a simple program that calls the shell script "defaults write com.apple.finder AppleShowAllFiles ON" to show hidden files like .DS_store files. I used an Xcode project to make a window with two buttons, ON and OFF, that use seperate script files ON.applescript and OFF.applescript in the project to turn the ability to see hidden files on or off when clicked. my problem is that, to make the change to see or hide hidden files come into effect, the finder must be restarted. But when I run my application, when a btton is clicked, it just does part of the programmed command, and turns the finder off, and then when clicked again, it continues and launches the finder again with the hidden files hidden or not, depending on which button is pressed. It is really frustrating, and is pushing me toward just giving up applescript and going back to C++.
    MacBook Pro   Mac OS X (10.4.9)  

    Here is the script of my Hidden Files app for the result on the on button being clicked:
    on clicked theObject
    tell application "Finder"
    quit
    end tell
    do shell script "defaults write com.apple.finder AppleShowAllFiles ON"
    tell application "Finder"
    launch
    end tell
    end clicked
    (This is pretty much all that is in this app in the way of scripts, the rest is done with the interface builder and .nib file)
    After building this app, when I press the "HIDDEN FILES ON" button on my program, the finder shuts off... and thats all. There is no indication that it is loading, or doing anything else that migt prevent the finder from starting. Then, if I click the button again, then it turns the finder on, with all hidden files shown.I not sure how this is even possible, because my understanding of an executable is that it either runs, or returns an error message. And the "HIDDEN FILES OFF" button, with the same script exacly except for the ON in the 5th line replaced with OFF, works the same way, requiring 2 clicks on either button to fully complete the script's function.
    MacBook Pro   Mac OS X (10.4.9)  

  • IWeb Applescript and Automator - scripts you shouldn't be without

    Applescript and automator will automate mundane manual repetative task that seem to take forever. These scripts fill in iWeb's void that makes it hard to implement advance features such one click ftp publishing, code editing, swithching domain site files, etc. Don't miss out on these scripts that will save you ton of time. These are scripts you shouldn't be without.
    Work smarter not harder with iWeb applescript, only from MacEzzy.
    -- Also check out the free downloadable iWeb templates.
    Powerbook G4 Ti   Mac OS X (10.4.4)  

    Thank you for your feedback.
    -- Article never mentions compressed or uncompressed. Traditionally tiff format is used for buttons and small images on web pages and jpeg is used for higher quality photos exemplified by iWeb.
    -- Search engine spiders or crawlers start from top of the page to the bottom of html pages. They craw for topic as well as content. This is exactly what appears from iWeb html pages for meta (meta name="Generator" content="iWeb 1.0.1")
    -- I am the first to admit I don't know everything but I don't make up information. I use iWeb on a daily bases and try new things to push the envelope. Things that I find helpful to me I make it available for other iWeb community users so that they don't go through tribulation.
    -- I put google ads and paypal donate buttons throughout the pages to test if iWeb is up for commercial challenge. I also tested how well the search and replace script worked. I have exemplified in macezzy website it is possible to use iWeb for business purpose. The script worked extremely well, it would have taken hours to insert google and paypal codes manually. Using the script it only took 10 min. I wanted to share that with other users who might wanted to do similar things. Sorry if that offend you, I will remove them.
    -- I never claimed to have created the script except the script that makes the first folder in documents folder. I did change the wording so that it is clear to users that they are switching sites(domain file). I did not create the awesome search and replace script either. I do mention that I have made the iWeb_ftpUpload automator.
    I have started macezzy site when iWeb was introduced and there wasn't much information about iWeb. I have and do try many things with iWeb and report to iWeb community users of things that I find helpful. I haven't made a dollar off the site and I have invested lot of my time because I like to see other users succeed.
    Powerbook G4 Ti   Mac OS X (10.4.4)  

  • HT201448 How to override the default order of Websites, Wiki, and Xcode services?

    Greetings,
    On my Mac server, I have the Websites, Wiki, and Xcode services all enabled but, as detailed by the Apple support article, Xcode takes precedence over all, or Wiki if Xcode is disabled.
    What I would like to see is a virtual host (e.g. wiki.myhost.com) and/or directory alias (www.mydomain.com/xcode) that opens the home page for the respective service while the default (e.g. www.mydomain.com) goes to the home page for mydomain.com.
    I'm no httpd configuration expert but I expect some manual httpd configuration will be required.  Any help appreciated.

    At the end, I decided to adopt Firefox add-on "Classic Theme Restore"—amazing output. I guess it is impossible to get such a space saving but full furnished solution somehow else.

  • Help Menu crashes Xcode

    When I select Help/XCode Help, my Xcode hangs for awhile then crashes. I threw out the preferences file and it worked ok for awhile. Now it's crashing again after working for only about a week. I don't want to keep setting my prefs every couple of weeks. Any ideas/suggestions?
    -Phil
    OSX 10.4.5
    XCode Version 2.2.1
    Component versions
    Xcode IDE: 656.0
    Xcode Core: 660.0
    ToolSupport: 651.0
    G4 iBook, 640Mb   Mac OS X (10.4.5)  

    Most times FCE4 itself doesn't crash. The only reason I noticed it was I happened to be looking in my console logs for something else and noticed it.
    Basically, with FCE4 open....simply go to the Help menu and start typing something...say..."Open". This should activate help.
    Now in my situation, help works just fine, however, in looking in my console logs, I noticed that by invoking the help menu in FCE4, it crashes the helpdatad process. That's the crash that's happening in the log.
    So if you simply go to the help menu and start typing something, then look in you console logs....do you see helpdatad crash as well?
    -Kevin

Maybe you are looking for

  • Call functions in ABAP : CALL 'ThSysInfo'

    hi i am in need of certain information abt the blow code\ i just wanted to knw where the value HWID gets populated from after executing the below code can any body help plzzz CALL 'ThSysInfo'      ID 'OPCODE'   FIELD OPCODE_MSGSERVER      ID 'MSOPCOD

  • Sales order Item condition currency

    HI i have following requirement In sales order item conditions Currency should change automatically From USD to INR, it means USD is sales document currency. But in PO currecny is INR, so i want to populate INR in Sale order items condition type PR00

  • HELP!! I lost all bookmarks and email

    Hi Guys I dont know what's happened but all of a sudden I have lost all the bookmarks on Safari, all the address book is empty. I had to reset Mail like it was the first time. It looks like I have just installed the OS. I have the dock not customised

  • Choosing new MBP purchase based on screen

    My 2 year old 15" MBP bit the dust - it appears to be the GPU, but Apple can't confirm it, so they won't do a logicboard replacement. That makes it a write-off in my book; paying £750 for a 90 warranty on something that could fail again isn't somethi

  • EMERGENCY! Problem with an .m4a file

    I was recording an episode of my podcast (Radio Allegro- radio-allegro.com) and for some reason my software quit on me. I was using Audio HiJack and recording multiple people in Skype. I have never had a problem before, but when I repopened Audio Hij