Listbox. Scollbars, Spaltenbreiten

  • Ich bin Neuling in Autoit und habe das Problem in einer Liste Scrollbars einzufügen und die Spaltenbreiten anzugeben

    Mein Code

    $List = _GUICtrlListBox_Create($GUI, "Belegung INIT-Datei", 10, 2, 580, 400)

    Func List_Fill()

    Local $sFilePath, $oExcel, $sCellValue
    Local $i, $j, $s1

    $sFilePath = @ScriptDir & "\INIT.xlsx"
    $oExcel = _ExcelBookOpen($sFilePath,0,true)

    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath = @ScriptDir & "\INIT.xls"
    $oExcel = _ExcelBookOpen($sFilePath,1,true)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf

    $View = _GUICtrlListView_Create($List, "Col 0|Col 1|Col 2", 10, 20, 580, 400 )

    $i = 1
    $j = 0
    $s1 = _ExcelReadCell($oExcel, $i, 1)

    If $s1 = "" Or $s1 = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der Init-Tabelle")
    Exit
    EndIf

    while $s1 <> "" And $s1 <> " "
    ;msgbox(0," ",_ExcelReadCell($oExcel, $i, 2))
    _GUICtrlListView_AddItem($View, _ExcelReadCell($oExcel, $i, 1), $j)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel, $i, 2), 1)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel, $i, 3), 2)
    $i = $i + 1
    $j = $j + 1
    $s1 = _ExcelReadCell($oExcel, $i, 1)
    WEnd ?(

    • Offizieller Beitrag

    Willkommen im Forum.

    Benutze bitte in Zukunft einen Spoiler und das Autoit Highlighting. Zu finden im Editor Taste SP und das mit dem AutoIt Logo.
    [ spoiler][ autoit] Dazwischen kommt der Code [ /autoit][/spoiler]
    Damit wird dein Script ungemein leserlicher.

    Zu Deinem Problem:
    Du erstellst erst eine ListBox und willst dann in diese ListBox ein Listview einfügen, das wird nicht funktionieren.
    Wie ich den Code so sehe, vermute ich das eventuell noch mehr Fehler in deinem Script sind.
    Poste am besten mal den kompletten Code.

    PS: Ich denke du willst Hilfe zu deinem Script und nicht das es jemand für dich erstellt.
    Sollte das der Fall sein, dann ist es im falchen Forum und gehört in Hilfe und Unterstützung.

  • Hallo Gunter_s,

    herzlich willkommen im Forum und viel Spass mit AutoIt.

    Hier kannst du dir die deutsche Hilfe herunterladen.
    Hier gibt es ein AutoIt-Tutorial: http://wiki.autoit.de/wiki/index.php/TutorialSehr hilfreich ist auch das Buch von peethebee

    und jetzt zu deinem Skript, denn es ist so mit Sicherheit nicht lauffähig denn 1. Tidy meldet:

    Code
    idy AutoIt3 v2.1.0.0   Copyright (c) Jos van der Zande  December 28, 2009
    C:\Programme\AutoIt3\Examples\asdfghkljhga.au3(3) : ### Tidy Error -> "func" is never closed in your script.
    !> there were  1 error(s) encountered. look in your source for:### Tidy Error:
    +> Tidy AutoIt3 finished. Original copied to:"C:\Programme\AutoIt3\Examples\BackUp\asdfghkljhga_old1.au3"
    >Exit code: 1    Time: 0.372

    das sagt du hast vergessen die func List_Fill mit

    [autoit]

    Endfunc

    [/autoit]

    zu schliessen. Aber auch wenn ich ganz am Ende Endfunc einfüge (weis nicht ob es da sein soll) zeigt mir der AU3-Check folgende Fehler:

    Spoiler anzeigen

    du solltest die Hilfe durcharbeiten damit du verstehts was du schreibst. Einige Fehler beruhen darauf dass du die benötigten UDF 's vergessen hast, wie z.B.:

    [autoit]

    #include <Excel.au3>

    [/autoit]

    diese muss unbedingt sein wegen Excel. Alls Anfänger solltest du besser native AutoIt-Funktionen benutzen anstatt die UDF 's. Diese kannst du immer noch hinzufügen.
    Also anstatt mit

    [autoit]

    _GUICtrlListBox_Create

    [/autoit]

    erstellst du deine ListBox mit

    [autoit]

    GUICtrlCreateList

    [/autoit]

    und die Listview mit

    [autoit]

    GUICtrlCreateListView

    [/autoit]

    auch darfst du hier nicht die Listbox als Parent verwenden sondern die GUI.
    Bevor du allerdings Controls erstellst solltest du zuerst mit

    [autoit]

    GuiCreate

    [/autoit]

    eine Gui erstellen. Ich höre jetzt besser auf habe eh kein Excel installiert, aber du siehst du hast einiges zu lesen.

    mfg autoBert

  • Vielen Dank für eure Hilfe.

    Die Hinweise mit #Include, EndFunc waren zwar richtig, aber sie hatte ich meinen vollständigen Script schon drin - nur nicht gepostet (Asche auf mein graues Haupt :( )

    Wesentlich war der Hinweis, dass ich mich mit der ListView nicht auf die Listbox sondern auf die GUI beziehen muss. Nun funktioniert die Scrollbar.

    Bleibt noch das Problem der Splatenbreite. Wie kann ich die Breite einer Listenspalte definieren - außer mit einer entsprechend breiten Überschrift.

    Danke

    Gunter_s

  • Die Hinweise mit #Include, EndFunc waren zwar richtig, aber sie hatte ich meinen vollständigen Script schon drin - nur nicht gepostet (Asche auf mein graues Haupt :( )

    Naja, da hätte ich mir die Mühe ja sparen können zum Glück habe ich irgedwann mit dem Fehler suchen aufgehört.

    Zitat

    _GUICtrlListView_SetColumnWidth

    Ändert die Breite einer Spalte

    [autoit]

    #Include <GuiListView.au3>
    _GUICtrlListView_SetColumnWidth($hWnd, $iCol, $iWidth)

    [/autoit]

    Quelle: dt. Hilfe

    mfg autoBert

  • Hallo,

    zuerst mal besten Dank für die Hilfe wegen der Spaltenbreite, funktioniert so, wie gewünscht. :thumbup:

    Aber wie das nun mal so ist: ist ein Problem gelöst, stehen 2 neue vor der Tür. Aber keine Angst - zunächst ist es nur eins.

    In meiner ListView muss ich noch die Schriftart und -grösse ändern. Mit

    GUICtrlSetFont($View, 12, 400, 0, "ARIAL") oder GUISetFont($View, 12, 400, 0, "ARIAL")


    habe ich leider bei ListViews keinen Erfolg. Und trotz langem Suchen habe ich auch nichts entsprechendes gefunden. Ist wahrscheinlich auch wieder nur eine simple Anweisung - aber welche?

    Spoiler anzeigen

    Func List_Fill()
    ;*********************************************************************************
    ;* Excel öffnen *
    ;* Inhalt in ListView übertragen (mehrspaltig) *
    ;*********************************************************************************

    ; Excel öffnen
    $sFilePath = @ScriptDir & "\INIT.xlsx"
    $oExcel = _ExcelBookOpen($sFilePath,0,true)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath = @ScriptDir & "\INIT.xls"
    $oExcel = _ExcelBookOpen($sFilePath,0)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf

    ; ListView anlegen
    $View = _GUICtrlListView_Create($GUI, "", 10, 60, 580, 400 )
    _GUICtrlListView_SetExtendedListViewStyle($View, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))


    GUICtrlSetFont($View, 12, 400, 0, "ARIAL")
    ; GUICtrlSetColor($View, 0x000000)
    $vc1 = _GUICtrlListView_InsertColumn($View, 0, "Schlüssel", 100)
    GUISetFont($View, 12, 400, 0, "ARIAL")
    ;GUICtrlSetColor($vc1, 0x0000ff)
    $vc2 =_GUICtrlListView_InsertColumn($View, 1, "Beschriftung", 300)
    $vc3 = _GUICtrlListView_InsertColumn($View, 2, "Anzeige", 50)

    ; ListView befüllen
    $i = 1
    $j = 0
    $s1 = _ExcelReadCell($oExcel, $i, 1)

    If $s1 = "" Or $s1 = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der Init-Tabelle")
    Exit
    EndIf

    While $s1 <> "" And $s1 <> " "
    _GUICtrlListView_AddItem($View, _ExcelReadCell($oExcel, $i, 1), $j)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel, $i, 2), 1)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel, $i, 3), 2)
    $i = $i + 1
    $j = $j + 1
    $s1 = _ExcelReadCell($oExcel, $i, 1)
    WEnd

    _ExcelBookclose($oExcel,1,0)
    EndFunc

    Gruß

    Gunter_s

    • Offizieller Beitrag

    GUICtrlSetFont funktioniert nur bei Standardcontrols.
    Dein ListView ist aber ein UDFListView.

    Lösung: Benutze ein GUICtrlCreateListView, die UDF Funktionen kannst du damit auch benutzen.
    Nach dem Erstellen des Listviews holst du dir das Handle des Listviews.

    [autoit]

    $ListView = GUICtrlCreateListView ("", 10, 60, 580, 400 )
    $View= GUICtrlGetHandle($ListView)

    [/autoit]


    Bei den UDF-Funktionen benutzt du dann das Handle $View.

    • Offizieller Beitrag

    Also Schriftart ändern geht nicht so ohne weiteres. Aber wenn du für alle Einträge dieselbe Schriftart wünschst, kannst du folgendes Bsp. verwenden:
    Falls du einzelne Zeilen anders darstellen möchtest:

    Spoiler anzeigen
    [autoit]

    #include <FontConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <StructureConstants.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

    $GUI = GUICreate("Listview Custom Draw", 400, 440)
    $cListView = GUICtrlCreateListView("", 2, 2, 394, 268, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    $hListView = GUICtrlGetHandle($cListView)
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)
    For $i = 1 To 30
    _GUICtrlListView_AddItem($hListView, "Row" & $i & ": Col 1", $i-1)
    For $j = 1 To 2
    _GUICtrlListView_AddSubItem ($hListView, $i-1, "Row" & $i & ": Col " & $j+1, $j)
    Next
    Next

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

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUISetState()

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

    Do
    Until GUIGetMsg() = -3

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

    Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $hListView
    Switch $iCode
    Case $NM_CUSTOMDRAW
    If Not _GUICtrlListView_GetViewDetails($hWndFrom) Then Return $GUI_RUNDEFMSG
    Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
    Local $iDrawStage, $hDC, $iItem
    $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage')
    Switch $iDrawStage
    Case $CDDS_ITEMPREPAINT
    Return $CDRF_NOTIFYSUBITEMDRAW
    Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM)
    $hDC = DllStructGetData($tCustDraw, 'hdc')
    $iItem = DllStructGetData($tCustDraw, 'dwItemSpec')
    Switch $iItem
    Case 1,3,5,7
    $hFont = _WinAPI_CreateFont(14,0,0,0,$FW_NORMAL,False,False,False,$DEFAULT_CHARSET,$OUT_DEFAULT_PRECIS, _
    $CLIP_DEFAULT_PRECIS,$DEFAULT_QUALITY,0,'Courier New')
    _WinAPI_SelectObject($hDC, $hFont)
    EndSwitch
    Return $CDRF_NEWFONT
    EndSwitch
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit]


    Ansonsten kannst du meine ListviewFormat-UDF verwenden.

    • Offizieller Beitrag

    Wenn alle Einträge die selbe Schrift haben sollen, dann reicht auch GUICtrlSetFont ;)

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    Opt('MustDeclareVars', 1)

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

    Example()

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

    Func Example()
    Local $listview, $button, $item1, $item2, $item3, $input1, $msg

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

    GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF) ; will change background color

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

    $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING)
    GUICtrlSetFont($listview, 6, 400, 0, "ARIAL");Schrift gilt für das ganze ListView
    $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview)
    $item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview)
    $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)
    $input1 = GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
    GUISetState()
    GUICtrlSetData($item2, "ITEM1")
    GUICtrlSetData($item3, "||COL33")
    GUICtrlDelete($item1)

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

    Do
    $msg = GUIGetMsg()

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

    Select
    Case $msg = $button
    MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)), 2)
    Case $msg = $listview
    MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
    EndSelect
    Until $msg = $GUI_EVENT_CLOSE
    EndFunc ;==>Example

    [/autoit]
  • Danke,

    funktioniert jetzt nach meinen Vorstellungen

    bis zum nächsten Problem

    Gruß

    Gunter_s

  • Hallo,

    nun sind doch noch weitere Probleme aufgetreten

    1Wie kann ich die Auswahlmöglichkeit in einer Listwiew unterbinden - sie soll nur als Anzeige dienen

    Spoiler anzeigen

    #cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.4.0
    Author: Gunter Neurohr

    Script Function:
    Excel-Tabelle lesen und anzeigen
    mehrere Excel-Tabellen verknüpfen
    #ce ----------------------------------------------------------------------------

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>
    #include <Excel.au3>
    #include <File.au3>
    #include <Array.au3>
    #include <EditConstants.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <FontConstants.au3>

    Opt('MustDeclareVars', 1)

    Global $GUI

    Global $View

    Global $Button_Ende
    Global $cl1, $cl2

    Global $Hinweis, $tHinweis

    Global $msg

    Global $sFilePath[2], $oExcel[2], $sCellValue[2]
    Global $i[2], $j, $s1[2]

    ; Definition des Dialogfensters
    $GUI = GUICreate("Webseiten Werner Lebsanft - Passwort zu Anwendungen anzeigen", 900, 700)

    ; Definition der Schaltflächen
    $Button_Ende = GUICtrlCreateButton("zurück", 10, 550, 100)
    GUICtrlSetFont($Button_Ende, 11, 400, 0, "ARIAL")
    GUICtrlSetColor($Button_Ende, 0x000000)
    GUICtrlSetBkColor($Button_Ende, 0xb2b6b6)

    ; Definition eines Trennstriches
    GUICtrlCreateLabel ( "", 1, 540, 899, 1, $SS_GRAYRECT )

    ; Definition der Überschriften im Dialogfenster
    GUICtrlCreateLabel ( "", 10, 10, 880, 40, $SS_GRAYRECT )
    $cl1 = GUICtrlCreateLabel ( "Benutzerkennungen und Passworte zu Anwendungen", 30, 20, 840, 20, $SS_CENTER )
    GUICtrlSetFont($cl1, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($cl1, 0x000000)
    GUICtrlSetBkColor($cl1, 0xffe69c)

    ; Hinweise
    GUICtrlCreateLabel ( "", 10, 600, 880, 70, $SS_GRAYRECT )
    $Hinweis = GUICtrlCreateLabel ( "", 15, 605, 870, 60 )
    GUICtrlSetFont($Hinweis, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($Hinweis, 0x000000)
    GUICtrlSetBkColor($Hinweis, 0xdd8675)
    $tHinweis = "nur Anzeige !!!" & @CRLF & _
    "mit <zurück> in die Auswahl" & @CRLF & _
    "die Anwendung kann dort beendet werden - nicht mit <X> beenden !!!!"
    GUICtrlSetData($Hinweis, $tHinweis)

    ; Füllen einer ListView mit Werten aus der Excel-Tabelle
    List_Fill()

    ; Dialogfenster anzeigen
    GUISetState(@SW_SHOW)

    While 1
    $msg = GUIGetMsg()
    Select
    ; Dialogfenster schliessen und Aufruf "Aufrufe.exe"
    Case $msg = $Button_Ende
    GUISetState(@SW_DISABLE)
    Run("Aufrufe.exe")
    Exit
    Case Else
    EndSelect
    WEnd

    Func List_Fill()
    ;*********************************************************************************
    ;* Excel öffnen *
    ;* Inhalt in ListView übertragen (mehrspaltig) *
    ;*********************************************************************************

    ; Excel öffnen
    $sFilePath[1] = @ScriptDir & "\INIT.xlsx"
    $oExcel[1] = _ExcelBookOpen($sFilePath[1],0,true)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath[1] = @ScriptDir & "\INIT.xls"
    $oExcel[1] = _ExcelBookOpen($sFilePath[1],0)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf

    $sFilePath[0] = @ScriptDir & "\Verbindung.xlsx"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0,true)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath[0] = @ScriptDir & "\Verbindung.xls"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf

    ; ListView anlegen
    $View = GUICtrlCreateListView("", 10, 60, 880, 400, -1, $LVS_EX_GRIDLINES)
    GUICtrlSetFont($View, 10, 400, 0, "ARIAL")
    GUICtrlSetColor($View, 0x0000ff)
    GUICtrlSetBkColor($View, 0xdcdcdc)
    _GUICtrlListView_InsertColumn($View, 0, "Schlüssel", 100)
    _GUICtrlListView_InsertColumn($View, 1, "Anwendung", 270)
    _GUICtrlListView_InsertColumn($View, 2, "Benutzerkennung", 250)
    _GUICtrlListView_InsertColumn($View, 3, "Passwort", 250)

    ; ListView befüllen
    $i[0] = 1
    $j = 0
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)

    If $s1[0] = "" Or $s1[0] = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der Verbindung-Tabelle")
    Exit
    EndIf

    While $s1[0] <> "" And $s1[0] <> " "
    ; _GUICtrlListView_AddItem($View, _ExcelReadCell($oExcel[0], $i[0], 1), $j)
    _GUICtrlListView_AddItem($View, $s1[0], $j)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[0], $i[0], 2), 2)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[0], $i[0], 3), 3)
    ANW()
    $i[0] = $i[0] + 1
    $j = $j + 1
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)
    WEnd

    _ExcelBookclose($oExcel[0],1,0)
    _ExcelBookclose($oExcel[1],1,0)
    EndFunc

    Func ANW()
    ;*********************************************************************************
    ;* Anwendung zum Schlüssel lesen *
    ;* aus Tabelle INIT *
    ;*********************************************************************************
    Local $gefunden

    $i[1] = 1
    $s1[1] = _ExcelReadCell($oExcel[1], $i[1], 1)
    $gefunden = 0

    If $s1[1] = "" Or $s1[1] = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der INIT-Tabelle")
    Exit
    EndIf

    While $s1[1] <> "" And $s1[1] <> " " And $gefunden = 0
    If $s1[0] = $s1[1] Then
    $gefunden = 1
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[1], $i[1], 2), 1)
    Else
    $i[1] = $i[1] + 1
    $s1[1] = _ExcelReadCell($oExcel[1], $i[1], 1)
    EndIf
    WEnd

    If $gefunden = 0 Then
    _GUICtrlListView_AddSubItem($View, $j, "unbekannt", 1)
    EndIf
    EndFunc

    2. nach Speichern ist keine Auswahl aus der Listview möglich

    Spoiler anzeigen

    #cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.4.0
    Author: Gunter Neurohr

    Script Function:
    verwaltung der Verbindungstabelle
    Excel-Tabelle lesen und anzeigen
    Einträge auswählen und ändern
    Änderungen in Exceltabelle speichern
    neue Einträge einfügen möglich
    Prüfung, ob mit INIT-Tabelle verbunden

    #ce ----------------------------------------------------------------------------
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>
    #include <Excel.au3>
    #include <File.au3>
    #include <Array.au3>
    #include <EditConstants.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <FontConstants.au3>

    Opt('MustDeclareVars', 1)

    Global $GUI

    Global $View, $hView
    Global $vc1, $vc2, $vc3, $line

    Global $Button_Ende
    Global $Button_Speichern
    Global $cl1, $cl2

    Global $Hinweis, $tHinweis

    Global $msg
    Global $bkey, $bname, $bPW, $bURL, $lkey, $lPW, $lname, $lURL

    Global $sFilePath[2], $oExcel[2], $sCellValue[2]
    Global $i[2], $j, $s1[2]

    ; Definition des Dialogfensters
    $GUI= GUICreate("Webseiten Werner Lebsanft - Verwalten der Anzeige", 900, 900)

    ; Definition der Schaltflächen
    $Button_Ende = GUICtrlCreateButton("zurück", 10, 750, 100)
    GUICtrlSetFont($Button_Ende, 11, 400, 0, "ARIAL")
    GUICtrlSetColor($Button_Ende, 0x000000)
    GUICtrlSetBkColor($Button_Ende, 0xb2b6b6)

    $Button_Speichern = GUICtrlCreateButton("Speichern", 790, 750, 100)
    GUICtrlSetFont($Button_Speichern, 11, 400, 0, "ARIAL")
    GUICtrlSetColor($Button_Speichern, 0x000000)
    GUICtrlSetBkColor($Button_Speichern, 0xb2b6b6)

    ; Definition eines Trennstriches
    GUICtrlCreateLabel ( "", 1, 740, 899, 1, $SS_GRAYRECT )

    ; Definition der Überschriften im Dialogfenster
    GUICtrlCreateLabel ( "", 10, 10, 880, 40, $SS_GRAYRECT )
    $cl1 = GUICtrlCreateLabel ( "Inhalt der Verbindungstabelle verwalten", 30, 20, 840, 20, $SS_CENTER )
    GUICtrlSetFont($cl1, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($cl1, 0x000000)
    GUICtrlSetBkColor($cl1, 0xffe69c)

    GUICtrlCreateLabel ( "", 10, 500, 880, 40, $SS_GRAYRECT )
    $cl2 = GUICtrlCreateLabel ( "Verwaltungsbereich", 30, 510, 840, 20, $SS_CENTER )
    GUICtrlSetFont($cl2, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($cl2, 0x000000)
    GUICtrlSetBkColor($cl2, 0xffe69c)

    ; Hinweise
    GUICtrlCreateLabel ( "", 10, 800, 880, 70, $SS_GRAYRECT )
    $Hinweis = GUICtrlCreateLabel ( "", 15, 805, 870, 60 )
    GUICtrlSetFont($Hinweis, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($Hinweis, 0x000000)
    GUICtrlSetBkColor($Hinweis, 0xdd8675)
    $tHinweis = "bitte wählen sie eine Verbindung aus (Click mit der linken Mousetaste auf eine Zeile der Liste)" & @CRLF & _
    "oder geben sie eine neue Vebinbingung ein" & @CRLF & _
    "gehen sie mit <zurück> in die Auswahl, dort kann die Anwendung beendet werden - nicht mit <X> beenden !!!!"
    GUICtrlSetData($Hinweis, $tHinweis)

    ; Definition der Anzeige- und Eingabefelder
    $lkey = GUICtrlCreateLabel("Schlüssel", 10, 560, 150, 30)
    GUICtrlSetFont($lkey, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($lkey, 0x000000)
    $bkey = GUICtrlCreateInput(" ", 200, 560, 50, 30)
    GUICtrlSetFont($bkey, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($bkey, 0x000000)
    GUICtrlSetBkColor($bkey, 0xda5dfac)

    $lname = GUICtrlCreateLabel("Benutzerkennung", 10, 600, 150, 30)
    GUICtrlSetFont($lname, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($lname, 0x000000)
    $bname = GUICtrlCreateInput(" ", 200, 600, 300, 30)
    GUICtrlSetFont($bname, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($bname, 0x000000)
    GUICtrlSetBkColor($bname, 0xa5dfac)

    $lPW = GUICtrlCreateLabel("Passwort", 10, 640, 150, 30)
    GUICtrlSetFont($lPW, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($lPW, 0x000000)
    $bPW = GUICtrlCreateInput(" ", 200, 640, 300, 30)
    GUICtrlSetBkColor($bPW, 0xa5dfac)

    $lURL = GUICtrlCreateLabel("URL", 10, 680, 150, 30)
    GUICtrlSetFont($lURL, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($lURL, 0x000000)
    $bURL = GUICtrlCreateInput(" ", 10, 700, 880, 30)
    GUICtrlSetBkColor($bURL, 0xa5dfac)

    ; Füllen einer ListView mit Werten aus der Excel-Tabelle
    List_Fill()

    ; Dialogfenster anzeigen
    GUISetState(@SW_SHOW)

    ; per Click einen ListVieweintrag auswählen und Werte in den
    ; Anzeige- und Eingabefeldern anzeigen
    GUIRegisterMsg($WM_notify, "_ClickOnListView")

    While 1
    $msg = GUIGetMsg()
    Select
    ; Dialogfenster schliessen und Aufruf "Aufrufe.exe"
    Case $msg = $Button_Ende
    GUISetState(@SW_DISABLE)
    Run("Aufrufe.exe")
    Exit
    Case $msg = $Button_Speichern
    ; Eingaben in Excel-Tabelle speichern
    ;msgbox(0," ","Funktion offen")
    Save_Excel()
    GUIRegisterMsg($WM_notify, "_ClickOnListView")
    ; ExitLoop
    Case Else
    EndSelect
    WEnd

    Func List_Fill()
    ;*********************************************************************************
    ;* Excel öffnen *
    ;* Inhalt in ListView übertragen (mehrspaltig) *
    ;*********************************************************************************

    ; Excel öffnen
    $sFilePath[1] = @ScriptDir & "\INIT.xlsx"
    $oExcel[1] = _ExcelBookOpen($sFilePath[1],0,true)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath[1] = @ScriptDir & "\INIT.xls"
    $oExcel[1] = _ExcelBookOpen($sFilePath[1],0)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf

    $sFilePath[0] = @ScriptDir & "\Verbindung.xlsx"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0,true)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath[0] = @ScriptDir & "\Verbindung.xls"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf

    ; ListView anlegen
    $View = GUICtrlCreateListView("", 10, 60, 880, 400, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUICtrlSetFont($View, 10, 400, 0, "ARIAL")
    GUICtrlSetColor($View, 0x0000ff)
    GUICtrlSetBkColor($View, 0xdcdcdc)
    _GUICtrlListView_InsertColumn($View, 0, "Schlüssel", 100)
    _GUICtrlListView_InsertColumn($View, 1, "Anwendung", 270)
    _GUICtrlListView_InsertColumn($View, 2, "Benutzerkennung", 250)
    _GUICtrlListView_InsertColumn($View, 3, "Passwort", 250)

    ; ListView befüllen
    $i[0] = 1
    $j = 0
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)

    If $s1[0] = "" Or $s1[0] = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der Verbindung-Tabelle")
    Exit
    EndIf

    While $s1[0] <> "" And $s1[0] <> " "
    _GUICtrlListView_AddItem($View, $s1[0], $j)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[0], $i[0], 2), 2)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[0], $i[0], 3), 3)
    ANW()
    $i[0] = $i[0] + 1
    $j = $j + 1
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)
    WEnd

    _ExcelBookclose($oExcel[0],1,0)
    _ExcelBookclose($oExcel[1],1,0)
    EndFunc

    Func ANW()
    ;*********************************************************************************
    ;* Anwendung zum Schlüssel lesen *
    ;* aus Tabelle INIT *
    ;*********************************************************************************
    Local $gefunden

    $i[1] = 1
    $s1[1] = _ExcelReadCell($oExcel[1], $i[1], 1)
    $gefunden = 0

    If $s1[1] = "" Or $s1[1] = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der INIT-Tabelle")
    Exit
    EndIf

    While $s1[1] <> "" And $s1[1] <> " " And $gefunden = 0
    If $s1[0] = $s1[1] Then
    $gefunden = 1
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[1], $i[1], 2), 1)
    Else
    $i[1] = $i[1] + 1
    $s1[1] = _ExcelReadCell($oExcel[1], $i[1], 1)
    EndIf
    WEnd

    If $gefunden = 0 Then
    _GUICtrlListView_AddSubItem($View, $j, "unbekannt", 1)
    EndIf
    EndFunc


    Func _ClickOnListView($hWndGUI, $MsgID, $wParam, $lParam)
    ;*********************************************************************************
    ;* Satz aus ListView auswählen (Click mit linker Maustaste) *
    ;* ausgewählten Satz in Verwaltungsbereich des Fensters anzeigen *
    ;*********************************************************************************
    Local $tagNMHDR, $event, $hwndFrom, $code

    ;ConsoleWrite( $hWndGUI& @CRLF& $MsgID& @CRLF& $wParam& @CRLF& $lParam& @CRLF& "Einstieg"& @CRLF)
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    $line = _GUICtrlListView_GetSelectedindices($View)
    $event = DllStructGetData($tagNMHDR, 3)
    If $event = $NM_CLICK Then
    If $line <> "" Then
    ; Excel öffnen
    $sFilePath[0] = @ScriptDir & "\Verbindung.xlsx"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0,true)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath[0] = @ScriptDir & "\Verbindung.xls"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf

    GUICtrlSetData($bkey, _ExcelReadCell($oExcel[0], $line + 1, 1))
    GUICtrlSetFont($bkey, 12, 400, 0, "ARIAL")
    GUICtrlSetData($bname, _ExcelReadCell($oExcel[0], $line + 1, 2))
    GUICtrlSetFont($bname, 12, 400, 0, "ARIAL")
    GUICtrlSetData($bPW, _ExcelReadCell($oExcel[0], $line + 1, 3))
    GUICtrlSetFont($bPW, 12, 400, 0, "ARIAL")
    GUICtrlSetData($bURL, _ExcelReadCell($oExcel[0], $line + 1, 4))
    GUICtrlSetFont($bURL, 12, 400, 0, "ARIAL")
    _ExcelBookclose($oExcel[0],1,0)
    Endif
    EndIf
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
    EndFunc

    Func Save_Excel()
    ;*********************************************************************************
    ;* Änderungen in Excel speichern *
    ;* ListView neu aufbauen *
    ;*********************************************************************************
    Local $result, $gefunden

    $result = msgbox(36,"Sicherheitsabfrage", "Wollen sie wirklich speichern?")
    If $result = 6 Then
    ; Excel öffnen
    $sFilePath[0] = @ScriptDir & "\Verbindung.xlsx"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0,false)
    ;msgbox(0," ", GUICtrlRead($bkey))
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath[0] = @ScriptDir & "\Verbindung.xls"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf

    $i[0] = 1
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)
    $gefunden = 0

    If $s1[0] = "" Or $s1[0] = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der INIT-Tabelle")
    Exit
    EndIf

    While $s1[0] <> "" And $s1[0] <> " " And $gefunden = 0
    If $s1[0] = GUICtrlRead($bkey) Then
    $gefunden = 1
    Else
    $i[0] = $i[0] + 1
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)
    EndIf
    WEnd

    If $gefunden = 1 Then
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bname), $i[0], 2)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bPW), $i[0], 3)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bURL), $i[0], 4)
    Else
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bkey), $i[0], 1)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bname), $i[0], 2)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bPW), $i[0], 3)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bURL), $i[0], 4)
    EndIf
    ;_ExcelWriteCell($oExcel[0], GUICtrlRead($bkey), $line + 1, 1)
    ;_ExcelWriteCell($oExcel[0], GUICtrlRead($bname), $line + 1, 2)
    ;_ExcelWriteCell($oExcel[0], GUICtrlRead($bPW), $line + 1, 3)
    _ExcelBookclose($oExcel[0],1,1)

    List_Fill()
    Endif
    EndFunc

    Gruß

    Gunter_s

  • Vielen Dank für die schnelle Hilfe, habe das Problem durch Probieren und vergleichen mit anderen Programmiersprachen (autoit ist nicht die erste Programmiersprache, die ich benutze) selbst gelöst. War wieder einmal nur ein einziger Befehl, der gefehlt hat: Listview nach dem Speichern löschen

    Gruß

    Gunter_s

  • Hallo,

    ich habe folgendes Problem:

    in einer GUI erstelle ich eine Listview aus einer Exceltabelle. Die Listview sortiere ich anschließend - nun stimmen die Zeilennummern in der View und der Exceltabelle nicht mehr überein. Wenn ich nun eine Zeile aus der View auswähle, benötige ich einen Wert (Spalte 1 der View), um in der Exceltabelle nachzulesen. So mein Konzept.

    Ich versuche die View mit _GUICtrlListView_GetItemtext($View, 0) auszulesen. Dies haut auch solange hin, wie ich für den Index (2 Parameter) eine feste Zahl eingebe. Ersetze ich ihn durch eine Variable ($line = _GUICtrlListView_GetSelectedindices($View)) klappt es nicht mehr.

    Was mache ich falsch? Den Teil in der Func _ClickOnListView nach Zeile 364 habe ich nicht angepasst - die Msgbox bringt kein richtiges Ergebnis

    Spoiler anzeigen

    #cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.4.0
    Author: Gunter Neurohr

    Script Function:
    ****************************************
    * Verbindung_Verwalten.au3 *
    ****************************************

    verwaltung der Verbindungstabelle
    Excel-Tabelle lesen und anzeigen
    Einträge auswählen und ändern
    Änderungen in Exceltabelle speichern
    neue Einträge einfügen möglich
    bestehende Einträge ändern
    Tabelleneinträge löschen

    #ce ----------------------------------------------------------------------------
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>
    #include <Excel.au3>
    #include <File.au3>
    #include <Array.au3>
    #include <EditConstants.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <FontConstants.au3>
    #include <GUIComboBox.au3>

    Opt('MustDeclareVars', 1)

    Global $GUI

    Global $View
    Global $vc1, $vc2, $vc3, $line

    Global $Button_Ende
    Global $Button_Speichern
    Global $Button_Delete
    Global $cl1, $cl2

    Global $Hinweis, $tHinweis, $Meldung, $tMeldung

    Global $msg
    Global $bkey, $bname, $bPW, $bURL, $bTyp, $iTyp, $lkey, $lPW, $lname, $lURL, $lTyp, $itTyp , $hTyp

    Global $sFilePath[2], $oExcel[2], $sCellValue[2]
    Global $i[2], $j, $s1[2]
    Global $eline

    ; Definition des Dialogfensters
    $GUI= GUICreate("Webseiten Werner Lebsanft - Verwalten der Anzeige", 900, 900)

    ; Definition der Schaltflächen
    $Button_Ende = GUICtrlCreateButton("zurück", 10, 750, 100)
    GUICtrlSetFont($Button_Ende, 11, 400, 0, "ARIAL")
    GUICtrlSetColor($Button_Ende, 0x000000)
    GUICtrlSetBkColor($Button_Ende, 0xb2b6b6)

    $Button_Speichern = GUICtrlCreateButton("Speichern", 790, 750, 100)
    GUICtrlSetFont($Button_Speichern, 11, 400, 0, "ARIAL")
    GUICtrlSetColor($Button_Speichern, 0x000000)
    GUICtrlSetBkColor($Button_Speichern, 0xb938fc3)

    $Button_Delete = GUICtrlCreateButton("Löschen", 670, 750, 100)
    GUICtrlSetFont($Button_Delete, 11, 400, 0, "ARIAL")
    GUICtrlSetColor($Button_Delete, 0x000000)
    GUICtrlSetBkColor($Button_Delete, 0xb938fc3)

    ; Definition eines Trennstriches
    GUICtrlCreateLabel ( "", 1, 740, 899, 1, $SS_GRAYRECT )

    ; Definition der Überschriften im Dialogfenster
    GUICtrlCreateLabel ( "", 10, 10, 880, 45, $SS_GRAYRECT )
    $cl1 = GUICtrlCreateLabel ( "Inhalt der Verbindungstabelle verwalten", 30, 20, 840, 25, $SS_CENTER )
    GUICtrlSetFont($cl1, 14, 400, 0, "ARIAL")
    GUICtrlSetColor($cl1, 0x000000)
    GUICtrlSetBkColor($cl1, 0xffe69c)

    GUICtrlCreateLabel ( "", 10, 500, 880, 45, $SS_GRAYRECT )
    $cl2 = GUICtrlCreateLabel ( "Verwaltungsbereich", 30, 510, 840, 25, $SS_CENTER )
    GUICtrlSetFont($cl2, 14, 400, 0, "ARIAL")
    GUICtrlSetColor($cl2, 0x000000)
    GUICtrlSetBkColor($cl2, 0xffe69c)

    ; Hinweise
    GUICtrlCreateLabel ( "", 10, 790, 880, 100, $SS_GRAYRECT )
    $Meldung = GUICtrlCreateLabel ( "", 15, 795, 870, 25 )
    GUICtrlSetFont($Meldung, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($Meldung, 0x000000)
    GUICtrlSetBkColor($Meldung, 0xaa0bb49)
    $Hinweis = GUICtrlCreateLabel ( "", 15, 825, 870, 60 )
    GUICtrlSetFont($Hinweis, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($Hinweis, 0x000000)
    GUICtrlSetBkColor($Hinweis, 0xdd8675)
    $tHinweis = "bitte wählen sie eine Verbindung aus (Click mit der linken Mousetaste auf eine Zeile der Liste)" & @CRLF & _
    "oder geben sie eine neue Vebinbingung ein; eine ausgewählte Verbindung kann gelöscht werden" & @CRLF & _
    "mit <zurück> in die Auswahl, die Anwendung kann dort beendet werden - nicht mit <X> beenden !!!!"
    GUICtrlSetData($Hinweis, $tHinweis)

    ; Definition der Anzeige- und Eingabefelder
    $lkey = GUICtrlCreateLabel("Schlüssel", 10, 560, 150, 30)
    GUICtrlSetFont($lkey, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($lkey, 0x000000)
    $bkey = GUICtrlCreateInput(" ", 200, 560, 50, 30)
    GUICtrlSetFont($bkey, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($bkey, 0x000000)
    GUICtrlSetBkColor($bkey, 0xda5dfac)

    $lname = GUICtrlCreateLabel("Benutzerkennung", 10, 600, 150, 30)
    GUICtrlSetFont($lname, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($lname, 0x000000)
    $bname = GUICtrlCreateInput(" ", 200, 600, 300, 30)
    GUICtrlSetFont($bname, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($bname, 0x000000)
    GUICtrlSetBkColor($bname, 0xa5dfac)

    $lPW = GUICtrlCreateLabel("Passwort", 10, 640, 150, 30)
    GUICtrlSetFont($lPW, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($lPW, 0x000000)
    $bPW = GUICtrlCreateInput(" ", 200, 640, 300, 30)
    GUICtrlSetFont($bPW, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($bPW, 0x000000)
    GUICtrlSetBkColor($bPW, 0xa5dfac)

    $lURL = GUICtrlCreateLabel("URL", 10, 680, 150, 30)
    GUICtrlSetFont($lURL, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($lURL, 0x000000)
    $bURL = GUICtrlCreateInput(" ", 10, 700, 880, 30)
    GUICtrlSetFont($bURL, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($bURL, 0x000000)
    GUICtrlSetBkColor($bURL, 0xa5dfac)

    $lTyp = GUICtrlCreateLabel("Verbindungstyp", 600, 600, 150, 30)
    GUICtrlSetFont($lTyp, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($lTyp, 0x000000)
    $bTyp = GUICtrlCreateCombo(" ", 800, 600, 80, 60)
    GUICtrlSetBkColor($bTyp, 0xa5dfac)
    GUICtrlSetFont($bTyp, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($bTyp, 0x000000)
    $iTyp = GUICtrlCreateInput(" ", 600, 640, 290, 30, $ES_READONLY)
    GUICtrlSetBkColor($iTyp, 0xdcdcdc)
    GUICtrlSetFont($iTyp, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($iTyp, 0x000000)

    ; notwendige Excel-Tabellen öffnen
    Excel_open(0)
    Excel_open(1)

    ; Füllen einer ListView mit Werten aus der Excel-Tabelle
    List_Fill()

    ; Combobox füllen (Verbindugnstypen)
    Combo_Fill()

    ; Dialogfenster anzeigen
    GUISetState(@SW_SHOW)

    ; per Click einen ListVieweintrag auswählen und Werte in den
    ; Anzeige- und Eingabefeldern anzeigen
    GUIRegisterMsg($WM_notify, "_ClickOnListView")

    While 1
    $msg = GUIGetMsg()
    Select
    ; Dialogfenster schliessen und Aufruf "Aufrufe.exe"
    Case $msg = $Button_Ende
    Excel_close(0)
    Excel_close(1)
    GUISetState(@SW_DISABLE)
    Run("Aufrufe.exe")
    Exit
    Case $msg = $Button_Speichern
    ; Eingaben in Excel-Tabelle speichern
    Save_Excel()
    Case $msg = $Button_Delete
    ; ausgewählte Zeile in Excel-Tabelle löschen
    Delete_Excel()
    case $msg = $btyp
    Typ_Text_Find(GUICtrlRead($bTyp))
    Case Else
    EndSelect
    WEnd

    Func Excel_open($e)
    ;*********************************************************************************
    ;* Excel-Tabellen (Verbindung, INIT) öffnen *
    ;*********************************************************************************

    If $e = 0 Then
    $sFilePath[0] = @ScriptDir & "\Verbindung.xlsx"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0,false)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath[0] = @ScriptDir & "\Verbindung.xls"
    $oExcel[0] = _ExcelBookOpen($sFilePath[0],0,false)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf
    EndIf

    If $e = 1 then
    $sFilePath[1] = @ScriptDir & "\INIT.xlsx"
    $oExcel[1] = _ExcelBookOpen($sFilePath[1],0,false)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    $sFilePath[1] = @ScriptDir & "\INIT.xls"
    $oExcel[1] = _ExcelBookOpen($sFilePath[1],0,false)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist")
    Exit
    EndIf
    EndIf
    Endif

    EndFunc

    Func Excel_close($e)
    ;*********************************************************************************
    ;* Excel-Tabellen (Verbindung, INIT) schließen *
    ;*********************************************************************************

    If $e = 0 Then
    _ExcelBookclose($oExcel[0],1,0)
    EndIf

    If $e = 1 Then
    _ExcelBookclose($oExcel[1],1,0)
    EndIf

    EndFunc

    Func Combo_Fill()
    ;*********************************************************************************
    ;* Combobox aus Excel füllen *
    ;*********************************************************************************

    _ExcelSheetActivate($oExcel[0], 2)

    $i[0] = 1
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)

    If $s1[0] = "" Or $s1[0] = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der Verbindung-Tabelle")
    Exit
    EndIf

    While $s1[0] <> "" And $s1[0] <> " "
    _GUICtrlComboBox_AddString($bTyp, $s1[0])
    $i[0] = $i[0] + 1
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)
    WEnd

    EndFunc

    Func List_Fill()
    ;*********************************************************************************
    ;* Excel öffnen *
    ;* Inhalt in ListView übertragen (mehrspaltig) *
    ;*********************************************************************************

    _ExcelSheetActivate($oExcel[0], 1)

    ; ListView anlegen
    $View = GUICtrlCreateListView("", 10, 60, 880, 400, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUICtrlSetFont($View, 12, 400, 0, "ARIAL")
    GUICtrlSetColor($View, 0x0000ff)
    GUICtrlSetBkColor($View, 0xdcdcdc)
    _GUICtrlListView_InsertColumn($View, 0, "Schlüssel", 100)
    _GUICtrlListView_InsertColumn($View, 1, "Anwendung", 220)
    _GUICtrlListView_InsertColumn($View, 2, "Benutzerkennung", 250)
    _GUICtrlListView_InsertColumn($View, 3, "Passwort", 200)
    _GUICtrlListView_InsertColumn($View, 4, "Typ", 100)

    ; ListView befüllen
    $i[0] = 1
    $j = 0
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)

    If $s1[0] = "" Or $s1[0] = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der Verbindung-Tabelle")
    Exit
    EndIf

    While $s1[0] <> "" And $s1[0] <> " "
    _GUICtrlListView_AddItem($View, $s1[0], $j)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[0], $i[0], 2), 2)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[0], $i[0], 3), 3)
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[0], $i[0], 5), 4)
    ANW()
    $i[0] = $i[0] + 1
    $j = $j + 1
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)
    WEnd
    _GUICtrlListView_SimpleSort($View, false, 0)

    EndFunc

    Func ANW()
    ;*********************************************************************************
    ;* Anwendung zum Schlüssel lesen *
    ;* aus Tabelle INIT *
    ;*********************************************************************************
    Local $gefunden

    $i[1] = 1
    $s1[1] = _ExcelReadCell($oExcel[1], $i[1], 1)
    $gefunden = 0

    If $s1[1] = "" Or $s1[1] = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der INIT-Tabelle")
    Exit
    EndIf

    While $s1[1] <> "" And $s1[1] <> " " And $gefunden = 0
    If $s1[0] = $s1[1] Then
    $gefunden = 1
    _GUICtrlListView_AddSubItem($View, $j, _ExcelReadCell($oExcel[1], $i[1], 2), 1)
    Else
    $i[1] = $i[1] + 1
    $s1[1] = _ExcelReadCell($oExcel[1], $i[1], 1)
    EndIf
    WEnd

    If $gefunden = 0 Then
    _GUICtrlListView_AddSubItem($View, $j, "unbekannt", 1)
    EndIf

    EndFunc


    Func _ClickOnListView($hWndGUI, $MsgID, $wParam, $lParam)
    ;*********************************************************************************
    ;* Satz aus ListView auswählen (Click mit linker Maustaste) *
    ;* ausgewählten Satz in Verwaltungsbereich des Fensters anzeigen *
    ;*********************************************************************************
    Local $tagNMHDR, $event, $hwndFrom, $code, $sItem, $h

    ;ConsoleWrite( $hWndGUI& @CRLF& $MsgID& @CRLF& $wParam& @CRLF& $lParam& @CRLF& "Einstieg"& @CRLF)
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    $line = _GUICtrlListView_GetSelectedindices($View)
    $event = DllStructGetData($tagNMHDR, 3)
    If $event = $NM_CLICK Then
    If $line <> "" Then
    _ExcelSheetActivate($oExcel[0], 1)
    msgbox(0,"selektierte Line",$line)
    ;$h = $line
    ;msgbox(0,"", $h)
    $sItem = _GUICtrlListView_GetItemtext($View, 0)
    MsgBox(4160, "Information", "Item 2 Text: " & $sitem)


    GUICtrlSetData($bkey, _ExcelReadCell($oExcel[0], $line + 1, 1))
    GUICtrlSetData($bname, _ExcelReadCell($oExcel[0], $line + 1, 2))
    GUICtrlSetData($bPW, _ExcelReadCell($oExcel[0], $line + 1, 3))
    GUICtrlSetData($bURL, _ExcelReadCell($oExcel[0], $line + 1, 4))
    _GUICtrlComboBox_SetEditText($bTyp, _ExcelReadCell($oExcel[0], $line + 1, 5))

    Typ_Text_Find(_ExcelReadCell($oExcel[0], $line + 1, 5))

    $tMeldung = "die Verbindung zum Schlüssel " & GUICtrlRead($bkey) & " wurde ausgewählt"
    GUICtrlSetData($Meldung, $tMeldung)

    Endif
    EndIf
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
    EndFunc

    Func Save_Excel()
    ;*********************************************************************************
    ;* Änderungen in Excel speichern *
    ;* ListView neu aufbauen *
    ;*********************************************************************************
    Local $result, $gefunden

    $result = msgbox(36,"Sicherheitsabfrage", "Wollen sie wirklich speichern?")
    If $result = 6 Then
    $i[0] = 1
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)
    $gefunden = 0
    _ExcelSheetActivate($oExcel[0], 1)

    If $s1[0] = "" Or $s1[0] = " " Then
    Msgbox(0, "Tabelle leer", "es sind keine Einträge in der INIT-Tabelle")
    Exit
    EndIf

    While $s1[0] <> "" And $s1[0] <> " " And $gefunden = 0
    If $s1[0] = GUICtrlRead($bkey) Then
    $gefunden = 1
    Else
    $i[0] = $i[0] + 1
    $s1[0] = _ExcelReadCell($oExcel[0], $i[0], 1)
    EndIf
    WEnd

    If $gefunden = 1 Then
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bname), $i[0], 2)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bPW), $i[0], 3)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bURL), $i[0], 4)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bTyp), $i[0], 5)
    Else
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bkey), $i[0], 1)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bname), $i[0], 2)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bPW), $i[0], 3)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bURL), $i[0], 4)
    _ExcelWriteCell($oExcel[0], GUICtrlRead($bTyp), $i[0], 5)
    EndIf

    $tMeldung = "Daten zum Schlüssel " & GUICtrlRead($bkey) & " wurden gespeichert"
    GUICtrlSetData($Meldung, $tMeldung)

    _GUICtrlListView_Destroy($View)
    List_Fill()
    Endif
    EndFunc

    Func Typ_Text_Find($t)
    ;*********************************************************************************
    ;* Text zu Verbindungstyp suchen *
    ;*********************************************************************************
    Local $i, $tgefunden, $iCell

    If $t = " " Or $t = "" Then
    $itTyp = "undefiniert"
    Else
    $i = 1
    $tgefunden = 0
    _ExcelSheetActivate($oExcel[0], 2)

    $iCell = _ExcelReadCell($oExcel[0], $i, 1)

    While $iCell <> " " And $iCell <> "" And $tgefunden = 0
    If $iCell = $t Then
    $tgefunden = 1
    $itTyp = _ExcelReadCell($oExcel[0], $i, 2)
    Else
    $i = $i + 1
    $iCell = _ExcelReadCell($oExcel[0], $i, 1)
    EndIf
    WEnd

    If $tgefunden = 0 Then
    $itTyp = "nicht vorhanden"
    EndIf

    GUICtrlSetData($iTyp, $itTyp)
    EndIf

    _ExcelSheetActivate($oExcel[0], 1)

    EndFunc

    Func Delete_Excel()
    ;*********************************************************************************
    ;* Löschen einer ausgewählten Zeile in Excel *
    ;*********************************************************************************
    Local $i, $tgefunden, $result

    $result = msgbox(36,"Sicherheitsabfrage", "Wollen sie wirklich löschen?")
    If $result = 6 Then
    _ExcelSheetActivate($oExcel[0], 1)
    _ExcelRowDelete($oExcel[0], $line + 1, 1)

    $tMeldung = "Daten zum Schlüssel " & GUICtrlRead($bkey) & " wurden gelöscht"
    GUICtrlSetData($Meldung, $tMeldung)

    GUICtrlSetData($bkey, " ")
    GUICtrlSetData($bname, " ")
    GUICtrlSetData($bPW, " ")
    GUICtrlSetData($bTyp, " ")
    GUICtrlSetData($bURL, " ")
    GUICtrlSetData($iTyp, " ")

    _GUICtrlListView_Destroy($View)
    List_Fill()
    EndIf

    EndFunc


    Gruß

    Gunter_s