So here the Applescript code that does that. Paste it into the Applescript Editor, save it as an Application and then tell finder to open all .exe files with that. Done.
on run argv
set executable to (item 1 of argv)
set executable to posix_path(executable)
do shell script "/usr/local/bin/wine " & executable
end run
on open argv
set executable to (item 1 of argv)
set executable to posix_path(executable)
do shell script "/usr/local/bin/wine " & executable
end open
on posix_path(mac_path)
set mac_path to (mac_path as text)
set root to (offset of ":" in mac_path)
set rootdisk to (characters 1 thru (root - 1) of mac_path)
tell application "Finder"
if (disk (rootdisk as string) is the startup disk) then
set unixpath to "/" & (characters (root + 1) thru end of mac_path)
else
set unixpath to "/Volumes:" & mac_path
end if
end tell
set chars to every character of unixpath
repeat with i from 2 to length of chars
if item i of chars as text is equal to "/" then
set item i of chars to ":"
else if item i of chars as text is equal to ":" then
set item i of chars to "/"
else if item i of chars as text is equal to "'" then
set item i of chars to "\\'"
else if item i of chars as text is equal to "\"" then
set item i of chars to "\\" & "\""
else if item i of chars as text is equal to "*" then
set item i of chars to "\\*"
else if item i of chars as text is equal to "?" then
set item i of chars to "\\?"
else if item i of chars as text is equal to " " then
set item i of chars to "\\ "
else if item i of chars as text is equal to "\\" then
set item i of chars to "\\\\"
end if
end repeat
return every item of chars as string
end posix_path
The trickiest part was to find out how Applescript handlers work.
It still spits out some errors but it's working well enough.
0 comments:
Post a Comment