View Single Post
I've hacked together a cludgy solution for myself that works under Mountain Lion, OmniWeb 5.11, and 1Password 3.9.6. It uses Applescript and GUI scripting to get around the fact 1Password isn't scriptable.

The script gets the Domain Name from the URL of the front window/tab in OmniWeb, and then uses GUI scripting to search for it in 1Password. If 1Password is locked, the script pauses for 5 seconds to allow you to unlock it manually. It then searches for the Domain Name and copies the User Name and Password of the 1st matching login record. Having done so, it returns to OmniWeb so I can paste these values into the login fields myself.

Because of the way this references UI elements, it may not work for you, or it may break suddenly if there's an update to 1Password. That's the nature of GUI scripting. Sorry!

But I'm including it here, because others may find it useful, or it may serve as a starting point for others to modify to their own ends.

My script also takes advantage of Keyboard Maestro 5 for two things: To run the script with a keyboard shortcut; and because both a user name and password are returned, I take advantage of Keyboard Maestro's multiple clipboards, which is why the script copies both the name and password to the clipboard one after the other. That doesn't make much sense without multiple clipboards.

Hope this is of mild help to someone out there. (This script is supplied as-is - I can't modify it for other people.)

Cheers
Robert Black

Code:
tell application "OmniWeb"
	set a_tab to active tab of front browser
	set the_url to address of a_tab
	set the_domain to word 2 of the_url -- as chance would have it, that's the domain
end tell

tell application "1Password"
	activate
	tell application "System Events"
		tell process "1Password"
			click menu item "Main Window" of menu 1 of menu bar item "Window" of menu bar 1
			if menu item "Unlock" of menu 1 of menu bar item "1Password" of menu bar 1 exists then
				say "Pausing for 5 seconds"
				delay 5
			end if
			click menu item "Logins" of menu 1 of menu bar item "Go" of menu bar 1
			click menu item "Find Item" of menu 1 of menu item "Find" of menu 1 of menu bar item "Edit" of menu bar 1
			set value of text field 1 of window "1Password" to the_domain
			delay 0.5 -- allow time for the search to work. This value may need to be increased.
			set pass_word to get value of static text 7 of scroll area 1 of splitter group 1 of splitter group 1 of window 1
			set user_name to get value of static text 5 of scroll area 1 of splitter group 1 of splitter group 1 of window 1
			
		end tell
	end tell
end tell
set the clipboard to pass_word
delay 1 -- Keyboard Maestro seems to need a second or so here to recognise the clipboard has been changed by the script rather than user input.
set the clipboard to user_name -- Because I'm using Keyboard Maestro 5, this second Set Clipboard pushes the value onto a clipboard stack
tell application "OmniWeb"
	activate
end tell