ฟอรั่ม PSsix

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ฟอรั่มของบล็อก http://pssix.blogspot.com


4 posters

    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ

    avatar
    pureexe
    PSsix Member High Class
    PSsix Member High Class


    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty
    จำนวนข้อความ : 73
    ความนิยม : 8
    เข้าร่วมเมื่อ : 27/04/2011

    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ

    ตั้งหัวข้อ by pureexe 27/04/11, 10:19 am

    เห็นคุณเจ้าของblogทำโปรแกรม PSsix NetMeter v1.2 วัดความเร็วดาวน์โหลด/อัปโหลด
    ก็เลยอยากจะรู้โค้ดวัดความเร็วเน็ตอะครับ
    POS
    POS
    PSsix
    PSsix


    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty
    จำนวนข้อความ : 1152
    ความนิยม : 326
    เข้าร่วมเมื่อ : 19/07/2010

    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty Re: ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ

    ตั้งหัวข้อ by POS 27/04/11, 05:30 pm

    ไม่มีนโยบายเผยแพร่สคริปต์สำหรับโปรแกรมที่แจกครับ เพราะไม่ได้ส่งเสริมความคิด คนส่วนใหญ่เอาไปก็แค่เอาไปดัดแปลงนิดหน่อยเท่านั้น อย่างไรก็ตามหากคุณสนใจสามารถศึกษาโค้ดตั้งต้นด้านล่างนี้ได้ครับ ผลลัพธ์ที่แสดงจะเป็นผลรวมทั้งหมด(รับและส่ง)มีหน่วยเป็นไบต์ ซึ่งต้องนำมาแปลงเป็น KB หรือ MB อีกที เมื่อแปลงเสร็จ ก็นำมาเขียนโค้ดต่อว่าแต่ละวินาทีหรือมากกว่านั้นวินโดวส์รับและส่งข้อมูลเท่าไหร่

    Code:
    Global $oWMIService = ObjGet("winmgmts:\\.\root\cimv2")
    Global $oClass = $oWMIService.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface", "WQL", 0x10 + 0x20 )
    Global $Downb, $Uploadb

    For $obj In $oClass
       $Downb = $obj.BytesReceivedPerSec
       $Uploadb = $obj.BytesSentPerSec
       ExitLoop
    Next

    While 1
       Sleep(1000)
       Getstatus()
       ToolTip ($Downb&"<>"&$Uploadb)
       WEnd


    Func Getstatus()
     $oClass = $oWMIService.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface", "WQL", 0x10 + 0x20 )
        For $obj In $oClass
       $Downb = $obj.BytesReceivedPerSec
       $Uploadb = $obj.BytesSentPerSec
       ExitLoop
          ExitLoop
       Next
    EndFunc
    sak20102005
    sak20102005
    ระงับสมาชิก
    ระงับสมาชิก


    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty
    จำนวนข้อความ : 96
    ความนิยม : 4
    เข้าร่วมเมื่อ : 07/04/2011

    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty Re: ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ

    ตั้งหัวข้อ by sak20102005 27/04/11, 07:53 pm

    WMI Code Creator:Download คลิ๊กที่นี่

    ท่านผู้ถามคงคิดในใจกับผมว่า.. เอ๊ะ! ในเมื่อลงโปรแกรมให้ดาวน์โหลดแล้ว ทำไม? ไม่บอกวิธีใช้งานและวิธีการนำไปประยุกต์ใช้ด้วย จริงๆแล้วผมเคยลงบทความเกี่ยวกับ WMI ไว้ แต่ไม่ใช่ที่บอร์ดนี้ ลงเป็นโค๊ดสำเร็จรูปไว้ให้เท่านั้น แต่ยังไม่ได้แนะนำวิธีใช้งานโปรแกรม ก็เลยถือโอกาสแนะนำให้เล็กๆน้อยๆเท่าที่รู้ ผมจะพยายามแนะนำวิธีหาปลา จะไม่ค่อยอยากหาปลามาแจก
    ซึ่งหมายถึง แนะนำให้พอที่จะใช้งานโปรแกรมได้ จากนั้นก็นำไปประยุกต์ใช้งานกันเอง ใครทำได้หรือไม่ได้
    ขึ้นอยู่กับ การฝึกฝนค้นคิดของบุคคลนั้นๆ ..ถ้าเอาจริง.. รับรองสามารถเข้าไปล้วงลึกถึงตับไตใส้พุงของวินโดว์ได้อย่างสบาย.
    ---------------------------------------------------------------------------------------------
    โปรแกรมนี้ ..โค๊ดคำสั่งที่เขียนออกมาจะอยู่ในรูปไฟล์สกุล *.vbs (Visual Basic Script)
    ต้องใช้ความสามารถของตนเอง นำมาเขียนดัดแปลงให้เป็นไฟล์สกุล *.au3
    ซึ่งก็ไม่ยากเย็นอะไร เพราะ AutoIt เป็นโปรแกรมอัจฉริยะ สามารถนำไปเขียนดัดแปลงให้เข้ากับภาษาอื่นๆได้
    อย่า่งเช่น AutoitX3 เป็นต้น.
    -----------------------------------------------------------------------------------------------------------------
    โดยปกติแล้ว สิ่งที่เราต้องการ จากการเขียนคำสั่ง คือ ค่าการแสดงผลที่ออกมาจาก Output โดยมี Input เป็นตัวช่วย
    ค่าต่างๆที่ได้ยังแบ่งออกเป็น2แบบคือ แบบคงที่ และแบบไม่คงที่ มีการเปลี่ยนแปลงอยู่ตลอดเวลา
    ถ้ามีสิ่งใด?มากระตุ้น (Trigger) คราวหน้ามาดูกันว่า จะนำโค๊ดที่ได้จากโปรแกรมนี้ ไปประยุกต์ใช้งานยังไง?
    --------------------------------------------------------------------------------------------------------------------
    AutoIt ScriptOMatic Tool

    Code:

    #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #RequireAdmin
    #include <GuiConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    Global $strAppTitle, $strCtrlWMINameSpace, $strCtrlWMIClass, $strCtrlRun, $strCtrlOpen, $strCtrlSave
    Global $strCtrlQuit, $strCtrlOutput, $strCtrlDialog, $strCtrlText, $strCtrlHTML, $strWait, $strClassHelpTip
    Global $strWaitNamespaces, $strWMIWaitMsg, $strSelectWmiClass, $NoDynamiqueClass, $ClassError, $GeneratedBy
    Global $SetWMI_RS, $CompWMI_Rs, $HtmlOutput, $TitleWMIOutput, $strWMIOutput, $SaveScript, $strProperty, $StrValue
    Global $msg, $szFlag, $StrMessage, $NoDynamiqueClassError = 0
    Global $g_strCurrentNamespace = "\root\CIMV2"
    Global $g_iCurrentNamespaceIndex = 0
    Global $g_strWMISource = "localhost"
    Global $g_strOutputFormat = "Dialog"
    If StringInStr("040c, 080c, 0c0c, 100c, 140c, 180c", @OSLang) Then
       _French()
    Else
       _English()
    EndIf
    Global $GUI_Main = GUICreate($strAppTitle, 684, 561, (@DesktopWidth - 684) / 2, (@DesktopHeight - 561) / 2)
    Global $GUI_AST_MainGroup = GUICtrlCreateGroup("", 10, 10, 660, 530)
    Global $GUI_WMI_NamespaceLabel = GUICtrlCreateLabel($strCtrlWMINameSpace, 20, 30, 150, 20)
    Global $GUI_WMI_Namespace = GUICtrlCreateCombo("WMI_Namespaces", 20, 50, 280, 80, BitOR(0x1, 0x2, 0x40, 0x00200000))
    Global $GUI_WMI_ClassLabel = GUICtrlCreateLabel($strCtrlWMIClass, 320, 30, 240, 20)
    Global $GUI_WMI_Classes = GUICtrlCreateCombo("WMI_Classes", 320, 50, 340, 80, BitOR(0x1, 0x2, 0x40, 0x00200000))
    Global $GUI_AST_ButtonGroup = GUICtrlCreateGroup("", 10, 80, 660, 50)
    Global $GUI_WMI_ClassHelp = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -211, 635, 18, 32, 32)
    GUICtrlSetTip(-1, $strClassHelpTip)
    Global $GUI_AST_Run = GUICtrlCreateButton($strCtrlRun, 20, 100, 50, 20)
    Global $GUI_AST_CIMv2 = GUICtrlCreateButton("CIMv2", 80, 100, 50, 20)
    Global $GUI_AST_WMISource = GUICtrlCreateButton("WMISource", 140, 100, 70, 20)
    Global $GUI_AST_Open = GUICtrlCreateButton($strCtrlOpen, 220, 100, 60, 20)
    Global $GUI_AST_Save = GUICtrlCreateButton($strCtrlSave, 290, 100, 60, 20)
    Global $GUI_AST_Quit = GUICtrlCreateButton($strCtrlQuit, 360, 100, 60, 20)
    Global $GUI_AST_OptionGroup = GUICtrlCreateGroup($strCtrlOutput, 430, 80, 240, 50)
    Global $GUI_AST_RadioDialog = GUICtrlCreateRadio($strCtrlDialog, 440, 100, 60, 20)
    Global $GUI_AST_RadioText = GUICtrlCreateRadio($strCtrlText, 510, 100, 50, 20)
    Global $GUI_AST_RadioHTML = GUICtrlCreateRadio($strCtrlHTML, 570, 100, 50, 20)
    Global $GUI_AST_ScriptCode = GUICtrlCreateEdit($strWait, 20, 140, 640, 390)
    GUISetState()
    GUICtrlSetState($GUI_AST_RadioDialog, $GUI_CHECKED)
    GuiWait(1, $strWait & @CRLF & $strWaitNamespaces)
    LoadWMINamespaces()
    HandleNamespaceChange()

    While 1
       $msg = GUIGetMsg()
       Switch $msg
            Case $GUI_EVENT_CLOSE
             ExitLoop
            Case $GUI_AST_Quit
             ExitLoop
            Case $GUI_WMI_Namespace
             GuiWait(1, $strWait)
             HandleNameSpaceChange()
            Case $GUI_WMI_Classes
             ComposeCode()
            Case $GUI_WMI_ClassHelp
             ShellExecute("http://msdn.microsoft.com/en-us/library/aa394554%28v=VS.85%29.aspx")
            Case $GUI_AST_Run
             RunScript()
            Case $GUI_AST_Save
             SaveScript()
            Case $GUI_AST_Open
             OpenScript()
            Case $GUI_AST_CIMv2
             GUICtrlSetData($GUI_AST_ScriptCode, $strWait)
             SetNamespaceToCIMV2()
             HandleNameSpaceChange()
            Case $GUI_AST_WMISource
             SetWMIRepository()
             GUICtrlSetData($GUI_AST_ScriptCode, $strWait)
             HandleNamespaceChange()
            Case $GUI_AST_RadioDialog Or $GUI_AST_RadioText Or $GUI_AST_RadioHTML
             HandleOutputChange()
        EndSwitch
    WEnd

    GUIDelete()
    Exit

    Func LoadWMINamespaces()
        Local $strCsvListOfNamespaces = ""
       Local $strNameSpacesCombo = ""
        GUICtrlSetData($GUI_AST_ScriptCode, "", "")
       GUICtrlSetData($GUI_AST_ScriptCode, $strWait & @CRLF & $strWaitNamespaces)
        EnumNameSpaces("root", $strCsvListOfNamespaces)
        Local $arrNamespaces = StringSplit($strCsvListOfNamespaces, ",")
        For $strNamespace In $arrNamespaces
          $strNameSpacesCombo = $strNameSpacesCombo & "|" & $strNamespace
       Next
        GUICtrlSetData($GUI_WMI_Namespace, $strNameSpacesCombo, "ROOT\CIMV2")
       If GUICtrlRead($GUI_WMI_Namespace) = "" Then GUICtrlSetData($GUI_WMI_Classes, "", "")
    EndFunc

    Func EnumNamespaces($strNamespace, ByRef $tmpCsvListOfNamespaces)
        If $tmpCsvListOfNamespaces = "" Then
          $tmpCsvListOfNamespaces = $strNamespace
       Else
          $tmpCsvListOfNamespaces = $tmpCsvListOfNamespaces & "," & $strNamespace
       EndIf
        Local $objWMIService = ObjGet("winmgmts:\\" & $g_strWMISource & "\" & $strNamespace)
        If Not @error Then
            Local $colNameSpaces = $objWMIService.InstancesOf("__NAMESPACE")
            For $objNameSpace In $colNameSpaces
             EnumNamespaces($strNamespace & "\" & $objNameSpace.Name, $tmpCsvListOfNamespaces)
          Next
       Else
          $tmpCsvListOfNamespaces = ""
       EndIf
    EndFunc

    Func HandleNamespaceChange()
        Local $strSelectedNamespace = GUICtrlRead($GUI_WMI_Namespace)
        GuiWait(1, GUICtrlRead($GUI_AST_ScriptCode) & @CRLF & $strWMIWaitMsg & $strSelectedNamespace)
        $g_strCurrentNamespace = "\" & $strSelectedNamespace
       LoadWMIClasses()
        GuiWait(0, "")
    EndFunc

    Func LoadWMIClasses()
        Const $SORT_KEYS = 1
        Local $objClassDictionary = ObjCreate("Scripting.Dictionary")
       Local $objQualifierDictionary = ObjCreate("Scripting.Dictionary")
        Local $strComputer = "."
       Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & $g_strCurrentNamespace)
        If Not @error Then
            For $objClass In $objWMIService.SubclassesOf()
                For $objQualifier In $objClass.Qualifiers_()
                $objQualifierDictionary.Add(StringLower($objQualifier.Name), "")
             Next
                If $objQualifierDictionary.Exists("dynamic") Then
                    $objClassDictionary.Add($objClass.Path_.Class, "")
                EndIf
                $objQualifierDictionary.RemoveAll
            Next
            $objQualifierDictionary = ""
            If $objClassDictionary.Count Then
                SortDictionary($objClassDictionary, $SORT_KEYS)
                Local $strClassesCombo = "|" & $strSelectWmiClass
                For $strWMIClass In $objClassDictionary
                $strClassesCombo = $strClassesCombo & "|" & $strWMIClass
             Next
                 GUICtrlSetData($GUI_WMI_Classes, $strClassesCombo, $strSelectWmiClass)
          EndIf
       EndIf
        If @error Or $objClassDictionary.Count = 0 Then
          $NoDynamiqueClassError = 1
       EndIf
            $objClassDictionary = ""
    EndFunc

    Func SortDictionary(ByRef $objDict, $intSort)
        Const $dictKey = 1
       Const $dictItem = 2
        Local $strDict[1][3]
       Local $intCount = $objDict.Count
        If $intCount > 1 Then
            ReDim $strDict[$intCount][3]
            Local $i = 0
          For $objKey In $objDict
                $strDict[$i][$dictKey] = String($objKey)
             $strDict[$i][$dictItem] = String($objDict($objKey))
                $i = $i + 1
          Next
            For $i = 0 To ($intCount - 2)
             For $j = $i To ($intCount - 1)
                If $strDict[$i][$intSort] > $strDict[$j][$intSort] Then
                   Local $strKey = $strDict[$i][$dictKey]
                   Local $strItem = $strDict[$i][$dictItem]
                   $strDict[$i][$dictKey] = $strDict[$j][$dictKey]
                   $strDict[$i][$dictItem] = $strDict[$j][$dictItem]
                   $strDict[$j][$dictKey] = $strKey
                   $strDict[$j][$dictItem] = $strItem
                EndIf
             Next
          Next
            $objDict.RemoveAll
            For $i = 0 To ($intCount - 1)
             $objDict.Add($strDict[$i][$dictKey], $strDict[$i][$dictItem])
          Next
        EndIf
    EndFunc

    Func ComposeCode()
        Local $objClass = ""
       Local $strSelectedClass = GUICtrlRead($GUI_WMI_Classes)
       If $strSelectedClass <> $strSelectWmiClass Then
            Local $bHasDates = False
          Local $strHeaderStart = Chr(34)
          Local $strRowStart = Chr(34)
          Local $strColumnSeparator = ": "
          Local $strRowEnd = " & @CRLF"
            Local $strComputerCommand = "$strComputer = " & Chr(34) & $g_strWMISource & Chr(34)
          Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & $g_strCurrentNamespace)
          $objClass = $objWMIService.Get($strSelectedClass)
            If IsObj($objClass) Then
                Local $strScriptCode = ""
             $strScriptCode = $strScriptCode & $GeneratedBy & @CRLF & @CRLF
             $strScriptCode = $strScriptCode & "$wbemFlagReturnImmediately = 0x10" & @CRLF
             $strScriptCode = $strScriptCode & "$wbemFlagForwardOnly = 0x20" & @CRLF
             $strScriptCode = $strScriptCode & '$colItems = ""' & @CRLF
             $strScriptCode = $strScriptCode & $strComputerCommand & @CRLF & @CRLF
             $strScriptCode = $strScriptCode & '$OutputTitle = ""' & @CRLF
             $strScriptCode = $strScriptCode & '$Output = ""' & @CRLF
                If $g_strOutputFormat = "HTML" Then
                $strScriptCode = $strScriptCode & "$Output = $Output & '<html><head><title>" & $HtmlOutput & "</title></head><body> " & _
                "<style>table {font-size: 10pt; font-family: arial;} th {background-color: buttonface; font-decoration: bold;} " & _
                "</style><table BORDER=" & Chr(34) & "1" & Chr(34) & "><tr><th>" & $strProperty & "</th><th>" & $StrValue & "</th></tr>'" & @CRLF
                $strRowStart = Chr(34) & "<tr><td>"
                $strHeaderStart = "'<tr bgcolor=" & Chr(34) & "yellow" & Chr(34) & "><td>' & " & Chr(34)
                $strColumnSeparator = "</td><td>&nbsp;"
                $strRowEnd = " & " & Chr(34) & "</td></tr>" & Chr(34) & " & @CRLF"
             EndIf
                $strScriptCode = $strScriptCode & "$OutputTitle &= " & $strHeaderStart & "Computer" & $strColumnSeparator & Chr(34) & " & $strComputer " & $strRowEnd & @CRLF
                If $g_strOutputFormat = "Dialog" Then
                $strScriptCode = $strScriptCode & "$OutputTitle &= " & Chr(34) & "==========================================" & Chr(34) & $strRowEnd & @CRLF
             EndIf
                $strScriptCode = $strScriptCode & "$objWMIService = ObjGet(" & Chr(34) & "winmgmts:\\" & Chr(34) & " & $strComputer & " & Chr(34) & $g_strCurrentNamespace & Chr(34) & ")" & @CRLF
             $strScriptCode = $strScriptCode & "$colItems = $objWMIService.ExecQuery(" & Chr(34) & "SELECT * FROM " & $strSelectedClass & Chr(34) & ", " & Chr(34) & "WQL" & Chr(34) & ", _" & @CRLF
             $strScriptCode = $strScriptCode & "                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)" & @CRLF & @CRLF
             $strScriptCode = $strScriptCode & "If IsObj($colItems) then" & @CRLF
             $strScriptCode = $strScriptCode & "  Local $Object_Flag = 0" & @CRLF
                $strScriptCode = $strScriptCode & "  For $objItem In $colItems" & @CRLF
             $strScriptCode = $strScriptCode & "      $Object_Flag = 1" & @CRLF
                For $objProperty In $objClass.Properties_()
                    If $objProperty.IsArray = True Then
                   $strScriptCode = $strScriptCode & "      $str" & $objProperty.Name & " = $objItem." & $objProperty.Name & "(0)" & @CRLF
                   $strScriptCode = $strScriptCode & "      $Output &= " & $strRowStart & $objProperty.Name & $strColumnSeparator & Chr(34) & " & $str" & $objProperty.Name & $strRowEnd & @CRLF
                ElseIf $objProperty.CIMTYPE = 101 Then
                   $bHasDates = True
                   $strScriptCode = $strScriptCode & "      $Output &= " & $strRowStart & $objProperty.Name & $strColumnSeparator & Chr(34) & " & WMIDateStringToDate($objItem." & $objProperty.Name & ")" & $strRowEnd & @CRLF
                Else
                   $strScriptCode = $strScriptCode & "      $Output &= " & $strRowStart & $objProperty.Name & $strColumnSeparator & Chr(34) & " & $objItem." & $objProperty.Name & $strRowEnd & @CRLF
                EndIf
             Next
                If $g_strOutputFormat = "Dialog" Then
                $strScriptCode = $strScriptCode & '      if Msgbox(1,"' & $TitleWMIOutput & '",$Output) = 2 then ExitLoop' & @CRLF
                $strScriptCode = $strScriptCode & '      $Output=""' & @CRLF
             EndIf
             $strScriptCode = $strScriptCode & '  Next' & @CRLF
             $strScriptCode = $strScriptCode & '  If $Object_Flag = 0 Then Msgbox(1,"' & $TitleWMIOutput & '",$OutputTitle)' & @CRLF
                If $g_strOutputFormat = "Text" Then
                $strScriptCode = $strScriptCode & '  ConsoleWrite($Output)' & @CRLF
                $strScriptCode = $strScriptCode & '  FileWrite(@TempDir & "\' & $strSelectedClass & '.TXT", $Output )' & @CRLF
                $strScriptCode = $strScriptCode & '  Run(@Comspec & " /c start " & @TempDir & "\' & $strSelectedClass & '.TXT" )' & @CRLF
             ElseIf $g_strOutputFormat = "HTML" Then
                $strScriptCode = $strScriptCode & '  FileWrite(@TempDir & "\' & $strSelectedClass & '.HTML", $Output )' & @CRLF
                $strScriptCode = $strScriptCode & '  Run(@Comspec & " /c start " & @TempDir & "\' & $strSelectedClass & '.HTML" )' & @CRLF
             EndIf
             $strScriptCode = $strScriptCode & "Else" & @CRLF
             $strScriptCode = $strScriptCode & '  Msgbox(0,"' & $TitleWMIOutput & '","' & $strWMIOutput & '" & ' & Chr(34) & $strSelectedClass & Chr(34) & ' )' & @CRLF
                $strScriptCode = $strScriptCode & "Endif" & @CRLF
             $strScriptCode = $strScriptCode & @CRLF & @CRLF
                If $bHasDates Then
                $strScriptCode = $strScriptCode & "Func WMIDateStringToDate($dtmDate)" & @CRLF
                $strScriptCode = $strScriptCode & Chr(9) & "Return (StringMid($dtmDate, 5, 2) & ""/"" & _" & @CRLF
                $strScriptCode = $strScriptCode & Chr(9) & "StringMid($dtmDate, 7, 2) & ""/"" & StringLeft($dtmDate, 4) _" & @CRLF
                $strScriptCode = $strScriptCode & Chr(9) & "& "" "" & StringMid($dtmDate, 9, 2) & "":"" & StringMid($dtmDate, 11, 2) & "":"" & StringMid($dtmDate,13, 2))" & @CRLF
                $strScriptCode = $strScriptCode & "EndFunc"
             EndIf
          Else
             $strScriptCode = $ClassError & $g_strCurrentNamespace & "\" & $strSelectedClass
          EndIf
            GUICtrlSetData($GUI_AST_ScriptCode, $strScriptCode)
          GUICtrlSetState($GUI_AST_Run, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_Save, $GUI_ENABLE)
        Else
           GUICtrlSetState($GUI_AST_Run, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Save, $GUI_DISABLE)
       EndIf
    EndFunc

    Func RunScript()
       Local $strTmpName = @TempDir & "\temp_script.au3"
        If FileExists($strTmpName) Then FileDelete($strTmpName)
        FileWrite($strTmpName, GUICtrlRead($GUI_AST_ScriptCode))
        Local $strCmdLine = @AutoItExe & " /AutoIt3ExecuteScript " & $strTmpName ;  ChrisL Fix
        RunWait($strCmdLine)
        FileDelete($strTmpName)
    EndFunc

    Func SaveScript()
        Local $strTmpName = FileSaveDialog($SaveScript, @DesktopDir, "AutoIt3 Scripts (*.au3)", 16, GUICtrlRead($GUI_WMI_Classes), $GUI_Main)
        If Not @error And $strTmpName <> "" Then
          If StringRight($strTmpName, 4) <> ".AU3" Then $strTmpName = $strTmpName & ".AU3"
          If FileExists($strTmpName) Then FileDelete($strTmpName)
          FileWrite($strTmpName, GUICtrlRead($GUI_AST_ScriptCode))
       EndIf
    EndFunc

    Func OpenScript()
        Local $strTmpName = FileOpenDialog("Open Script", @DesktopDir, "AutoIt3 Scripts (*.au3)", Default, "", $GUI_Main)
        If Not @error And $strTmpName <> "" Then
          If FileExists($strTmpName) Then
             GUICtrlSetData($GUI_AST_ScriptCode, FileRead($strTmpName, FileGetSize($strTmpName)))
          EndIf
       EndIf
    EndFunc

    Func SetNamespaceToCIMV2()
       If StringUpper(GUICtrlRead($GUI_WMI_Namespace)) <> "ROOT\CIMV2" Then
          GUICtrlSetData($GUI_WMI_Namespace, "ROOT\CIMV2", "ROOT\CIMV2")
          HandleNamespaceChange()
       EndIf
    EndFunc

    Func SetWMIRepository()
        Local $strWMISourceName = InputBox($SetWMI_RS, $CompWMI_Rs, $g_strWMISource, Default, Default, Default, Default, Default, Default, $GUI_Main)
       If $strWMISourceName <> "" Then
        GuiWait(1, "")
          $g_strWMISource = StringStripWS($strWMISourceName, 1 + 2)
          LoadWMINamespaces()
       EndIf
       GuiWait(0, "")
    EndFunc

    Func HandleOutputChange()
        Local $ChosenFormat = $g_strOutputFormat
       If GUICtrlRead($GUI_AST_RadioDialog) = $GUI_CHECKED Then $ChosenFormat = "Dialog"
       If GUICtrlRead($GUI_AST_RadioText) = $GUI_CHECKED Then $ChosenFormat = "Text"
       If GUICtrlRead($GUI_AST_RadioHTML) = $GUI_CHECKED Then $ChosenFormat = "HTML"
       If $ChosenFormat <> $g_strOutputFormat Then
          $g_strOutputFormat = $ChosenFormat
          ComposeCode()
       EndIf
    EndFunc

    Func GuiWait($szFlag, $StrMessage)
       If $szFlag = 1 Then
          GUISetCursor(15, 1, $GUI_Main)
          GUICtrlSetState($GUI_WMI_Namespace, $GUI_DISABLE)
          GUICtrlSetState($GUI_WMI_Classes, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Run, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_CIMv2, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_WMISource, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Open, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Save, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Quit, $GUI_DISABLE)
            GUICtrlSetData($GUI_AST_ScriptCode, "", "")
          GUICtrlSetData($GUI_AST_ScriptCode, $StrMessage)
       Else
          GUICtrlSetData($GUI_AST_ScriptCode, "", $StrMessage)
            GUICtrlSetState($GUI_WMI_Classes, $GUI_ENABLE)
          GUICtrlSetState($GUI_WMI_Namespace, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_CIMv2, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_WMISource, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_Open, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_Quit, $GUI_ENABLE)
          GUISetCursor(2, 1, $GUI_Main)
       EndIf
        If $NoDynamiqueClassError = 1 Then
          GUICtrlSetData($GUI_WMI_Classes, "", "")
          GUICtrlSetData($GUI_AST_ScriptCode, $NoDynamiqueClass, "")
          $NoDynamiqueClassError = 0
       EndIf
    EndFunc

    Func _English()
       $strAppTitle = "AutoIt ScriptOMatic Tool"
       $strCtrlWMINameSpace = "WMI Namespace"
       $strCtrlWMIClass = "WMI Class"
       $strCtrlRun = "Run"
       $strCtrlOpen = "Open"
       $strCtrlSave = "Save"
       $strCtrlQuit = "Quit"
       $strCtrlOutput = "Output"
       $strCtrlDialog = "Dialog"
       $strCtrlText = "Text"
       $strCtrlHTML = "HTML"
       $strWait = "One moment..."
        $strWaitNamespaces = "Please wait, Loading WMI Namespaces"
       $strWMIWaitMsg = "Please wait, trying to load WMI Classes in namespace "
       $strSelectWmiClass = "Select a WMI class"
       $strClassHelpTip = "WMI Classes on Microsoft site"
       $NoDynamiqueClass = "No dynamic classes found in current namespace." & @CRLF & "Select a different namespace."
       $ClassError = "Error: No Class properties found for "
       $GeneratedBy = "; Generated by AutoIt ScriptOMatic"
       $SetWMI_RS = "Set WMI Repository Source"
       $CompWMI_Rs = "Please enter the computer whose WMI repository you want to read from: "
       $HtmlOutput = "ScriptOMatic HTML Output"
       $TitleWMIOutput = "WMI Output"
       $strWMIOutput = "No WMI Objects Found for class: "
       $SaveScript = "Save Script"
       $strProperty = " Property "
       $StrValue = " Value "
    EndFunc

    Func _French()
       $strAppTitle = "Outil AutoIt ScriptOMatic"
       $strCtrlWMINameSpace = "Espaces de Nom WMI"
       $strCtrlWMIClass = "Classes WMI"
       $strCtrlRun = "Lancer"
       $strCtrlOpen = "Ouvrir"
       $strCtrlSave = "Sauver"
       $strCtrlQuit = "Quitter"
       $strCtrlOutput = "Sortie"
       $strCtrlDialog = "Dialogue"
       $strCtrlText = "Texte"
       $strCtrlHTML = "HTML"
       $strWait = "Veuillez patienter un moment SVP ..."
        $strWaitNamespaces = "Chargement des espaces de nom "
       $strWMIWaitMsg = "Chargement des Classes WMI dans l'espace de nom "
       $strSelectWmiClass = "S้lectionnez une Classe WMI"
       $strClassHelpTip = "WMI Classes sur le site Microsoft"
       $NoDynamiqueClass = "Aucune Classes dynamiques trouv้e dans cet espace de nom." & @CRLF & "S้lectionnez un espace de nom diff้rent."
       $ClassError = "Erreur : Aucune propri้t้s de Classe trouv้e pour "
       $GeneratedBy = ";G้n้r้ par AutoIt ScriptOMatic"
       $SetWMI_RS = "Source de D้p๔t WMI"
       $CompWMI_Rs = "Veuillez entrer le nom de l'ordinateur source de D้p๔t WMI que vous voulez lire (localhost par d้faut) : "
       $HtmlOutput = "Sortie ScriptOMatic HTML"
       $TitleWMIOutput = "Sortie WMI"
       $strWMIOutput = "Aucun objets WMI trouv้s pour la Classe :"
       $SaveScript = "Sauver le script"
       $strProperty = " Propri้t้(s) "
       $StrValue = " Valeur(s) "
    EndFunc
    aut
    aut
    PSsix Powerful Scripting Class
    PSsix Powerful Scripting Class


    PSsix Game Coder
    จำนวนข้อความ : 472
    ความนิยม : 126
    เข้าร่วมเมื่อ : 24/07/2010

    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty Re: ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ

    ตั้งหัวข้อ by aut 03/05/11, 10:37 am

    อานนี้มัวจัดเขียนหลอกห้ายคนเข้าใจว่ามานทำได้ มัวอย่างเด๋วเลยแน่จิงทำได้ย่างปากว่าทำโปรแกรมเลียนแบบ PSsix NetMeter มาให้ดูเลยไม่ต้องเอาโค้ดมาเอาแค่ตัวโปรแกรมก็พอนะบอกให้เลยมานทำไม่ได้อ่านะ ถามมานดิ WMI คือรัย ร้อยเปอร์เซนตอบมามัวแน่นอนคับ

    sak20102005 พิมพ์ว่า:WMI Code Creator:Download คลิ๊กที่นี่

    ท่านผู้ถามคงคิดในใจกับผมว่า.. เอ๊ะ! ในเมื่อลงโปรแกรมให้ดาวน์โหลดแล้ว ทำไม? ไม่บอกวิธีใช้งานและวิธีการนำไปประยุกต์ใช้ด้วย จริงๆแล้วผมเคยลงบทความเกี่ยวกับ WMI ไว้ แต่ไม่ใช่ที่บอร์ดนี้ ลงเป็นโค๊ดสำเร็จรูปไว้ให้เท่านั้น แต่ยังไม่ได้แนะนำวิธีใช้งานโปรแกรม ก็เลยถือโอกาสแนะนำให้เล็กๆน้อยๆเท่าที่รู้ ผมจะพยายามแนะนำวิธีหาปลา จะไม่ค่อยอยากหาปลามาแจก
    ซึ่งหมายถึง แนะนำให้พอที่จะใช้งานโปรแกรมได้ จากนั้นก็นำไปประยุกต์ใช้งานกันเอง ใครทำได้หรือไม่ได้
    ขึ้นอยู่กับ การฝึกฝนค้นคิดของบุคคลนั้นๆ ..ถ้าเอาจริง.. รับรองสามารถเข้าไปล้วงลึกถึงตับไตใส้พุงของวินโดว์ได้อย่างสบาย.
    ---------------------------------------------------------------------------------------------
    โปรแกรมนี้ ..โค๊ดคำสั่งที่เขียนออกมาจะอยู่ในรูปไฟล์สกุล *.vbs (Visual Basic Script)
    ต้องใช้ความสามารถของตนเอง นำมาเขียนดัดแปลงให้เป็นไฟล์สกุล *.au3
    ซึ่งก็ไม่ยากเย็นอะไร เพราะ AutoIt เป็นโปรแกรมอัจฉริยะ สามารถนำไปเขียนดัดแปลงให้เข้ากับภาษาอื่นๆได้
    อย่า่งเช่น AutoitX3 เป็นต้น.
    -----------------------------------------------------------------------------------------------------------------
    โดยปกติแล้ว สิ่งที่เราต้องการ จากการเขียนคำสั่ง คือ ค่าการแสดงผลที่ออกมาจาก Output โดยมี Input เป็นตัวช่วย
    ค่าต่างๆที่ได้ยังแบ่งออกเป็น2แบบคือ แบบคงที่ และแบบไม่คงที่ มีการเปลี่ยนแปลงอยู่ตลอดเวลา
    ถ้ามีสิ่งใด?มากระตุ้น (Trigger) คราวหน้ามาดูกันว่า จะนำโค๊ดที่ได้จากโปรแกรมนี้ ไปประยุกต์ใช้งานยังไง?
    --------------------------------------------------------------------------------------------------------------------
    AutoIt ScriptOMatic Tool

    Code:

    #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #RequireAdmin
    #include <GuiConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    Global $strAppTitle, $strCtrlWMINameSpace, $strCtrlWMIClass, $strCtrlRun, $strCtrlOpen, $strCtrlSave
    Global $strCtrlQuit, $strCtrlOutput, $strCtrlDialog, $strCtrlText, $strCtrlHTML, $strWait, $strClassHelpTip
    Global $strWaitNamespaces, $strWMIWaitMsg, $strSelectWmiClass, $NoDynamiqueClass, $ClassError, $GeneratedBy
    Global $SetWMI_RS, $CompWMI_Rs, $HtmlOutput, $TitleWMIOutput, $strWMIOutput, $SaveScript, $strProperty, $StrValue
    Global $msg, $szFlag, $StrMessage, $NoDynamiqueClassError = 0
    Global $g_strCurrentNamespace = "\root\CIMV2"
    Global $g_iCurrentNamespaceIndex = 0
    Global $g_strWMISource = "localhost"
    Global $g_strOutputFormat = "Dialog"
    If StringInStr("040c, 080c, 0c0c, 100c, 140c, 180c", @OSLang) Then
       _French()
    Else
       _English()
    EndIf
    Global $GUI_Main = GUICreate($strAppTitle, 684, 561, (@DesktopWidth - 684) / 2, (@DesktopHeight - 561) / 2)
    Global $GUI_AST_MainGroup = GUICtrlCreateGroup("", 10, 10, 660, 530)
    Global $GUI_WMI_NamespaceLabel = GUICtrlCreateLabel($strCtrlWMINameSpace, 20, 30, 150, 20)
    Global $GUI_WMI_Namespace = GUICtrlCreateCombo("WMI_Namespaces", 20, 50, 280, 80, BitOR(0x1, 0x2, 0x40, 0x00200000))
    Global $GUI_WMI_ClassLabel = GUICtrlCreateLabel($strCtrlWMIClass, 320, 30, 240, 20)
    Global $GUI_WMI_Classes = GUICtrlCreateCombo("WMI_Classes", 320, 50, 340, 80, BitOR(0x1, 0x2, 0x40, 0x00200000))
    Global $GUI_AST_ButtonGroup = GUICtrlCreateGroup("", 10, 80, 660, 50)
    Global $GUI_WMI_ClassHelp = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -211, 635, 18, 32, 32)
    GUICtrlSetTip(-1, $strClassHelpTip)
    Global $GUI_AST_Run = GUICtrlCreateButton($strCtrlRun, 20, 100, 50, 20)
    Global $GUI_AST_CIMv2 = GUICtrlCreateButton("CIMv2", 80, 100, 50, 20)
    Global $GUI_AST_WMISource = GUICtrlCreateButton("WMISource", 140, 100, 70, 20)
    Global $GUI_AST_Open = GUICtrlCreateButton($strCtrlOpen, 220, 100, 60, 20)
    Global $GUI_AST_Save = GUICtrlCreateButton($strCtrlSave, 290, 100, 60, 20)
    Global $GUI_AST_Quit = GUICtrlCreateButton($strCtrlQuit, 360, 100, 60, 20)
    Global $GUI_AST_OptionGroup = GUICtrlCreateGroup($strCtrlOutput, 430, 80, 240, 50)
    Global $GUI_AST_RadioDialog = GUICtrlCreateRadio($strCtrlDialog, 440, 100, 60, 20)
    Global $GUI_AST_RadioText = GUICtrlCreateRadio($strCtrlText, 510, 100, 50, 20)
    Global $GUI_AST_RadioHTML = GUICtrlCreateRadio($strCtrlHTML, 570, 100, 50, 20)
    Global $GUI_AST_ScriptCode = GUICtrlCreateEdit($strWait, 20, 140, 640, 390)
    GUISetState()
    GUICtrlSetState($GUI_AST_RadioDialog, $GUI_CHECKED)
    GuiWait(1, $strWait & @CRLF & $strWaitNamespaces)
    LoadWMINamespaces()
    HandleNamespaceChange()

    While 1
       $msg = GUIGetMsg()
       Switch $msg
            Case $GUI_EVENT_CLOSE
             ExitLoop
            Case $GUI_AST_Quit
             ExitLoop
            Case $GUI_WMI_Namespace
             GuiWait(1, $strWait)
             HandleNameSpaceChange()
            Case $GUI_WMI_Classes
             ComposeCode()
            Case $GUI_WMI_ClassHelp
             ShellExecute("http://msdn.microsoft.com/en-us/library/aa394554%28v=VS.85%29.aspx")
            Case $GUI_AST_Run
             RunScript()
            Case $GUI_AST_Save
             SaveScript()
            Case $GUI_AST_Open
             OpenScript()
            Case $GUI_AST_CIMv2
             GUICtrlSetData($GUI_AST_ScriptCode, $strWait)
             SetNamespaceToCIMV2()
             HandleNameSpaceChange()
            Case $GUI_AST_WMISource
             SetWMIRepository()
             GUICtrlSetData($GUI_AST_ScriptCode, $strWait)
             HandleNamespaceChange()
            Case $GUI_AST_RadioDialog Or $GUI_AST_RadioText Or $GUI_AST_RadioHTML
             HandleOutputChange()
        EndSwitch
    WEnd

    GUIDelete()
    Exit

    Func LoadWMINamespaces()
        Local $strCsvListOfNamespaces = ""
       Local $strNameSpacesCombo = ""
        GUICtrlSetData($GUI_AST_ScriptCode, "", "")
       GUICtrlSetData($GUI_AST_ScriptCode, $strWait & @CRLF & $strWaitNamespaces)
        EnumNameSpaces("root", $strCsvListOfNamespaces)
        Local $arrNamespaces = StringSplit($strCsvListOfNamespaces, ",")
        For $strNamespace In $arrNamespaces
          $strNameSpacesCombo = $strNameSpacesCombo & "|" & $strNamespace
       Next
        GUICtrlSetData($GUI_WMI_Namespace, $strNameSpacesCombo, "ROOT\CIMV2")
       If GUICtrlRead($GUI_WMI_Namespace) = "" Then GUICtrlSetData($GUI_WMI_Classes, "", "")
    EndFunc

    Func EnumNamespaces($strNamespace, ByRef $tmpCsvListOfNamespaces)
        If $tmpCsvListOfNamespaces = "" Then
          $tmpCsvListOfNamespaces = $strNamespace
       Else
          $tmpCsvListOfNamespaces = $tmpCsvListOfNamespaces & "," & $strNamespace
       EndIf
        Local $objWMIService = ObjGet("winmgmts:\\" & $g_strWMISource & "\" & $strNamespace)
        If Not @error Then
            Local $colNameSpaces = $objWMIService.InstancesOf("__NAMESPACE")
            For $objNameSpace In $colNameSpaces
             EnumNamespaces($strNamespace & "\" & $objNameSpace.Name, $tmpCsvListOfNamespaces)
          Next
       Else
          $tmpCsvListOfNamespaces = ""
       EndIf
    EndFunc

    Func HandleNamespaceChange()
        Local $strSelectedNamespace = GUICtrlRead($GUI_WMI_Namespace)
        GuiWait(1, GUICtrlRead($GUI_AST_ScriptCode) & @CRLF & $strWMIWaitMsg & $strSelectedNamespace)
        $g_strCurrentNamespace = "\" & $strSelectedNamespace
       LoadWMIClasses()
        GuiWait(0, "")
    EndFunc

    Func LoadWMIClasses()
        Const $SORT_KEYS = 1
        Local $objClassDictionary = ObjCreate("Scripting.Dictionary")
       Local $objQualifierDictionary = ObjCreate("Scripting.Dictionary")
        Local $strComputer = "."
       Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & $g_strCurrentNamespace)
        If Not @error Then
            For $objClass In $objWMIService.SubclassesOf()
                For $objQualifier In $objClass.Qualifiers_()
                $objQualifierDictionary.Add(StringLower($objQualifier.Name), "")
             Next
                If $objQualifierDictionary.Exists("dynamic") Then
                    $objClassDictionary.Add($objClass.Path_.Class, "")
                EndIf
                $objQualifierDictionary.RemoveAll
            Next
            $objQualifierDictionary = ""
            If $objClassDictionary.Count Then
                SortDictionary($objClassDictionary, $SORT_KEYS)
                Local $strClassesCombo = "|" & $strSelectWmiClass
                For $strWMIClass In $objClassDictionary
                $strClassesCombo = $strClassesCombo & "|" & $strWMIClass
             Next
                 GUICtrlSetData($GUI_WMI_Classes, $strClassesCombo, $strSelectWmiClass)
          EndIf
       EndIf
        If @error Or $objClassDictionary.Count = 0 Then
          $NoDynamiqueClassError = 1
       EndIf
            $objClassDictionary = ""
    EndFunc

    Func SortDictionary(ByRef $objDict, $intSort)
        Const $dictKey = 1
       Const $dictItem = 2
        Local $strDict[1][3]
       Local $intCount = $objDict.Count
        If $intCount > 1 Then
            ReDim $strDict[$intCount][3]
            Local $i = 0
          For $objKey In $objDict
                $strDict[$i][$dictKey] = String($objKey)
             $strDict[$i][$dictItem] = String($objDict($objKey))
                $i = $i + 1
          Next
            For $i = 0 To ($intCount - 2)
             For $j = $i To ($intCount - 1)
                If $strDict[$i][$intSort] > $strDict[$j][$intSort] Then
                   Local $strKey = $strDict[$i][$dictKey]
                   Local $strItem = $strDict[$i][$dictItem]
                   $strDict[$i][$dictKey] = $strDict[$j][$dictKey]
                   $strDict[$i][$dictItem] = $strDict[$j][$dictItem]
                   $strDict[$j][$dictKey] = $strKey
                   $strDict[$j][$dictItem] = $strItem
                EndIf
             Next
          Next
            $objDict.RemoveAll
            For $i = 0 To ($intCount - 1)
             $objDict.Add($strDict[$i][$dictKey], $strDict[$i][$dictItem])
          Next
        EndIf
    EndFunc

    Func ComposeCode()
        Local $objClass = ""
       Local $strSelectedClass = GUICtrlRead($GUI_WMI_Classes)
       If $strSelectedClass <> $strSelectWmiClass Then
            Local $bHasDates = False
          Local $strHeaderStart = Chr(34)
          Local $strRowStart = Chr(34)
          Local $strColumnSeparator = ": "
          Local $strRowEnd = " & @CRLF"
            Local $strComputerCommand = "$strComputer = " & Chr(34) & $g_strWMISource & Chr(34)
          Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & $g_strCurrentNamespace)
          $objClass = $objWMIService.Get($strSelectedClass)
            If IsObj($objClass) Then
                Local $strScriptCode = ""
             $strScriptCode = $strScriptCode & $GeneratedBy & @CRLF & @CRLF
             $strScriptCode = $strScriptCode & "$wbemFlagReturnImmediately = 0x10" & @CRLF
             $strScriptCode = $strScriptCode & "$wbemFlagForwardOnly = 0x20" & @CRLF
             $strScriptCode = $strScriptCode & '$colItems = ""' & @CRLF
             $strScriptCode = $strScriptCode & $strComputerCommand & @CRLF & @CRLF
             $strScriptCode = $strScriptCode & '$OutputTitle = ""' & @CRLF
             $strScriptCode = $strScriptCode & '$Output = ""' & @CRLF
                If $g_strOutputFormat = "HTML" Then
                $strScriptCode = $strScriptCode & "$Output = $Output & '<html><head><title>" & $HtmlOutput & "</title></head><body> " & _
                "<style>table {font-size: 10pt; font-family: arial;} th {background-color: buttonface; font-decoration: bold;} " & _
                "</style><table BORDER=" & Chr(34) & "1" & Chr(34) & "><tr><th>" & $strProperty & "</th><th>" & $StrValue & "</th></tr>'" & @CRLF
                $strRowStart = Chr(34) & "<tr><td>"
                $strHeaderStart = "'<tr bgcolor=" & Chr(34) & "yellow" & Chr(34) & "><td>' & " & Chr(34)
                $strColumnSeparator = "</td><td>&nbsp;"
                $strRowEnd = " & " & Chr(34) & "</td></tr>" & Chr(34) & " & @CRLF"
             EndIf
                $strScriptCode = $strScriptCode & "$OutputTitle &= " & $strHeaderStart & "Computer" & $strColumnSeparator & Chr(34) & " & $strComputer " & $strRowEnd & @CRLF
                If $g_strOutputFormat = "Dialog" Then
                $strScriptCode = $strScriptCode & "$OutputTitle &= " & Chr(34) & "==========================================" & Chr(34) & $strRowEnd & @CRLF
             EndIf
                $strScriptCode = $strScriptCode & "$objWMIService = ObjGet(" & Chr(34) & "winmgmts:\\" & Chr(34) & " & $strComputer & " & Chr(34) & $g_strCurrentNamespace & Chr(34) & ")" & @CRLF
             $strScriptCode = $strScriptCode & "$colItems = $objWMIService.ExecQuery(" & Chr(34) & "SELECT * FROM " & $strSelectedClass & Chr(34) & ", " & Chr(34) & "WQL" & Chr(34) & ", _" & @CRLF
             $strScriptCode = $strScriptCode & "                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)" & @CRLF & @CRLF
             $strScriptCode = $strScriptCode & "If IsObj($colItems) then" & @CRLF
             $strScriptCode = $strScriptCode & "  Local $Object_Flag = 0" & @CRLF
                $strScriptCode = $strScriptCode & "  For $objItem In $colItems" & @CRLF
             $strScriptCode = $strScriptCode & "      $Object_Flag = 1" & @CRLF
                For $objProperty In $objClass.Properties_()
                    If $objProperty.IsArray = True Then
                   $strScriptCode = $strScriptCode & "      $str" & $objProperty.Name & " = $objItem." & $objProperty.Name & "(0)" & @CRLF
                   $strScriptCode = $strScriptCode & "      $Output &= " & $strRowStart & $objProperty.Name & $strColumnSeparator & Chr(34) & " & $str" & $objProperty.Name & $strRowEnd & @CRLF
                ElseIf $objProperty.CIMTYPE = 101 Then
                   $bHasDates = True
                   $strScriptCode = $strScriptCode & "      $Output &= " & $strRowStart & $objProperty.Name & $strColumnSeparator & Chr(34) & " & WMIDateStringToDate($objItem." & $objProperty.Name & ")" & $strRowEnd & @CRLF
                Else
                   $strScriptCode = $strScriptCode & "      $Output &= " & $strRowStart & $objProperty.Name & $strColumnSeparator & Chr(34) & " & $objItem." & $objProperty.Name & $strRowEnd & @CRLF
                EndIf
             Next
                If $g_strOutputFormat = "Dialog" Then
                $strScriptCode = $strScriptCode & '      if Msgbox(1,"' & $TitleWMIOutput & '",$Output) = 2 then ExitLoop' & @CRLF
                $strScriptCode = $strScriptCode & '      $Output=""' & @CRLF
             EndIf
             $strScriptCode = $strScriptCode & '  Next' & @CRLF
             $strScriptCode = $strScriptCode & '  If $Object_Flag = 0 Then Msgbox(1,"' & $TitleWMIOutput & '",$OutputTitle)' & @CRLF
                If $g_strOutputFormat = "Text" Then
                $strScriptCode = $strScriptCode & '  ConsoleWrite($Output)' & @CRLF
                $strScriptCode = $strScriptCode & '  FileWrite(@TempDir & "\' & $strSelectedClass & '.TXT", $Output )' & @CRLF
                $strScriptCode = $strScriptCode & '  Run(@Comspec & " /c start " & @TempDir & "\' & $strSelectedClass & '.TXT" )' & @CRLF
             ElseIf $g_strOutputFormat = "HTML" Then
                $strScriptCode = $strScriptCode & '  FileWrite(@TempDir & "\' & $strSelectedClass & '.HTML", $Output )' & @CRLF
                $strScriptCode = $strScriptCode & '  Run(@Comspec & " /c start " & @TempDir & "\' & $strSelectedClass & '.HTML" )' & @CRLF
             EndIf
             $strScriptCode = $strScriptCode & "Else" & @CRLF
             $strScriptCode = $strScriptCode & '  Msgbox(0,"' & $TitleWMIOutput & '","' & $strWMIOutput & '" & ' & Chr(34) & $strSelectedClass & Chr(34) & ' )' & @CRLF
                $strScriptCode = $strScriptCode & "Endif" & @CRLF
             $strScriptCode = $strScriptCode & @CRLF & @CRLF
                If $bHasDates Then
                $strScriptCode = $strScriptCode & "Func WMIDateStringToDate($dtmDate)" & @CRLF
                $strScriptCode = $strScriptCode & Chr(9) & "Return (StringMid($dtmDate, 5, 2) & ""/"" & _" & @CRLF
                $strScriptCode = $strScriptCode & Chr(9) & "StringMid($dtmDate, 7, 2) & ""/"" & StringLeft($dtmDate, 4) _" & @CRLF
                $strScriptCode = $strScriptCode & Chr(9) & "& "" "" & StringMid($dtmDate, 9, 2) & "":"" & StringMid($dtmDate, 11, 2) & "":"" & StringMid($dtmDate,13, 2))" & @CRLF
                $strScriptCode = $strScriptCode & "EndFunc"
             EndIf
          Else
             $strScriptCode = $ClassError & $g_strCurrentNamespace & "\" & $strSelectedClass
          EndIf
            GUICtrlSetData($GUI_AST_ScriptCode, $strScriptCode)
          GUICtrlSetState($GUI_AST_Run, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_Save, $GUI_ENABLE)
        Else
           GUICtrlSetState($GUI_AST_Run, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Save, $GUI_DISABLE)
       EndIf
    EndFunc

    Func RunScript()
       Local $strTmpName = @TempDir & "\temp_script.au3"
        If FileExists($strTmpName) Then FileDelete($strTmpName)
        FileWrite($strTmpName, GUICtrlRead($GUI_AST_ScriptCode))
        Local $strCmdLine = @AutoItExe & " /AutoIt3ExecuteScript " & $strTmpName ;  ChrisL Fix
        RunWait($strCmdLine)
        FileDelete($strTmpName)
    EndFunc

    Func SaveScript()
        Local $strTmpName = FileSaveDialog($SaveScript, @DesktopDir, "AutoIt3 Scripts (*.au3)", 16, GUICtrlRead($GUI_WMI_Classes), $GUI_Main)
        If Not @error And $strTmpName <> "" Then
          If StringRight($strTmpName, 4) <> ".AU3" Then $strTmpName = $strTmpName & ".AU3"
          If FileExists($strTmpName) Then FileDelete($strTmpName)
          FileWrite($strTmpName, GUICtrlRead($GUI_AST_ScriptCode))
       EndIf
    EndFunc

    Func OpenScript()
        Local $strTmpName = FileOpenDialog("Open Script", @DesktopDir, "AutoIt3 Scripts (*.au3)", Default, "", $GUI_Main)
        If Not @error And $strTmpName <> "" Then
          If FileExists($strTmpName) Then
             GUICtrlSetData($GUI_AST_ScriptCode, FileRead($strTmpName, FileGetSize($strTmpName)))
          EndIf
       EndIf
    EndFunc

    Func SetNamespaceToCIMV2()
       If StringUpper(GUICtrlRead($GUI_WMI_Namespace)) <> "ROOT\CIMV2" Then
          GUICtrlSetData($GUI_WMI_Namespace, "ROOT\CIMV2", "ROOT\CIMV2")
          HandleNamespaceChange()
       EndIf
    EndFunc

    Func SetWMIRepository()
        Local $strWMISourceName = InputBox($SetWMI_RS, $CompWMI_Rs, $g_strWMISource, Default, Default, Default, Default, Default, Default, $GUI_Main)
       If $strWMISourceName <> "" Then
        GuiWait(1, "")
          $g_strWMISource = StringStripWS($strWMISourceName, 1 + 2)
          LoadWMINamespaces()
       EndIf
       GuiWait(0, "")
    EndFunc

    Func HandleOutputChange()
        Local $ChosenFormat = $g_strOutputFormat
       If GUICtrlRead($GUI_AST_RadioDialog) = $GUI_CHECKED Then $ChosenFormat = "Dialog"
       If GUICtrlRead($GUI_AST_RadioText) = $GUI_CHECKED Then $ChosenFormat = "Text"
       If GUICtrlRead($GUI_AST_RadioHTML) = $GUI_CHECKED Then $ChosenFormat = "HTML"
       If $ChosenFormat <> $g_strOutputFormat Then
          $g_strOutputFormat = $ChosenFormat
          ComposeCode()
       EndIf
    EndFunc

    Func GuiWait($szFlag, $StrMessage)
       If $szFlag = 1 Then
          GUISetCursor(15, 1, $GUI_Main)
          GUICtrlSetState($GUI_WMI_Namespace, $GUI_DISABLE)
          GUICtrlSetState($GUI_WMI_Classes, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Run, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_CIMv2, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_WMISource, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Open, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Save, $GUI_DISABLE)
          GUICtrlSetState($GUI_AST_Quit, $GUI_DISABLE)
            GUICtrlSetData($GUI_AST_ScriptCode, "", "")
          GUICtrlSetData($GUI_AST_ScriptCode, $StrMessage)
       Else
          GUICtrlSetData($GUI_AST_ScriptCode, "", $StrMessage)
            GUICtrlSetState($GUI_WMI_Classes, $GUI_ENABLE)
          GUICtrlSetState($GUI_WMI_Namespace, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_CIMv2, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_WMISource, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_Open, $GUI_ENABLE)
          GUICtrlSetState($GUI_AST_Quit, $GUI_ENABLE)
          GUISetCursor(2, 1, $GUI_Main)
       EndIf
        If $NoDynamiqueClassError = 1 Then
          GUICtrlSetData($GUI_WMI_Classes, "", "")
          GUICtrlSetData($GUI_AST_ScriptCode, $NoDynamiqueClass, "")
          $NoDynamiqueClassError = 0
       EndIf
    EndFunc

    Func _English()
       $strAppTitle = "AutoIt ScriptOMatic Tool"
       $strCtrlWMINameSpace = "WMI Namespace"
       $strCtrlWMIClass = "WMI Class"
       $strCtrlRun = "Run"
       $strCtrlOpen = "Open"
       $strCtrlSave = "Save"
       $strCtrlQuit = "Quit"
       $strCtrlOutput = "Output"
       $strCtrlDialog = "Dialog"
       $strCtrlText = "Text"
       $strCtrlHTML = "HTML"
       $strWait = "One moment..."
        $strWaitNamespaces = "Please wait, Loading WMI Namespaces"
       $strWMIWaitMsg = "Please wait, trying to load WMI Classes in namespace "
       $strSelectWmiClass = "Select a WMI class"
       $strClassHelpTip = "WMI Classes on Microsoft site"
       $NoDynamiqueClass = "No dynamic classes found in current namespace." & @CRLF & "Select a different namespace."
       $ClassError = "Error: No Class properties found for "
       $GeneratedBy = "; Generated by AutoIt ScriptOMatic"
       $SetWMI_RS = "Set WMI Repository Source"
       $CompWMI_Rs = "Please enter the computer whose WMI repository you want to read from: "
       $HtmlOutput = "ScriptOMatic HTML Output"
       $TitleWMIOutput = "WMI Output"
       $strWMIOutput = "No WMI Objects Found for class: "
       $SaveScript = "Save Script"
       $strProperty = " Property "
       $StrValue = " Value "
    EndFunc

    Func _French()
       $strAppTitle = "Outil AutoIt ScriptOMatic"
       $strCtrlWMINameSpace = "Espaces de Nom WMI"
       $strCtrlWMIClass = "Classes WMI"
       $strCtrlRun = "Lancer"
       $strCtrlOpen = "Ouvrir"
       $strCtrlSave = "Sauver"
       $strCtrlQuit = "Quitter"
       $strCtrlOutput = "Sortie"
       $strCtrlDialog = "Dialogue"
       $strCtrlText = "Texte"
       $strCtrlHTML = "HTML"
       $strWait = "Veuillez patienter un moment SVP ..."
        $strWaitNamespaces = "Chargement des espaces de nom "
       $strWMIWaitMsg = "Chargement des Classes WMI dans l'espace de nom "
       $strSelectWmiClass = "S้lectionnez une Classe WMI"
       $strClassHelpTip = "WMI Classes sur le site Microsoft"
       $NoDynamiqueClass = "Aucune Classes dynamiques trouv้e dans cet espace de nom." & @CRLF & "S้lectionnez un espace de nom diff้rent."
       $ClassError = "Erreur : Aucune propri้t้s de Classe trouv้e pour "
       $GeneratedBy = ";G้n้r้ par AutoIt ScriptOMatic"
       $SetWMI_RS = "Source de D้p๔t WMI"
       $CompWMI_Rs = "Veuillez entrer le nom de l'ordinateur source de D้p๔t WMI que vous voulez lire (localhost par d้faut) : "
       $HtmlOutput = "Sortie ScriptOMatic HTML"
       $TitleWMIOutput = "Sortie WMI"
       $strWMIOutput = "Aucun objets WMI trouv้s pour la Classe :"
       $SaveScript = "Sauver le script"
       $strProperty = " Propri้t้(s) "
       $StrValue = " Valeur(s) "
    EndFunc
    sak20102005
    sak20102005
    ระงับสมาชิก
    ระงับสมาชิก


    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty
    จำนวนข้อความ : 96
    ความนิยม : 4
    เข้าร่วมเมื่อ : 07/04/2011

    ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ Empty Re: ขอสคริปที่ใช้วัดความเร็วเน็ตของautoit3หน่อยครับ

    ตั้งหัวข้อ by sak20102005 03/05/11, 08:27 pm

    อานนี้มัวจัดเขียนหลอกห้ายคนเข้าใจว่ามานทำได้ มัวอย่างเด๋วเลยแน่จิงทำได้ย่างปากว่าทำโปรแกรมเลียนแบบ PSsix NetMeter มาให้ดูเลยไม่ต้องเอาโค้ดมาเอาแค่ตัวโปรแกรมก็พอนะบอกให้เลยมานทำไม่ได้อ่านะ ถามมานดิ WMI คือรัย ร้อยเปอร์เซนตอบมามัวแน่นอนคับ

    เขียนด้วยอารมณ์ (ฟิวส์ขาด)

    ยาที่ให้ไว้หมดแล้วเรอะ!?! คลั่งอะไร?ขึ้นมาอีกล่ะ

    ไปดูกระทู้ที่มันตอบผู้อื่่นไว้ มี A<< B แค่เนี๊ย พอเราเข้าไปแจมบ้าง เลยทำให้มันเสียหน้า

    ด้วยความไม่มีน้ำ้ใจของมัน มันแจ้งผู้ดูแลบอร์ด ย้ายคำตอบผมออกเฉยเลย หาว่าไปเกาะมันดัง

    บทความไหนที่มันตอบใครไว้ อย่าได้เข้ายุ่งเชียว โดนแจ้งย้ายคำตอบทันที

    เราจะไม่พูดดีกับนายอีกแล้ว ถ้านายเขียนข้อความในเชิงดูหมิ่นเหยียดหยามเรา โดนสวนกลับตลอด

    ทั้งในกระทู้ที่ตอบปัญหาใครไว้แบบคลุมเครือ โดนสวนหมดไม่เว้น.


      เวลาขณะนี้ 28/04/24, 04:37 pm