|
发表于 2009-11-6 00:33:24
|
显示全部楼层
经测试:
#include <SendMessage.au3>
_SendMessage(ControlGetHandle("未命名","","[CLASS:Afx:1000000:8; INSTANCE:1]"), 0x201, 1,_MakeLong(500, 500) )
Func _MakeLong($LoWord, $HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
向画图板发送一个鼠标点击,同理只能向控件发送点击,需要获得控件句柄
它等同于
Func _MakeLong($LoWord, $HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
; I = PostMessage(hwnd, WM_LBUTTONDOWN, 0, (mX And &HFFFF) + (mY And &HFFFF) * &H10000)
Func _MouseClick($hWnd, $button, $x, $y, $times=1, $delay=250)
If $hWnd = 0 Then
SetError(-1)
Return
EndIf
Local $ix
Local $lParam = _MakeLong($x, $y)
Local $user32 = DllOpen("user32.dll")
$button = StringLower($button)
If $button = "left" Then
For $ix = 1 To $times
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam)
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", $lParam)
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", $lParam)
; I = PostMessage(hwnd, WM_LBUTTONDOWN, 0, (mX And &HFFFF) + (mY And &HFFFF) * &H10000)
If $ix < $times Then Sleep($delay)
Next
ElseIf $button = "right" Then
For $ix = 1 To $times
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", $lParam)
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x204, "int", 2, "long", $lParam)
DllCall($user32, "int", "PostMessage", "hwnd", $hWnd, "int", 0x205, "int", 0, "long", $lParam)
If $ix < $times Then Sleep($delay)
Next
Else
SetError(-2)
If $user32 <> -1 Then DllClose($user32)
Return
EndIf
If $user32 <> -1 Then DllClose($user32)
EndFunc
;'lp = Y * 65536 + X
_MouseClick(ControlGetHandle("未命名","","[CLASS:Afx:1000000:8; INSTANCE:1]"), "left", 500,500) |
|