Quantcast
Channel: Mouse-click without moving cursor? - Stack Overflow
Viewing all articles
Browse latest Browse all 10

Answer by Midas Cwb for Mouse-click without moving cursor?

$
0
0

I needed something similar, and the solution I found was this:

import win32guiimport win32apiimport win32condef control_click(x, y, handle, button='left'):    l_param = win32api.MAKELONG(x, y)    if button == 'left':        win32gui.PostMessage(handle, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, l_param)        win32gui.PostMessage(handle, win32con.WM_LBUTTONUP, win32con.MK_LBUTTON, l_param)    elif button == 'right':        win32gui.PostMessage(handle, win32con.WM_RBUTTONDOWN, 0, l_param)        win32gui.PostMessage(handle, win32con.WM_RBUTTONUP, 0, l_param)

The window does not need to be in the foreground, but it cannot be minimized, the handle and coordinates must be from the control, example: in a notepad, the handle and coordinates are for the 'Edit1' control, not for the window, if the application has no controls visible through a spytool, you can use the handle and the window coordinates, example: the pycharm itself.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images