The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    circa86's first App, "fn"

    Discussion in 'Apple and Mac OS X' started by circa86, Mar 9, 2008.

  1. circa86

    circa86 Notebook Virtuoso NBR Reviewer

    Reputations:
    685
    Messages:
    2,463
    Likes Received:
    0
    Trophy Points:
    55
    [UPDATED Check bottom of this post!]

    some of you may remember this issue I was recently having: with Application specific System Preferences

    this is a very minor thing and isn't necessarily an issue at all, but i could improve my workflow if I had a way to set application specific system preferences.

    for example, I like having all my function keys act as the different built in adjustments for brightness, volume, etc. in most cases.

    but, with applications like Maya, and a few others, it is much more efficient to have the functions keys set to their normal F1-F19 or whatever functions.

    just figured I would see if anyone new a efficient way to do this.



    Well, I was able to solve it in a pretty interesting and FUNCtional way.

    i used Automator to create an App called "fn".

    when you run the App, all it does is check/or uncheck the "Use all F1, F2, etc. keys as standard function keys" option in the Keyboard Preference pane, and then quits.

    i used Automator to create an Applescript then created this App that simply runs the Applescript, this way, I can just have this App in my dock and click it whenever I want to switch back and forth.

    this may seem lazy, as it only takes a few clicks to go change this setting step by step, but this is going to save me a lot of time and take some repetition out of my workflow.

    also, I guess I have created my first App ever, exciting stuff.

    here are some screenshots, I made a nice icon and everything ^_^

    [​IMG]
    Here is the shiny new Fn sitting in the dock.

    [​IMG]
    Launch the App.

    [​IMG]

    and Voila! you have changed the preference with one simple click.

    enjoy the laziness ^_^

    I doubt this is the most elegant solution, but hey it works.

    [UPDATED! fn_1.1 is finished!]

    hey all I have recently been learning more and more about Applescript, and I have completely re-written "fn" using only Applescript, not only does it function much better, it is faster, and no longer visually opens the System Preference window and closes it, it just opens, changes the preference and closes without really getting in the way.

    Download "fn_1.1" here:

    fn_1.1.dmg

    file hosted on .Mac by the way ^_^
     
  2. Jalf

    Jalf Comrade Santa

    Reputations:
    2,883
    Messages:
    3,468
    Likes Received:
    0
    Trophy Points:
    105
    Hehe, neat. Now you just need to make it automatically switch settings depending on which app is running in the foreground. :)
     
  3. Sam

    Sam Notebook Virtuoso

    Reputations:
    3,661
    Messages:
    9,249
    Likes Received:
    0
    Trophy Points:
    205
    Woo, fancy circa86! :)
     
  4. circa86

    circa86 Notebook Virtuoso NBR Reviewer

    Reputations:
    685
    Messages:
    2,463
    Likes Received:
    0
    Trophy Points:
    55
    if someone can tell me how to do that I would be forever greatful.
     
  5. circa86

    circa86 Notebook Virtuoso NBR Reviewer

    Reputations:
    685
    Messages:
    2,463
    Likes Received:
    0
    Trophy Points:
    55
    I seem to have already found a small bug in it. if you have the keyboard preference pane open, and you are on the trackpad settings tab, then you run the app, it seems to think it is already on the correct tab and doesn't attempt to switch, so it can't find the correct option to turn on/off. but that is only if you already have system preferences open, so not a big deal. as this app was made to not have to deal with that.

    I am really interested in seeing what I can accomplish with Applescripts now.
     
  6. Dana

    Dana Notebook Consultant

    Reputations:
    12
    Messages:
    165
    Likes Received:
    0
    Trophy Points:
    30
    Really neat, i love when I accomplish something :D Why are your stack so different than mine? Yours look like bins or something, mine is just a folder?
     
  7. circa86

    circa86 Notebook Virtuoso NBR Reviewer

    Reputations:
    685
    Messages:
    2,463
    Likes Received:
    0
    Trophy Points:
    55
    those are drawers, made by a guy from Japan, I can post up the link soon, it is somewhere on this site already, but if you just Google os x stacks drawers, or something you should find it.

    I am not so sure about the functionality of this App on others machines, as I have not had the chance to test it.
     
  8. circa86

    circa86 Notebook Virtuoso NBR Reviewer

    Reputations:
    685
    Messages:
    2,463
    Likes Received:
    0
    Trophy Points:
    55
    updated the first post with new package for the App, now in .dmg format with full documentation! ^_^
     
  9. Kaushal

    Kaushal Notebook Consultant

    Reputations:
    113
    Messages:
    228
    Likes Received:
    0
    Trophy Points:
    30
    good one circa :claps:
     
  10. stealthsniper96

    stealthsniper96 What Was I Thinkin'?

    Reputations:
    207
    Messages:
    1,398
    Likes Received:
    0
    Trophy Points:
    55
    You have inspired me. haha. I just went and made an app that does everything I do when I turn my MB on after I get home from school. I feel even lazier now.
     
  11. circa86

    circa86 Notebook Virtuoso NBR Reviewer

    Reputations:
    685
    Messages:
    2,463
    Likes Received:
    0
    Trophy Points:
    55
    i always have aspired to inspire laziness! ^_^
     
  12. circa86

    circa86 Notebook Virtuoso NBR Reviewer

    Reputations:
    685
    Messages:
    2,463
    Likes Received:
    0
    Trophy Points:
    55
    UPDATE!

    fn 1.1 is now complete! haha.

    after some more testing and r&d, eh ehm, I discoverdd that the "fn" app was not really functioning properly on other people's machines, and that it would also run quite slow at times for some reason.

    well, I have done what I should have done in the first place and learned a little more about Applescripting!

    fn 1.1 is entirely built through the Script Editor, which you can find in Applications/Applescript, and is a very interesting and powerful too, and its fantastic that all of this is simply part of the OS.

    Applescript uses very friendly language that is very simple to pick up and understand.

    for the "fn" app to fully function how it should here is the script I wrote,

    Code:
    (*
    fn_1.1
    
    Written by circa86 in 2008
    
    This script will simply open the "System Preferences" App, open the Keybaord Preferences Pane, and check/uncheck the "Use all F1, F2, etc. keys as standard function keys" checkbox.  If "System Preferences" is already open it will switch to the Keyboard Pane and check the same checkbox.  After the box is checked/unchecked, System preferences will quit.
    
    The reason for this script comes from the use of Applications like Maya where F1-12 fn keys are extremely important.  I found that I hated going into system preferences to check/uncheck the specific preference each time I wanted to switch the functionality, so this was an excellent solution.
    *)
    
    --Check if GUI Scripting is Enabled
    tell application "System Events"
    	if not UI elements enabled then
    		set UI elements enabled to true
    	end if
    end tell
    
    --Enable/Disable "Use all F1, F2, etc. keys as standard function keys" option in Keyboard & Mouse Preference pane and close System Preferences
    tell application "System Events"
    	tell application "System Preferences"
    		reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
    	end tell
    	click checkbox "Use all F1, F2, etc. keys as standard function keys" of tab group 1 of window "Keyboard & Mouse" of application process "System Preferences"
    end tell
    if application "System Preferences" is running then
    	tell application "System Preferences" to quit
    end if
    which includes working on an machine running Leopard, and most likely older systems as well, and also, working properly no matter what system preference pane was last open.

    not to mention running instantly without any of the wierd issues that can result in building a script using Automators record function, which is the only method I knew of at the time really. also, you don't get a "Running Applescript" in the menu bar any more as well, just some icons dancing around in the dock and instance Keyboard Preference switching action!

    it is possible to have the App run entirely in the background as well, besides some the icons bouncing once each in the dock, that is how the provided script functions. to have the script show exactly what it is doing, you can just add "activate" right under the line "tell application "System Preferences"

    I believe I may be able take it even further and have it specifically check or uncheck the setting depending on what application is in the foreground, or if an application is currently running or not. I have built a version that only allows the script to run if Maya is running, so I will see what I can do about that type of functionality. I think that would open a pretty awesome window for automation, and would be a actual way to use Applicaiton specific system preferences, although a somewhat difficult way.

    I will post up a link to download the truly functional version of this App, soon, I am sure anyone that tried the version currently available that it most likely did not work unless GUI scripting was enabled. The new version should work no problem, if the proper option is not enabled, it will just ask you for your admin password to enable it.

    here is the Download link for "fn_1.1": fn_1.1.dmg
     
  13. circa86

    circa86 Notebook Virtuoso NBR Reviewer

    Reputations:
    685
    Messages:
    2,463
    Likes Received:
    0
    Trophy Points:
    55
    I have actually begin to develop a version that will do this, but I have found it is more efficient to just have an App that you run whenever you like, as it doens't have to constantly run that way.

    I am working on developing a version that will actually know what Apps are currently running and make a decision what to do based on that, that way, I could even develop entire System Preference, setups for whatever workflow I like, basically a single App that will choose what prefs are best for what I am currently doing, based on what I programed it to do. fun stuff indeed.

    it can even be taken as far as writing a script that, changes all the main system prefs to my own settings, then even having the script go onto the web and downloading an image, using it as my desktop background, changing my dock position, size, keyboard, mouse settings, you name it really, almost anything is possible just by running a script.

    if it isn't then you need to learn more and build a full fledged application with its own interface, etc.