doppelte einträge im listview

  • hi leute!

    ich will mir eine kleines admintool schreiben. unter anderem mit prozess manager. ich hab den teil das der alle prozesse in ein listview einträgt schon.
    allerdings tut der bei jeder aktualisierung alle prozesse noch mal eintragen. (d.h. sie sind dann alle doppelt drin, nach ein paar schleifen auch zehn mal etc.)

    kann mir jemand sagen wie ich alle einträge im listview löschen kann? oder halt vorm eintrage überprüfe ob der eintrag schon vorhanden ist??

    danke schon im voraus!

    mfg mr. sex pistols

  • Deine aktuellen Listview Einträge in ne Array packen und dann gucken ob der Prozess schon in der Array vorhanden ist , wenn nicht dann neu hinzufügen.

  • yup danke! aber wenn zb ein prozess ni mehr vorhanden ist muss der ja gelöscht werden!! also is es bestimmt sinnvoller erst die komplette liste zu löschen und dann zu aktualisieren!?

  • Kannst ja auch gucken welche Items im alten drin sind und im neuen nicht und genau die dann löschen.

  • yup danke!!

    hab mir jetz die beta gedownloaded...aber wenn ich versuche das skript mit
    _GUICTRLListViewDeleteAllItems zu starten, dann zeigt der mir fehler in GuiListView.au3!?

  • ah ja das war das problem...danke!! nur noch ein letztes problem: wenn ich vor jeder aktualisierung _GUICTRLListViewDeleteAllItems benutze dann flackert die ganze liste ununterbrochen!!! gibts ne möglichkeit das zu umgehen/unterbinden??

    EDIT:

    ok ich hab ne idee aber wenn ich die liste runter scrolle und der löscht die liste, dann bin ich wieder ganz oben... also muss ich doch die umständliche variante mit arrays auswerten nehmen... :(

    vielen dank an alle!!

    Einmal editiert, zuletzt von mR. sEx p!sT0Ls (7. November 2006 um 19:13)

  • Wenn du alle paar Millisekunden die ganze Liste neu aufbaust flackert das natürlich... Musst halt bissel selber an diesem Check arbeiten.

    • Offizieller Beitrag

    Hi,

    im Eng Forum sind einige gute Anfäge von Admin tools:

    Wie gefällt dir dies?

    http://www.autoitscript.com/forum/index.php?showtopic=28453&hl=Pcinfo

    Spoiler anzeigen
    [autoit]

    #region Start-up Vars
    ProgressOn("Loading...", "Gathering Data...", "0%", -1, -1)

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

    Global $SelectAll = 0
    Dim $Key = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    ProgressSet(10, "10%")
    Dim $Title = "Display Uninstall"
    Dim $EnableList = 1
    Dim $RemoteComputer
    $SelectedCount = 0
    ProgressSet(20, "20%")
    HotKeySet("{Esc}", "Stop")
    HotKeySet('^a', 'SelectAll')
    AutoItSetOption("RunErrorsFatal", 0)
    $vid_card = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\0004", "DriverDesc")
    If @error Then
    $vid_card = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E968-E325-11CE-BFC1-08002BE10318}\0000", "DriverDesc")
    EndIf
    ProgressSet(25, "25%")
    $processer = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E966-E325-11CE-BFC1-08002BE10318}\0000", "DriverDesc")
    ProgressSet(30, "30%")
    $sound_card = Regread("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{71A27CDD-812A-11D0-BEC7-08002BE2092F}\0000", "DriverDesc")
    ProgressSet(40, "40%")
    Dim $Bin = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductID")
    Dim $key4RegisteredOwner = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    ProgressSet(45, "45%")
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    $colSettings = $objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    ProgressSet(50, "50%")
    $colMemory = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
    $colCPU = $objWMIService.ExecQuery ("Select * from CIM_Processor")
    ProgressSet(60, "60%")
    ;~ $colVideoinfo = $objWMIService.ExecQuery ("Select * from Win32_VideoController")
    Dim $pcinfo, $pcinfo2, $clockspeed
    Dim $ffcase = 0
    Dim $labelinc = 0
    Dim $spy1 = 0

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

    For $object In $colSettings
    $wininfo = String($object.Caption)
    $winsp = String($object.CSDVersion)
    ;~ $clockspeed = String(Int(Number($object.CurrentClockSpeed))) / 1000
    Next
    ProgressSet(70, "70%")
    For $object In $colCPU
    $pcinfo = String($object.Name)
    $clockspeed = String(Int(Number($object.CurrentClockSpeed))) / 1000
    Next

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

    For $object In $colMemory
    $primaryowner = String($object.PrimaryOwnerName)
    $pcinfo2 = String(Int(Number($object.TotalPhysicalMemory) / (1024))) & " KB" & " (" & String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024)) + 1) & " MB)"
    Next

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

    $audiocardquery = $objWMIService.ExecQuery ("Select * from Win32_SoundDevice")
    ProgressSet(80, "80%")
    $cpu = StringFormat("%.2f", $clockspeed)

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

    Dim $audiocardinfo,$devices

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

    For $object In $audiocardquery
    $devices = String($object.DeviceID)
    ProgressSet(90, "90%")
    $firstaudiocard = $objWMIService.ExecQuery ("Select * from Win32_SoundDevice.DeviceID=" & $devices)

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

    $audiocardinfo = String($object.Name)
    $audiocardinfo2 = String($object.Status)
    ProgressSet(100, "100%")
    ConsoleWrite(@CRLF & $audiocardinfo & @CRLF)
    ProgressOff()

    Next
    #endregion Start-up Vars

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

    #region Main Script

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

    #include <File.au3>
    #include <Constants.au3>
    #include <GuiStatusBar.au3>
    #include <GUIConstants.au3>
    #include <GuiListView.au3>

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

    $mainWindows = GUICreate("Computer Details", 495 + 350, 700, -1, -1)

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

    $label_1 = GUICtrlCreateLabel("Computer Name: ", 24, 8, 86, 17)
    $Label_2 = GUICtrlCreateLabel(@ComputerName, 112, 8, 150, 17)
    $ID = GUICtrlCreateLabel("UserName: " & @UserName, 200, 8, 155, 17)
    $Group_8 = GUICtrlCreateGroup("Operating System", 176, 64, 127, 41)
    $Label_9 = GUICtrlCreateLabel(@OSVersion, 192, 80, 110, 17)
    $Group2 = GUICtrlCreateGroup("Monitor", 24, 56, 145, 121)
    $Label_4 = GUICtrlCreateLabel("Width: " & @DesktopWidth & " Pixels", 40, 72, 120, 17)
    $Label_5 = GUICtrlCreateLabel("Height: " & @DesktopHeight & " Pixels", 40, 96, 120, 17)
    $Label_6 = GUICtrlCreateLabel("Refresh Rate: " & @DesktopRefresh & " Pixels", 40, 120, 120, 17)
    $label_11 = GUICtrlCreateLabel("Depth: " & @DesktopDepth & " Pixels", 40, 140, 120, 17)
    $Label_14 = GUICtrlCreateLabel("The Full Path for this Program is: ", 24, 32, 159, 17)
    $Label_14 = GUICtrlCreateLabel(@ScriptFullPath, 184, 36, 300, 17, $SS_SUNKEN)
    $Group3 = GUICtrlCreateGroup("Internet", 24, 184, 281, 73)
    $retest_c = GUICtrlCreateButton("Retest", 32, 200, 97, 25)
    $Internet = GUICtrlCreateLabel("Testing Internet Connection...", 32, 232, 250, 17)
    $Label_7 = GUICtrlCreateLabel("IP:" & @IPAddress1, 150, 205, 150, 17, $SS_SUNKEN)
    $Group4 = GUICtrlCreateGroup("Drives", 24, 264, 233, 169)
    $Button_11 = GUICtrlCreateButton("Find All Drives", 32, 280, 121, 25)
    $Button_12 = GUICtrlCreateButton("Find CD-Drives", 32, 312, 121, 25)
    $Button_13 = GUICtrlCreateButton("Find Removable Drives", 32, 344, 121, 25)
    $Button_15 = GUICtrlCreateButton("Get Size of Drive:", 32, 376, 121, 25)
    $cd_o = GUICtrlCreateButton("Open Drive", 168, 280, 73, 25)
    $Label_10 = GUICtrlCreateLabel("Home Drive:" & @HomeDrive, 160, 320, 80, 17)
    $Credits = GUICtrlCreateButton("Credits", 420, 10, 65, 25)
    $Group5 = GUICtrlCreateGroup("Windows", 264, 264, 225, 169)
    $winCombo_C = GUICtrlCreateCombo("", 272, 280, 209, 21)
    $winClose_R = GUICtrlCreateRadio("Win Close", 272, 328, 73, 17)
    $winKill_R = GUICtrlCreateRadio("Win Kill", 360, 328, 65, 17)
    $winshow_R = GUICtrlCreateRadio("Win Show", 272, 304, 73, 17)
    $winhide_R = GUICtrlCreateRadio("Win Hide", 360, 304, 65, 17)
    $Go_B = GUICtrlCreateButton("Activate", 272, 376, 209, 25)
    $status_L = GUICtrlCreateLabel("Ready...", 272, 408, 210, 17)
    $GroupP = GUICtrlCreateGroup("Programs", 312, 156, 177, 101)
    $processClose_R = GUICtrlCreateRadio("Process End", 320, 212, 161, 17)
    $Go_A = GUICtrlCreateButton("Activate...", 320, 232, 161, 20)
    $processCombo_C = GUICtrlCreateCombo("", 320, 180, 161, 21)
    $tree = GuiCtrlCreateButton("Folder Tree", 355, 10, 65, 25)
    $r_input = GUICtrlCreateInput("Enter program to run", 174, 117, 130, 20)
    $rp_input = GUICtrlCreateInput("Enter path to program", 174, 137, 130, 20)
    $rr_run = GUICtrlCreateButton("Run program", 174, 157, 130, 20)
    $hard_group = GUICtrlCreateGroup("Hard Ware", 310, 50, 196, 100)
    $vid_card_L = GUICtrlCreateLabel("Vid Card: " & $vid_card, 315, 66, 190, 20)
    ;~ $processer_L = GUICtrlCreateLabel("Processor: " & $processer, 315, 86, 174, 20)
    GUICtrlCreateLabel("Processer: " & $pcinfo, 315, 86, 174, 30)
    ;~ $sound_car_L = GUICtrlCreateLabel("Sound Card: " & $sound_card, 315, 116, 174, 20)
    GUICtrlCreateLabel("Sound Card: " & $audiocardinfo & " Status: " & $audiocardinfo2, 315, 116, 174, 30)

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

    ;Windows Info
    $microsoft_info = GUICtrlCreateGroup("Microsoft Information", 24, 445, 450, 220)
    $status_L = GUICtrlCreateLabel("Information read out ...", 27, 475, 400, 20)
    $description_L = GUICtrlCreateLabel("Description-----------------------------------", 27, 495, 103, 20)
    $windowsType_L = GUICtrlCreateLabel("WindowsType------------------------------------", 27, 515, 103, 20)
    $serialNumber_L = GUICtrlCreateLabel("SerialNumber-----------------------------------", 27, 535, 103, 20)
    $ProductKey_L = GUICtrlCreateLabel("ProductKey-------------------------------------", 27, 555, 103, 20)
    $InstallDate_L = GUICtrlCreateLabel("InstallDate--------------------------------", 27, 575, 103, 20)
    $LastBootUpTime_L = GUICtrlCreateLabel("LastBootUpTime------------------------------", 27, 595, 103, 20)
    $RegisteredOwner_L = GUICtrlCreateLabel("RegisteredOwner--------------------------------", 27, 615, 103, 20)
    $officeKey_L = GUICtrlCreateLabel("OfficeKey----------------------------------", 27, 635, 113, 20)

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

    $description_I = GUICtrlCreateInput("Description", 135, 495, 315, 21)
    $windowsType_I = GUICtrlCreateInput("WindowsType", 135, 515, 315, 21)
    $serialNumber_I = GUICtrlCreateInput("SerialNumber", 135, 535, 315, 21)
    $ProductKey_I = GUICtrlCreateInput("ProductKey", 135, 555, 315, 21)
    $InstallDate_I = GUICtrlCreateInput("InstallDate", 135, 575, 315, 21)
    $LastBootUpTime_I = GUICtrlCreateInput("LastBootUpTime", 135, 595, 315, 21)
    $RegisteredOwner_I = GUICtrlCreateInput("RegisteredOwner", 135, 615, 315, 21)
    $officeKey_I = GUICtrlCreateInput("OfficeKey", 135, 635, 315, 21)

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

    ;Trans-=-Alpha
    $trans = GUICtrlCreateSlider(510, 620, 300, 30)
    GUICtrlSetLimit($trans, 255,50)
    $transbutton = GUICtrlCreateButton("Set window alpha", 510, 590, 300, 20)

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

    ;Installed Programs List
    $ulist = GUICtrlCreateListView("Icon|Display Name|Key Name", 510, 40, 285, 520, BitOR($LVS_NOSORTHEADER, $LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES))
    GUICtrlSetResizing($ulist, $GUI_DOCKBORDERS)
    _GUICtrlListViewSetColumnWidth ($ulist, 0, $LVSCW_AUTOSIZE_USEHEADER)
    _GUICtrlListViewSetColumnWidth ($ulist, 1, 310)
    _GUICtrlListViewSetColumnWidth ($ulist, 2, 310)
    $but1 = GUICtrlCreateButton("Refresh List", 520, 15, -1, -1, $BS_DEFPUSHBUTTON)
    GUICtrlSetResizing($but1, $GUI_DOCKALL)
    $but2 = GUICtrlCreateButton("Uninstall Programs", 600, 15)
    GUICtrlSetResizing($but2, $GUI_DOCKALL)
    GUICtrlSetState($but2, $GUI_DISABLE)
    $chkbox = GUICtrlCreateCheckbox("Enable\Disable Silent Uninstall", 9000, 12)
    GUICtrlSetResizing($chkbox, $GUI_DOCKALL)
    $Label1 = GUICtrlCreateLabel('Remote Computer', 4700, 15, 85, 20)
    GUICtrlSetResizing($Label1, $GUI_DOCKALL)
    $Input1 = GUICtrlCreateInput('', 5600, 12, 130, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_UPPERCASE))
    GUICtrlSetResizing($Input1, $GUI_DOCKALL)
    $StatusBar1 = _GuiCtrlStatusBarCreate ($mainWindows, 400, "", $SBT_TOOLTIPS)
    _GuiCtrlStatusBarSetMinHeight ($StatusBar1, 15)
    $Progress1 = GUICtrlCreateProgress(510, 560, 285, 20)
    GUICtrlSetResizing($Progress1, $GUI_DOCKSTATEBAR)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUISetState(@SW_SHOW)
    $List = ReadKeys()

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

    GuiSetState()

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

    _INITIATE()

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

    While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $transbutton
    $var2 = GUICtrlRead($trans)
    WinSetTrans("Computer Details", "", $var2)
    MsgBox(0,$var2, "The Window alpha is now: " & $var2)
    Case $msg = $Button_11
    $pass = 1
    $dr_all = DriveGetDrive("all")
    If @error Then
    Msgbox(0, "ERROR", "No Drives found.")
    $pass = 0
    EndIf
    If $pass = 1 Then
    If NOT @error Then
    MsgBox(4096,"", "Found " & $dr_all[0] & " drives")
    For $i = 1 to $dr_all[0]
    MsgBox(4096,"Drive " & $i, $dr_all[$i])
    Next
    EndIf
    EndIf
    Case $msg = $Button_12
    $pass = 1
    $dr_cd = DriveGetDrive("CDROM")
    If @error Then
    Msgbox(0, "ERROR", "No CDROM Drives found.")
    $pass = 0
    EndIf
    If $pass = 1 Then
    If NOT @error Then
    MsgBox(4096,"", "Found " & $dr_cd[0] & " drives")
    For $i = 1 to $dr_cd[0]
    MsgBox(4096,"Drive " & $i, $dr_cd[$i])
    Next
    EndIf
    EndIf
    Case $msg = $Button_13
    $pass = 1
    $dr_removable = DriveGetDrive("REMOVABLE")
    If @error Then
    Msgbox(0, "ERROR", "No Removable Drives found.")
    $pass = 0
    EndIf
    If $pass = 1 Then
    If NOT @error Then
    MsgBox(4096,"", "Found " & $dr_removable[0] & " drives")
    For $i = 1 to $dr_removable[0]
    MsgBox(4096,"Drive " & $i, $dr_removable[$i])
    Next
    EndIf
    EndIf
    Case $msg = $Button_15
    $SD = InputBox("Selection", "Please Enter the drive path that you want the size of.", "C:\")
    $SDI = DriveSpaceTotal($SD)
    $SDI2 = DriveSpaceFree($SD)
    If Not @error Then
    MsgBox(0, "Drive Space for Drive: " & $SD, "Drive total space: " & Round($SDI/ 1024, 2) & " MegaBytes")
    MsgBox(0, "Drive Free Space for Drive: " & $SD, "Drive free space: " & Round($SDI2/ 1024, 2) & " MegaBytes")
    EndIf
    If @error Then
    MsgBox(0, "ERROR: DRIVE NOT FOUND!!!", "---That is an invalid drive path, please enter correct path!!!---")
    EndIf
    Case $msg = $Go_B
    If GUICtrlRead($winClose_R) = $GUI_CHECKED Then _winClose()
    If GUICtrlRead($winKill_R) = $GUI_CHECKED Then _winKill()
    If GUICtrlRead($winshow_R) = $GUI_CHECKED Then _winshow()
    If GUICtrlRead($winhide_R) = $GUI_CHECKED Then _winhide()
    Case $msg = $processClose_R
    _processCombo()
    Case $msg = $winKill_R Or $msg = $winClose_R
    _winListCombo()
    Case $msg = $cd_o
    $o = InputBox("Open", "Please enter the Drive you want to open. If it is a CD drive the disk will eject", "C:\")
    CDTray($o, "OPEN")
    If @error = 0 Then
    Run('Explorer.exe "' & $o & '"', @WorkingDir, @SW_SHOW)
    EndIf
    Case $msg = $retest_c
    GuiCtrlSetData($Internet, GetToggle3r(GuiCtrlRead($Internet)))
    _Internet()
    Case $msg = $Credits
    MsgBox(0, "Credits", "This program was made by Firestorm.")
    MsgBox(0, "Q/C", "Questions? Comments? Errors? E-mail me at [email='firestorm037@hotmail.com'][/email]!")
    Case $msg = $tree
    $Path = FileSelectFolder("Choose a folder.", "")
    Run('Explorer.exe "' & $Path & '"', @WorkingDir, @SW_SHOW)
    Case $msg = $Go_A
    If GuiCtrlRead($processClose_R) = $GUI_CHECKED Then _processClose()
    Case $msg = $rr_run
    $program = GUICtrlRead($r_input)
    $program_path = GUICtrlRead($rp_input)
    Run($program & ".exe", $program_path)
    If @error = 1 Then
    MsgBox(48, "ERROR", "That is an invailid file or file path.")
    EndIf
    Case $MSG = $but1
    _GUICtrlListViewDeleteAllItems ($ulist)
    $RemoteComputer = StringReplace(GUICtrlRead($Input1), '\', '')
    $List = ReadKeys($RemoteComputer)
    GUICtrlSetData($Input1, '')
    Case $MSG = $but2
    $ListIndices = _GUICtrlListViewGetSelectedIndices ($ulist, 1)
    If $ListIndices == $LV_ERR Then ContinueLoop
    If $ListIndices[0] > 1 Then GUICtrlSetState($Progress1, $GUI_SHOW)
    Opt('RunErrorsFatal', 0)
    $Count = 0
    ControlListView('', '', $ulist, "SelectClear")
    For $x = $ListIndices[0] To 1 Step - 1
    $Count += 1
    $SelectKey = ''
    GUICtrlSetData($Progress1, Int(($Count / $ListIndices[0]) * 100))
    $ListInfo = StringSplit($List[$ListIndices[$x]], '|');ListInfo[0] = 5, ListInfo[1] = Display Name, ListInfo[2] = Regkey Name, ListInfo[3] = Icon, ListInfo[4] = QuietUninstallString, ListInfo[5] = UnistallString
    If GUICtrlRead($chkbox) == $GUI_CHECKED Or $RemoteComputer <> '' Then
    $SelectKey = $ListInfo[4]
    If $SelectKey == '' Then $SelectKey = StringReplace($ListInfo[5], '/i', '/X', 1) & ' /qn /norestart'
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Uninstalling Program ' & $Count & ' Of ' & $ListIndices[0] & ' ' & $ListInfo[1])
    EndIf
    If GUICtrlRead($chkbox) == $GUI_UNCHECKED And $SelectKey == '' Then
    $SelectKey = $ListInfo[5]
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Uninstalling Program ' & $Count & ' Of ' & $ListIndices[0] & ' ' & $ListInfo[1])
    EndIf
    If $RemoteComputer == '' Then
    $Pid = Run($SelectKey, @WorkingDir, @SW_SHOW)
    Else
    $Pid = Run('BeyondExec.exe ' & StringMid($RemoteComputer, 1, StringInStr($RemoteComputer, '\', 0, -1) - 1) & ' -s -n -r ' & $SelectKey, @WorkingDir, @SW_HIDE)
    EndIf
    If @error Then
    _FileWriteLog(@ScriptDir & '\UninstallFail.Log', $ListInfo[1] & ' | ' & $SelectKey)
    EndIf
    If Not @error And $RemoteComputer <> "" Then GUISetCursor(15, 1);set cursor to wait
    While ProcessExists($Pid)
    Sleep(50)
    WEnd
    GUISetCursor(2, 1);set cursor to arrow
    ;ProcessWaitClose($Pid)
    SetError(0)
    RegRead($RemoteComputer & $Key & "\" & $ListInfo[2], 'UninstallString')
    If @error == 1 Then
    _GUICtrlListViewDeleteItem ($ulist, $ListIndices[$x])
    _ArrayDelete($List, $ListIndices[$x])
    EndIf
    Next
    ;$Pos = WinGetPos($Title)
    ;_GUICtrlListViewScroll($ulist, 0, Number('-' & $Pos[3] * 20))
    Opt('RunErrorsFatal', 1)
    GUICtrlSetData($Progress1, 0)
    If $ListIndices[0] > 1 Then GUICtrlSetState($Progress1, $GUI_HIDE)
    If $RemoteComputer == '' Then
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Local Computer: ' & _GUICtrlListViewGetItemCount ($ulist) & ' Objects, ' & _GUICtrlListViewGetSelectedCount ($ulist) & ' Objects Selected')
    Else
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Remote Computer: ' & '"' & StringReplace($RemoteComputer, '\', '') & '"' & ', ' & _GUICtrlListViewGetItemCount ($ulist) & ' Objects, ' _
    & _GUICtrlListViewGetSelectedCount ($ulist) & ' Objects Selected')
    EndIf
    GUICtrlSetState($but2, $GUI_DISABLE)
    Case $MSG = $GUI_EVENT_CLOSE
    Exit
    ; resize columns based on window size
    Case $MSG = $GUI_EVENT_MINIMIZE
    $width = ControlGetPos($mainWindows, "", $ulist)
    $Resize = $width[2] - _GUICtrlListViewGetColumnWidth ($ulist, 0)
    _GUICtrlListViewSetColumnWidth ($ulist, 1, $Resize / 2.1)
    _GUICtrlListViewSetColumnWidth ($ulist, 2, $Resize / 2.1)
    _GuiCtrlStatusBarResize ($StatusBar1)
    Case $MSG = $GUI_EVENT_MAXIMIZE
    $width = ControlGetPos($mainWindows, "", $ulist)
    $Resize = $width[2] - _GUICtrlListViewGetColumnWidth ($ulist, 0)
    _GUICtrlListViewSetColumnWidth ($ulist, 1, $Resize / 2.1)
    _GUICtrlListViewSetColumnWidth ($ulist, 2, $Resize / 2.1)
    _GuiCtrlStatusBarResize ($StatusBar1)
    Case $MSG = $GUI_EVENT_RESIZED
    $width = ControlGetPos($mainWindows, "", $ulist)
    $Resize = $width[2] - _GUICtrlListViewGetColumnWidth ($ulist, 0)
    _GUICtrlListViewSetColumnWidth ($ulist, 1, $Resize / 2.1)
    _GUICtrlListViewSetColumnWidth ($ulist, 2, $Resize / 2.1)
    _GuiCtrlStatusBarResize ($StatusBar1)
    Case $MSG = $GUI_EVENT_RESTORE
    $width = ControlGetPos($mainWindows, "", $ulist)
    $Resize = $width[2] - _GUICtrlListViewGetColumnWidth ($ulist, 0)
    _GUICtrlListViewSetColumnWidth ($ulist, 1, $Resize / 2.1)
    _GUICtrlListViewSetColumnWidth ($ulist, 2, $Resize / 2.1)
    _GuiCtrlStatusBarResize ($StatusBar1)
    Case Else
    If $EnableList And $SelectedCount == 1 Then
    $EnableList = 0
    GUICtrlSetState($but2, $GUI_ENABLE);enable uninstall button
    EndIf
    If Not $EnableList And $SelectedCount == 0 Then
    $EnableList = 1
    GUICtrlSetState($but2, $GUI_DISABLE);disable uninstall button
    EndIf
    If $SelectedCount <> _GUICtrlListViewGetSelectedCount ($ulist) Then
    $SelectedCount = _GUICtrlListViewGetSelectedCount ($ulist)
    If $RemoteComputer == '' Then
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Local Computer: ' & _GUICtrlListViewGetItemCount ($ulist) & ' Objects, ' & _GUICtrlListViewGetSelectedCount ($ulist) & ' Objects Selected')
    Else
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Remote Computer: ' & '"' & StringReplace($RemoteComputer, '\', '') & '"' & ', ' & _GUICtrlListViewGetItemCount ($ulist) & ' Objects, ' _
    & _GUICtrlListViewGetSelectedCount ($ulist) & ' Objects Selected')
    EndIf
    EndIf
    EndSelect
    WEnd
    Exit
    #endregion Main Script

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

    #region Functions

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

    Func _INITIATE()
    GUICtrlSetData($trans,255)
    $product = "XP"
    _processCombo()
    _winListCombo()
    _Internet()
    For $objOperatingSystem In $colSettings
    Next
    GUICtrlSetData($description_I, StringMid($objOperatingSystem.Description, 1))
    GUICtrlSetData($windowsType_I, '(' & @OSVersion & ') ' & StringMid($objOperatingSystem.Caption, 19))
    GUICtrlSetData($serialNumber_I, StringMid($objOperatingSystem.SerialNumber, 1))
    GUICtrlSetData($ProductKey_I, DecodeProductKey($Bin))
    GUICtrlSetData($InstallDate_I, WMIDateStringToDate($objOperatingSystem.InstallDate))
    GUICtrlSetData($LastBootUpTime_I, WMIDateStringToDate($objOperatingSystem.LastBootUpTime))
    GUICtrlSetData($RegisteredOwner_I, RegRead($key4RegisteredOwner, "RegisteredOwner"))
    GUICtrlSetData($officeKey_I, getOfficeKey())
    GUICtrlSetData($officeKey_L, "Office " & $product & "-------------------")
    EndFunc

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

    Func _winClose()
    If WinExists(GUICtrlRead($winCombo_C)) Then
    WinClose(GUICtrlRead($winCombo_C))
    Else
    GUICtrlSetData($status_L, "Window doesn't exist")
    Sleep(2500)
    GUICtrlSetData($status_L, "Ready...")
    EndIf
    EndFunc;==>_winClose

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

    Func _winKill()
    If WinExists(GUICtrlRead($winCombo_C)) Then
    WinKill(GUICtrlRead($winCombo_C))
    Else
    GUICtrlSetData($status_L, "Window doesn't exist")
    Sleep(2500)
    GUICtrlSetData($status_L, "Ready...")
    EndIf
    EndFunc;==>_winKill

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

    Func _processClose()
    If ProcessExists(GUICtrlRead($processCombo_C)) Then
    ProcessClose(GUICtrlRead($processCombo_C))
    Else
    GUICtrlSetData($status_L, "Process doesn't exist")
    Sleep(2500)
    GUICtrlSetData($status_L, "Ready...")
    EndIf
    EndFunc;==>_processClose

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

    ;~ Func _killByPID()
    ;~ If _ProcessGetName(GUICtrlRead($processCombo_C)) <> '' Then
    ;~ $rc = _RunDOS("start taskkill /PID " & GUICtrlRead($processCombo_C) & " /T")
    ;~ GUICtrlSetData($status_L, "ProcessID " & GUICtrlRead($processCombo_C) & " - (" & _ProcessGetName(GUICtrlRead($processCombo_C)) & ")" & " killed")
    ;~ Sleep(2500)
    ;~ GUICtrlSetData($status_L, "Ready...")
    ;~ Else
    ;~ GUICtrlSetData($status_L, "ProcessID doesn't exist")
    ;~ Sleep(2500)
    ;~ GUICtrlSetData($status_L, "Ready...")
    ;~ EndIf
    ;~ EndFunc;==>_killByPID

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

    Func _processCombo()
    Dim $processArray = ProcessList()
    For $i = 1 To $processArray[0][0]
    GUICtrlSetData($processCombo_C, $processArray[$i][0])
    Next
    EndFunc;==>_processCombo

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

    Func _winListCombo()
    Dim $windowArray = WinList()
    For $i = 1 To $windowArray[0][0]
    ; Only display visble windows that have a title
    If $windowArray[$i][0] <> "" Then;AND IsVisible($var[$i][1]) Then
    GUICtrlSetData($winCombo_C, $windowArray[$i][0])
    EndIf
    Next
    EndFunc;==>_winListCombo

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

    Func _winshow()
    If WinExists(GUICtrlRead($winCombo_C)) Then
    WinSetState(GUICtrlRead($winCombo_C),"", @SW_SHOW)
    Else
    GUICtrlSetData($status_L, "Window doesn't exist")
    Sleep(2500)
    GUICtrlSetData($status_L, "Ready...")
    EndIf
    EndFunc;==>_winshow

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

    Func _winhide()
    If WinExists(GUICtrlRead($winCombo_C)) Then
    WinSetState(GUICtrlRead($winCombo_C),"", @SW_HIDE)
    Else
    GUICtrlSetData($status_L, "Window doesn't exist")
    Sleep(2500)
    GUICtrlSetData($status_L, "Ready...")
    EndIf
    EndFunc;==>_winhide

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

    Func _Internet()
    Local $sInputBoxAnswer = InputBox("Test Connection","Do you want to test your internet connection?" & @CRLF & _
    "You may get a firewall warning dialog warning this will only ping the website you specify to test your connection.","www.yahoo.com")
    If @Error = 0 Then;The Okay button was pushed
    Sleep(500)
    $var = Ping($sInputBoxAnswer)
    If $var Then; also possible: If @error = 0 Then ...
    GuiCtrlSetData($Internet, GetToggle1(GuiCtrlRead($Internet)))
    Else
    GuiCtrlSetData($Internet, GetToggle2(GuiCtrlRead($Internet)))
    EndIf
    ElseIf @Error = 1 Then;The Cancel button was pushed
    GuiCtrlSetData($Internet, 'Internet Connection Test canceled')
    ElseIf @Error = 3 Then;error
    GuiCtrlSetData($Internet, 'Internet Connection Test an error has occured')
    EndIf
    EndFunc

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

    Func GetToggle1($stext)
    if $stext = "Testing Internet Connection..." then
    GUICtrlSetColor($Internet, "0x0000ff")
    return "You are connected to the internet!"
    else
    return " "
    endif
    EndFunc

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

    Func GetToggle2($stext)
    if $stext = "Testing Internet Connection..." then
    GUICtrlSetColor($Internet, "0xff0000")
    return "WARNING! You are NOT connected to the internet!"
    else
    return " "
    endif
    EndFunc

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

    Func GetToggle3r($stext)
    if $stext = "WARNING! You are NOT connected to the internet!" OR "You are connected to the internet!" then
    GUICtrlSetColor($Internet, "0x000000")
    return "Testing Internet Connection..."
    else
    return " "
    endif
    EndFunc

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

    ; ----------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.1.1 beta
    ; Author: Unknown & Thorsten Meger <[email='Thorsten.Meger@gmx.de'][/email]>
    ;
    ; Script Function: Decode REG_BINARY
    ; ----------------------------------------------------------------------------

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

    Func DecodeProductKey($BinaryDPID)
    Local $bKey[15]
    Local $sKey[29]
    Local $Digits[24]
    Local $Value = 0
    Local $hi = 0
    Local $n = 0
    Local $i = 0
    Local $dlen = 29
    Local $slen = 15
    Local $Result

    $Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
    $BinaryDPID = StringMid($BinaryDPID, 105, 30)
    For $i = 1 To 29 Step 2
    $bKey[Int($i / 2) ] = Dec(StringMid($BinaryDPID, $i, 2))
    Next
    For $i = $dlen - 1 To 0 Step - 1
    If Mod(($i + 1), 6) = 0 Then
    $sKey[$i] = "-"
    Else
    $hi = 0
    For $n = $slen - 1 To 0 Step - 1
    $Value = BitOR(BitShift($hi, -8), $bKey[$n])
    $bKey[$n] = Int($Value / 24)
    $hi = Mod($Value, 24)
    Next
    $sKey[$i] = $Digits[$hi + 1]
    EndIf
    Next
    For $i = 0 To 28
    $Result = $Result & $sKey[$i]
    Next
    Return $Result
    EndFunc ;==>DecodeProductKey

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

    ; ----------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.1.1 beta
    ; Author: Unknown & Thorsten Meger <[email='Thorsten.Meger@gmx.de'][/email]>
    ;
    ; Script Function: WMIDateStringToDate (changed Date format)
    ; ----------------------------------------------------------------------------

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

    Func WMIDateStringToDate($dtmDate)
    Return (StringMid($dtmDate, 7, 2) & "/" & _
    StringMid($dtmDate, 5, 2) & "/" & StringLeft($dtmDate, 4) _
    & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate, 13, 2))
    EndFunc ;==>WMIDateStringToDate

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

    ; ----------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.1.1 beta
    ; Author: Thorsten Meger <[email='Thorsten.Meger@gmx.de'][/email]>
    ;
    ; Script Function: Display a "fake" progressbar at the beginning
    ; ----------------------------------------------------------------------------
    #cs
    Func progress()
    If $counter = 3 Then
    For $i = 0 To 20 Step 1
    GUICtrlSetData($progressbar, $i)
    Sleep($wait / 20)
    Next
    ElseIf $counter = 2 Then
    For $i = 20 To 50 Step 1
    GUICtrlSetData($progressbar, $i)
    Sleep($wait / 30)
    Next
    ElseIf $counter = 1 Then
    For $i = 50 To 80 Step 1
    GUICtrlSetData($progressbar, $i)
    Sleep($wait / 30)
    Next
    ElseIf $counter = 0 Then
    For $i = 80 To 100 Step 1
    GUICtrlSetData($progressbar, $i)
    Sleep($wait / 20)
    Next
    GUICtrlSetState($progressbar, $GUI_HIDE)
    EndIf
    EndFunc ;==>progress
    #ce
    ; ----------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.1.1 beta
    ; Author: Thorsten Meger <[email='Thorsten.Meger@gmx.de'][/email]>
    ;
    ; Script Function:Get & decode OfficeKey
    ; ----------------------------------------------------------------------------

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

    Func getOfficeKey()
    Local $List[1]
    Local $i = 1
    $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot", "Path")
    If $var <> "" Then
    $product = "2003"
    Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration"
    Else
    $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Common\InstallRoot", "Path")
    If @error <> 0 Then
    GUICtrlSetData($status_L, "Info: Unable to find installationPath, maybe no Office installed!")
    Return "No Office XP or 2003 found"
    EndIf
    If $var <> "" Then
    $product = "XP"
    Dim $officeKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration"
    EndIf
    EndIf
    Dim $var = RegEnumKey($officeKey, $i)
    If @error <> 0 Then
    GUICtrlSetData($status_L, "Info: Unable to find REG_BINARY 'DigitalProductID', maybe no Office installed!")
    Return "No Office XP or 2003 found"
    Else
    $List[$i - 1] = RegRead($officeKey & "\" & $var, "DigitalProductID")
    If $List[$i - 1] = "" Then
    GUICtrlSetData($status_L, "Info: Unable to find REG_BINARY 'DigitalProductID', maybe no Office installed!")
    Else
    $key = $List[$i - 1]
    Return DecodeProductKey($key)
    EndIf
    EndIf
    EndFunc ;==>getOfficeKey

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

    Func ReadKeys($s_RemoteComputer = '')
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Reading Registry Keys, Please Wait....')
    GUISetCursor(15, 1);set cursor to wait
    Local $even = 1
    Local $Count = 1
    Dim $avArray[1]

    If $s_RemoteComputer <> '' Then
    If StringMid($s_RemoteComputer, 1, 1) <> '\' Or StringMid($s_RemoteComputer, 2, 1) <> '\' Or StringRight($s_RemoteComputer, 1) <> '\' Then
    $s_RemoteComputer = '\\' & StringReplace($s_RemoteComputer, '\', '') & '\'
    EndIf
    EndIf
    Local Const $regkey = $s_RemoteComputer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    While 1
    $skey = RegEnumKey($regkey, $Count)
    If @error <> 0 Then ExitLoop
    $line = RegRead($regkey & '\' & $skey, 'Displayname')
    $line = StringReplace($line, ' (remove only)', '')
    If $line == '' Then $line = "No Display Name"
    $SilentUnistall = RegRead($regkey & '\' & $skey, 'QuietUninstallString')
    $Unistall = RegRead($regkey & '\' & $skey, 'UninstallString')
    $Icon = RegRead($regkey & '\' & $skey, 'DisplayIcon')
    $Icon = StringReplace(StringMid($Icon, 1, StringInStr($Icon, ',') - 1), '"', '')
    If $Icon = "" Then $Icon = "SHELL32.DLL"

    If $SilentUnistall <> '' Or $Unistall <> '' Then
    If (GUICtrlRead($chkbox) == $GUI_CHECKED And $SilentUnistall <> '') Or ($s_RemoteComputer <> '' And $SilentUnistall <> '') Then
    $avArray[UBound($avArray) - 1] = $line & '|' & $skey & '|' & $Icon & '|' & $SilentUnistall & '|'
    ReDim $avArray[UBound($avArray) + 1]
    ElseIf ($s_RemoteComputer == '' And GUICtrlRead($chkbox) == $GUI_UNCHECKED) Or (GUICtrlRead($chkbox) == $GUI_CHECKED And StringInStr($Unistall, 'msiexec.exe')) Or ($s_RemoteComputer <> '' And StringInStr($Unistall, 'msiexec.exe')) Then
    $avArray[UBound($avArray) - 1] = $line & '|' & $skey & '|' & $Icon & '|' & $SilentUnistall & '|' & $Unistall
    ReDim $avArray[UBound($avArray) + 1]
    EndIf
    EndIf
    $Count += 1
    WEnd
    If (UBound($avArray) - 1) == 0 Then
    If $RemoteComputer == '' Then _GuiCtrlStatusBarSetText ($StatusBar1, ' Local Computer: ' & _GUICtrlListViewGetItemCount ($ulist) & ' Objects, ' & _GUICtrlListViewGetSelectedCount ($ulist) & ' Objects Selected')
    If $RemoteComputer <> '' And _GUICtrlListViewGetItemCount ($ulist) Then
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Remote Computer: ' & '"' & StringReplace($RemoteComputer, '\', '') & '"' & ', ' & _GUICtrlListViewGetItemCount ($ulist) & ' Objects, ' _
    & _GUICtrlListViewGetSelectedCount ($ulist) & ' Objects Selected')
    $RemoteComputer = '\\' & $RemoteComputer & '\'
    ElseIf $RemoteComputer <> '' And _GUICtrlListViewGetItemCount ($ulist) == 0 Then
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Could Not Connect To Remote Computer ' & '"' & StringReplace($RemoteComputer, '\', '') & '"')
    $RemoteComputer = ''
    EndIf
    Else
    ReDim $avArray[UBound($avArray) - 1]
    _ArraySort($avArray)
    GUICtrlSetState($Progress1, $GUI_SHOW)
    For $i = 0 To UBound($avArray) - 1
    GUICtrlSetData($Progress1, Int(($i / (UBound($avArray) - 1)) * 100))
    $Item = StringSplit($avArray[$i], '|')
    Local $lv_item = GUICtrlCreateListViewItem("" & "|" & $Item[1] & "|" & $Item[2], $ulist)
    GUICtrlSetImage(-1, $Item[3])
    If $even Then
    $even = 0
    GUICtrlSetBkColor($lv_item, 0x5CACEE)
    Else
    GUICtrlSetBkColor($lv_item, 0x9FB6CD)
    $even = 1
    EndIf
    Sleep(15)
    Next
    Sleep(1000)
    If $RemoteComputer == '' Then _GuiCtrlStatusBarSetText ($StatusBar1, ' Local Computer: ' & _GUICtrlListViewGetItemCount ($ulist) & ' Objects, ' & _GUICtrlListViewGetSelectedCount ($ulist) & ' Objects Selected')
    If $RemoteComputer <> '' And _GUICtrlListViewGetItemCount ($ulist) Then
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Remote Computer: ' & '"' & StringReplace($RemoteComputer, '\', '') & '"' & ', ' & _GUICtrlListViewGetItemCount ($ulist) & ' Objects, ' _
    & _GUICtrlListViewGetSelectedCount ($ulist) & ' Objects Selected')
    $RemoteComputer = '\\' & $RemoteComputer & '\'
    ElseIf $RemoteComputer <> '' And _GUICtrlListViewGetItemCount ($ulist) == 0 Then
    _GuiCtrlStatusBarSetText ($StatusBar1, ' Could Not Connect To Remote Computer ' & '"' & StringReplace($RemoteComputer, '\', '') & '"')
    $RemoteComputer = ''
    EndIf
    EndIf
    GUICtrlSetState($Progress1, $GUI_HIDE)
    GUISetCursor(2, 1);set cursor to arrow
    Return ($avArray)
    EndFunc;==>ReadKeys

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

    Func SelectAll()
    If $SelectAll Then
    $SelectAll = 0
    GUICtrlSetState($but2, $GUI_DISABLE)
    Else
    $SelectAll = 1
    GUICtrlSetState($but2, $GUI_ENABLE)
    EndIf
    _GUICtrlListViewSetItemSelState ($ulist, -1, $SelectAll)
    EndFunc;==>SelectAll

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

    Func Stop();exit the gui
    Exit
    EndFunc;==>Stop
    #endregion Functions

    [/autoit]

    So long,

    Mega

  • @th.meger: ja is ganz cool aber ich wills mir halt selbst basteln (sicher verständlich) ;)

    @all: ich ahb das jetz mit arrays auswerten versucht und denk ich mal auch den richtigen denkansatz... aber irgendwie kommt da immer ein fehler! :weinen:

    kann mir bitte jemand sagen was in meinem script falst ist???
    hab das script als datei anhang angehängt...

    vielen dank schon im voraus!!!!

  • :help:

    kann mir bitte jemand ganz schnell sagen was der fehler in meinem script ist??!!! ich verzweifle hier noch!!!!! :comp2:

    danke jetz schon für alle antworten


    EDIT:

    ok ich weiss jetz was der fehler ist: _ArraySearch sucht nur in 1 dimensionalen arrays!!!... :hammer:
    hat jemand ne ahnung obs eine funktion gibt, die auch in 2 dimensionalen arrays sucht???

    bitte ganz schnelle posten!!!!

    Einmal editiert, zuletzt von mR. sEx p!sT0Ls (8. November 2006 um 20:43)

    • Offizieller Beitrag
    Zitat

    hat jemand ne ahnung obs eine funktion gibt, die auch in 2 dimensionalen arrays sucht???


    Von Haus aus gibts da keine Funktion.
    Als Alternative:
    - lagere die Dimension, die den Search-Wert enthält in ein 1D-Array aus
    - suche auf dieses Array anwenden
    - Ergebnisindex auf Ausgangsarray anwenden

  • HiHo

    ... evtl. nicht schnell genug :)

    [autoit]


    ;===============================================================================
    ;
    ; Function Name: ArraySearch2D()
    ; Description::
    ; Parameter(s):
    ; Requirement(s):
    ; Return Value(s):
    ; Author(s): <jonk>
    ;
    ;===============================================================================
    ;

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

    Func _ArraySearch2D($avArray2d,$sSearchString,$iIndexSecondDim=-1)
    If IsArray($avArray2D) And UBound($avArray2d,2)<>0 Then
    For $i = 0 To UBound($avArray2D,1)-1
    If $iIndexSecondDim <> -1 And $iIndexSecondDim <= UBound($avArray2d,2) Then
    If $avArray2D[$i][$iIndexSecondDim] = $sSearchString Then Return True
    Else
    For $j = 0 To UBound($avArray2d,2)-1
    If $avArray2D[$i][$j] = $sSearchString Then Return True
    Next
    EndIf
    Next
    SetError(1)
    Return False
    EndIf
    EndFunc

    [/autoit]

    EDIT:
    Die Funition gibt nur zurück ob der Suchbegriff gefunden wurde... aber das kann man ja ganz leicht den eigenen Bedürfnissen anpassen ;)

    2 Mal editiert, zuletzt von jonk (8. November 2006 um 21:52)

  • ja vielen vielen dank!! ich hättes nie auf die reihe gebracht so eine funktion zu schreiben!! :lol: