吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 955|回复: 2
收起左侧

[求助] 关于vba中mouse_event函数按下QQ截图键后的问题

[复制链接]
放羊的狼 发表于 2022-11-17 08:58
代码如下,在sendkeys按下截图组合键后鼠标坐标会执行,但鼠标左键按下和抬起的两个动作不执行,不知道是什么原因,希望有大佬能帮助一下。

[Visual Basic] 纯文本查看 复制代码
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Const MouseEventf_LeftDown = &H2     '按下左键
Public Const MouseEventf_LeftUp = &H4       '弹起左键

Type POINTAPI
    x As Long
    y As Long
End Type

Public Function 移动到(x As Long, y As Long)
    SetCursorPos x, y
End Function

Public Function getmouse_x_y() As POINTAPI    '坐标
    GetCursorPos getmouse_x_y
End Function

Public Function 左单击(单击次数 As Long)
    For MKi = 1 To 单击次数
        mouse_event MouseEventf_LeftDown, 0, 0, 0&, 0&
        mouse_event MouseEventf_LeftUp, 0, 0, 0&, 0&
    Next MKi
End Function

Sub test()
    移动到 450, 230     '移动到截图起始位
    SendKeys ("^%a")    '组合键截图
'    左单击 1
    mouse_event MouseEventf_LeftDown, 0, 0, 0&, 0&  '按下开始截图
    
'    delay 1
    
    移动到 1300, 1030     '移动到截图末位
    
    mouse_event MouseEventf_LeftUp, 0, 0, 0&, 0&    '松开左键
    
    '滚动鼠标滚轮
End Sub

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| 放羊的狼 发表于 2022-11-17 14:09
没大佬回复一下么....
fengtian99 发表于 2023-2-14 09:29
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 01:56

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表