找回密码
 加入
搜索
查看: 2711|回复: 1

[AU3基础] 請求高手加註解

[复制链接]
发表于 2013-12-26 03:27:50 | 显示全部楼层 |阅读模式
這是來自於sanhen的一篇發文
不知是否有高手可以幫忙解釋設計思路及語法說明,先謝謝了。
#Include <array.au3>
 
Global $avCtrlList[1] = [0]
$Title = "AutoIt Help"
$Text = ""
 
$ClassNames = _WinGetClassNameList($Title, $Text)
ConsoleWrite($ClassNames)
 
 
;==================================================
; Function _WinGetClassNameList()
;   Returns a string containing a list of all ClassNameNN control IDs in a window.
;   On success returns all ClassNameNN's in a string delimited by @LF.
;   On failure returns 0 and sets @error.
;==================================================
Func _WinGetClassNameList($sWinTitle = "", $sWinText = "")
    Local $c, $NN, $hCtrl
    ; Get list of classes in the window
    Local $sClassList = WinGetClassList($sWinTitle, $sWinText)
    If @error Then Return SetError(1, 0, 0)
    Local $avClassList = StringSplit($sClassList, @LF)
    ; Try different values of NN
    $sClassList = ""
    For $c = 1 To $avClassList[0]
        $NN = 1
        While 1
            $hCtrl = ControlGetHandle($sWinTitle, $sWinText, $avClassList[$c] & $NN)
            If @error Then
                ExitLoop
            Else
                $sClassList &= $avClassList[$c] & $NN & @LF
                $NN += 1
            EndIf
        WEnd
    Next
    Return $sClassList
EndFunc   ;==>_WinGetClassNameList
Global $Array = _WinGetCtrlInfo(WinGetTitle($Title))
Global $sOne = '[0][0] = ' & $Array[0][0] & @CR, $sTwo
For $iCC = 1 To $Array[0][0]
    $sOne &= '[' & $iCC & '][0] = ' & $Array[$iCC][0] & @CR
    $sTwo &= '[' & $iCC & '][1] = ' & $Array[$iCC][1] & @CR
Next
MsgBox(64, 'WinInfo', StringTrimRight($sOne, 1) & @CR & StringTrimRight($sTwo, 1))
Func _WinGetCtrlInfo($hWin)
    If IsString($hWin) Then $hWin = WinGetHandle($hWin)
    Local $sClassList = WinGetClassList($hWin), $iAdd = 1, $aDLL, $sHold
    Local $aSplitClass = StringSplit(StringTrimRight($sClassList, 1), @LF), $aReturn[1][2]
    For $iCount = $aSplitClass[0] To 1 Step - 1
        Local $nCount = 0
        While 1
            $nCount += 1
            If ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount) = '' Then ExitLoop
            If Not StringInStr(Chr(1) & $sHold, Chr(1) & $aSplitClass[$iCount] & $nCount & Chr(1)) Then
                $sHold &= $aSplitClass[$iCount] & $nCount & Chr(1)
                $iAdd += 1
                ReDim $aReturn[$iAdd][2]
                $aReturn[$iAdd - 1][0] = $aSplitClass[$iCount] & $nCount
                $aDLL = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', _
                    ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount))
                If @error = 0 Then
                    $aReturn[$iAdd - 1][1] = $aDLL[0]
                Else
                    $aReturn[$iAdd - 1][1] = ''
                EndIf
            EndIf
        WEnd
    Next
    $aReturn[0][0] = $iAdd - 1
    Return $aReturn
EndFunc   ;==>_WinGetCtrlInfo()
 楼主| 发表于 2013-12-26 04:29:53 | 显示全部楼层
請問由上面程式所產生的這些是什麼?是不是控件ID?


[1][1] = -31987

[2][1] = 10219

[3][1] = 14685

[4][1] = 14846

[5][1] = 14914

[6][1] = 14982

[7][1] = 15046

[8][1] = 15110

[9][1] = 15271

[10][1] = 15339

[11][1] = 15412

[12][1] = 15529

[13][1] = 15690

[14][1] = 15748

[15][1] = 15814

[16][1] = 15887

[17][1] = 15953

[18][1] = 16017

[19][1] = 16083

[20][1] = 16147

[21][1] = 16220

[22][1] = 16381

[23][1] = -31998

[24][1] = -31997

[25][1] = -31996

[26][1] = -31995

[27][1] = -31994

[28][1] = -31993

[29][1] = -31992

[30][1] = -31991

[31][1] = -31989

[32][1] = -31988

[33][1] = 7023

[34][1] = 7023

[35][1] = 10069

[36][1] = 10079

[37][1] = 10137

[38][1] = 10140

[39][1] = 7023

[40][1] = 7023

[41][1] = -31990
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-24 01:52 , Processed in 0.071198 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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