大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import SendMessage [as 别名]
def click(self, coords, button=”left”,hold=False):
“””
Args:
coords (touple): coords takes two arguments, either both float
or int. If float is supplied, it will try to treat them as
percentages. X, Y
button (string): either “left”,”right” or “middle”. Decides what button that
will be sent to the running program.
Returns:
bool: True if successful, False otherwise.
Raises:
SyntaxError: The button param does not contain “left”,”right og “middle”
“””
hwnd = self.win_handler.get_hwnd()
if all(isinstance(elem, float) for elem in coords):
coords = self.to_pixel(coords)
logging.debug(“Trying to click on:” + str(coords) + ” with ” + button + ” button”)
x = coords[0]
y = coords[1]
if “right” in button.lower():
_button_state = win32con.MK_RBUTTON
_button_down = win32con.WM_RBUTTONDOWN
_button_up = win32con.WM_RBUTTONUP
elif “left” in button.lower():
_button_state = win32con.MK_LBUTTON
_button_down = win32con.WM_LBUTTONDOWN
_button_up = win32con.WM_LBUTTONUP
elif “middle” in button.lower():
_button_state = win32con.MK_MBUTTON
_button_down = win32con.WM_MBUTTONDOWN
_button_up = win32con.WM_MBUTTONUP
else:
raise SyntaxError(‘”Button” needs to contain “left”, “right” or “middle”‘)
l_param = win32api.MAKELONG(x, y)
win32api.SendMessage(hwnd, win32con.WM_MOUSEMOVE,0,l_param)
time.sleep(0.2)
win32api.SendMessage(hwnd,_button_down, _button_state, l_param)
time.sleep(0.1)
if not hold: #Do not release the button if hold is true
win32api.SendMessage(hwnd, _button_up, 0, l_param)
self._last_x = x
self._last_y = y
return True
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/183453.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...