Applescript in Xcode Saving Preferences

Ok I am writing a simple applescript based xcode application but I can't figure out how to save these properties:
property fade_speed : true
property fade_on : false
property the_choice : false
property first_run : true
... between launches of the application which controls itunes. I want the user to be able to set preferences of if they want itunes to fade between songs every time they click the next or previous buttons or not to fade and to have a dialog pop up the first time they open the app and "the_choice" is their favorite playlist which they can play by clicking a button. How can I have these settings saved so that the user does not have to set them up each time?
Im using the latest version of Mac OS 10.5.7 and the latest version of Xcode.

Properties do not persist between runs in AppleScript Studio like they do in a regular AppleScript. To save your preferences, etc., use the user defaults.

Similar Messages

  • Question regarding definition "Applescript in Xcode"

    Hello, I've got a question:
    How would you define Applescript in Xcode 3.1.2? Is one making an app with Cocoa? Is it called Applescript Studio or Cocoa Applescript?
    Thanks in advanced

    AppleScript in XCode is generally known as AppleScriptObjC (AppleScript/Objective C). More details as Apple's Developer Site.
    As a categorization, 'pure' AppleScript is generally perceived as a high-level scripting language (generally used on top of other processes that do the work. AppleScriptObjC is more of a high-level programming language since you can develop full-blown standalone applications.

  • Lion not saving preferences

    I just switched to a new retina macbook, with os 10.7. I'm having trouble with Linotype Font Explorer X not retaining its settings - previously, you could turn a font on & it would stay on. Although sometimes it does retain some of the font settings, but not all.
    I've also noticed other programs occasionally not saving preferences.
    Is this a known issue with Lion?

    Make sure the systemprefs plist file is not locked. If it is, unlock it. If it isn't, delete it then restart.
    To find the file
    1. Make Finder active. Choose 'Go' from the menu bar, hold down the option key.
    2. Choose Library (you must have the 'option' key held down).
    3. Go to Preferences > com.apple.systemprefereces.plist
    4. Right-click (or hit 'cmd-i' on the keyboard) and choose 'Get Info'. If the 'Locked' option is ticked, untick it. Then Restart. If the 'Locked' option is not ticked, close the dialogue, remove the file to trash. Restart.
    5. What happens now is that system will restart at default system prefs. However, it should now save your new settings. To test it, just set one of the setting that you know didn't 'stick before', then restart and see if all is good. 

  • Mail - Error saving Preferences Msg

    I am unable to reset my junk mail filter. In Mail preferences I select RESET and this message pops up:
    Error Saving Preferences
    Writing your preferences to disk has failed. Your preferences may not have been saved. The permissions on -/Library/preferences may be wrong or your disk may be full.
    After getting this message, I used disk utility to repair permissions ( I did it twice and it appears that the same permission repairs occur each time I use repair permissions) I also tried to repair disk permissions usind Disk Warrior - with similar results.)  In addition, the disk is far from being full.
    Can anyone shed some
    TIA

    Amount of free space on my computer:
    Capacity: 499.76GB
    Available 432.54GB
    You are doing great on free space.
    I tried to "repair disk partitions" but this didnt work, and everywhere I looked on the web it would say that this does not work.
    It does work, but not for permissions issues on individual user files. It only has benefit on systemwide issues.
    I also did a complete TimeMachine restore. This didnt work.
    This is really only affective if you restore from a point in time when the issue did not occur which can be tough to know unless you try adding new Mail accounts every day.
    _Go to Your User > Library > Preferences.
    _Click on the Preferences folder once to highlight it.
    _Go to File > Get Info
    _Make sure that your user name is listed in the Sharing & Permissions window with Read & Write access
    _Go to the bottom of the info window and click on the pad lock to unlock it
    _Click on the cog / gear and then click on apply to enclosed items
    _Now try adding an account in Mail again.
    If the issue persists at this point it may be necessary to reset Mail which may require you to re-enter your account settings.
    Remove Your User > Preferences > com.apple.mail.plist to the desktop and then open Mail and try adding an account.
    Cheers.

  • Can i set different energy saving preferences for different accounts?

    Hi,
    I have bought an Mbox for my iMac. Its instructions for installation include disabling the energy saving features in Preferences.
    However, I also want to use the machine for many other purposes and would prefer to have energy saving activated.
    I set up a new account but it seems that energy saving preferences can't be different between different users on the machine? Is that true?
    I have tried unlocking and locking after making the change and switching between accounts (both admin accounts at present)
    imac   Mac OS X (10.4.7)   c2d, 2GB
    imac   Mac OS X (10.4.7)  

    Niel,
    When i entered the syntax exactly as you recommended, and as provided as example code within the general commands manual for PMSET ie
    do shell script pmset - a displaysleep 0 disksleep 0 sleep 0 password
    "password" with administrator privileges
    I got a syntax error "A identifier can't go after this identifier." and it highlighted [-a displaysleep]
    By inserting carriage returns to spread the command over lines, and adding brackets around the minutes, I got increasing acceptance of the script, up to the following point
    do shell script pmset - a
    displaysleep(0)
    disksleep(0)
    sleep(0)
    password
    "password" with administrator
    privileges
    at which point it said "The variable pmset is not defined."
    Can you suggest where I am getting stuck? Is something missing?
    Late news: A friend of mine found script on line which seemed to suggest that the following would be the format
    do shell script ("pmset displaysleep 0 disksleep 0 sleep 0") password "my password"
    with administrator privileges
    However, when i try to compile or run that it says:
    Expected “timeout” or “transaction” but found identifier
    and it highlights the word [administrator]
    If you can see where i am going wrong I'd love to hear from you.
    david

  • Error Saving Preferences on exiting Mail Preferences

    Hi, I am getting the Error Saving Preferences error on exiting Mail Preferences with advice to check disk space and directory permissions on ~/Library/Preferences. Not knowing what the official permissions should be I booted the iMac from the Leopard installation disk and in Disk Utility I repaired file permissions but this did not make any difference. I have followed other instructions I found in Apple Discussions which were for a previous OSX where I backed up the Mail directory and then moved ~/System/Preferences/com.apple.mail.plist to the Desktop. Per instructions I then fired up Mail which picked up my Mac account straight away but again on exiting Preferences without even adding any new mailboxes the same error cropped up... in fact I don't think a new plist was created. I returned the old plist and Mail directory.
    It may be worth mentioning that just before this problem cropped up I had been trouble-shooting another problem where every minute my active window would lose focus, I tracked this down to HP_scheduler (I have an HP all-in-one printer, C6180) and on killing the process the problem went away, but I think it was also a symptom of the real cause which is still unknown as the printer software has been installed for about a year, last update was months ago... but before I had tracked the issue down to this I had use MacScan2 to flush just my Safari caches and temporary files etc, it was running in authenticated mode, may mean something, may not. Subsequently to discovering HP Scheduler was to blame I uninstalled all the printer software using the HP uninstall package.
    Around this time a third problem transpired where settings were not being retained in various System Preferences. Unfortunately I didn't pick up on it straight away as being a third problem and now can't remember whether it started before the window lost focus problem or not. The first time it happened was when I tried to put MacScan2 into the startup list for my login, it could be added but on checking the addition it wasn't retained in the list and well I thought nothing more of it as it was the first time I had tried to do such a thing. Then I noticed the Mail issue just by chance and subsequently, through seeing someone else's problems logged back in 2006 I think, I noticed that although I could change screensaver I could not make a change in desktop photo stick.
    I have since reinstalled the printer software and I am no longer losing focus from the active window.
    However, I think it is probably the case that the Mail Preferences, Startup Items and Desktop Preferences issues are all the symptoms of one and the same problem and I would be very grateful if anyone is familiar with and/or knows of a solution to this issue.
    Many thanks for reading!

    Well, in the end I tried many things including lots of things that I thought wouldn't help such as cleaning out caches, running crons; I was using IceClean and pretty much tried every system maintenance option but to no avail. I have removed MacScan and have kept Norton, which this time found a few things in my .wine folder, but I have only performed a few full system scans as it takes a full day.
    This resulted in the knowledge that I would have to do a Leopard reinstall if that failed then a complete restore from TimeMachine which I knew would take ages, but fortunately the reinstall worked perfectly and effortlessly to solve the problem, and it only took 30 mins to update the security patches including 2 automatic restarts.
    Phew!

  • RichQuery Component - not saving criteria while Saving Preference

    I am using RichQuery component to advantage of saving preferences and picking them to execute it once saved. Using the out-of-box component with no customization.
    Criteria values are not as part of saving preferences.
    Ex. Ran the page, then enter criteria like employee name and then hit search button. It displays the result. Now saving preference using save button. I am thinking employee name(what i entered) will be saving as part of perference. Does this save criteria values? Somehow not saving it. Can anyone help me fixing this problem.
    Thanks

    Yes, I am using ADF BC viewcriteria for creating query component. Please try the sample from the below link
    http://andrejusb-samples.blogspot.com/2008/11/jdevadf-sample-adf-query-component-and.html
    Run the main.jspx file -> enter some criteria -> search -> then save -> give a name -> select the criteria from the dropdown.
    Thanks

  • 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).

  • AppleScript or Xcode?

    Hi,
    I have a rather unusual project and don't know if I should use AppleScript or Xcode. I'm a bit used to applescript but don't know Xcode at all.
    *Here is the main idea and goal :*
    I have a mac mini which has a mediaplayer which runs video and such for digital signage.
    That mac mini is connected to a USB Internet key (Roger's RocketStick). Everything works fine but I need to click on connect each time for it to connect on the internet and I must disconnect each night for the mac to shut down. Plus, I need to start the player and shut it off too. This is really a pain in the......
    *Current setup* (+works okay but has alot of bugs that I can't put my finger on+)
    I'm working with a script I did using automator and AppleScript, LogIn items for the startup script and iCal for shutdown times which then activates the shutdown script.
    I thought I was pretty clever doing it this way, but sometimes for reasons unknown, the mac gets confused and loads both shutdown and startup scripts on bootup and hangs.
    Guess on what type of code to use? Or do you have a better solution than what I'm doing.

    kpott wrote:
    Anyway, the piece of software Roger's gave with their Internet USB key can't connect by itself, you must click on the connect button when their software boots or else it just finds the signal and waits for your command. I guess this was done intentionally by their part to save on bandwidth use.
    You need to click a button. AppleScript can do this & is done all the time.
    See the script below.
    Get the scripting setup right then
    Might be simple as:
    keystroke return
    The problem I'm getting is that I usually get the "Finder canceled "Shutdown"...." error message when the mac mini boots. "Shutdown" is the name of my script. This only happens sometimes, which is my biggest frustration. The method I'm using isn't stable.
    Rename your script. The name is confusing. Something like myShutdown.
    This is why I'm trying to look into a better way to work this out. I'm using Energy Saver to schedule the power on process and login items to start the script. The reason why I'm using iCal is to shutdown the computer using a script. I couldn't get the mac to start a script while Shutdown was initialized using the Energy Saver feature. PLUS, only to make things worst, on sundays, the mac must shutdown earlier in the day.
    Interesting...
       Remember you need to enable assistive devices.
       This lets applications software access screen elements.
       blue apple > system perferences > universal access > enable assistive devices
    -- Write a message into the event log.
       Run this program from the Script Editor.  Click on the Event Log tab at the
       bottom of the screen.
    log "  --- Starting on " & ((current date) as string) & " --- "
    set the_item_ref to choose file with prompt "Select an html, text, or some other file Safari will display."
    -- Activate
    activate application "Safari"
    -- Open the URL 
    tell application "Safari"
       open the_item_ref
       -- print
       -- System Events interacts with the current active applications.
       tell application "System Events"
          tell process "Safari"
             -- Your simulating typing on the keyboard.  You need to allow time
             -- for the application to run. It's always a guess about delay in seconds.
             delay 3
             -- Be sure your printer is up & running before printing.
             keystroke "p" using command down
             delay 3
             keystroke return
             delay 10
             keystroke "w" using command down
          end tell
       end tell
    end tell -- of Safari

  • 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.

  • 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 Studio/Xcode problem - Problem with text entries! Please help!

    Hey, I've been up for hours each night looking for solutions to this but still have had no luck.
    I am creating an app in Xcode/Applescript studio that will ask you to enter how many times you would like system events to repeat a certain keystroke. First of all, the code would look something like this:
    on click theObject
    If the name of theObject is equal to "myApplication" then
    (Right here would be where the variables representing text in an input in the app's window would be, which I have absolutely no clue what to type.)
    tell application "text edit"
    activate
    tell application "system events"
    keystroke x (x representing a variable)
    end tell
    end tell
    end clicked
    and that's about as far as I can get. I want a variable representing the text in the main text entry box, but I have no clue how to access that text, or even know if it's submitted or detected when I hit a button. Hopefully you're following, as I am way to confused to fully explain it, but please try and help me out if you can.

    Hi Kamprath445,
    Though this mentions iTunes, I think it has good examples you can use...
    http://dougscripts.com/itunes/itinfo/keycodes.php
    More in depth...
    http://developer.apple.com/documentation/applescript/conceptual/applescriptlangg uide/conceptual/ASLR_variables.html

  • Yosemite Mail mail not saving preferences

    OS X 10.10, Mail 8.0
    I have several mail accounts set up, a mix of POP and IMAP
    One IMAP account does not use secure authentication.
    If I set the preferences for the account under the Advanced tab, and tick 'Allow insecure authentication', then save preferences, I can send mail to the account.
    However if I return to Mail after 5 minutes or so the preference has changed back to disallow insecure authentication, and that mail account no loner works. I get a message:
    "Mail cannot send your password securely to the server. You can remove this restriction in the Accounts preferences by setting “Allow insecure authentication”, which could put your password at risk."
    I have a POP account for a different email address with the same provider, and the preference to allow insecure authentication is saved.
    I have tried deleting the account and setting it ip again, but the IMAP presence to use insecure authentication is still not saved.

    I have this issue as well.  This includes the inability of font preferences to stick, and the toolbar changes to be retained.

  • AppleScript Problem when saving Web Receipt

    Hi everybody!
    I bought a Macbook. Everytime I try to save receipts and invoices as PDF files in my Web Receipts folder (By pressing the Apple Key - P, and selecting PDF - Save PDF in Web Receipt), I get an error saying that the receipt has already been saved: AppleScript error (-41). When I go to the Web Receipts folder, there is nothing there...
    What should I do?

    How can one deactivate the vault file as I think my grandaughter has been playing itunes and may have done something there to cause me not to be able to download. Any help would be greatly appreciated. Thankyou. Teresa, sorry to butt into this thread.

  • Applescript (in Xcode): set text in label (in window) to .....

    Hello,
    How do you change the text of a label (in a window) in Xcode, with AppleScript?
    I use Xcode, but inside my app I use Xcode. Applescript studio actually, only it's isn't called like that anymore.
    It's also called applescriptobjc...
    Example:
    I have a label, containing the text "Hello" in my main window.
    Next to it, is a button. I want that button connected to an applescript action, like:
    on thebuttonclicked_(aNotification)
    set thelabel1 to "Bye!"
    end thebuttonclicked_
    Please help,
    Isaiah v. Hunen
    P.S. Is there a way to also use the text of the label, like;
    on thebuttonclicked_(aNotification)
    display dialog thelabel1
    end thebuttonclicked_

    AppleScript Studio was deprecated in Snow Leopard - the new framework (AppleScriptObjC) is quite a bit different.  One of the main differences is the way that user interface objects are referred to.
    Typically, in your project you would create an outlet property for the label and connect that to the UI item.  This outlet would then be used with the desired NSTextField methods (a label is just a text field that looks a little different).
    property theLabel1 : missing value -- connect to the label text field
    on thebuttonclicked_(aNotification)
      theLabel1's setStringValue_("Bye!")
      display dialog theLabel1's stringValue() as text
    end thebuttonclicked_
    Bindings can also be used to bind the value of the text field to a property.

Maybe you are looking for

  • Value flow to COPA

    Hi All, We map condition types in SD to value fields in COPA to see revenues and costs in COPA. But how do we send the plan values to COPA. What are the configuration settings. Are plan values also updated under version 0. Regards, Reddy

  • How to mimic Pull Down Menu like APEX WORKSPACE

    Hi, I want to have Pull Down Menu like APEX Workspace pages where Application Developer, SQL Workspace, Team Developement and Administration have menus attached to them. They appear in Pull Down format. I want to mimic the same in my application. I h

  • Phone doesn't show up after new software update

    After dowloading the new software I am unable to see my phone when connected to the computer. I'd like to transfer music and pictures but now I can't. Any idea how to get my phone to show back up in iTunes?

  • Since updating to 8.1.2 i now have no sounds

    hi,since updating to 8.1.2 my iphone 4s no longer has sounds when typing,recieving calls or txts,it just vibrates,the volume is set to max,its very frustrating as its my business phone,anyone had similar problems,or knows how to correct this ?? thank

  • Load an interactive slide into an AIR iOS app. Is it possible?

    HI, Imagine having a Flash app which could dynamically load an external interactiveSlide.swf with which you could interact with. You could then unload/remove the interactiveSlide.swf. I'm wanting to create a similar model for iOS. So I create my AIR