InsertionLocator Reference

InsertionLocator is an AppleScript module to obtain insertion/selected location in Finder with a smarter way than Finder does.

Finder's insertion location always means the top level folder of a Finder window. This behavior is not enough in same cases, for example an expanded sub-folder shown in a list view window can not be the insertion location.

InsertionLocator allow following behaviors.

These behavior can be customizable to meet your application.

GUI Scripting must be enabled for full features of InsertionLocator.GUIScriptingChercker is useful to check availability of GUI Scripting.

Basic Usage

use GUIScriptingChecker : script "GUIScriptingChecker"
use InsertionLocator : script "InsertionLocator"

if not do() of GUIScriptingChecker then
-- GUI Scripting is disable
return
end if

tell (make InsertionLocator)
-- It is assumed that a folder is selected in Finder window of icon view.
log do() -- if folder is selected, the item will be return.
log is_closed_folder() -- true

-- Folders whose contents are not shown should not be insertion location
log set_allow_closed_folder(false)'s do() -- return container of selected folder.
log is_closed_folder() -- false
end tell

Constructor Method

make

Make a new instance.

Getting Insertion Location

do

Getting selected location in Finder

last_result

Get a result of formaly called do().

Customize Behaviors

Handlers to customize behaviors. Following handlers should be called before do().

set_allow_package_contents

If true is given, the result of do() may package or its contents.

set_use_gui_scripting

If false is given, commands depends of GUI Scripting is not used. But some functions are lost.

set_allow_closed_folder

If false is given, do() should not return the folder whose contents are not visible.

Accessors

Handlers to access additional information related the result of do().Following handlers can be used after do().

is_determined_by_selection

If the result of do() is determined by selected items of Finder, true will be returned.

is_location_in_window

If the result of do() is contained in Finder window 1, true should be returned.

target_window

A reference to the window containing the result of do() should be returned.

view_type

The view type of the window containing the result of do().

is_closed_folder

If the contents of the result of do() is not displayed in Finder, true should be returned.