recording input from USB port and write to text file

Diez B. Roggisch deets at nospam.web.de
Wed Aug 19 23:16:32 CEST 2009


Diez B. Roggisch schrieb:
> Simon Forman schrieb:
>> On Aug 18, 7:33 pm, Allan <af2... at gmail.com> wrote:
>>> Hi! I'm fairly new to Python.  I understand the basics basics but I'm
>>> been trying to write a simple python code that will let me read input
>>> data (such as mouse movement) from my USB port and write it in a text
>>> file and I am so lost.  Can anyone help or direct me to some
>>> resources?  Thank you!
>>
>> This isn't exactly what you were looking for, but maybe it will give
>> you some ideas:
>>
>>
>> from Tkinter import *
>>
>> def printMotionEvents(event):
>>     print "mouse coords: %i x %i" % (event.x, event.y)
>>
>> t = Tk()
>> t.bind('<Motion>', printMotionEvents)
>> t.mainloop()
>>
>>
>> This script creates a little Tkinter window and then makes it so that
>> when you move the mouse over the window the mouse coordinates are
>> printed to stdout.
> 
> If it has focus.
> 
> The overall problem is hard - see e.g. this:
> 
> http://www.wintellect.com/CS/blogs/jrobbins/archive/2008/08/30/so-you-want-to-set-a-windows-journal-recording-hook-on-vista-it-s-not-nearly-as-easy-as-you-think.aspx 

But then, there is a solution :)

http://pypi.python.org/pypi/pyHook/1.4/

Diez



More information about the Python-list mailing list