Page 1 of 1

how to drag and drop files?

Posted: Fri Jul 25, 2014 6:31 pm
by jack
hello,
I would like to be able to drag and drop files that launch the Terminal and then execute the file,
for example here's basically what I am looking for http://hints.macworld.com/article.php?s ... 7142625782
the script worked just perfect at first, but now it does not bring the Terminal to the front.
here's the slightly modified AppleScript from the link above

Code: Select all

set filecount to 0

on open filelist
	repeat with i in filelist
		set filecount to 1
		tell application "Terminal"
			set filename to do shell script ¬
				"perl -e \"print quotemeta ('" & POSIX path of i & "');\""
			do script "a68g " & filename & "; exit"
		end tell
	end repeat
end open
where a68g is the algol68 interpreter.

anyone knows why terminal is not brought to the front?
also for whatever reason that script now launches two terminal sessions whereas before it did not, I am stumped.

Re: how to drag and drop files?

Posted: Fri Jul 25, 2014 6:45 pm
by Danilo
jack wrote:anyone knows why terminal is not brought to the front?
Try 'activate' within your tell-block

Code: Select all

      tell application "Terminal"
         activate
      end tell

Re: how to drag and drop files?

Posted: Fri Jul 25, 2014 7:13 pm
by jack
thanks Danilo, that brings the terminal to the front but I still get two sessions but it's no big deal.

Re: how to drag and drop files?

Posted: Fri Jul 25, 2014 7:35 pm
by jack
solved, adding in front window to the do script fixed the two session problem.

Code: Select all

set filecount to 0

on open filelist
	repeat with i in filelist
		set filecount to 1
		tell application "Terminal"
			activate
			set filename to do shell script ¬
				"perl -e \"print quotemeta ('" & POSIX path of i & "');\""
			do script "a68g " & filename & "; exit" in front window
		end tell
	end repeat
end open