Selected text operations, Second mouse button action, etc

Hi all!

My first message here so forgive me if I’m asking dumb questions.

I want to script Camino. Or more specific, i want to script CamiTools. What i want to achieve is that, when i right-click on an object on a web page, the URL of that object gets passed to CamiTools’ blocking database.

I want to develop the script myself just to learn AS and to achieve something myself instead of asking people to do it for me. :cool:

But i need some startup. I’ve gone through the AS introduction tutorials, so i know how to reference applications, menus, etc, but wnat i cannot find is:

  • How to assign selected text to a variable
  • How to do get the URL of an object under the mouse (with or without the second mouse button pressed).
  • Ideally i want to add the script to the context menu that pops up when the second mouse button is used.

Any ideas? Can this be done with AS or Automator?

Thanks,

Ton (going back to reading…)

Hi toontje,

You can use ui scripting to create a macro for copying selected text to the clipboard. Then you get the clipboard contents.


tell application "Camino" to activate
tell application "System Events"
	tell process "Camino"
		keystroke "c" using command down
	end tell
end tell
tell application "Camino"
	set t to the clipboard
end tell

Camino is not scriptable, so this is the only way I think. This should get you started. I’m thinking about your other question. Would you mind a drag and drop of the link to your desktop? I don’t think you can change Camino’s contextual menu, but may be wrong.

Edited: oops, changed ‘with’ to ‘using’ in the 'keystroke command.

gl,

What I did was create a folder on my desktop. I connected this folder action to the folder:


on adding folder items to this_folder after receiving these_items
	set int_loc_file to item 1 of these_items
	tell application "Finder"
		set the_url to location of int_loc_file
	end tell
	activate
	display dialog the_url
end adding folder items to

When you drag a link to the folder, an internet location file is created in the folder, the folder action fires, and a dialog displays the url of the link.

See your sytem help for folder action info.

And BTW, I didn’t test it but it should work for any browser.

gl,