Func _Main()
$_whand = DllCallbackRegister("_Mouse_Events_Handler", "int", "int;ptr;ptr")
$hmod = _WinAPI_GetModuleHandle(0)
$_whook=_WinAPI_SetWindowsHookEx($WH_MOUSE_LL,DllCallbackGetPtr($_whand),$hmod)
While 1
Sleep(10)
WEnd
EndFunc
Func _Mouse_Events_Handler($wnCode, $wwParam, $wlParam)
Local $Pos,$activeh,$size1,$size2,$lPos
Local $F = False
If $flag = False Then Return
Opt("MouseCoordMode", 2)
Switch $wwParam
Case $WM_LBUTTONUP ;按下鼠标左键
If $wnCode < 0 Then
Return _WinAPI_CallNextHookEx($_whook, $wnCode, $wwParam, $wlParam) ;消息传递到下一个钩子
EndIf
$activeh = _My_WinAPI_GetForegroundWindow()
For $hd In $hand
If $hd == $activeh Then $F = True
Next
If $F = False Then Return
$size1 = WinGetPos($activeh)
If UBound($size1) < 2 Then Return
$Pos = MouseGetPos()
_WinAPI_PostMessage($activeh,0x202,1,_MakeLong($Pos[0], $Pos[1]))
For $hd In $hand
If $hd == $activeh Then ContinueLoop
If $_ControlHandle <> "" Then
$hd = ControlGetHandle($hd, "", $_ControlHandle)
EndIf
$size2 = WinGetPos($hd)
_WinAPI_PostMessage($hd,0x200,1,_MakeLong($Pos[0], $Pos[1]))
_WinAPI_PostMessage($hd,0x201,1,_MakeLong($Pos[0], $Pos[1]))
;Sleep(10)
_WinAPI_PostMessage($hd,0x202,1,_MakeLong($Pos[0], $Pos[1]))
;msgbox(0,$Pos[0], $Pos[1])
;MouseMove($Pos[0]+$size2[0] - $size1[0], $Pos[1]+$size2[1] - $size1[1],1)
;ControlClick($hd,"","","left",1,$lPos[0], $lPos[1])
Next
;MouseMove($Pos[0], $Pos[1],1)
EndSwitch
Return _WinAPI_CallNextHookEx($_whook, $wnCode, $wwParam, $wlParam) ;消息传递到下一个钩子
EndFunc