Global $pos[2], $var
Opt("PixelCoordMode", 0) ;;设置用于象素函数的坐标参照,相对当前激活窗口的坐标位置
Opt("MouseCoordMode", 0);;设置用于鼠标函数的坐标参照,可以是相对当前激活窗口的坐标位置
HotKeySet("", "leave")
HotKeySet("`", "shijian")
$hwd = GUICreate("主窗口", 200, 240, 0, 0, BitXOR(0x80880000, 0x00800000), 0x00000080 + 0x00000008)
GUICtrlCreateLabel("坐标颜色代码:", 12, 203, 90, 15)
$S = GUICtrlCreateInput("", 102, 201, 80, 18)
GUICtrlCreateLabel("相对X坐标:", 3, 223, 66, 16)
$X = GUICtrlCreateInput("", 63, 220, 30, 18)
GUICtrlCreateLabel("相对Y坐标:", 98, 223, 66, 16)
$Y = GUICtrlCreateInput("", 160, 220, 35, 18)
GUISetState()
While 1
Sleep(25)
MAG()
WEnd
Func MAG()
$MyHDC = DllCall("user32.dll", "int", "GetDC", "hwnd", $hwd)
If @error Then Return
$DeskHDC = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
If Not @error Then
$pos = MouseGetPos()
If Not @error Then
DllCall("gdi32.dll", "int", "StretchBlt", "int", $MyHDC[0], "int", 0, "int", 0, "int", 200, "int", 200, "int", $DeskHDC[0], "int", $pos[0] - 25, "int", $pos[1] - 25, "int", 50, "int", 50, "long", 0x00CC0020)
EndIf
DllCall("user32.dll", "int", "ReleaseDC", "int", $DeskHDC[0], "hwnd", 0)
EndIf
DllCall("user32.dll", "int", "ReleaseDC", "int", $MyHDC[0], "hwnd", $hwd)
Sleep(25)
$var = PixelGetColor($pos[0], $pos[1]);;
GUICtrlSetData($X, $pos[0])
GUICtrlSetData($Y, $pos[1]);;
GUICtrlSetData($S, "0x" & Hex($var, 6));;
GUICtrlSetBkColor($S, $var)
EndFunc ;==>MAG
Func leave()
Exit
EndFunc ;==>leave
Func shijian()
FileWrite(@DesktopDir & '\MOUSEPOS.LOG', @CRLF & '记录生成时间:' & @YEAR & '年' & @MON & '月' & @MDAY &'日' & _
' ' & @HOUR & '时' & @MIN & '分' & @SEC & '秒' & @CRLF & '鼠标X坐标:' & $pos[0] & @CRLF & _
'鼠标Y坐标:' & $pos[1] & @CRLF & '颜色代码:' & "0x" & Hex($var, 6) & @CRLF)
If MsgBox(262212, '选择', "保存成功,是否继续?") = 6 Then Return
Exit
EndFunc ;==>shijian
|