Warum erscheint bei MSGBOS nicht der gewählte Hostname?

  • Hallo Zusammen
    Bin der Meinung dass bei der vorletzten Zeile der gewählte Computername erscheinen sollte, bis anhin kommt nur immer die Zahl 0
    Bitte währe froh um tips und Hilfe damit der gewählte name erscheinen würde.

    Danke für Eure Feedback
    MC

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt('MustDeclareVars', 1)
    Local $hname, $section
    Example1()
    Func Example1()
    Local $msg
    GUICreate(" GUI ") ; will create a dialog box that when displayed is centered
    GUICtrlCreateLabel("HostName ", 11, 80)
    $hname = GUICtrlCreateCombo("", 10, 102)
    $section = IniReadSection("C:\Dokumente und Einstellungen\Administrator\Desktop\autoit\reg\muster.ini", "HostName")
    For $i = 1 To UBound($section) - 1
    GUICtrlSetData($hname, IniRead("muster.ini", "HostName", $i, ""))

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

    Next

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

    GUISetState(@SW_SHOW) ; will display an empty dialog box

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

    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()
    MsgBox(1, "", GUICtrlRead($hname))
    EndFunc ;==>Example1

    [/autoit]


    Muster.ini

    Spoiler anzeigen
    [autoit]

    [HostName]
    1=save2L001
    2=save2L002
    3=save2L003
    4=save2L004
    5=save2L005
    6=save2L006
    7=save2L007
    8=save2L008
    9=save2L009
    10=save2L010

    [/autoit]
  • du kannst kein control auslesen das nicht mehr existiert ;)

    du löscht ja die Gui und dann versuchst du das noch auszulesen

    [autoit]

    GUIDelete()
    MsgBox(1, "", GUICtrlRead($hname))

    [/autoit]

    andersrum könnte es eher klappen

    Edit:
    oh und gibt ein 2D array zurück.
    probiers so:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    Opt('MustDeclareVars', 1)
    Local $hname, $section
    Example1()
    Func Example1()
    Local $msg
    GUICreate(" GUI ") ; will create a dialog box that when displayed is centered
    GUICtrlCreateLabel("HostName ", 11, 80)
    $hname = GUICtrlCreateCombo("", 10, 102)
    $section = IniReadSection(@desktopdir & "\autoit\reg\muster.ini", "HostName")
    For $i = 1 To UBound($section) - 1
    GUICtrlSetData($hname, $section[$i][1])
    Next

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

    GUISetState(@SW_SHOW) ; will display an empty dialog box

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

    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    MsgBox(1, "", GUICtrlRead($hname))
    GUIDelete()
    EndFunc ;==>Example1

    [/autoit]
  • Wenn du die GUI löscht wie soll er dann das Control auslesen???? Wenn dann musste das schon zwischenspeichern. Und wenn du schon IniReadSection vernwendest, warum nimmst du dann auch noch IniRead?

    Edit. Mist zu spät ;). Und statt UBound kannste auch $section[0][0] verwenden.