# 需要导入模块: 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

python win32api sendmessage_Python win32api.SendMessage方法代码示例相关推荐

  1. doc python 颜色_Python wordcloud.ImageColorGenerator方法代码示例

    本文整理汇总了Python中wordcloud.ImageColorGenerator方法的典型用法代码示例.如果您正苦于以下问题:Python wordcloud.ImageColorGenerat ...

  2. python asyncio future_Python asyncio.isfuture方法代码示例

    本文整理汇总了Python中asyncio.isfuture方法的典型用法代码示例.如果您正苦于以下问题:Python asyncio.isfuture方法的具体用法?Python asyncio.i ...

  3. python operator __gt___Python operator.gt方法代码示例

    本文整理汇总了Python中operator.gt方法的典型用法代码示例.如果您正苦于以下问题:Python operator.gt方法的具体用法?Python operator.gt怎么用?Pyth ...

  4. python socket connection_Python socket.create_connection方法代码示例

    本文整理汇总了Python中gevent.socket.create_connection方法的典型用法代码示例.如果您正苦于以下问题:Python socket.create_connection方 ...

  5. python中shelf_Python cmds.shelfLayout方法代码示例

    本文整理汇总了Python中maya.cmds.shelfLayout方法的典型用法代码示例.如果您正苦于以下问题:Python cmds.shelfLayout方法的具体用法?Python cmds ...

  6. python中summary_Python summary_pb2.Summary方法代码示例

    本文整理汇总了Python中tensorflow.core.framework.summary_pb2.Summary方法的典型用法代码示例.如果您正苦于以下问题:Python summary_pb2 ...

  7. python cpu count_Python multiprocessing.cpu_count方法代码示例

    本文整理汇总了Python中multiprocessing.cpu_count方法的典型用法代码示例.如果您正苦于以下问题:Python multiprocessing.cpu_count方法的具体用 ...

  8. python args keargs_Python metrics.silhouette_score方法代码示例

    本文整理汇总了Python中sklearn.metrics.silhouette_score方法的典型用法代码示例.如果您正苦于以下问题:Python metrics.silhouette_score ...

  9. python socket send_Python socket.send方法代码示例

    本文整理汇总了Python中socket.send方法的典型用法代码示例.如果您正苦于以下问题:Python socket.send方法的具体用法?Python socket.send怎么用?Pyth ...

  10. python torch exp_Python torch.diag方法代码示例

    本文整理汇总了Python中torch.diag方法的典型用法代码示例.如果您正苦于以下问题:Python torch.diag方法的具体用法?Python torch.diag怎么用?Python ...

最新文章

  1. LaTeX入门最终集 :LaTeX格式的调整LaTeX中怎么打出数学公式LaTeX的各种上下标
  2. 数据降维与可视化——t-SNE
  3. 20145217信息安全系统设计基础第11周学习总结
  4. java 编译器获得型号_关于编译器构造:如何找到已编译类的目标Java版本?
  5. Spring基础篇——Spring容器和应用上下文理解
  6. u大师制作linux系统,U大师官方下载|U大师U盘启动盘制作工具官方版 v4.7.37.56 最新版 - 系统天堂...
  7. Magic Data上榜互联网周刊2022数字经济100强
  8. k8s教程01(k8s环境配置及私有仓库搭建)
  9. iptables中DNAT、SNAT和MASQUERADE的原理
  10. Outlook_Hotkey
  11. Supervisor socket.error No such file or directory file /usr/lib64/pyth
  12. 电动机三相电流为什么不平衡?
  13. 【英语六级笔记】翻译部分
  14. 功能测试与抓包工具Fiddler(http与fiddler)
  15. XMU 1617 刘备闯三国之汉中之战 【BFS+染色】
  16. 早期 计算机网络只是包括,计算机网络-判断题.docx
  17. 04. JavaMail 查询/读取邮件
  18. 百度地图自定义标注点
  19. DELL T410服务器 重装
  20. 2022年天猫年货节红包时间,2022年1月7日20点开始

热门文章

  1. 【课程·研】高性能计算机网络 | 学堂在线习题解答:期末考试
  2. 微信小程序下载文件,保存文件功能总结
  3. 微信打飞机项目前期心得
  4. EndNote编辑毕业论文格式
  5. java计算交点高程_javascirpt怎样模仿块级作用域(js高程笔记)
  6. 【读书笔记-数据挖掘概念与技术】数据仓库与联机分析处理(OLAP)
  7. java jsp交友系统_Jsp+Servlet+Javabean网络交友程序设计+源代码
  8. pp助手苹果版_苹果一键刷机助手app免费版下载-一键刷机精灵下载手机版
  9. POP3协议主要功能及命令简介
  10. 计算机软件评估资料,软件项目工作量评估方法 计算机软件及应用 IT计算机 专业资料.doc...