amplifier
amplifier

Reputation: 1833

Applescript application and Open with

I have a simple script

on run
    display dialog "Hello" buttons {"Ok"}
end run

I saved it as application (let's say myapp.app) If I just launch it from finder by double clicking then it works (i.e. shows the dialog box), but I want to use it for opening files.

The problem: For example I have file.xyz, then right-click it to "open with" and choose my.app. In this case my.app doesn't start (no icon at the dock panel, no dialog box shown).

Upvotes: 1

Views: 394

Answers (1)

adayzdone
adayzdone

Reputation: 11238

You can use an open handler to drag items on the application like this:

on open of theFiles
    --  Executed when files are dropped on the application

    display dialog "There are " & (count of theFiles) & " files dropped" buttons {"OK"}
end open

Upvotes: 2

Related Questions