Jump to content
Sign in to follow this  
Particle

Problems with GuiCtrlListView

Recommended Posts

Particle

So I'm working on this Proxy verifier that will verify prescanned proxy lists. It will have 3 methods: Ping, TCP, UDP.

The problem I'm running into is when I run a test list with ping verify the _GUICtrlListView_SetItem messes up the subitems and readds them again but only to the first column of the index.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <Constants.au3>
#include <File.au3>
#include <Date.au3>

Global $timer, $Hour, $Mins, $Secs, $Time, $iCount
Global $aNumb = 0
Global $lNumb = 0
If UBound(ProcessList(@ScriptName)) > 2 Then
    MsgBox(64, "Proxy Verify", "Program Already running!", 6)
    Exit
EndIf

AdlibEnable("ReduceMemory",30000)

$Form1 = GUICreate("Proxy Verify", 634, 297, -1, -1)
$Group1 = GUICtrlCreateGroup("Loaded Proxies", 176, 0, 449, 241)
$ListView1 = GUICtrlCreateListView("Ip Address:Port|Ping|Current Status", 184, 16, 430, 220)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Active Proxies", 8, 0, 161, 241)
$ListView2 = GUICtrlCreateListView("", 16, 16, 148, 220)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("", 8, 240, 617, 33)
$StatusLabel = GUICtrlCreateLabel("Status: Offline", 16, 251, 100, 17)
$ProgressLabel = GUICtrlCreateLabel("Progress:", 104, 251, 48, 17)
$LoadedLabel = GUICtrlCreateLabel("Total Loaded Proxies: "&$lNumb, 304, 251, 155, 17)
$ActiveLabel = GUICtrlCreateLabel("Total Active Proxies: "&$aNumb, 474, 251, 150, 17)
$Progress = GUICtrlCreateProgress(152, 253, 142, 12)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$MenuItem1 = GUICtrlCreateMenu("&File")
$MenuItem3 = GUICtrlCreateMenuItem("&Open", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("&Save", $MenuItem1)
$MenuItem13 = GUICtrlCreateMenuItem("&Disconnect All", $MenuItem1)
GUICtrlCreateMenuItem("", $MenuItem1)
$MenuItem5 = GUICtrlCreateMenuItem("&Exit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Tools")
$MenuItem6 = GUICtrlCreateMenuItem("&Ping Verify", $MenuItem2)
$MenuItem7 = GUICtrlCreateMenuItem("T&CP Verify", $MenuItem2)
$MenuItem11 = GUICtrlCreateMenuItem("&UDP Verify", $MenuItem2)
$MenuItem8 = GUICtrlCreateMenu("&Extra")
$MenuItem9 = GUICtrlCreateMenuItem("&Credits", $MenuItem8)
$MenuItem10 = GUICtrlCreateMenuItem("&Help", $MenuItem8)
$MenuItem12 = GUICtrlCreateMenuItem("&Support", $MenuItem8)
GUISetState(@SW_SHOW,$Form1)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $MenuItem3;Load File
            LoadFile()
        Case $MenuItem4;Save File
            If _GUICtrlListView_GetItemCount($ListView2) <> 0 Then
                SaveFile()
            Else
                MsgBox(16,"Wait!","There are no proxies in Active Proxies to be saved!",8)
            EndIf
        Case $GUI_EVENT_CLOSE, $MenuItem5;Close Program
            Exit
        Case $MenuItem6;Ping Verify
            If _GUICtrlListView_GetItemCount($ListView1) <> 0 Then
                AdlibDisable()
                $iCount = _GUICtrlListView_GetItemCount($ListView1)
                AdlibEnable("PingPong",500)
                GUICtrlSetData($StatusLabel,"Status: Online")
            EndIf
        Case $MenuItem7;tcp verify
        Case $MenuItem9;credits
            MsgBox(0+64+262144+524288,"","Created by: Rodent    ©2009",30,$Form1)
        Case $MenuItem10;help
            ShellExecute("ReadMe.txt")
        Case $MenuItem11;udp verify
        Case $MenuItem12;Support
    ;Email()
        Case $MenuItem13;Disconnect All
            AdlibDisable()
            AdlibEnable("ReduceMemory",30000)
            GUICtrlSetData($StatusLabel,"Status: Offline")
    EndSwitch
    Sleep(1)
WEnd
Func PingPong()
    Local $x
    For $x = 0 to $iCount
        $aItem = _GUICtrlListView_GetItem($ListView1, $x)
        $Split = StringSplit($aItem[3],":")
        $iPing = Ping($Split[1],1000)
        If $iPing = 0 Then
    ;Fail
            _GUICtrlListView_BeginUpdate($ListView1)
            _GUICtrlListView_SetItem($ListView1, $aItem[3] & "|" & $iPing & " ms|Disconnected", $x)
            _GUICtrlListView_EndUpdate($ListView1)
            _GUICtrlListView_BeginUpdate($ListView2)
    ;check if $aItem matches one from the active list, if yes then remove
            $zCount = _GUICtrlListView_GetItemCount($ListView2)
            For $z = 0 to $zCount
                $zItem = _GUICtrlListView_GetItem($ListView2, $z)
                If $zItem = $aItem Then
                    _GUICtrlListView_DeleteItem($ListView2, $z)
                    ExitLoop
                ElseIf $zItem <> $aItem and $z = $zCount Then
                    ExitLoop
                EndIf
            Next
            _GUICtrlListView_EndUpdate($ListView2)
        Else
    ;Work
            _GUICtrlListView_BeginUpdate($ListView1)
            _GUICtrlListView_SetItem($ListView1, $aItem[3] & "|" & $iPing & " ms|Connected", $x)
            _GUICtrlListView_EndUpdate($ListView1)
            _GUICtrlListView_BeginUpdate($ListView2)
    ;check if $aItem matches one from the active list, if not then add
            $xCount = _GUICtrlListView_GetItemCount($ListView2)
            For $y = 0 to $xCount
                $xItem = _GUICtrlListView_GetItem($ListView2, $y)
                If $xItem = $aItem Then
                    ExitLoop
                ElseIf $xItem <> $aItem and $y = $xCount Then
                    _GUICtrlListView_AddItem($ListView2, $aItem)
                    ExitLoop
                EndIf
            Next
            _GUICtrlListView_EndUpdate($ListView2)
        EndIf
    Next
;random burst part
    Do
        $gMsg = GUIGetMsg()
        $Numb = Random(0,_GUICtrlListView_GetItemCount($ListView1),1)
        $Itema = _GUICtrlListView_GetItem($ListView1, $Numb)
        $SS = StringSplit($Itema[3],":")
        $Check1 = Ping($SS[1],3000)
        If $Check1 = 0 Then
    ;Fail
            _GUICtrlListView_BeginUpdate($ListView1)
            _GUICtrlListView_SetItem($ListView1, $Itema[3] & "|" & $Check1 & " ms|Disconnected", $x)
            _GUICtrlListView_EndUpdate($ListView1)
            _GUICtrlListView_BeginUpdate($ListView2)
    ;check if $aItem matches one from the active list, if yes then remove
            $zCount = _GUICtrlListView_GetItemCount($ListView2)
            For $z = 0 to $zCount
                $zItem = _GUICtrlListView_GetItem($ListView2, $z)
                If $zItem = $Itema[3] Then
                    _GUICtrlListView_DeleteItem($ListView2, $z)
                    ExitLoop
                ElseIf $zItem <> $Itema[3] and $z = $zCount Then
                    ExitLoop
                EndIf
            Next
            _GUICtrlListView_EndUpdate($ListView2)
        Else
    ;Work
            _GUICtrlListView_BeginUpdate($ListView1)
            _GUICtrlListView_SetItem($ListView1, $Itema[3] & "|" & $Check1 & " ms|Connected", $x)
            _GUICtrlListView_EndUpdate($ListView1)
            _GUICtrlListView_BeginUpdate($ListView2)
    ;check if $aItem matches one from the active list, if not then add
            $xCount = _GUICtrlListView_GetItemCount($ListView2)
            For $y = 0 to $xCount
                $xItem = _GUICtrlListView_GetItem($ListView2, $y)
                If $xItem = $Itema[3] Then
                    ExitLoop
                ElseIf $xItem <> $Itema[3] and $y = $xCount Then
                    _GUICtrlListView_AddItem($ListView2, $Itema[3])
                    ExitLoop
                EndIf
            Next
            _GUICtrlListView_EndUpdate($ListView2)
        EndIf
        Sleep(1)
        _GUICtrlListView_BeginUpdate($ListView2)
        $Numb = Random(0,_GUICtrlListView_GetItemCount($ListView2),1)
        $bItem = _GUICtrlListView_GetItem($ListView2, $Numb)
        $SS = StringSplit($bItem[3],":")
        $Check1 = Ping($SS[1],3000)
        If $Check1 = 0 Then
    ;Fail
    ;Remove from active list
            _GUICtrlListView_DeleteItem($ListView2, $Numb)
        Else
    ;Work
            ContinueLoop
        EndIf
        _GUICtrlListView_EndUpdate($ListView2)
        Sleep(2000)
    Until $gMsg = $MenuItem13
    AdlibDisable()
    AdlibEnable("ReduceMemory",30000)
    GUICtrlSetData($StatusLabel,"Status: Offline")
EndFunc

Func LoadFile()
    $File = FileOpenDialog("Choose File...", @WorkingDir, "Text Documents (*.txt)")
    _GUICtrlListView_DeleteAllItems($ListView1)
    _GUICtrlListView_DeleteAllItems($ListView2)
    Local $Array
    If _FileCountLines($File) > 99999999 Then
        MsgBox(0,"!","Limit Exceeded!",5)
    Else
        _FileReadToArray($File, $Array )
        If $Array = 0 Then
            MsgBox(0,"", "File is empty")
        Else
            For $i = 1 to $Array[0]
                If $Array[$i] = "" Then ExitLoop
                GuiCtrlCreateListViewItem($Array[$i] & "|0 ms" & "|Disconnected",$ListView1)
                $lNumb = $lNumb + 1
            Next
        EndIf
    EndIf
    GUICtrlSetData($LoadedLabel,"Total Loaded Proxies: "&$lNumb)
    ReduceMemory()
EndFunc

Func SaveFile()
    $Save = FileSaveDialog("Save Active Proxies",@DesktopDir,"Text Files (*.txt)|All Files (*.*)",18,"Active.txt")
    $Count = _GUICtrlListView_GetItemCount($ListView1)
    $xFile = FileOpen($Save,8+2)
    For $x = 0 to $Count
        $Item = _GUICtrlListView_GetItem($ListView1, $x)
        FileWrite($xFile,$Item[3] & @CRLF)
    Next
    FileClose($xFile)
EndFunc

Func ReduceMemory()
   DllCall(@ScriptDir & "\psapi.dll", "int", "EmptyWorkingSet", "long", -1)
EndFunc

*forgot to add

HTTP Proxy List:

202.105.182.87:808

222.221.6.144:808

207.160.131.168:80

128.238.88.64:3128

203.158.221.226:443

211.38.131.22:80

152.3.138.3:3127

195.116.60.1:3127

203.177.74.137:8080

203.177.74.136:8080

203.177.74.141:8080

195.75.146.238:80

195.75.146.235:80

62.12.137.20:80

130.37.198.244:3128

147.102.3.102:3124

203.177.74.139:8080

131.247.2.241:3127

128.208.04.198:3128

128.208.4.198:3127

128.208.4.198:3128

169.229.50.10:3128

169.229.50.8:3124

147.102.3.102:3127

198.82.160.220:3127

128.6.192.158:3124

133.11.240.57:3127

195.116.60.34:3128

198.163.152.229:3128

169.229.50.11:3127

206.117.37.5:3124

152.3.138.3:3124

195.75.146.232:80

195.116.60.1:3128

194.29.178.13:3127

192.42.43.22:3127

130.192.157.131:3124

141.13.16.201:3128

134.34.246.5:3124

147.83.30.167:3128

192.33.90.68:3124

192.41.135.219:3124

137.226.138.154:3128

137.226.138.154:3127

147.102.3.101:3124

193.174.155.27:3127

138.246.99.249:3127

194.29.178.13:3128

193.136.227.163:3128

130.192.157.132:3124

Edited by Particle

Share this post


Link to post
Share on other sites
Authenticity

I didn't read the whole code but I saw mixing of list view ID with _GUICtrlListView_* functions or more precisely _GUI* functions that require a handle so first get the handle of the list view control and then call those functions with the handle...

GuiCtrlGetHandle($ListView1).

Share this post


Link to post
Share on other sites
Particle

No help, but thanks for trying I figured it out already :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×