recording input from USB port and write to text file

A

Allan

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!
 
D

Diez B. Roggisch

Allan said:
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 as easy as you think. And dependend on your operating-system.

Diez
 
P

Piet van Oostrum

Allan said:
A> Hi! I'm fairly new to Python. I understand the basics basics but I'm
A> been trying to write a simple python code that will let me read input
A> data (such as mouse movement) from my USB port and write it in a text
A> file and I am so lost. Can anyone help or direct me to some
A> resources? Thank you!

You could try http://sourceforge.net/projects/pyusb/
 
S

Simon Forman

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.
 
D

Diez B. Roggisch

Simon said:
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/...sta-it-s-not-nearly-as-easy-as-you-think.aspx

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top