Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Open Wikipedia Topic from Script Menu' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open Wikipedia Topic from Script Menu
Authored by: robot_guy on May 30, '07 09:33:41PM
I use a script which allows me to do various things with a selection in OmniWeb:
(*DoXwithSelection is a collection of actions which I wish were available in OmniWeb's contextual menu; each takes as input the current selection in the front window and does something with it*)

set theList to {"Google Search", "Apple Support Search", "Wikipedia Lookup", "ARIN Whois"}

set theFocus to (choose from list theList)

tell application "OmniWeb" to activate
tell application "System Events"
	tell process "OmniWeb"
		keystroke "c" using {command down}
	end tell
end tell
delay 1
set theSelection to the clipboard

set thisURL to doXwith(theFocus as text, theSelection)

tell application "OmniWeb" to activate
tell application "System Events"
	tell process "OmniWeb"
		keystroke "t" using {command down}
	end tell
end tell

tell application "OmniWeb"
	set theId to id of front window
	OpenURL thisURL toWindow theId
end tell
to doXwith(thisFocus, thisSelection)
	if thisFocus = "Google Search" then
		set AppleScript's text item delimiters to " "
		set thisSelection to (text items of thisSelection)
		set AppleScript's text item delimiters to "+"
		set theSearchString to thisSelection as text
		set AppleScript's text item delimiters to ""
		set theURL to "http://www.google.com/search?hl=en&q=" & theSearchString & "&btnG=Google+Search"
	else if thisFocus = "Apple Support Search" then
		set AppleScript's text item delimiters to " "
		set thisSelection to (text items of thisSelection)
		set AppleScript's text item delimiters to "+"
		set theSearchString to thisSelection as text
		set AppleScript's text item delimiters to ""
		set theURL to "http://search.info.apple.com/?q=%22" & theSearchString & "%22&type=ktech+OR+klearn&search=Search&lr=lang_en&search=Go"
	else if thisFocus = "Wikipedia Lookup" then
		set theURL to "http://en.wikipedia.org/wiki/" & thisSelection
	else
		set theURL to "http://ws.arin.net/whois/?queryinput=" & thisSelection
	end if
	return theURL
end doXwith


[ Reply to This | # ]