Script schritt für schritt "erklären"

  • Hallo Zusammen,

    ich hab hier einen script, der das automatische einfügen von Wlan keys ermöglicht.
    dies funktioniert auch soweit bestens.

    allerdings würde ich dieses script "genau" kennen. in der schule musste ich immer am anfang einer programmiersprache jede zeile kommentieren was die bedeutet bzw macht.
    das würde ich hier auch gerne machen. allerdings bin ich auf dem gebiet noch etwas .. lassen wir das etwas weg .. UNERFAHREN.

    ich weiss das es mühsam ist .. würde mich aber trotzdem freuen wenn mir einer dies kommenteiren könnte.


    Spoiler anzeigen
    [autoit]


    ;*******************************************************************************
    ;variables
    ;*******************************************************************************
    ;parameters file
    Local $iniFile = "autowep.ini"

    [/autoit] [autoit][/autoit] [autoit]

    ;wireless parameters
    Local $WlanSSID = ""
    Local $Wlankey = ""
    Local $UseWPA = ""

    [/autoit] [autoit][/autoit] [autoit]

    ;wizard window title control
    Local $xpsp2resLib = 0
    Local $resource[4]
    Local $wwName = ""

    [/autoit] [autoit][/autoit] [autoit]

    ;System stuff
    Local $wizPID
    Local $handle
    ;*******************************************************************************
    ;GET the Wireless parameters
    ;*******************************************************************************

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    If $CmdLine[0]<2 Then
    If $CmdLine[0] = 1 Then $iniFile = $CmdLine[1]

    [/autoit] [autoit][/autoit] [autoit]

    If Not FileExists($iniFile) Then
    ;MsgBox(0,"Fehler","Ungültige Pfadangabe, Ini-Datei konnte nicht gefunden werden!")
    Exit
    EndIf

    $WlanSSID = IniRead($iniFile, "Wlan", "WlanSSID", "")
    $Wlankey = IniRead($iniFile, "Wlan", "Wlankey", "")
    $UseWPA = IniRead($iniFile, "Wlan", "UseWPA", "")

    [/autoit] [autoit][/autoit] [autoit]

    Else
    $WlanSSID = $CmdLine[1]
    $Wlankey = $CmdLine[2]
    If $CmdLine[0]>2 Then $UseWPA = $CmdLine[3]
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If @error Or Not ($WlanSSID And $Wlankey) Then Exit

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    If $UseWPA <> "yes" And $UseWPA <> "WPA" Then $UseWPA = ""

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;*******************************************************************************
    ;GET the name of the "Wireless Network setup Wizard"
    ;*******************************************************************************
    $xpsp2resLib = DllCall("KERNEL32.dll", "long", "LoadLibrary", "str", "xpsp2res.dll")

    [/autoit] [autoit][/autoit] [autoit]

    If $xpsp2resLib = 0 Then Exit
    If Not @error Then
    $resource = DllCall("user32.dll", "long", "LoadString", "long", $xpsp2resLib[0], "long", 16201, "str", "", "long", 256)
    $wwName = $resource[3]
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;*******************************************************************************
    ;RUN the "Wireless Network setup Wizard", or whatever its exact name is
    ;*******************************************************************************
    $wizPID = Run("rundll32.exe shell32.dll,Control_RunDLL NetSetup.cpl,@0,WNSW", "") ;, @SW_MAXIMIZE)
    If Not $wizPID Then Exit

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    If $wwName Then
    Opt("WinTitleMatchMode", 1)
    WinWait($wwName, $wwName, 5)
    $handle = WinGetHandle($wwName);, $wwName)
    Else
    Opt("WinTitleMatchMode", 4)
    WinWait("classname=#32770", "", 5)
    $handle = WinGetHandle("classname=#32770", "")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If @error Then
    MsgBox(1, "Error", "Der Fehler " & @error & " ist aufgetreten" )
    ProcessClose ( $wizPID )
    WinClose($handle)
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;*******************************************************************************
    ;FILL in the wizard pages
    ;*******************************************************************************
    If Not WinActive($handle) Then WinActivate($handle)
    WinWaitActive($handle)

    [/autoit] [autoit][/autoit] [autoit]

    ControlClick($handle, "", 12324)

    [/autoit] [autoit][/autoit] [autoit]

    While Not (ControlCommand($handle, "", 7423, "IsVisible", "") And _
    ControlCommand($handle, "", 7422, "IsVisible", "") And _
    ControlCommand($handle, "", 7424, "IsVisible", ""))
    WinActivate($handle)

    If ControlCommand($handle, "", 7416, "IsVisible", "") Then
    ControlClick($handle, "", 7416)
    ControlClick($handle, "", 12324)
    EndIf
    WEnd
    ControlSetText($handle, "", 7423, $WlanSSID)
    ControlClick($handle, "", 7422)
    If $UseWPA Then ControlClick($handle, "", 7424)

    ControlClick($handle, "", 12324)

    [/autoit] [autoit][/autoit] [autoit]

    While Not (ControlCommand($handle, "", 7434, "IsVisible", "") And _
    ControlCommand($handle, "", 2007, "IsVisible", "") And _
    ControlCommand($handle, "", 2012, "IsVisible", ""))
    WinActivate($handle)
    WEnd
    ControlClick($handle, "", 7434)
    ControlSetText($handle, "", 2007, $Wlankey)
    ControlSetText($handle, "", 2012, $Wlankey)

    ControlClick($handle, "", 12324)

    ;page 4
    While Not ControlCommand($handle, "", 7442, "IsVisible", "")
    WinActivate($handle)
    WEnd
    ControlClick($handle, "", 7442)

    ControlClick($handle, "", 12324)

    ;final page
    While Not ControlCommand($handle, "", 12325, "IsVisible", "")
    WinActivate($handle)
    WEnd
    ControlClick($handle, "", 12325)

    [/autoit] [autoit][/autoit] [autoit]

    Exit

    [/autoit]

    Edit BugFix: Tags gesetzt

    Auch wenn es ein Skript ist, du bittest um Hilfe - deshalb: Verschoben

  • Hallo.

    Poste bitte mal eine Beispiel "autowep.ini". Dann kann man damit auch besser was anfangen und vielleicht noch erweitern.

    Gruß, Lina.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • Hallo Lina,


    klar bitte:

    [AutoWEP]
    version = 0.0.3b0
    [Wlan]
    WlanSSID = MYWLAN
    Wlankey = XXXXXXXXXXXXXXXXXXXXXX


    grß mari

  • Hallo.

    Habe es mit einem Netzgear WLan Router ausprobiert (Alter cirka 1 Jahr). Bekomme immer die Meldung: Fehler 1 ist aufgetreten.

    Kannst Du die Fehlernummern die möglich sind bitte darstellen, so das man Dir ggf. auch weiter helfen kann? Vielen Dnak.

    Lina

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl

  • Hallo Alina,

    wie meinst du das mit "fehlermeldungen die möglich sind" ?

    Allgemein aufs Wlan bezogen oder aus dem code?

    gruß mari

  • hallo mari.

    ich habe es in diesem fall auf den aktuellen code bezogen.

    gruss, lina.

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    OuBVU5ebLhHu5QvlnAyQB4A7SzBrvWulwL7RLl2BdH5tI6sIYspeMKeXMSXl