Alternative to DefaultFolder needed !!!!!!!!! Please help !!!!

Hi fellow scripters,

I need an Applescript alternative to the program DefaultFolder. For those of you who don’t know what DefaultFolder is please go here: http://www.stclairsoft.com/DefaultFolderX/.

Basically the script I need will perform the following task:
When this new Applescript is executed using a hot key (via Spark, QuicKeys, etc.) in an open or save dialog box in any application, the target directory of the open or save dialog box will target the frontmost finder window. An added feature would be to send the frontmost finder widow to the back so each time you run the script it will advance to the next window until the preferred target folder is achieved.

I pieced together scripts I found on the web. However, in the example below the target dialog box is not automatically changed. The script uses system events… which is clunky and slow. BTW, in the example it uses “Safari” as the test application… However, this script need to work with any application (frontmost).

Any info would be greatly appreciated,
CarbonQuark


set allPaths to {}

tell application "Finder"
	set allwindows to (every Finder window)
	
	if allwindows is not {} then
		repeat with thisWindow in allwindows
			try
				set thisWindowPath to the POSIX path of (target of thisWindow as alias)
				if thisWindowPath is not in allPaths then
					set allPaths to allPaths & thisWindowPath
				end if
			end try
		end repeat
	else
		display dialog "No open Finder windows" with icon stop buttons {"OK!"} default button 1
		return
	end if
end tell

set strPath to choose from list allPaths with prompt "Copy the path of a Finder window:" default items item 1 of allPaths without multiple selections allowed

if strPath is not false then
	set the clipboard to item 1 of strPath
end if

set the_app to "Safari"
tell application the_app to activate
tell application "System Events"
	tell process the_app
		delay 1
		keystroke "o" using command down
		delay 1
		keystroke "G" using command down
		delay 1
		keystroke item 1 of strPath
		delay 1
		keystroke return
	end tell
end tell

Hi,

it’s quite difficult to make the script working for all applications,
because several kinds of open/save dialogs are used.
Try this


.
set the_app to name of (info for (path to frontmost application))
activate application the_app
tell application "System Events"
	tell process the_app
		keystroke "o" using command down
		delay 0.5
		keystroke "G" using command down
		delay 0.5
		keystroke item 1 of strPath
		tell window 1
			if exists sheet 1 then
				tell sheet 1
					if exists button "Go" then
						click button "Go"
					else if exists button "OK" then
						click button "OK"
					end if
				end tell
			else
				delay 0.5
				key code 36
			end if
		end tell
	end tell
end tell