This holiday has played a lot of galgame, but some very old game does not automatically run mode, click the mouse and too hurt the button, so want to roll the mouse wheel map to click the mouse.
Online search, did not find any off-the-shelf software, and the key wizard is too heavy, so consider simply using Python to write a forget.
Very lucky to find the "with Python monitor mouse and keyboard events" This article, so the Pyhook and PyWin32 are installed (recommended under EXE version, lest the installation of all kinds of egg pain).
Turned over the tutorial, found very simple:
#-*-Coding:utf-8-*-
import pythoncom, Pyhook
def onmouseevent (event):
print ' MessageName: ', event. MessageName
print ' message: ', event. Message
print ' time: ', event. Time
print ' Window: ', event. Window
print ' windowname: ', event. Windowname
print ' Position: ', event. Position
print ' Wheel: ', event. Wheel
print ' injected: ', event. Injected
print '---
# returns True to pass an event to another handler, otherwise stop propagate event return
true
# Create Hook management object
HM = Pyhook.hookmanager ()
# listens for all mouse events
hm. Mouseall = onmouseevent # is equivalent to HM. Subscribemouseall (Onmouseevent)
# begins to monitor mouse events
hm. Hookmouse ()
# listens until manually exiting the program
pythoncom. Pumpmessages ()
This example program captures all the mouse events, and in fact I just need to catch the events that scroll down the wheel. Turn over the document, corresponding to the MouseWheel, and then just judge the event. Whether the wheel is-1 can be.
The last is to trigger the mouse click, which will need to use the win32api.mouse_event (), send a press the left mouse button event, and then send the bounce event, the completion of a click.
The final code is as follows:
#-*-Coding:utf-8-*-
import pythoncom import pyhook import time
import win32api
import win32con< C5/>def OnMouseWheel (Event):
if event. Wheel = =-1:
win32api.mouse_event (Win32con. Mouseeventf_leftdown, 0, 0)
time.sleep (0.05)
win32api.mouse_event (Win32con. Mouseeventf_leftup, 0, 0) return
True
HM = Pyhook.hookmanager ()
hm. MouseWheel = OnMouseWheel
hm. Hookmouse ()
pythoncom. Pumpmessages ()