Colderleo's blog Colderleo's blog
首页
Linux
C++
Python
前端
工具软件
mysql
索引
关于
GitHub (opens new window)

Colder Leo

热爱代码的打工人
首页
Linux
C++
Python
前端
工具软件
mysql
索引
关于
GitHub (opens new window)
  • Windows
gaoliu
2021-10-06

使用spy++查看win窗口接收到的鼠标键盘消息

参考:https://www.zhihu.com/question/268367725

打开vs中的spy++(也可能有独立版的),然后找到窗口,右键点击点消息,弹出消息记录窗口

下面是安卓模拟器中鼠标拖拽对应的消息:

对应python代码

# 其中SendMessage的第三个参数对应fwKeys
win32gui.SendMessage(self.hgame,win32con.WM_LBUTTONDOWN,win32con.MK_LBUTTON,start_pos) #按下左键

for i in range(20):
    drap_dist += random.randint(0,1)
    next_pos = win32api.MAKELONG(*self._rand_circle(start_x-i*drap_dist, start_y, radius))
    random_sleep_range(0.002, 0.003)
    # win32gui.SendMessage(self.hgame,win32con.WM_MOUSEMOVE,0,next_pos)  # 移动鼠标,
    win32gui.SendMessage(self.hgame,win32con.WM_MOUSEMOVE,win32con.MK_LBUTTON,next_pos)  # 移动鼠标,
    random_sleep_range(0.002, 0.003)

win32gui.SendMessage(self.hgame,win32con.WM_LBUTTONUP,0,next_pos)  # 松开左键
1
2
3
4
5
6
7
8
9
10
11
12
编辑 (opens new window)
上次更新: 2021/10/11, 12:43:58
最近更新
01
通过模板实现结构体成员拷贝-按成员名匹配
05-07
02
c++17通过模板获取类成员的个数
05-01
03
avx-sse切换惩罚
04-30
更多文章>
Theme by Vdoing | Copyright © 2019-2023 Colder Leo | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×