asked for favourite scripts. Here's one of mine. Its to quickly add
an item to a groceries.txt file:
retCode, gitem = dialog.input_dialog("Add to groceries", "What would
you like to pick up at the grocery store?")
output = system.exec_command("date '+ - %a %b %d '")
gitem2 = "\n" + gitem
fileHandle = open ( '/home/david/Dropbox/groceries.txt', 'a' )
fileHandle.write (gitem2)
fileHandle.write (output)
fileHandle.close()
and I use this to open the file:
keyboard.send_key("<escape>")
import subprocess
subprocess.call(['xdg-open', '/home/david/Dropbox/groceries.txt'])
simple, but effective. :-)
http://code.google.com/apis/calendar/data/1.0/developers_guide_python.html#CreatingQuickAdd
You have to download the Python client library, then put this into a
script (just change the username and password)
retCode, date = dialog.calendar(title="Choose a date", format="%Y-%m-
%d", date="today")
#retCode, seedate = dialog.input_dialog(title="here's the date",
message="", default=(getdate))
retCode, time = dialog.input_dialog("what time?", "starting at what
time?")
retCode, event1 = dialog.input_dialog("the event?", "what's the
event?")
event2 = event1 + " " + date + " " + time
#retCode, seedate = dialog.input_dialog(title="here's the event",
message="", default=(event2))
#everything from here down is from:
#http://code.google.com/apis/calendar/data/1.0/
developers_guide_python.html#CreatingQuickAdd
try:
from xml.etree import ElementTree # for Python 2.5 users
except ImportError:
from elementtree import ElementTree
import gdata.calendar.service
import gdata.service
import atom.service
import gdata.calendar
import atom
import getopt
import sys
import string
import time
calendar_service = gdata.calendar.service.CalendarService()
# your info goes here
calendar_service.email = 'user...@gmail.com'
calendar_service.password = 'password'
calendar_service.source = 'Google-Calendar_Python_Sample-1.0'
calendar_service.ProgrammaticLogin()
event = gdata.calendar.CalendarEventEntry()
event.content = atom.Content(text=(event2))
event.quick_add = gdata.calendar.QuickAdd(value='true')
# Send the request and receive the response:
new_event = calendar_service.InsertEvent(event, '/calendar/feeds/
default/private/full')
That's it. I just made it, and it works for me, hope it works for you
too.
Dave P
On Mar 21, 10:49 pm, cedardoc <cedardocs...@gmail.com> wrote:
> This closed thread:
>
> http://groups.google.com/group/autokey-users/browse_thread/thread/ed0...
On Mar 28, 9:30 pm, cedardoc <cedardocs...@gmail.com> wrote:
> Here's a good one that lets you use google calendar quick add to make
> an appointment in your appointment book without having to open your
> calendar or even your browser directly. It uses the google calendar
> API found here:
>
> http://code.google.com/apis/calendar/data/1.0/developers_guide_python...
> calendar_service.email = 'usern...@gmail.com'
--- code ---
retCode, date = dialog.calendar(title="Choose a date",
format="%Y-%m-%d", date="today")
if retCode == 0:
retCode, time = dialog.input_dialog("what time?", "starting at what time?")
if retCode == 0:
retCode, event1 = dialog.input_dialog("the event?", "what's the event?")
if retCode == 0:
event2 = event1 + " " + date + " " + time
try:
from xml.etree import ElementTree # for Python 2.5 users
except ImportError:
from elementtree import ElementTree
import gdata.calendar.service, gdata.service, atom.service, gdata.calendar
import atom, getopt, sys, string, time
calendar_service = gdata.calendar.service.CalendarService()
# your info goes here
calendar_service.email = 'user...@gmail.com'
calendar_service.password = 'password'
calendar_service.source = 'Google-Calendar_Python_Sample-1.0'
calendar_service.ProgrammaticLogin()
event = gdata.calendar.CalendarEventEntry()
event.content = atom.Content(text=(event2))
event.quick_add = gdata.calendar.QuickAdd(value='true')
# Send the request and receive the response:
new_event = calendar_service.InsertEvent(event,
'/calendar/feeds/default/private/full')
--- code ---
You have a lot of unused imports there as well... your script will run
quicker (at least the first time) if you get rid of the unused
imports.
> To unsubscribe from this group, send email to autokey-users+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
>
Regarding the unused imports, as I'm just a "cut, paste and cross your
fingers" kind of person, I'm not sure how to tell which imports are
used and which are not.
It doesn't seem safe to assume that if the word after "import" (e.g.
"getopt") doesn't occur in the code after the import, that's the way
to tell you can delete it because I commented out all imports that
didn't follow and now it doesn't work. These were:
#import gdata.service
#import atom.service
#import atom
#import getopt
#import sys
#import string
#import time
Is the way that you know just your experience using python etc, or is
there a simpler way to know this?
By the way, thank you for this software - its nice to be able to come
over to Linux. I was one of those resisting only due to the lack of
AHK.
Dave
That is in fact exactly how it works in Python - if it is not directly
referenced in the code then you don't need the import statement. You
must have accidentally commented out one that is being used. Have a
look at the 'view script error' menu option to see what is causing the
exception.