懒得截图说明了,下面代码楼主可以摸索摸索
激活窗口的相对坐标:指的是当前所激活的窗口的左上角为基准,左上角的坐标是:X=0,Y=0
激活窗口客户区的相对坐标 :客户区是指窗口边框里面的区域,以该区域的左上角为基准#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$GUI = GUICreate("函数演示", 300, 200) ; 创建居中显示的对话框窗口
GUICtrlCreateLabel("鼠标当前坐标", 10, 10, 80, 20)
$Label1 = GUICtrlCreateLabel("", 10, 40, 250, 20)
$Label2 = GUICtrlCreateLabel("", 10, 60, 250, 20)
$Label3 = GUICtrlCreateLabel("", 10, 80, 250, 20)
GUISetState(@SW_SHOW) ; 显示对话框窗口
AdlibRegister("Pos")
While 1
If WinActive($GUI, "") = 0 Then WinActivate($GUI, "")
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd
Func Pos()
Opt("MouseCoordMode", 0)
$Pos = MouseGetPos()
GUICtrlSetData($Label1, "相对于当前窗口, X: " & $Pos[0] & " Y: " & $Pos[1])
Opt("MouseCoordMode", 1)
$Pos = MouseGetPos()
GUICtrlSetData($Label2, "相对于整个屏幕, X: " & $Pos[0] & " Y: " & $Pos[1])
Opt("MouseCoordMode", 2)
$Pos = MouseGetPos()
GUICtrlSetData($Label3, "相对于窗口客户区, X: " & $Pos[0] & " Y: " & $Pos[1])
EndFunc
|