Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Scripts to help search AppleScript via Spotlight Apps
Tiger only hintMacscripter.net partly inspired me to make the two scripts below -- I love the way the scripts on their site can be loaded into Script Editor with one click. And I hate that I cannot search my scripts for references in Spotlight.

My first venture in solving the Spotlight issue was to make a script that would copy the script to a text file. This way, I could use Spotlight to search for AppleScript code. I soon found reading the text files was a pain, and had to copy and paste them into Script Editor -- I had been spoilt by Script Editor's colour coding and bold fonts. And could not see the wood for the trees in the plain text.

Looking at how Macscripter.com uses the Open Script in Editor, I thought, I wonder if I could do that. Looking around, I could not find an easy way of writing out the files to the correct format.

Then I had the idea of trying the Open Location command, with the script code being the location with this at the beginning of the line:
applescript://com.apple.scripteditor?action=new&script="
Bingo! So I rewrote my save script to save the code out to a plain text file. The new file was given a new extension type, .aslt (AppleScript Location Text). Then I wrote a script that uses the open location comamnd to open the .aslt files.

Next I associated the .aslt files to be always opened with the open_aslt.app, using the Open With contextual menu and 'Always open with.' It took a couple of tries, but it worked in the end.

I also changed the info.plist for the open_aslt.app, though I am not sure it is needed:
<dict>
      <key>CFBundleTypeExtensions</key>
      <array>
        <string>aslt</string>
      </array>
      <key>CFBundleTypeOSTypes</key>
      <array>
        <string>TEXT</string>
      </array>
      <key>CFBundleTypeRole</key>
      <string>Viewer</string>
    </dict>
The last thing I did, using this hint, was to make sure Spotlight sees the new text files that have the .aslt extension.

Now when I double click, or select them in Spotlight, the files open as though they are AppleScript script files. I also use a hotkey app to run the 'Save_as_aslt.scpt' script. I now only save the scripts this way, and not as native AppleScript scripts, so I do not have dupes. If I do need a script to actually use, I open one of aslt files, compile and save using Script Editor.

The 'Save_as_aslt.scpt' script offers renaming options, so you can save them as new files, and both the 'Save_as_aslt.scpt' and the 'open_aslt.app' scripts set the window name to the name of the aslt file -- but not the original file (unless its in the Applescript (aslt) folder.)

The way it does this may seem odd at first. But I found it works well for me at least, and saves me overwriting originals -- if you open an AppleScript.scpt script and then use the 'Save_as_aslt.scpt' script, any name you give the new .aslt file will show as the name in the open script. Only if you use Save from Script Editor will the original be changed. The name of the original will remain un-changed, even though the window name says something different.

The files will be saved in a folder called "AppleScripts," which you need to put inside your Documents folder first. As usual, I have tested as much as I can, so use this at your own risk.

Here's the first script; save it as a script (Save_as_aslt.scpt). And here's the second script, which should be saved as an AppleScript application (open_aslt.app).

[robg adds: I have note tested these scripts...]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[9,749 views]  

10.4: Scripts to help search AppleScript via Spotlight | 3 comments | Create New Account
Click here to return to the '10.4: Scripts to help search AppleScript via Spotlight' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Scripts to help search AppleScript via Spotlight
Authored by: DougAdams on Apr 07, '06 08:16:07AM
SOT: "I love the way the scripts on their site can be loaded into Script Editor with one click."

Check out Apple's URL Protocol Support page.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

10.4: Scripts to help search AppleScript via Spotlight
Authored by: mark hunte on Apr 07, '06 09:34:01AM

Hi Doug, Thanks,
But the point here is I can save my scripts as a plain text type files with the aslt extension and search them using Spotlight. Also by double clicking the files or selecting them in the Spotlight Drop Down. They will open up straight in Script Editor.

I'm glad I did not find that page as I would have been side tracked.

The open location in script editor does all the conversion for you. when you add the "applescript://...." tag to the start of the script code/text.


---
mh



[ Reply to This | # ]
10.4: Scripts to help search AppleScript via Spotlight
Authored by: alauser on Apr 08, '06 02:19:19PM

You probably want to fix the Macscripter URL. The .com address you provided is one of those parasitic advertising sites. The correct URL is
http://www.macscripter.net



[ Reply to This | # ]