2

I have to make a application, that do the followings:

  • disable that the given usb mouse move the pointer in the screen (just the given, not all mouses).
  • get the coordinates of the mouse pointer
  • change the y coordinate of the mouse pointer

I've tried out pyusb, but i've never found any examples for any of the 3 problems.
Any ideas?

JMax
  • 26,109
  • 12
  • 69
  • 88
bikmak
  • 147
  • 1
  • 1
  • 7
  • 2
    You should at least specify what operating system it is (I guess Linux, but you should tell us) and what environment (I guess Xorg, but you should tell). – Luke404 Sep 22 '11 at 12:45

1 Answers1

1

I don't know enough pyusb but you can deal with the second issue with Tkinter (one of the most used GUI with Python). Here is a sample of code (found here):

# show mouse position as mouse is moved and create a hot spot

import Tkinter as tk

root = tk.Tk()

def showxy(event):
    xm = event.x
    ym = event.y
    str1 = "mouse at x=%d  y=%d" % (xm, ym)
    root.title(str1)
    # switch color to red if mouse enters a set location range
    x = 100
    y = 100
    delta = 10  # range
    if abs(xm - x) < delta and abs(ym - y) < delta:
        frame.config(bg='red')
    else:
        frame.config(bg='yellow')


frame = tk.Frame(root, bg= 'yellow', width=300, height=200)
frame.bind("<Motion>", showxy)
frame.pack()

root.mainloop()

Yet, it seems like you cannot change the cursor position with Tkinter only (see this thread for some workarounds). But if you are trying to set position within a text, you can use a widget as described in this SO thread: Set cursor position in a Text widget.

To disable mouse, you could have a look at this post and adapt the code to disable mouse instead of touchpad (but the post gives some interesting keys to begin with).

Community
  • 1
  • 1
JMax
  • 26,109
  • 12
  • 69
  • 88