VB中如何虚拟按下鼠标左键

2025-01-02 15:10:19
推荐回答(2个)
回答1:

下面两个的答案一点用都没有。
模拟鼠标操作首先你要先把鼠标移到正确位置。
SetCursorPos
'这个API可以解决问题
然后就是模拟点击
mouse_event
'这个API就可以模拟点击了

回答2:

用api
private
declare
function
postmessage
lib
"user32"
alias
"postmessagea"
(byval
hwnd
as
long,
byval
wmsg
as
long,
byval
wparam
as
long,
byval
lparam
as
long)
as
long
private
const
wm_lbuttondown
=
&h201
private
const
wm_lbuttonup
=
&h202
private
sub
command1_click()
postmessage
command2.hwnd,
&h201,
0&,
0&
postmessage
command2.hwnd,
&h202,
0&,
0&
end
sub
private
sub
com缉梗光妓叱幻癸潍含璃mand2_click()
static
i
as
long
i
=
i
+
1
print
"command2按钮点了"
&
i
&
"次"
end
sub