how to get a script to invoke an abbreviation

405 views
Skip to first unread message

cedardoc

unread,
May 23, 2010, 4:07:39 PM5/23/10
to autokey-users
Good afternoon,

I'm trying to make a script open a terminal and type in the following:

curl -u gmailname --silent "https://mail.google.com/mail/feed/atom" |
perl -ne 'print "\t" if //; print "$2\n" if /<(title)>(.*)<\/\1>/;'

(its a thing that fetches the titles of your most recent gmails)

but when I use this: keyboard.send_keys("clgs ")
in the script (clgs is the abbreviation trigger) it doesn't expand
out.

Initially I tried to put the whole "curl..." thing in
"keyboard.send_keys("curl... "), but with all the quotes in there
already I couldn't get that to be rendered by the script. I tried
using single quotes and two double quotes and square brackets, but to
no avail...

Can someone help me out with either approach to getting this to work?


Thanks, and don't forget the final episode of Lost (if you're into
that sort of thing) ;-)
Dave

Christiaan Dekter

unread,
May 23, 2010, 8:44:15 PM5/23/10
to autoke...@googlegroups.com
You can't trigger an abbreviation by typing it using a script - this is a deliberate design decision to avoid infinite recursive abbreviations from accidental miss-configuration.

The easiest way to escape that string would be to triple-quote it, like so:


"""curl -u gmailname --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if //; print "$2\n" if /<(title)>(.*)<\/\1>/;'"""


cedardoc

unread,
May 23, 2010, 11:05:53 PM5/23/10
to autokey-users
thank you - that worked.

On May 23, 6:44 pm, Christiaan Dekter <cdek...@gmail.com> wrote:
> You can't trigger an abbreviation by typing it using a script - this is a
> deliberate design decision to avoid infinite recursive abbreviations from
> accidental miss-configuration.
>
> The easiest way to escape that string would be to triple-quote it, like so:
>
> """curl -u gmailname --silent
> "https://mail.google.com/mail/feed/atom<feed/atom>"
> | perl -ne 'print "\t" if //; print "$2\n" if /<(title)>(.*)<\/\1>/;'"""
>

cedardoc

unread,
May 25, 2010, 12:39:19 AM5/25/10
to autokey-users
One final note - it actually didn't work until I added an extra
backslash for every one in the original - I guess in Autokey the
backslash is some sort of escape thingie. Anyway, for those who are
interested, here's the final script that works - its handy for
checking just the titles of emails really quickly.

If anyone can figure out how to get it to write the list out to a file
instead of print it, I think that would be even more valuable.

if window.wait_for_exist(".*david@linux.*", timeOut=.5):
window.activate("david@linux", switchDesktop=False)
keyboard.send_keys("clear<enter>")
keyboard.send_keys("""curl -u accountname --silent "https://
mail.google.com/mail/feed/atom" | perl -ne 'print "\\t" if //; print
"$2\\n" if /<(title)>(.*)<\/\\1>/;'""")
keyboard.send_key("<enter>")
keyboard.send_keys("accountpassword<enter>")
else:
system.exec_command("gnome-terminal", False)
time.sleep(0.5)
keyboard.send_keys("""curl -u accountname --silent "https://
mail.google.com/mail/feed/atom" | perl -ne 'print "\\t" if //; print
"$2\\n" if /<(title)>(.*)<\/\\1>/;'""")
keyboard.send_key("<enter>")
keyboard.send_keys("accountpassword<enter>")

cedardoc

unread,
May 25, 2010, 12:47:28 AM5/25/10
to autokey-users
ps, if it sometimes doesn't work for you, throw in a

time.sleep(0.5)

before the part where you enter the password


Dave
(ref for searches: "favourite scripts")
Reply all
Reply to author
Forward
0 new messages