Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Feature Suggestion: Create new scripts directly from FastScripts menu

edited June 2008 in FastScripts
I often create new global or application-specific scripts while I'm in the application where I'd like to use the script.

For this purpose, it would be convenient to be able to create a new script directly via FastScripts instead of having to go to the corresponding Scripts folder first.

This screenshot illustrates where I'd like to have a "Create New Script..." menu item:


Location a is the most important of all, because most of my scripts are application-specific. Locations b and c would be nice to have.

Choosing the item should prompt me for the script file name, create an empty script in the appropriate location and then open that with my script editor.

It could be displayed optionally, controlled by a prefs setting.

What do you think?


  • I can definitely see the usefulness. My first thought though is that I would want to take care not to clutter the menus with a ton of "Create Script" items ... one alternative to adding the feature in FastScripts is you could actually write a script to do what you're describing, and put it in FastScripts with a convenient keyboard shortcut ;)

    I have a script for instance, "New Script With Active App" that does a pretty good job. Maybe I should include some example scripts with the download.

  • Oh, great idea, why didn't I think of that :-)

    Care to share your script?
  • Sure ... it's pretty simple but there are some weird nuances. I'm on the road now (at Apple's WWDC conference) but I'll dig it up when I get home!

  • Hi liyanage,

    Here is the script that I use to create a new script from the frontmost application. Maybe you'll find it useful:

    set NL to ASCII character 10

    tell application \"System Events\"
    set thisApp to name of first process whose frontmost is true
    tell process thisApp
    set appName to (name of menu 2) of menu bar 1
    end tell
    end tell

    tell application \"Script Editor\"
    make new document
    set paragraph 1 of contents of document 1 to \"tell application \\"\" & appName & \"\\"\" & NL & \"--do some stuff\" & NL & \"end tell\"
    compile document 1
    end try
    set selection to (characters 2 thru 16 of paragraph 2) of document 1
    end tell

    I think with a bit of effort, you could have it search for the current application's script folder and save it there with a name you specify.

    The names of most applications can be retrieved using the straight "name of first process whose frontmost is true" System Events call, but some, like Firefox or Azureus, return strange values when using this alone, which is why the script uses a bit of GUI voodoo to get the app name (a 'wierd nuance,' you might call it).

    If you see anything that can be improved let me know! Cheers.

    Incidentally, I blogged this little script here.
Sign In or Register to comment.