Dreamer 发表于 2013-12-26 03:27:50

請求高手加註解

這是來自於sanhen的一篇發文
不知是否有高手可以幫忙解釋設計思路及語法說明,先謝謝了。
#Include <array.au3>

Global $avCtrlList =
$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
      $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 = ' = ' & $Array & @CR, $sTwo
For $iCC = 1 To $Array
    $sOne &= '[' & $iCC & '] = ' & $Array[$iCC] & @CR
    $sTwo &= '[' & $iCC & '] = ' & $Array[$iCC] & @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
    For $iCount = $aSplitClass 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]
                $aReturn[$iAdd - 1] = $aSplitClass[$iCount] & $nCount
                $aDLL = DllCall('User32.dll', 'int', 'GetDlgCtrlID', 'hwnd', _
                  ControlGetHandle($hWin, '', $aSplitClass[$iCount] & $nCount))
                If @error = 0 Then
                  $aReturn[$iAdd - 1] = $aDLL
                Else
                  $aReturn[$iAdd - 1] = ''
                EndIf
            EndIf
      WEnd
    Next
    $aReturn = $iAdd - 1
    Return $aReturn
EndFunc   ;==>_WinGetCtrlInfo()

Dreamer 发表于 2013-12-26 04:29:53

請問由上面程式所產生的這些是什麼?是不是控件ID?


= -31987

= 10219

= 14685

= 14846

= 14914

= 14982

= 15046

= 15110

= 15271

= 15339

= 15412

= 15529

= 15690

= 15748

= 15814

= 15887

= 15953

= 16017

= 16083

= 16147

= 16220

= 16381

= -31998

= -31997

= -31996

= -31995

= -31994

= -31993

= -31992

= -31991

= -31989

= -31988

= 7023

= 7023

= 10069

= 10079

= 10137

= 10140

= 7023

= 7023

= -31990
页: [1]
查看完整版本: 請求高手加註解