Droplet bug


Does anyone know if this is an old or new bug. When I drop an internet location file onto the following droplet, it opens the internet location and doesn’t process the parameter:

on open p
	set c to class of p
	display dialog (c as string)
end open

Edited: found one verification:
About 5 months ago.


That’s ok. Found verification on the mailing list:

Thanks anyway,

FWIW, it’s not really a droplet bug – it’s all intercepted before it gets near the droplet.

Hi Shane,

That’s interesting. I was wondering if the bug occurs in ASOC droplets Finally figured out how to make the droplet in Xcode from one of your posts. Thanks a lot.

Now about to test the webloc extension. I’d bet that it won’t work.

Thanks again,

Yes, it didn’t work. The dragged internet location file open in Safari.

Learned a lot,

Just thought of an idea. if you check the selected files in Finder before ‘application_openFile_(theSender, theFile)’, then you might be able to stop Safari opening it. I’ll try checking in the ‘applicationWillFinishLaunching_(aNotification)’ handler. Then, get the list of selected files in Finder.

I suppose that you all tried these workarounds already, but it’s fun.

Wish me luck, :slight_smile:

It happens everywhere. The way apps open files is as a result of an Apple event sent to them, listing the files. When it’s an internet location file, the whole mechanism is short-circuited.

You can do the same thing in AppleScript. The problem, though, is you can have a file selected in the Finder, and drag another file altogether – the dragged file is not necessarily the selection.

That’s what I was thinking. Sometimes, you might not know what selection to be directed towards maybe.

One other option I was thinking about is ui scripting Finder just to get selected items. Something like:
Darn I can’t find the script. Desktop is full.

Hi Shane,

I reread your posts. Didn’t think about dragging a file that is not selected. One track minded, me. :confused: Did manage to get the selection before Safari opened though. Another way it won’t work is if the droplet is in a different window from the selected dragged files. Then, the droplet becomes selected.

Edited: just thought of another workaround. Get the url from Safari. :slight_smile:

Edited: the only problem with that is if you have duplicate (or the same urls) in the internet location files. Need another workaround for that also. :slight_smile:

Edited: also, if one of the open windows contains many items, then you have a problem with time.

Edited: just thought of one thing. If there are more than one file dropped, then the selection must be true. Because you cannot drop more than one item unless they are selected.

Edited: i.e. in their windows.

Edited: it’s a good thing that Apple ended the text in their internet location files with a return. Then, you know the end of the url.


Just thought of something. Python has the MacOS module or something along that lines. Might need shell script for this.

Editeed: I don’t think there is anything in there. It’s all based on the same thing.

I’m quite sure that you can make a Python droplet. But, you need to download the update. It’s been a while since I’ve used that, the application. The Finder module is exactly like part of scripting the Finder, but what I’ve noticed is that Python doesn’t always return the same things. Need to look into it further.

Here’s the start of the new plan:

  1. Record the Safari window(s).
  2. After app will finish launching, find the new windows.
  3. Find the new windows and get the urls.
  4. look in Finder for window that contains files with these urls.
  5. return the files

Edited: and I forgot if they duplicate warn the user and allow deletion of duplicate (or same) files.


Maybe you can try to change the uti of the info plist file to process webloc files? What I am saying is that in order for your droplet to process a webloc file, you must configure the droplet to do so by editing the info plist file, with regards to which uti’s your droplet can handle. This will hopefully work. You’ll find how to edit the info plist file in at least property list programming guide, or that will point to the document. Shouldn’t it work, then you must try to write an on open location handler.

It may very well be so, that the Launchservices, opens and reads the url in the webloc file for you, regardless, if your app takes webloc files or not, but the only way of figuring that out, is by actually trying. If it don’t handle webloc files, then you should try to configure your droplet to take url’s. Then you at least know for sure what is happening. :slight_smile:

Hi Mcusr,

I’ve been trying all kinds of things with the info.plist with info from the internet and the developer docs. Can’t get it to work. It’s very hard trying something when you don’t know if it will work or not.

Trying to work with this example at the moment, but need some rest:

I have the feeling that it might not work. It seems like something is happening in the drag and not the drop. I’ll check it out again tomorrow. Also, I need to recheck what to enter the schemes.


Hello kel.

Well, I don’t think you can make the webpagehelper work anymore with Safari, at least I couldn’t, and I gave a fair try to it, as I had it working on Snow Leopard, with that version of Safari.

This snippet below does what it is intended to do. (Save as applet, then drop webloc) The problem with weblocs, is that they become urls, before you can see them. So this may not serve your purpose at all.

on open location url_item
	display dialog (url_item as text)
end open location

There is no good way to figure out where a webloc resideds in all cases. :confused:

Hi all,

Sorry if I’ve read too quickly all the posts but what I’ve ended up with is just a little series of trials on a drag and dropped webloc from Safari onto the Desktop. Double-clicking the webloc, we knew that, opens the URL straight in the default Web browser. So I tried to force open it in TextEdit: bad luck, also opens in Safari! So I decided to get inside of the webloc file itself by changing webloc extension into txt and bingo the file opens flawlessly in TextEdit. And the text is interesting: it reads bplist00”SURL_-http://macscripter.net/viewtopic.php?id=43021?
So I’m sure a little handler would convert the webloc file into a txt file and then read from it and extract the relevant URL as string.
Does it help?

EDIT: I think I get what you meant. :rolleyes: at opening a webloc file, nothing to do it opens in the Web browser! Gosh! Just an idea: what about creating a sorta hot folder with a script attached to it “on adding folder items to this_folder after receiving added_items” and process of the files without any open event?

on adding folder items to this_folder after receiving added_items
	repeat with an_item in added_items
		set a to info for an_item
		set c to name extension of a
		display dialog (c as string)
	end repeat
end adding folder items to

This script saved as a Folder Action Script and attached to a folder works like a charm here. So back to the OP’s needs, one could probably reach the initial aim. HTH.


I never thought of using a folder action instead. Need to check that out.

Btw, you can read the webloc file with the ‘read’ command:

set f to choose file
set t to read f

I think you could use unix’ ‘mdls’ also to get the url directly.

Edited: mdls doesn’t give you the url. I mistook it for something else.:roll eyes: