巧了,前两天还在研究这个功能。
#include <WinAPI.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
Global $hHook, $hPrevWnd
$hMouseProc = DllCallBackRegister("_MouseProc", "long", "long;long;ptr")
$pMouseProc = DllCallBackGetPtr($hMouseProc)
$hGUI = GUICreate("FindWindow", 400, 300)
$iFWIcon = GUICtrlCreateIcon("1.ico", -1, 40, 40, 32, 32)
GUICtrlCreateGroup("Window Info", 100, 30, 200, 210)
GUICtrlCreateLabel("Title:", 110, 55, 60, 20)
GUICtrlCreateLabel("Handle:", 110, 85, 60, 20)
GUICtrlCreateLabel("ID:", 110, 115, 60, 20)
GUICtrlCreateLabel("Class:", 110, 145, 60, 20)
GUICtrlCreateLabel("Style:", 110, 175, 60, 20)
GUICtrlCreateLabel("ExStyle:", 110, 205, 60, 20)
$iTitle = GUICtrlCreateInput("", 170, 53, 120, 20)
GUICtrlCreateInput("", 170, 83, 120, 20)
GUICtrlCreateInput("", 170, 113, 120, 20)
GUICtrlCreateInput("", 170, 143, 120, 20)
GUICtrlCreateInput("", 170, 173, 120, 20)
GUICtrlCreateInput("", 170, 203, 120, 20)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "_WndProc")
GUIRegisterMsg($WM_SYSCOMMAND, "_WndProc")
While 1
Sleep(100)
WEnd
Func _WndProc($hWnd, $iMsg, $iwParam, $ilParam)
Switch $iMsg
Case $WM_COMMAND
If ($iFWIcon = BitAnd($iwParam, 0xFFFF)) And (0 = BitShift($iwParam, 16)) Then
Local $hCursor = _WinAPI_LoadCursorFromFile("3.cur")
_WinAPI_SetSystemCursor($hCursor, 0x7F00)
_WinAPI_DestroyCursor($hCursor)
$hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pMouseProc, _WinAPI_GetModuleHandle(0))
GUICtrlSetImage($iFWIcon, "2.ico")
EndIf
Case $WM_SYSCOMMAND
If (0xF060 = BitAnd($iwParam, 0xFFFF)) Then
If $hHook Then _WinAPI_UnhookWindowsHookEx($hHook)
GUIDelete($hWnd)
DllCallbackFree($hMouseProc)
DllCall("User32.dll", "none", "PostQuitMessage", "uint", 0)
EndIf
EndSwitch
EndFunc ;==>_WndProc
Func _MouseProc($iCode, $iwParam, $ilParam)
Switch $iwParam
Case $WM_MOUSEMOVE
Local $tPoint = DllStructCreate($tagPOINT, $ilParam)
Local $hWnd = _WinAPI_WindowFromPoint($tPoint)
If ($hWnd <> $hPrevWnd) And (@AutoItPid <> WinGetProcess($hWnd)) Then
_DrawFrame($hWnd)
_DrawFrame($hPrevWnd)
GUICtrlSetData($iTitle + 0, WinGetTitle($hWnd))
GUICtrlSetData($iTitle + 1, String($hWnd))
GUICtrlSetData($iTitle + 2, _WinAPI_GetDlgCtrlId($hWnd))
GUICtrlSetData($iTitle + 3, _WinAPI_GetClassName($hWnd))
GUICtrlSetData($iTitle + 4, Ptr(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE)))
GUICtrlSetData($iTitle + 5, Ptr(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)))
$hPrevWnd = $hWnd
EndIf
Case $WM_LBUTTONUP
_DrawFrame($hPrevWnd)
_WinAPI_UnhookWindowsHookEx($hHook)
GUICtrlSetImage($iFWIcon, "1.ico")
DllCall("User32.dll", "bool", "SystemParametersInfo", "int", 0x57, "int", 0, "int", 0, "dword", 0)
$hPrevWnd = 0
$hHook = 0
Return
EndSwitch
Return _WinAPI_CallNextHookEx(0, $iCode, $iwParam, $ilParam)
EndFunc ;==>_MouseProc
Func _DrawFrame($hWnd)
If ($hWnd = 0) Then Return 0
Local $hDC, $hPen, $hRgn, $aPos
$hDC = _WinAPI_GetWindowDC($hWnd)
$hPen = _WinAPI_CreatePen(6, 3, 0)
$hRgn = _WinAPI_CreateRectRgn(0, 0, @DesktopWidth, @DesktopHeight)
_WinAPI_SelectObject($hDC, $hPen)
_WinAPI_SelectObject($hDC, _WinAPI_GetStockObject(5))
_WinAPI_SetROP2($hDC, 6)
If _WinAPI_GetWindowRgn($hWnd, $hRgn) Then
_WinAPI_FrameRgn($hDC, $hRgn, $hPen, 3, 3)
Else
$aPos = WinGetPos($hWnd)
If Not IsArray($aPos) Then Return 0
_WinAPI_Rectangle($hDC, 0, 0, $aPos[2], $aPos[3])
EndIf
_WinAPI_DeleteObject($hRgn)
_WinAPI_DeleteObject($hPen)
_WinAPI_ReleaseDC($hWnd, $hDC)
Return 1
EndFunc ;==>_DrawFrame
Func _WinAPI_Rectangle($hDC, $iLeft, $iTop, $iRight, $iBottom)
Local $iResult
$iResult = DllCall("Gdi32.dll", "bool", "Rectangle", "hwnd", $hDC, _
"long", $iLeft, "long", $iTop, "long", $iRight, "long", $iBottom)
Return $iResult[0]
EndFunc ;==>_WinAPI_Rectangle
Func _WinAPI_SetROP2($hDC, $iMode)
Local $iResult
$iResult = DllCall("Gdi32.dll", "bool", "SetROP2", "hwnd", $hDC, "dword", $iMode)
Return $iResult[0]
EndFunc ;==>_WinAPI_SetROP2
Func _WinAPI_FrameRgn($hDC, $hRgn, $hBrush, $iWidth, $iHeight)
Local $iResult
$iResult = DllCall("Gdi32.dll", "bool", "FrameRgn", "hwnd", $hDC, "hwnd", $hRgn, _
"hwnd", $hBrush, "long", $iWidth, "long", $iHeight)
Return $iResult[0]
EndFunc ;==>_WinAPI_FrameRgn
Func _WinAPI_LoadCursorFromFile($sCursor)
Local $iResult = DllCall("User32.dll", "hwnd", "LoadCursorFromFile", "str", $sCursor)
Return $iResult[0]
EndFunc ;==>_WinAPI_LoadCursorFromFile
Func _WinAPI_SetSystemCursor($hCursor, $iSystemCursor)
Local $iResult = DllCall("User32.dll", "bool", "SetSystemCursor", "hwnd", $hCursor, "dword", $iSystemCursor)
Return $iResult[0]
EndFunc ;==>_WinAPI_SetSystemCursor
Func _WinAPI_DestroyCursor($hCursor)
Local $iResult = DllCall("User32.dll", "bool", "DestroyCursor", "hwnd", $hCursor)
Return $iResult
EndFunc ;==>_WinAPI_DestroyCursor
附件中包含相关图片。
|