Using Automator to change System Preference when opening an app

Hello everyone,
I have been using a Mac for a good 8 years now and I'm a happy user. I recently found out about Automator ('hey what is this little robot for?') and what it can do, yet I lack the knowledge of finding out what I must do to make a script to perform the following thing:
When I launch an app (FL Studio), I want the box checked next to 'Use F1 and F2 as standard function keys' in the Keyboard preferences pane in the System Preferences app.
When I close the same app (FL Studio), I want the box unchecked next to 'Use F1 and F2 as standard function keys' in the Keyboard preference pane in the System Preferences app.
I have found several other topics about this subject, however, those were about scripts when logging in to your computer, and not upon opening/closing an app. Please note that I am seeking for the setting to be changed when the app is opened and closed.
I hope you can help,
Sander

This kind of question comes up a lot - how to run a script when an application launches/quits.
The short answer is that it's not easy to do directly, unless the application itself supports launching scripts on startup/quit (hint: few do).
Fortunately, a little difference in thinking can give you the same effect.
Rather than trying to have your script trigger AFTER the app launches, rethink your process to a script that FIRST changes the preference, THEN launches the app. You get the same result but about 14 billion times easier to implement.
In this case, write a script to set the function key preference, then launch FL Studio. The script can then hang around to wait for the app to quit and reset the pref.
Furthermore, don't try to do this the human way (open System preferences, select Keyboard, check the box). You can set the preference directly via the defaults command line utility:
on run
  do shell script "defaults write .GlobalPreferences com.apple.keyboard.fnState 1"
  tell application "FL Studio" to activate
end run
Resetting the preference is a little trickier since you need to detect when FL Studio has quit. You can do this with an idle() handler in your script that hangs around, periodically checking if the app is still running and then taking action:
on idle
  tell application "System Events"
  if (name of every application process) contains "FL Studio" then
  -- app is still running, so come back and check later:
  return 10
  else
  do shell script "defaults write .GlobalPreferences com.apple.keyboard.fnState 0"
  tell me to quit
  end if
  end tell
end idle
Putting these together in a Stay Open script should do much of what you want.

Similar Messages

  • Using automator to change system preferences

    can i use automator to change my network settings. my stupid wireless at home does not automatically connect so everytime i get home i have to open up sys preferences and change the airport settings to manual and enter in the ip address of the router manually. can i create an automator script to do this in one step?
    any help appreciated. thanks.

    I have a similar problem with the ultra sensitive trackpad with the "Clicking, Dragging, Drag lock" checked in Preferences/Keyboard & Mouse. I'm always turning them on and off depending on which application I am using.
    My problem is that when I record a series of actions in Automator, the resulting action list has no text behind the action for the mouse click for the Clicking checkbox. Its as though it doesn't even know that its there. All of the other actions show up.
    Got any ideas on how to fill that void or another workflow that would do the same thing ? I think that running the workflow again would turn it back on as the actions are identical.

  • Use Automator to Change System Preferences?

    Hi. I want to create a workflow or applescript that will open my system's sound preferences and change the output source. The Applescript editor doesn't record any of my actions.

    Modify the setting from System Preferences, and then look for plist files in ~/Library/Preferences/ and /Library/Preferences/ modified around that time. When you've located a possible plist, open the Terminal application in the /Applications/Utilities/ folder and enter 'defaults read ' without the quote marks. Drag the plist into the Terminal and press Enter; you will then see a list of keys. If a key looks like it contains what you're looking for, remember its value, change the setting again from System Preferences, and check the key again. Once you've found the key, you can use a 'defaults write' action in Automator's shell script option to change the value. If you can't write the key successfully, post back here with the name of the key and where you found it for further assistance.
    (12421)

  • In System Prefereneces, when I am in Desktop and Screen Saver, I am unable to remove folders. I can click the "-" and the folder appears to be gone, but when I close and then reopen System Preferences, and open Desktop and Screen Saver, the folder reappea

    In System Prefereneces, when I am in Desktop and Screen Saver, I am unable to remove folders. I can click the "-" and the folder appears to be gone, but when I close and then reopen System Preferences, and open Desktop and Screen Saver, the folder reappears in the list. I have tried deleting preferences "plist" but I am totally unable to remove the folders.

    I've seen one other report like yours, and I think the issue is caused by a bug, but I don't know what triggers it.
    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, or by corruption of certain system caches. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including sound output and  Wi-Fi on certain iMacs. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • When I send my ical link to my better half , who sadly, still uses a windows based system- He cannot open the link back to my calendar- any help?

    When I send my ical link to my better half , who sadly, still uses a windows based system- He cannot open the link back to my calendar- any help?

    I've been using iCloud since it's inception as "mac.com" or whatever it was called. I've been able to Sync Outlook Exchange Calenars to my iMac, iPhone and iPad. However, I cannot get iCal (when viewed in iCloud) to display Exchange or Google Calender items.
    It's odd, all other Mac versions of iCal are happy e.g. iMac, MacBook Air, iPad Air, iPhone etc. But nothing when I login to icloud.com and look at the iCal there.

  • Error in Local Message System: Error when opening an RFC connection Message

    Hi Gurus,
    We are not able to create support messages in our ECC production system but it can created in Development and Quality. Support message created appears in solution manager system. ECC System displays error message as
    Error in Local Message System: Error when opening
    an RFC connection Message was Not Created
    I have checked RFC connection between ECC and Solution Manager which displays following message
    Logon     Connection Error
    Error Details     Error when opening an RFC connection
    Error Details     ERROR: partner "local:sapgw00' not reached
    Error Details     LOCATION: SAP-Gateway on host local / sapgw05
    Error Details     DETAIL: NiPConnect2
    Error Details     CALL: connect
    Error Details     COMPONENT: NI (network interface)
    Error Details     COUNTER: 40142
    Error Details     ERROR NUMBER: 10060
    Error Details     ERROR TEXT: WSAETIMEDOUT: Connection timed out
    Error Details     MODULE: nixxi.cpp
    Error Details     LINE: 2835
    Error Details     RETURN CODE: -10
    Error Details     SUBRC: 0
    Error Details     RELEASE: 701
    Error Details     TIME: Wed Jan 11 23:26:54 2012
    Error Details     VERSION: 38
    Kindly Help.....

    Hi
    Based on the instance number of the servers, you can determine the gateway to be used.
    IF your ECC instance number is , 01 then gateway would be , sapgw01 (in ECC system)
    So check and change the settings accordingly, in the RFC connection. Also check, if this entry sapgw01 is made in /etc/service file. Also check, in transaction smgw for gateway parameters.
    Hope this info helps,
    ~ Raj

  • Under APPLE MENU system preferences only opens sporadically, mostly not

    Under APPLE MENU system preferences only opens sporadically, mostly not. I booted up with installation disk and ran a check but everything was alright. However, when I tried to click on items using the disk as a startup disk it frequently wouldn't function.

    George,
    Thanks for asking that question.
    I offered this solution based upon similar successful advice which was given to another poster who solved this problem:Long story short I ended up reinstalling Mac OS X using Archive and Install. When I first used the computer following reinstalling Mac OS X, I was able to access the System Preferences by selecting them under the Apple in the menu bar. However, I have now updated my software using Software Update, and now I can't access System Preferences when I click on them under the Apple in the menu. The computer just acts like I never selected System Preferences.
    Where have System Preferences gone??? provides another example of Previous Systems folder interfering with System Preferences.
    Applications don't work after reinstalling Mac OS X explains a different problem with a Previous Systems folder: Example 1: You downgrade by performing an Archive and Install installation, but do not update to a later version of Mac OS X. The Previous Systems folder contains later versions of applications that may contribute to this issue.If you have proper backups, I recommend trashing the Previous Systems folder as soon as you can determine that the new system is functioning properly. The Previous Systems folders will either take up too much space or contribute to unexplained system problems.
    ;~)

  • Override document preferences when opening a file

    Hi all
    Does anyone know if there is a way to override the document preferences with the InDesign preferences when opening a file (or even when a file is open).
    The issue i have is that I have a whole load of documents where for some reason the superscript has been set to size 100% and not the standard 58.3% and i want to revert it back to standard without the need to open preferences -> advanced type and then resetting all the sizes.
    I know that Quark (sorry to swear) had this ability where on file open it would warn of a preference mismatch and ask if document or Quark prefs should be used.
    Any help on this would be greatly appreciated as it will save me a lot of time.
    thanks
    Justin

    The issue is that although InDesign will open up Quark documents, it doesn't appear to allow you to add them to a book.
    Therefore, from what i can best make out, i would need to import the Quark doc into InDesign, save the file as an InDesign file, then import it into a book to run the script. We have few hundred single page Quark docs for a packaging job we are doing.
    It seems quicker to open the file, and just change the superscript preference, its not an insurmountable issue, just more of an inconvenience and a bit of a waste of time.
    Thanks for yours and everyones help on this as it will certainly use the script on InDesign projects should the same issue arise.

  • System Preferences pane opens off-screen

    What can I do to have the system preferences panel open in the center of the screen instead of off the screen?
    Whether I open it by Apple->System Preferences or open any other module within System Preferences (such as Network Preferences) it opens in the lower left-hand corner with 80% of the window off the screen. Then I have to drag it back to the center to use it.
    I used to have dual-monitors, but now only use the laptop screen.

    The position you have the System Prefs on your screen when you close it should be stored in the plist file.
    /Users/yourname/Library/Preferences/com.apple.systempreferences.plist
    Thus, if you trash the plist it really ought to be created with the default position, but even that shouldn't actually be necessary: when you move System Prefs window to where you want and close it the new position should be recorded in the plist and used next time you open it.
    The only thing I can think of is perhaps something is funky in the way your account is considering the dispaly. Launch the Displays preferences and try clicking the "Gather Windows" button and the "Detect Displays" button, check that Rotate is Standard, and also check the Arrangement tab to make sure it shows one display with the menu bar.
    Francine
    Francine
    Schwieder

  • System preference wont open

    i have a mac OSX version 10.5.8 under apple and system preference when i try to open it does not respond.  i can not defreg my hard drive howe do i fix this proplem

    First, Safe Boot , (holding Shift key down at bootup), use Disk Utility from there to Repair Permissions, test if things work OK in Safe Mode.
    Then move these files to the Desktop...
    /Users/YourUserName/Library/Preferences/com.apple.finder.plist
    /Users/YourUserName/Library/Preferences/com.apple.systempreferences.plist
    /Users/YourUserName/Library/Preferences/com.apple.desktop.plist
    /Users/YourUserName/Library/Preferences/com.apple.recentitems.plist
    Reboot & test.
    PS. Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.

  • Why system alarm sound when opening an app on my MBP 13"?

    Recently started to hear system alarm sound when opening an app., eg. Mail, Safari (usually from the Dock). No apparent operational problem, but quite annoying, especially since I don't know why. Happens on my 13" MBP, but not on my iMac, both running ML 10.7.4.
    Repair Disk Permissions and Verify Disk both OK.
    Any clues from anyone??

    Disable: Play user interface sound effects in System Preferences > Sound > Sound Effects
    If that doesn't make a diffeence, check your Dashboard widgets.

  • HT1338 system preference not open so how guide to sample?

    My mac book pro in system preference not open so how guide to sample?

    Hello,
    First, Safe Boot , (holding Shift key down at bootup), use Disk Utility from there to Repair Permissions, test if things work OK in Safe Mode.
    Then move these files to the Desktop for now...
    /Users/YourUserName/Library/Preferences/com.apple.finder.plist
    /Users/YourUserName/Library/Preferences/com.apple.systempreferences.plist
    /Users/YourUserName/Library/Preferences/com.apple.desktop.plist
    /Users/YourUserName/Library/Preferences/com.apple.recentitems.plist
    Reboot & test.
    PS. Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.

  • I always got error message when opening BlackBerry App World using 3g

    Hi there, I always got error message when opening BlackBerry App World using 3g network, but it's fine if I open it through wifi network. Does anyone ever had the same problem and how to fix it? Thanks.

    You need the latest version of BlackBerry World installed on your smartp

  • My system preferences wont open anymore, whats up

    my system preferences wont open anymore, whats up

    Hi xronjonesx,
    To make sure that we are on the same page, you cannot open System Preferences. Have you tried opening it from the Apple Drop down menu? If you are still unsuccessful, then the next step would be to reinstall OS X Snow Leopard as that app is part of the operating system and the reinstallation with all the software updates afterwards will resolve the issue. 
    Mac OS X 10.6: Reinstalling Mac OS X
    https://support.apple.com/kb/PH6606
    Take it easy,
    -Norm G. 

  • What does a 2 on the upper right corner of the Mail icon mean?  When opened, the app is essentially blank and unresponsive.  We've been using Mail for weeks.

    What does a 2 on the upper right corner of the Mail icon mean?  When opened, the app is essentially blank and unresponsive.  We've been using Mail for weeks.

    Thanks.  I used an Apple in 79-81, and got the first PC in EDS (Ross Perot) in Jan, 82.  Installed corporate email in 83.  Now have 4 pcs in a house of 2 people, supporting our 5 kids and 15 grandkids.  The iPad is what it took to get my wife to use her own email address.  I should have known about the red circle - my bad.  I did get fixed with a reset.  Vern Olson

Maybe you are looking for

  • Database connection timed out issue

    Thanks in advance for anyone that can provide some insight into this. I have a relatively simple BPEL process that is using a JDBC connection within Jdev (not using connection factories due to issues with security) that connects to an Oracle database

  • New install of Ubuntu, Firefox menu bar is missing.

    I have a new machine with a new install of Ubuntu 12.04. In Firefox the menu bar is missing. I have the black border with 3 buttons in the left and the current page title. I also have a tabs bar and toolbars. I've looked in the forum/help and tried t

  • Private field in a stateless session EJB

    Hi guys, I have a question about the design of a stateless session EJB. I would like to know : Does it make sense to put a private field in a stateless session bean??? Imagine the following sitiation: I have a stateless session bean. Its job is to de

  • Putting a check box above column for selection in WD ALV

    Hi, Can anyone provide me a code snippet and help me how I can provide a check box above column for selection in WD ALV. Best Regards Sid

  • Boot From Time Capsule

    Is it possible to boot from Time Capsule? I don't see any FireWire Ports.