python 读取鼠标点击坐标的实例

yipeiwu_com6年前Python基础

读取鼠标点击坐标,包括点下去和抬起来的坐标,注意不要在命令行点,可能会出问题

import pythoncom, pyHook
def onMouseEvent(event):
   print "Position:", event.Position
   return True
def main():
  hm = pyHook.HookManager()
  hm.HookKeyboard()
  hm.MouseAllButtonsDown = onMouseEvent
  hm.MouseAllButtonsUp = onMouseEvent
  hm.HookMouse()
  pythoncom.PumpMessages()
if __name__ == "__main__":
  main()

以上这篇python 读取鼠标点击坐标的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python使用turtle库绘制树

本文实例为大家分享了python使用turtle库绘制树的具体代码,供大家参考,具体内容如下 # -*- coding: utf-8 -*- """ Spyder Editor...

Python中zfill()方法的使用教程

 zfill()方法用零垫串来填充左边宽度。 语法 以下是zfill()方法的语法: str.zfill(width) 参数    ...

python 输出上个月的月末日期实例

如下所示: import dateutil def before_month_lastday(ti): today=dateutil.parser.parse(str(ti))...

Python处理CSV与List的转换方法

1.读取CSV文件到List def readCSV2List(filePath): try: file=open(filePath,'r',encoding="gbk")#...

Python中PyQt5/PySide2的按钮控件使用实例

Python中PyQt5/PySide2的按钮控件使用实例

在之前的文章中,我们介绍了PyQt5和PySide2中主窗口控件MainWindow的使用、窗口控件的4中基础布局管理。从本篇开始,我们来了解一下PyQt5和PySide2中基础控件的使...