Camino Export

Greetings,
I am very new to AppleScript and am trying to learn the ropes. I’ve been trying to write a script which will open up Camino for me, and then export my bookmarks in the Safari plist format. I’m having some problems, the first being setting the text field on the Save window, and the second actually clicking the “Export” button. Ideally, I want to save this script to my desktop as “Bookmarks.plist”.

If I am ever successful at getting this part fixed I am going move the exported file into my Safari folder, replacing the existing one - and if I wind up being able to do that it’d be nice to then sync dot mac… but baby steps, I just need to get this basic part working first.

Anyhow, here’s what I have. Again, I’m fresh meat to this turf, so any help that anyone can give me would be greatly appreciated. Thanks!


tell application "Camino"
	activate
end tell

tell application "System Events"
	tell process "Camino"
		tell menu bar 1
			tell menu bar item "File"
				tell menu "File"
					click menu item "Export Bookmarks."
				end tell
			end tell
		end tell
		
		tell window "Save"
			tell sheet 1
				set text field 1 of sheet 1 of window "Save" to "/Users/stan/Desktop/Bookmarks.plist"
				
				tell pop up button 0
					select "Safari"
				end tell
				
				click button "Export"
			end tell
		end tell
	end tell
end tell

  • Stan Lemon

Model: iMac Duo Core 2 20"
Browser: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; chrome://navigator/locale/navigator.properties; rv:1.9a1) Gecko/20061021 Camino/1.2+
Operating System: Mac OS X (10.4)

Hi Stan,

If you want to save as plist, then you need to script the pop up button also. I haven’t succeeded in doing that yet.

This can get you started.


tell application "Camino"
	activate
	set the clipboard to "Bookmarks"
end tell
tell application "System Events"
	tell process "Camino"
		tell menu bar 1
			tell menu "File"
				click menu item "Export Bookmarks."
			end tell
		end tell
		keystroke "v" with command down
		keystroke return
		(*
		tell window "Save"
			tell pop up button 1
				UI elements
			end tell
		end tell
		*)
	end tell
end tell

gl,

Here’s an easier way:


set lib_folder to (path to "dlib" from user domain as string)
set bm_ref to ¬
	(lib_folder & "Application Support:Camino:bookmarks.plist") as alias
tell application "Finder" to duplicate bm_ref to desktop

gl,

Kel,
I’ve had no luck with the changes you’ve posted.

The plist files for Camino and Safari are different, and unfortunately they can’t just be copied over either like the second example you posted.

With the first one cna you explain what the changed lines of script mean for me? Like I said, I’m really new to this.

Thank you for the help.

Pax.

  • Stan

Hi Stan,

In the first script, the text “Bookmarks” is first placed on the clipboard. Then, after the Save window is opened, the line:

keystroke “v” with command down

pastes (keyboard shortcut) the text from the clilpboard into the text field. Then the line:

keystroke return

hits the Return key. This selects the defaut button “Export”.

I forgot to say to change:

keystroke “v” with command down

to:

keystroke “v” using command down

Apple changed the syntax in your OSX version.

I still don’t know how to select Safari from the pop up button. Just got an idea. There might be something with the exported html file.

gl,

Kel,
Thanks, I ran the script with that change and got a bit closer… only problem is for some reason the keystroke return doesn’t seem to work right. Any ideas?

Thanks.

Pax,

  • Stan

Hi Stan,

You might need to add a delay between the keystrokes.

delay 1 – adjust for whatever works

Anyway, if you don’t like using the clipboard, this works without using the paste method.


tell application "Camino"
	activate
	--set the clipboard to "Bookmarks"
end tell
tell application "System Events"
	tell process "Camino"
		tell menu bar 1
			tell menu "File"
				click menu item "Export Bookmarks."
			end tell
		end tell
		--keystroke "v" with command down
		--keystroke return
		tell window "Save"
			tell pop up button 1 -- pop up for switching to Safari
				click
			end tell
			delay 2
			tell group 2
				tell group 1
					tell text field 1
						set value to "Bookmarks"
					end tell
				end tell
			end tell
			tell button "Export"
				click
			end tell
		end tell
	end tell
end tell

Remember that if things don’t work sometimes, adding delays makes it work.

gl,

Hmmm… I must be having terrible luck or something… It gave me that nasty NS…4 error on he word “click” under the popup button.

Any ideas? (Sorry I’m moving so slow!)

Pax.

I’m using Jaguar so things probably changed. Look in the dictionary for System Events. They have other commands like ‘pick’ and I think ‘press’. Apple Also added where you can set attributes. You might need that to select Safari from the popup menu. You can download ui element inspector to help you:

http://www.apple.com/applescript/uiscripting/02.html

Try searching for posts about setting attributes of ui elements.

gl,