Google Voice Action for QS

148 views
Skip to first unread message

elspub

unread,
Sep 17, 2009, 7:05:57 PM9/17/09
to Blacktree: Quicksilver
Below is a link to a QS Action I made to dial phone numbers entered in
the QS Text Window out through Google Voice. Use is simple enough.
Installation takes a few steps. There's a php script included that
needs to installed somewhere on your mac. And a couple easy changes
need to be made to the applescript action (typing in your username,
password, phone number, and where you put the php script). There's
better instructions in the zip file. And if you're involved enough
with QS to be reading this installation should be a breeze...

enjoy
http://tr.im/z0tm

Jon Stovell (a.k.a. Sesquipedalian)

unread,
Sep 18, 2009, 2:20:02 AM9/18/09
to Blacktree: Quicksilver
That's really cool. Thanks for this.

Here are two suggestions to make it easier for users who aren't tech
savvy:

1. Because Applescripts remember changes to their property values
between executions, it is possible to query the user for necessary
information the first time the script is run. It will only be
necessary for the user to enter it once, and the data will be saved
forever, unless the script is opened and recompiled.

This means that the script author can do this:

property usrnm : null
property psswrd : null
property phnm : null

if usrnm is null then set usrnm to (display dialog "Please enter your
full Gmail address. You should only have to do this the first time you
run this script." default answer "")

if psswrd is null then set psswrd to (display dialog "Please enter
your Google Voice password. You should only have to do this the first
time you run this script." default answer "")

if phnm is null then set phnm to (display dialog "Please enter your
Google Voice phone number. You should only have to do this the first
time you run this script." default answer "")

As an added benefit, this method of getting the user's password is
much less insecure, because it would require the greatest care on the
part of any attacker to extract the password from the saved properties
of the script without disturbing and thereby obliterating it. Of
course, for true security, this information should be stored and
retrieved in the keychain and retrieved using keychain scripting.

2. Instead of saving a separate php script file and then executing it
using

do shell script "php -f " & shFile & " " & thedigits & " " & usrnm & "
" & " " & psswrd & " " & phnm

you can simply include the full text of the php code in the
Applescript itself, and execute it using

do shell script "php -r '<your php code here>'"

This would save the user from having to manage a separate file. They
could simply drop the Applescript into QS's Actions folder and be done
with installation.

To do this will require adding proper escaping to your php code.
First, Applescript will require you to escape all double quotes ( " →
\" ). Second, because php -r requires single quotes around the entire
argument code block, you will have to escape all the single quotes;
moreover, to prevent Applescript from trying to interpret those escape
sequences, you have to double escape the single quotes ( ' → \\' ). Of
course, this is a simple find and replace operation in your text
editor, so no big deal.

3. Instead of passing in further arguments and then mucking around
with $argv[n] in your php code, you can simply substitute your
Applescript variables directly into the code block. For example, you
can delete

$usrnm = $argv[2];
$psswrd = $argv[3];
$phone = $argv[4];

from the first part of your php code, and replace

$gv = new GoogleVoice(\"$usrnm\", \"$psswrd\");

with

$gv = new GoogleVoice(\"" & usrnm & "\", \"" & psswrd & "\");

(As can be seen, these examples already display the necessary escaping
of double quotes.) In the second instance, we are simply substituting
your existing Applescript variables directly into the php code, rather
than making the php binary parse and interpret them. Now, with this
script the user won't know the difference, but for future
Applescripting that you do, it can come in handy as a time saver and
performance enhancer.

I hope these suggestions are helpful to you. If you could implement
the first two suggestions in order to make it easy for average users
to install, I would really like to add this script to the Applescripts
for Quicksilver page here on the group. Again, thanks for this helpful
script!

elspub

unread,
Sep 18, 2009, 3:02:53 AM9/18/09
to Blacktree: Quicksilver
Great suggestions, thanks. I've been teaching myself applescript and
javascript this summer and its always good to get knowledge. I was
trying to implement the php script in the applescript and couldn't and
now I know why (I didn't know about the need for all those special
characters.

I'll implement the changes and repost.

btw, the script also works great as a Snow Leopard service. Right
click on a phone number and have GV dial it.... gotta love the snow.


On Sep 18, 2:20 am, "Jon Stovell (a.k.a. Sesquipedalian)"

Jon Stovell (a.k.a. Sesquipedalian)

unread,
Sep 18, 2009, 3:30:41 AM9/18/09
to Blacktree: Quicksilver
Glad to help.

Also, I omitted a few important words of script code in my previous
post. The bits in suggestion one that read

if usrnm is null then set usrnm to (display dialog ...

should rather be

if usrnm is null then set usrnm to text returned of (display
dialog ...

elspub

unread,
Sep 20, 2009, 3:54:34 PM9/20/09
to Blacktree: Quicksilver
Hmmm. I'm having trouble implementing your suggestions.

As far as persistent properites goes, I'm wondering if QS uses
executeAndReturnError from the NSAppleScript class to run
applescripts. I found a discussion pointing out that this method does
not allow for persistent properties.

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSAppleScript_Class/Reference/Reference.html#//apple_ref/occ/instm/NSAppleScript/executeAndReturnError:

So I'm thinking that the script could create a text file in /tmp and
store the login properties there.

As far as getting the php script embedded in the applescript, that's
going to take someone who knows php. I tried to escape out from the
single and double quotes, and even tried variations of using extra
back-slashes, but I could not get it to work. I wonder if when a
method containing single quotes is called the quotes need to be triple
or extra escaped in someway....

Anyways I'm failing on both counts...

Any ideas?



On Sep 18, 2:20 am, "Jon Stovell (a.k.a. Sesquipedalian)"
<jonstov...@gmail.com> wrote:
> That's really cool. Thanks for this.
>
> Here are two suggestions to make it easier for users who aren't tech
> savvy:
>
> 1. Because Applescripts remember changes to their property values
> between executions, it is possible to query the user for necessary
> information the first time the script is run. It will only be
> necessary for the user to enter it once, and the data will be saved
> forever, unless the script is opened and recompiled.


Jon Stovell

unread,
Sep 20, 2009, 6:11:21 PM9/20/09
to blacktree-...@googlegroups.com
> As far as persistent properites goes, I'm wondering if QS uses > executeAndReturnError from the NSAppleScript class to run > applescripts. I found a discussion pointing out that this method does > not allow for persistent properties. > > http://developer.apple.com/documentation/Cocoa/Reference/Foundation/C... I think you may be right. In a discussion just a couple days ago in another thread here, this very problem was discovered and pointed out to me after I made a similar suggestion there. > So I'm thinking that the script could create a text file in /tmp and > store the login properties there. /tmp would not be a good place, because /tmp is emptied after every reboot. If the script is going to save the data in a file better storage location would be within ~/Library/Application Support/Quicksilver. 

However, it occurs to me that since account info and passwords are involved here, the proper place to store this info is in the user's keychain using keychain scripting. In the attached script I've included a handler to do so. > As far as getting the php script embedded in the applescript, that's > going to take someone who knows php. I tried to escape out from the > single and double quotes, and even tried variations of using extra > back-slashes, but I could not get it to work. I wonder if when a > method containing single quotes is called the quotes need to be triple > or extra escaped in someway.... Does this work? I can't test it because I don't have a Google voice account.
gvDialer2.scpt.zip

Jon Stovell (a.k.a. Sesquipedalian)

unread,
Sep 20, 2009, 6:35:00 PM9/20/09
to Blacktree: Quicksilver
Bleh, Google tossed the attached script in my previous post.
You can download it at http://files.me.com/jonstovell/o0w488

Joel Esler

unread,
Sep 21, 2009, 6:27:55 AM9/21/09
to blacktree-...@googlegroups.com
I don't know Jon,

I got the attachment!

J

elspub

unread,
Sep 21, 2009, 2:59:57 PM9/21/09
to Blacktree: Quicksilver
It doesn't work. Returns this error:
"error "System Events got an error: PHP Parse error: syntax error,
unexpected '@' in Command line code on line 1
sh: line 1: =: command not found
sh: line 2: =: command not found
sh: line 3: class: command not found
sh: -c: line 9: syntax error near unexpected token `('
sh: -c: line 9: `public function __construct($username, $password)'"
number 2"

Also, the parsenum function needed the line "return i" at the end.

I tried some variations on what you did and had no luck. But if we're
just concerned about ease of installation, this might not be
necessary. At this point installation no longer requires manually
entering login info in the script. In terms of installing the php
script, the tr.im link below should download two versions of the
action. gvDialer requires that you manually install the php script to
~/Library/App Support/Quicksilver; which really is what is required to
install the action anyway. gvDialer_alt checks to see if the script
exists, if not, it uses curl to download the script direct to the same
location.

Both work fine. I've also set up growl notifications.

http://tr.im/zgrH

Jon Stovell (a.k.a. Sesquipedalian)

unread,
Sep 22, 2009, 2:04:24 PM9/22/09
to Blacktree: Quicksilver
I've emailed you with a few suggestions to simplify the code, but
using curl to automatically download the php file is brilliant.

elspub

unread,
Sep 22, 2009, 5:13:35 PM9/22/09
to Blacktree: Quicksilver
More great tips. I'm learning a bunch of applescript. Thanks.

There were a few small bugs, I fixed as well as deleted much of the
comments. I think these actions are good to go.
The following link contains the gvDialer action, the SMSgv action, as
well as a Snow Leopard Service of the gvDialer (great for using with
Address Book. Just right click and dial...)

Requires Growl

[URL=http://www.zshare.net/download/65973283d3043733/]gvDialer1.0.zip
- 0.19MB[/URL]



On Sep 22, 2:04 pm, "Jon Stovell (a.k.a. Sesquipedalian)"

elspub

unread,
Sep 23, 2009, 3:58:23 PM9/23/09
to Blacktree: Quicksilver
I'm reposting up here now that these actions are updated.

The following link contains two actions:
gvDialer and SMSgv action, which send phone numbers (either entered
manually in the text entry field, or from the address book) to Google
Voice, and dial a phone call or send a text message, respectively.

There's also a Snow Leopard Service of the gvDialer (great for using
with Address Book. Just right click and dial...)

Requires Growl


http://www.zshare.net/download/65973283d3043733/

bikubay

unread,
Sep 23, 2009, 4:50:27 PM9/23/09
to Blacktree: Quicksilver
I accidentally entered the wrong number in the initial setup. How do I
'uninstall' the PHP script so that I can reset the Dial-OUT number?
thanks

On Sep 23, 3:58 pm, elspub <els...@gmail.com> wrote:
> I'm reposting up here now that these actions are updated.
>
> The following link contains two actions:
>  gvDialer and SMSgv action, which send phone numbers (either entered
> manually in the text entry field, or from the address book) toGoogleVoice, and dial a phone call or send a text message, respectively.

elspub

unread,
Sep 24, 2009, 1:57:52 PM9/24/09
to Blacktree: Quicksilver
Open Keychain Access (via QS or its in Applications/Utlities).
Find the entry called "Google Voice for Quicksilver".
Delete that.
The next time you run of one of the gv Actions it will ask you to
input your login info again.

RJWalkerz

unread,
Oct 14, 2009, 10:20:57 AM10/14/09
to Blacktree: Quicksilver
elspub,

I was so excited to find this. Thank you for putting something like
this together. I have installed it, it asked for all the appropriate
information when i ran it, growl even said it was dialing... but it
doesnt seem to place the call. At some point should it ask me for a
number to call ME first, before it dials my contact?
It does send SMS fine, but I just cant make a call. Is there
something in the install I might have missed?

Thanks for any help at all.

(p.s. I can send you a screen shot of my installed files if
necessary)

RJW

elspub

unread,
Oct 15, 2009, 2:24:37 PM10/15/09
to Blacktree: Quicksilver
Not necessary. Someone else recently had the same problem. They
emailed me back with one word after I suggested a few things:
"Fixed!". So I'm not sure which one is the issue, but I am almost
positive it is one, very simple thing:

The dialog that runs when setting up the keychain that holds your
login info asks you to input your username, password, and "Google
Voice Number", I realize that that wording is sort of wrong. It should
be asking for the the "Phone number you would like Google Voice to
reach you at to initiate the call". You should be entering a 10 digit
phone number here (no need for dashes, parenthesis, or other
formatting). That phone number is not the number Google gave you when
you signed up for a GV acct, but the number of the physical phone you
want to use.

I've updated the Actions' wording. It can be downloaded here:
http://tr.im/BUn0

But you can probably use your existing actions.

What you MUST do is open keychain access, find the entry named "Google
Voice Dialer for Quicksilver" and delete it. The next time the action
runs it will remake the entry allowing you to enter the correct phone
number.

If that's the answer, or not, let me know. I'd like more specific
confirmation than the last time.

Good luck.

AgentEd

unread,
Dec 12, 2009, 12:31:46 AM12/12/09
to Blacktree: Quicksilver
I'm confused.

1. There is no "Actions" folder in the Quicksilver folder as per the
installation documentation. Do I need to create it?
2. There is no "services" folder to install the GVDialer services as
per the documentation.
3. There is no documentation on how to install the php file.

On Oct 15, 11:24 am, elspub <els...@gmail.com> wrote:
> Not necessary. Someone else recently had the same problem. They
> emailed me back with one word after I suggested a few things:
> "Fixed!". So I'm not sure which one is the issue, but I am almost
> positive it is one, very simple thing:
>
> The dialog that runs when setting up the keychain that holds your
> login info asks you to input your username, password, and "GoogleVoiceNumber", I realize that that wording is sort of wrong. It should
> be asking for the the "Phone  number you would like GoogleVoiceto
> reach you at to initiate the call". You should be entering a 10 digit
> phone number here (no need for dashes, parenthesis, or other
> formatting). That phone number is not the number Google gave you when
> you signed up for a GV acct, but the number of the physical phone you
> want to use.
>
> I've updated the Actions' wording. It can be downloaded here:http://tr.im/BUn0
>
> But you can probably use your existing actions.
>
> What you MUST do is open keychain access, find the entry named "GoogleVoiceDialer for Quicksilver" and delete it. The next time the action

Joe R

unread,
Dec 14, 2009, 1:18:36 AM12/14/09
to Blacktree: Quicksilver
@AgentEd:
1. Yes you have to create the "Actions" folder
Once you create the actions folder drag both the apps into it and
restart quicksilver and make sure that they have been detected by the
app as actions. Then launch it and it will prompt you to have it move
the php file into the correct folder for you. Hope this helps,
Joe


btw thanks for creating this! Its amazing!
Joe

On Dec 11, 11:31 pm, AgentEd <agen...@gmail.com> wrote:
> I'm confused.
>
> 1. There is no "Actions" folder in the Quicksilver folder as per the
> installation documentation. Do I need to create it?
> 2. There is no "services" folder to install the GVDialer services as
> per the documentation.
> 3. There is no documentation on how to install the php file.
>
> On Oct 15, 11:24 am, elspub <els...@gmail.com> wrote:
>
>
>
> > Not necessary. Someone else recently had the same problem. They
> > emailed me back with one word after I suggested a few things:
> > "Fixed!". So I'm not sure which one is the issue, but I am almost
> > positive it is one, very simple thing:
>
> > The dialog that runs when setting up the keychain that holds your
> > login info asks you to input your username, password, and "GoogleVoiceNumber", I realize that that wording is sort of wrong. It should
> > be asking for the the "Phone  number you would like GoogleVoiceto
> > reach you at to initiate the call". You should be entering a 10 digit
> > phone number here (no need for dashes, parenthesis, or other
> > formatting). That phone number is not the numberGooglegave you when

D. Archibald Smart

unread,
Dec 20, 2009, 8:57:54 PM12/20/09
to Blacktree: Quicksilver
Yeah, I'm in the same boat. Growl says its dialing, but my phone never
rings. Any idea whats going on?
Reply all
Reply to author
Forward
0 new messages