Python script to control mouse clicks Python script to control mouse clicks tkinter tkinter

Python script to control mouse clicks


I don't think with win32api you can listen to clicks you can just generate them (not sure though). However, try using pyHook, it's a simple api easy to use and can be found here http://sourceforge.net/apps/mediawiki/pyhook/index.php?title=Main_Page. With pyhook you can create a listener to listen to a mouse event and upon a mouse click you can do whatever you want, the example in the link shows you how. As for key press, you can use the same api for that too, also an example is provided, good luck!


use pynput . It can control mouse, keyboard, etc.

examples:

from pynput.mouse import Button, Controllermouse = Controller()# Read pointer positionprint('The current pointer position is {0}'.format(    mouse.position))# Set pointer positionmouse.position = (10, 20)print('Now we have moved it to {0}'.format(    mouse.position))# Move pointer relative to current positionmouse.move(5, -5)# Press and releasemouse.press(Button.left)mouse.release(Button.left)# Double click; this is different from pressing and releasing# twice on Mac OSXmouse.click(Button.left, 2)# Scroll two steps downmouse.scroll(0, 2)