| | |
Simulating a mouseclick?
![]() |
•
•
Join Date: May 2008
Posts: 39
Reputation:
Solved Threads: 7
I found a very neat sample of doing this:
It may be long, but it is one of the few examples I have seen that work with little hassle in Python.
For your second question, I'd probably bind with gui. Follow the example here but it doesn't have to be right click:
http://www.daniweb.com/forums/post598858.html
Python Syntax (Toggle Plain Text)
from ctypes import * import time, curses, win32con, win32gui PUL = POINTER(c_ulong) class KeyBdInput(Structure): _fields_ = [("wVk", c_ushort), ("wScan", c_ushort), ("dwFlags", c_ulong), ("time", c_ulong), ("dwExtraInfo", PUL)] class HardwareInput(Structure): _fields_ = [("uMsg", c_ulong), ("wParamL", c_short), ("wParamH", c_ushort)] class MouseInput(Structure): _fields_ = [("dx", c_long), ("dy", c_long), ("mouseData", c_ulong), ("dwFlags", c_ulong), ("time",c_ulong), ("dwExtraInfo", PUL)] class Input_I(Union): _fields_ = [("ki", KeyBdInput), ("mi", MouseInput), ("hi", HardwareInput)] class Input(Structure): _fields_ = [("type", c_ulong), ("ii", Input_I)] class POINT(Structure): _fields_ = [("x", c_ulong), ("y", c_ulong)] def click(x,y): orig = POINT() windll.user32.GetCursorPos(byref(orig)) windll.user32.SetCursorPos(x,y) FInputs = Input * 2 extra = c_ulong(0) ii_ = Input_I() ii_.mi = MouseInput( 0, 0, 0, 2, 0, pointer(extra) ) ii2_ = Input_I() ii2_.mi = MouseInput( 0, 0, 0, 4, 0, pointer(extra) ) x = FInputs( ( 0, ii_ ), ( 0, ii2_ ) ) windll.user32.SendInput(2, pointer(x), sizeof(x[0])) return orig.x, orig.y click(150, 150)
It may be long, but it is one of the few examples I have seen that work with little hassle in Python.
For your second question, I'd probably bind with gui. Follow the example here but it doesn't have to be right click:
http://www.daniweb.com/forums/post598858.html
•
•
Join Date: Jul 2006
Posts: 608
Reputation:
Solved Threads: 149
If you're talking about mouse clicks in Tkinter, then you will want to check out the manual:
http://infohost.nmt.edu/tcc/help/pub...er/tkinter.pdf
OR in HTML format
http://infohost.nmt.edu/tcc/help/pubs/tkinter/
http://www.pythonware.com/library/index.htm
To get mouse clicks, check out the Bind method at the end of the manual. To handle file dialogs, check out the tkFileDialog module.
Hope that helps,
Jeff
http://infohost.nmt.edu/tcc/help/pub...er/tkinter.pdf
OR in HTML format
http://infohost.nmt.edu/tcc/help/pubs/tkinter/
http://www.pythonware.com/library/index.htm
To get mouse clicks, check out the Bind method at the end of the manual. To handle file dialogs, check out the tkFileDialog module.
Hope that helps,
Jeff
![]() |
Other Threads in the Python Forum
- Previous Thread: Chinese Strings in Python
- Next Thread: Adding tabs from plugins
| Thread Tools | Search this Thread |
alarm ansi anydbm app assignment backend beginner binary bluetooth character cipher cmd coordinates customdialog cx-freeze data decimals development directory dynamic exe feet file float format function generator getvalue gnu graphics halp handling heads homework http ideas input ip itunes java keycontrol leftmouse line linux list lists loop maintain maze millimeter module mouse number numbers output parsing path pointer prime programming progressbar push py2exe pygame pymailer python queue random recursion recursive schedule screensaverloopinactive script slicenotation sqlite ssh statistics string strings sudokusolver text thread time tlapse tuple ubuntu unicode url urllib urllib2 variable ventrilo vigenere web webservice wikipedia write wxpython xlib xlwt





