Showing the past five entries...

September 2, 2008

I'm a Chicken, See?

00263.jpg
View in Photoblog
CameraCanon PowerShot G9
Lens (35mm Equiv.)Canon 7.4-44.4mm f/2.8-4.8 IS (30mm)
Exp. Prog. / Shutter @ ApertureAperture Priority / 1/60sec @ f/3.5
Metering w/Adj. @ ISOEvaluative w/0.0 EV (Flash -1 EV) @ ISO 400

Mom and I stopped by the poultry barn at the Minnesota State Fair. This one looks like he's smoking a Lucky Strike.

Isn't it interesting how chickens can looks so intensely emotional and intelligent in one moment and then so completely vapid in the next?

 

Posted by jordanh at 12:01 AM | Comments (0) | TrackBack (0)

August 11, 2008

Standing Rigging

00262.jpg
View in Photoblog
CameraCanon PowerShot G9
Lens (35mm Equiv.)Canon 7.4-44.4mm f/2.8-4.8 IS (30mm)
Exp. Prog. / Shutter @ ApertureAperture Priority / 1/160sec @ f/4.5
Metering w/Adj. @ ISOEvaluative w/-0.7 EV @ ISO 100

Standing rigging on a 33' Hunter. We chartered this boat this past weekend in the Apostle Islands. We set sail from Pike's Bay to Sand Island, around Raspberry Island to Oak Island and back to Pike's Bay.

The winds were light. The sky was very blue.

 

Posted by jordanh at 10:54 AM | Comments (0) | TrackBack (0)

July 22, 2008

I Hope He'll Win

00261.jpg
View in Photoblog
CameraCanon Powershot G9
LensCanon 7.4-44.4mm f/2.8-4.8 IS
Exp. Prog. / Shutter @ ApertureAuto exposure / 1/50 1/160 s @ f/4.5
Metering w/Adj. @ ISOPattern w/+0.0 EV @ 200

Taken off the hip while walking in East Williamsburg, Brooklyn, New York.

 

Posted by jordanh at 11:22 AM | Comments (0) | TrackBack (0)

July 3, 2008

Brooklyn Breakfast Mascot

00260.jpg
View in Photoblog
CameraCanon Powershot G9
LensCanon 7.4-44.4mm f/2.8-4.8 IS
Exp. Prog. / Shutter @ ApertureAuto exposure / 1/50 1/500 s @ f/4.5
Metering w/Adj. @ ISOPattern w/+0.0 EV @ 100

Taken outside of a breakfast joint in Brooklyn, NY.

 

Posted by jordanh at 4:25 PM | Comments (0) | TrackBack (0)

April 21, 2008

Python Rosetta Stone Automation

Many, many months ago I had a long, long layover in the airport in Madrid. On the flight over from the States I had grown increasingly frustrated with the interface to "The Rosetta Stone" language learning software. Now I must confess, there actually is little to get wrong in this interface as the majority of the interaction with the software is done via clicking one of four buttons. However, I come from the UNIX world where I prefer everything to be able to be driven from a set of keyboard shortcuts and so I committed my layover to automating The Rosetta Stone.

Tonight I find myself writing from yet another long, long layover and I find myself revisiting The Rosetta Stone to brush up on my Spanish. I remembered my little application I wrote in Spain and so I made a few tweaks and decided to share it, just in case anybody should find it useful.

If anything, it demonstrates two concepts:

  • The bizarre Windows goop one must wade through in order to automate a Windows application with no known automation interface.
  • The power and expressiveness of well-abstracted code written in Python.

Here is the entire application. It is less than 50 meaningful lines of code:

import os
import sys
import time
from msvcrt import getch

sys.path.append("../win32automation")

import win32automation

os.system("title KeySetta")
win32automation.spawnProcess(
    r"C:\Program Files\The Rosetta Stone\The Rosetta Stone\TheRosettaStone.exe")
while 1:
    print "Waiting for application to start..."
    result = win32automation.windowFocus("The Rosetta Stone")
    if result:
        print "Window found!"
        break
    time.sleep(1.0)
print "Waiting 5 seconds for login screen to appear..."
time.sleep(5.0)
win32automation.sendKeys('jordanh{ENTER}')

print """
   Keyboard to Mouse Macros Enabled:

     - Answer selection:
       [7] [9]
       [1] [3]
       
    Please focus this window to enable them...
"""

coord_map = {"7": (180, 300),
             "9": (480, 300),
             "1": (180, 475),
             "3": (480, 475)}

while 1:
    win32automation.windowFocus("KeySetta")
    ch = getch()
    print "Last key pressed: %s\r" % (ch),
    if ch in ('1','3','7','9'):
        win32automation.windowFocus("The Rosetta Stone")
        x, y = coord_map[ch]
        win32automation.mouseMoveToRelative("The Rosetta Stone", x, y)
        win32automation.mouseClick(button="left")
    elif ch.lower() == 'q':
        print "Quitting!"
        break
    else:
        print "WARNING: Unknown key-macro event '%c'." % (ch)

sys.exit()

Granted the silly "win32automation" module I wrote is a little stupid. It is based on the excellent example provided over at http://del.icio.us/amoebapr/python. Notice for example none of the functions take an opaque handle to an object. Instead, all of the functions inside of the module require some sort of hint (such as a window title) in order to re-find the desired object before executing an operation on it.

Hopefully however sharing this code will spark somebody to develop a better, free Windows automation module for Python.

Download keysetta.zip (md5sum: a4336d883fcb10b11b8b660451e522a3)

Posted by jordanh at 11:30 PM | Comments (0) | TrackBack (0)