找回密码
 加入
搜索
查看: 3214|回复: 4

[GUI管理] SPY中用到的那个控件如何制作的?[已解决]

[复制链接]
发表于 2011-12-11 02:50:26 | 显示全部楼层 |阅读模式
本帖最后由 bdancerlc 于 2011-12-12 22:13 编辑

SPY中用到的那个控件如何制作的?
今天看到 “风行者” 发布的工具“网页快捕”,于是想了解一下这个控件是如何制作的!
如图:au3Info.exe

在网上找了很久,找到2条有用信息:
1、一个是用VB 实现的,据说是有一个叫“SPY控件”的一个扩展控件...
视频地址:http://video.baby.sina.com.cn/v/b/53435726-1676700661.html
他这个例子确实很简单可以直接调用控件..
2、这个是用易语言实现的,貌似是自己定义一个图片控件,然后拖拽的动画,获取窗口信息都是由自己编写的..
视频地址:http://www.tudou.com/programs/view/iTbDiFJ4MoY/
这个方法只看了一部分没有看全....

不知道AUTOIT3实现这个控件的功能是如何实现的呢?
是有类似1的方法,还是需要跟2一样自己编写代码呢?
希望各位大大赐教...
--------------------------------------------------------------------------------------------------------------------------
算了,不纠结了,在没有好的udf出来之前还是用2楼在方案吧!...

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-12-11 04:48:16 | 显示全部楼层
以前收集的一段代码 ,忘记是哪位高人写的了
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

;===============================================================================
;
; Description:      Window Finder 
; Author(s):        Dmitry Yudin (Lazycat)
; Date:             26.10.2007
; Notes:            Used for learning: 
;                   http://www.codeproject.com/dialog/windowfinder.asp 
;===============================================================================

; Initializing resources
Global $CURSOR_TARGET = WriteResource( _
"0x000002000100202000000F001000300100001600000028000000200000004000000001000100000000008000" & _
"00000000000000000000020000000200000000000000FFFFFF0000000000000000000000000000000000000000" & _
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _
"00000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" & _
"FFFFFFF83FFFFFE6CFFFFFD837FFFFBEFBFFFF783DFFFF7EFDFFFEAC6AFFFEABAAFFFE0280FFFEABAAFFFEAC6A" & _
"FFFF7EFDFFFF783DFFFFBEFBFFFFD837FFFFE6CFFFFFF83FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" & _
"FFFFFFFFFFFFFFFFFFFFFFFF")
Global $ICON_TARGET_FULL = WriteResource( _
"0x0000010001002020080000000000E80200001600000028000000200000004000000001000400000000000002" & _
"000000000000000000001000000010000000000000000000800000800000008080008000000080008000808000" & _
"00C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000000000000000" & _
"00000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFF" & _
"FFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFF00000FFFFFFFFFFFF000FFFFFFFFFF00FF0FF00FFFFFFFFFF000FF" & _
"FFFFFFF0FF00000FF0FFFFFFFFF000FFFFFFFF0FFFFF0FFFFF0FFFFFFFF000FFFFFFF0FFFF00000FFFF0FFFFFF" & _
"F000FFFFFFF0FFFFFF0FFFFFF0FFFFFFF000FFFFFF0F0F0FF000FF0F0F0FFFFFF000FFFFFF0F0F0F0FFF0F0F0F" & _
"0FFFFFF000FFFFFF0000000F0F0000000FFFFFF000FFFFFF0F0F0F0FFF0F0F0F0FFFFFF000FFFFFF0F0F0FF000" & _
"FF0F0F0FFFFFF000FFFFFFF0FFFFFF0FFFFFF0FFFFFFF000FFFFFFF0FFFF00000FFFF0FFFFFFF000FFFFFFFF0F" & _
"FFFF0FFFFF0FFFFFFFF000FFFFFFFFF0FF00000FF0FFFFFFFFF000FFFFFFFFFF00FF0FF00FFFFFFFFFF000FFFF" & _
"FFFFFFFF00000FFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF0" & _
"00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000007770CCCCCCCCCCCCCCCCCCCC" & _
"C07770007070CCCCCCCCCCCCCCCCCCCCC07070007770CCCCCCCCCCCCCCCCCCCCC0777000000000000000000000" & _
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _
"000000000000000000FFFFFFFF8000000080000000800000008000000080000000800000008000000080000000" & _
"800000008000000080000000800000008000000080000000800000008000000080000000800000008000000080" & _
"0000008000000080000000800000008000000080000000800000008000000080000000FFFFFFFFFFFFFFFFFFFF" & _
"FFFF")
Global $ICON_TARGET_EMPTY = WriteResource( _
"0x0000010001002020080000000000E80200001600000028000000200000004000000001000400000000000002" & _
"000000000000000000001000000010000000000000000000800000800000008080008000000080008000808000" & _
"00C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000000000000000" & _
"00000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFF" & _
"FFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FF" & _
"FFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFF" & _
"F000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFF" & _
"FFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFF" & _
"FFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFF" & _
"FFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFF" & _
"FFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF0" & _
"00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000000007770CCCCCCCCCCCCCCCCCCCC" & _
"C07770007070CCCCCCCCCCCCCCCCCCCCC07070007770CCCCCCCCCCCCCCCCCCCCC0777000000000000000000000" & _
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _
"000000000000000000FFFFFFFF8000000080000000800000008000000080000000800000008000000080000000" & _
"800000008000000080000000800000008000000080000000800000008000000080000000800000008000000080" & _
"0000008000000080000000800000008000000080000000800000008000000080000000FFFFFFFFFFFFFFFFFFFF" & _
"FFFF")

; Loading cursor from file
$hTargetCursor = DllCall("User32.dll", "int", "LoadCursorFromFile", "str", $CURSOR_TARGET)
$hTargetCursor = $hTargetCursor[0]

Global $g_StartSearch = False, $gFoundWindow = 0, $gOldCursor
;~ Global $WM_MOUSEMOVE = 0x200
;~ Global $WM_LBUTTONUP = 0x202

#Region ### START Koda GUI section ### Form=
$hGUI = GUICreate("Window Finder", 586, 104, -1, -1)
GUICtrlCreateGroup("Target", 80, 0, 497, 65)
GUICtrlCreateLabel("Title:", 101, 18, 27, 17, $SS_RIGHT)
GUICtrlCreateLabel("Handle:", 87, 42, 41, 17, $SS_RIGHT)
$hLabelTitle = GUICtrlCreateLabel("", 133, 18, 436, 17, BitOR($SS_CENTER,$SS_RIGHT,$SS_GRAYFRAME,$SS_WHITEFRAME,$SS_SIMPLE))
$hLabelWnd = GUICtrlCreateLabel("", 133, 42, 100, 17)
GUICtrlCreateLabel("Class:", 240, 42, 32, 17)
$hLabelClass = GUICtrlCreateLabel("", 272, 42, 300, 17, BitOR($SS_CENTER,$SS_RIGHT,$SS_GRAYFRAME,$SS_WHITEFRAME,$SS_SIMPLE))
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", 8, 0, 65, 65)
$hTargetPic = GUICtrlCreateIcon($ICON_TARGET_FULL, 0, 24, 20, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$hOK = GUICtrlCreateButton("Close", 504, 72, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg ($WM_MOUSEMOVE, "WM_MOUSEMOVE_FUNC")
GUIRegisterMsg ($WM_LBUTTONUP, "WM_LBUTTONUP_FUNC")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $hOK
            Exit
        Case $hTargetPic
            $g_StartSearch = True
            DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $hGUI)
            $gOldCursor = DllCall("user32.dll", "int", "SetCursor", "int", $hTargetCursor)
            If not @error Then $gOldCursor = $gOldCursor[0]
            GUICtrlSetImage($hTargetPic, $ICON_TARGET_EMPTY)
    EndSwitch
Wend

Func WM_MOUSEMOVE_FUNC($hWnd, $nMsg, $wParam, $lParam)
    If not $g_StartSearch Then Return 1
    Local $mPos = MouseGetPos()
    $hWndUnder = DllCall("user32.dll", "hwnd", "WindowFromPoint", "long", $mPos[0], "long", $mPos[1])
    If not @error Then $hWndUnder = $hWndUnder[0]
    If CheckFoundWindow($hWndUnder) Then
        GUICtrlSetData($hLabelTitle, WinGetTitle($hWndUnder))
        GUICtrlSetData($hLabelWnd, $hWndUnder)
        GUICtrlSetData($hLabelClass, GetWindowClass($hWndUnder))
        $gFoundWindow = $hWndUnder
    EndIf
    Return 1
EndFunc

Func WM_LBUTTONUP_FUNC($hWnd, $nMsg, $wParam, $lParam)
    If not $g_StartSearch Then Return 1
    $g_StartSearch = False
    ; Release captured cursor
    DllCall("user32.dll", "int", "ReleaseCapture")
    DllCall("user32.dll", "int", "SetCursor", "int", $gOldCursor)
    GUICtrlSetImage($hTargetPic, $ICON_TARGET_FULL)
    Return 1
EndFunc

Func CheckFoundWindow($hFoundWnd)
  If $hFoundWnd = $hGUI Then Return False
  If $hFoundWnd = 0 Then Return False
  If $hFoundWnd = $gFoundWindow Then Return False
  If not WinExists($hFoundWnd) Then Return False
  Local $hTemp = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hFoundWnd)
  If not @error and $hTemp[0] = $hGUI Then Return False
  Return True
EndFunc

Func GetWindowClass($hWnd)
    $pClassName = DllStructCreate("char[256]")
    DllCall("user32.dll", "int", "GetClassName", "hwnd", $hWnd, "ptr", DllStructGetPtr($pClassName), "int", 255)
    Return DllStructGetData($pClassName, 1)
EndFunc

Func WriteResource($sbStringRes)
    Local $sTempFile
    Do
        $sTempFile = @TempDir & "\temp" & Hex(Random(0, 65535), 4)
    Until not FileExists($sTempFile)
    Local $hFile = FileOpen($sTempFile, 2+16)
    FileWrite($hFile, $sbStringRes)
    FileClose($hFile)
    Return $sTempFile
EndFunc

Func OnAutoitExit()
    If IsDeclared("CURSOR_TARGET") Then
        FileDelete($ICON_TARGET_FULL)
        FileDelete($ICON_TARGET_EMPTY)
        FileDelete($CURSOR_TARGET)
    EndIf
EndFunc

评分

参与人数 1金钱 +20 收起 理由
bdancerlc + 20 谢谢分享..

查看全部评分

发表于 2011-12-11 07:29:28 | 显示全部楼层
记得A版有写一个这样的程序,可以请教A版
发表于 2012-6-29 10:49:22 | 显示全部楼层
要深入研究下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-22 23:27 , Processed in 0.094615 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表