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


Click here to return to the 'A Google personal lookup plug-in for Address Book' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A Google personal lookup plug-in for Address Book
Authored by: sdickers@mac.com on Dec 17, '04 09:57:18AM

Dear davegolden,

It works great. I have found that it works better if a middle name is included.

Is there a way to get AppleScript to put quotes around the entire name? It would reduce the number of entries down to only the relevant ones in most cases. I have no experience with AppleScript other than copying other peoples' codes character per character. I need to learn how to write my own scripts.

Thank you.

Sincerely,
Steve Dickerson



[ Reply to This | # ]
A Google personal lookup plug-in for Address Book
Authored by: maxsnet on Dec 17, '04 10:54:55AM

is that you need ?

set theURL to "http://www.google.com/search?q=\"" & name of thePerson & "\""



[ Reply to This | # ]
A Google personal lookup plug-in for Address Book
Authored by: bkazez on Dec 18, '04 10:48:54AM

Actually, it's considered better form to %-encode characters in URLs. I'd recommend replacing the \" items with %22.

Ben

---
http://ben.kazez.com/

[ Reply to This | # ]

A Google personal lookup plug-in for Address Book
Authored by: bkazez on Dec 18, '04 10:51:50AM

Sorry, the backslash in my post wasn't preserved. You should replace backslash-quote with percent-two-two.

---
http://ben.kazez.com/



[ Reply to This | # ]
re: %-encoding characters
Authored by: nicksay on Dec 18, '04 07:26:32PM
Actually, it's not always a good idea to %-encode characters. It depends on how you're going to open the url. If you're going to directly tell Safari to make a new document and set the path to the url, then, yes, you'll want to %-encode characters:
set theURL to "http://www.google.com/search?q=%22" & name of thePerson & "%22"
tell application "Safari"
    make new document
    set URL of first document to theURL
    activate
end tell
However, if you're going to use the open location command to let the system open the url in the default application using the default "Open links from applications" behavior (see your browser's preferences), then you shouldn't %-encode characters. The system (or browser, not sure which) will try to re-encode the url, replacing the % with %25 leaving you with %2522, which messes up your search. So, you'd want to leave it unencoded:
set theURL to "http://www.google.com/search?q=\"" & name of thePerson & "\""
tell application "System Events" to open location theURL
(See my comment above about why tell application "System Events" to is necessary.)

[ Reply to This | # ]
re: %-encoding characters
Authored by: koncept on Dec 20, '04 12:47:50PM
I altered your last handler to the following to account for spaces:

on perform action for thePerson with fone
  set od to AppleScript's text item delimiters
  set newDelim to space
  set theURL to "http://www.google.com/search?q=" & name of thePerson
  set AppleScript's text item delimiters to newDelim
  set ti to text items of theURL
  set AppleScript's text item delimiters to "%20"
  set urlEncoded to ti as string
  set AppleScript's text item delimiters to od
  do shell script ("open" & space & quoted form of urlEncoded)
  return true
end perform action


[ Reply to This | # ]