python win32api sendmessage_Python win32api.SendMessage方法代码示例[通俗易懂]

python win32api sendmessage_Python win32api.SendMessage方法代码示例[通俗易懂]#需要导入模块:importwin32api[as别名]#或者:fromwin32apiimportSendMessage[as别名]defclick(self,coords,button=”left”,hold=False):”””Args:coords(touple):coordstakestwoarguments,eitherbothfloato…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/183453.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Git提交代码步骤

    Git提交代码步骤目录1.Git提交代码步骤1.1第1步:查看当前状态:gitstatus1.2第2步:提交代码到本地git缓存区:gitadd1.3第3步:推送代码到本地git库:gitcommit1.4第4步:合并远程与本地代码:gitpull1.5第5步:提交本地代码到远程仓库:gitpush1.Git提交代码步骤1.1第1步:查看当前状态:gitstatus提交代码第1步:gitstatus查看当前状态当你忘记修改了哪些文件的时候可以使用git..

    2022年6月23日
    43
  • 谷歌浏览器中kindeditor编译器字体不能为微软雅黑的问题?

    谷歌浏览器中kindeditor编译器字体不能为微软雅黑的问题?

    2021年10月22日
    58
  • pcep协议什么意思_什么是SDN「建议收藏」

    pcep协议什么意思_什么是SDN「建议收藏」传统网络设备部署模式来说,基于整个网络状态的决策都要由每台网络设备独立承担,如果执行控制平面功能的模块的处理能力达到了设备极限,即便数据平面带宽仍有富余,也可能会出现瓶颈。此外,如果控制平面决策进程涉及多个节点的信息,如RSVP(ResourceReservationProtocol,资源预留协议)应用场景,那么就需要在节点之间执行额外的通信操作以收集相关信息,进而给设备带来不必要的开销负担。…

    2025年9月28日
    1
  • 红模仿在说谁(评价红模仿)

    各位读者,知识无穷而人力有穷,所以,要么改需求,要么找专业人士,要么自己研究。大家可以点赞、收藏、关注、评论我啦、需要完整文件随时联系我或交流哟~!

    2022年4月12日
    52
  • druid简单详解[通俗易懂]

    druid简单详解[通俗易懂]druid简单详解

    2022年7月23日
    12
  • 开心网外挂之争车位之发起比赛

    开心网外挂之争车位之发起比赛       publicvoidlalisai_KaiShiBiSai(stringid)       {           AccessHelperAH=newAccessHelper();           KaiXinHelperKH=newKaiXinHelper();           DataTabledt=AH.GetDataTable(“

    2025年9月16日
    7

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号