A Script Editor script for Script Editor version 2.6

Hello.

I have dropped the script below into my Script Editor Script’s folder, so I have easy access from the contextual menu, that you get up when you control-click in a Script Editor docucment.

Well, I have changed the templates folder to user domain, so I it easier to drop and change files there. (You’ll have to change the script accordingly).

Enjoy!

property scriptTitle : "Script Editor Folders"
property StdFolders : {"Templates Folder", "Scripts Folder", "Libraries Folder"}

-- set instigator to (path to frontmost application as text)
set choice to choose from list StdFolders with prompt "Which folder do you want to open?" default items item 1 of StdFolders with title my scriptTitle


if choice is false then
	error number -128 -- bummer
else if choice is {"Templates Folder"} then
	
	tell application id "MACS" to open ((path to library folder from user domain as text) & "Application Support:Script Editor:Templates:")
	
else if choice is {"Scripts Folder"} then
	
	tell application id "MACS" to ¬
		open ((path to library folder from local domain as text) & "Scripts:Script Editor Scripts:")
else
	
	try
		-- it doesn't exist by default so we'll check if it does.
		local probe
		set probe to ((path to library folder from user domain as text) & "Script Libraries:") as alias
	on error
		
		-- and if it didn't we'll as if we shall create it.
		
		set choice to button returned of (display dialog "The Script Libary Folder does not exist." buttons {"Cancel", "Create"} default button 2 cancel button 1 with title my scriptTitle with icon caution)
		if choice is "Create" then
			tell application id "MACS" to make new folder at (path to library folder from user domain) with properties {name:"Script Libraries"}
		else
			error number -128
		end if
		
	end try
	
	tell application id "MACS" to open folder ((path to library folder from user domain as text) & "Script Libraries:")
	
end if
tell application id "MACS" to ¬
	set pth to quoted form of POSIX path of (target of its Finder window 1 as alias)

tell (path to frontmost application as text) to tell me to do shell script "open  " & pth

“Why not putting the part of the script that activates the window into an ignoring applications block, prepend the activate part with a slight delay, so that the operation will take place after your script has finished?” :slight_smile:

In plain English:

I now see to that the operation that brings the window on top of every other to take place after the script has finished.

I do this, by putting that part into an ignoring application responces block, And I do start off with a slight delay inside that block, to get the precise effect.

This works only as I intended from the contextual menu of AppleScript Editor and not from the script menu. And that is what I really wanted, something simple, that made my window either the frontmost, or the second frontmost.

I think I have to approach the problem differently. You’ll hear from me. :slight_smile:

Hello.

I use the unix command open with great success. Some of you may think that this is a kluge, and if it is, then please show me a better solution. Well, I used to use ui scripting for nudging (clicking) on a window. Now, that is harder now adays, and this new way (for me) works for me. :slight_smile: