| | |
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: 150
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 |
accessdenied advanced apache application argv array beginner book change command converter countpasswordentry csv curved dan08 def dictionary dynamic edit enter event examples file float format function google gui homework import inches input jaunty java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric obexftp output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pygtk pyopengl python random recursion redirect remote return reverse scrolledtext session simple skinning software sprite statictext string strings syntax terminal text threading time tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable voip wordgame wxpython





