Jump to content
Sign in to follow this  
Celtic88

Help with listview :'(

Recommended Posts

Celtic88

Hello World ! :D my first script

i have a problem with listview When I put my information please help me!

Edited by yacmacdc
Added autoit tags

Share this post


Link to post
Share on other sites
BrewManNH

What is the problem with your script? If you expect anyone to help you, you have to help us first by explaining what the issue is.

I'm not going to run this script just to find out what that is, and looking through it line by line isn't going to do much without some idea of what to look for.

  • Like 1

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Celtic88

What is the problem with your script? If you expect anyone to help you, you have to help us first by explaining what the issue is.

I'm not going to run this script just to find out what that is, and looking through it line by line isn't going to do much without some idea of what to look for.

Thanks for the reply :) my problem is listeview Appear and then disappear

Share this post


Link to post
Share on other sites
Celtic88

look

http://www.youtube.com/watch?v=m-zcbXvKUx8

Share this post


Link to post
Share on other sites
BrewManNH

It's going to do that because you're updating the listview quickly in the loop. Here's a way to hide the process, yet still let the user know it's working in the background.

Here's your script modified with a function I created that will do that for you, the lines added have all been marked in the code.

#NoTrayIcon
#include <GUILIstview.au3> ;  <<<<<<<<<<<< added
Opt("GUIOnEventMode", 1)
Global $Lister[9999][2]
$COUNT = 0
;~ $LVM_SETCOLUMNWIDTH = (4096 + 30) ; <<<<<<<<<< not needed now
$Form1 = GUICreate("Hello " & @ComputerName, 609, 480, 302, 273)
GUISetOnEvent(-3, "__Exit")
$Tab1 = GUICtrlCreateTab(8, 49, 593, 393)
$TabSheet1 = GUICtrlCreateTabItem("         Liste proxy         ")
$ListView1 = GUICtrlCreateListView("IP:PORT|TYPE|COUNTRY|TIME", 8, 75, 591, 366)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150)
$settings = GUICtrlCreateContextMenu($ListView1)
$SENDS = GUICtrlCreateMenuItem("add to favoris", $settings)
GUICtrlSetOnEvent(-1, "add")
$Checkbox1 = GUICtrlCreateCheckbox("Use a proxy", 104, 8, 97, 17)
GUICtrlSetOnEvent(-1, "Checkbox")
$Checkbox2 = GUICtrlCreateCheckbox("Rendom proxy", 104, 24, 97, 17)
GUICtrlSetState(-1, 129)
$Checkbox3 = GUICtrlCreateCheckbox("Bypass proxy server for local addresses", 224, 8, 217, 17)
GUICtrlSetState(-1, 129)
$TabSheet2 = GUICtrlCreateTabItem("         favoris         ")
$ListView2 = GUICtrlCreateListView("IP:PORT|TYPE|COUNTRY|TIME", 8, 75, 591, 366)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150)
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("Set proxy", 8, 8, 75, 33)
GUICtrlSetOnEvent(-1, "SELECTED")
$Label1 = GUICtrlCreateLabel("", 16, 453, 111, 17)
$Label2 = GUICtrlCreateLabel("", 133, 453, 464, 17)
$Group1 = GUICtrlCreateGroup("", 8, 440, 593, 33)
GUISetState()
GETPROXY()
Do
    Sleep(10000)
Until False
Func __Exit()
    Exit
EndFunc   ;==>__Exit
Func _DownloadProgress($FileURL, $FileSave)
    $FileSize = InetGetSize($FileURL)
    If $FileSize = 0 Then Return 404
    $FileDownload = InetGet($FileURL, $FileSave, 0, 1)
    Do
        $Percentage = InetGetInfo($FileDownload, 0) * 100 / $FileSize
        GUICtrlSetData($Label1, "Please wait ... " & Round($Percentage, 0) & " % ")
        Sleep(200)
    Until InetGetInfo($FileDownload, 2)
EndFunc   ;==>_DownloadProgress

Func _StringBetween($s_String, $s_Start, $s_End, $v_Case = -1)
    Local $s_case = ""
    If $v_Case = Default Or $v_Case = -1 Then $s_case = "(?i)"
    Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
    $s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1")
    $s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1")
    If $s_Start = "" Then $s_Start = "\A"
    If $s_End = "" Then $s_End = "\z"
    Local $a_ret = StringRegExp($s_String, "(?s)" & $s_case & $s_Start & "(.*?)" & $s_End, 3)
    If @error Then Return SetError(1, 0, 0)
    Return $a_ret
EndFunc   ;==>_StringBetween
Func add()
    $selected = GUICtrlRead(GUICtrlRead($ListView1))
    If Not $selected <> "" And StringInStr(GUICtrlRead($Label1), "Please wait ... ") > 0 Or StringInStr(GUICtrlRead($Label1), "Error: Connection lost..") > 0 Then
        GUICtrlSetData($Label2, "")
        Return
    ElseIf Not $selected <> "" Then
        GUICtrlSetData($Label2, "Please select proxy first.")
        Return
    EndIf
    $StringSplit = StringSplit($selected, "|", 1)
    GUICtrlCreateListViewItem($StringSplit[1] & "|" & $StringSplit[2] & "|" & $StringSplit[3] & "|" & $StringSplit[4], $ListView2)
EndFunc   ;==>add
Func Checkbox()
    If GUICtrlRead($Checkbox1) = 1 Then
        GUICtrlSetState($Checkbox2, 64)
        GUICtrlSetState($Checkbox3, 64)
    Else
        GUICtrlSetState($Checkbox2, 128)
        GUICtrlSetState($Checkbox3, 128)
    EndIf
EndFunc   ;==>Checkbox
Func favo()
    $selected = GUICtrlRead(GUICtrlRead($ListView2))
    If Not $selected <> "" Then
        GUICtrlSetData($Label2, "Please select proxy first.!!!")
        Return
    EndIf
    $StringSplit = StringSplit($selected, "|", 1)
    $IP = StringLeft($StringSplit[1], StringInStr($StringSplit[1], ":") - 1)
    $ping = Ping($IP, 9999)
    GUICtrlSetData($Label2, " Your current ip " & $IP & " from " & $StringSplit[3] & " Ping: " & $ping)
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "1")
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyserver", "REG_SZ", $StringSplit[1])
    DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
EndFunc   ;==>favo
Func GETPROXY()
;~  RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "0")
    DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
    GUICtrlSetData($Label1, "Please wait ...")
    $FileURL1 = "http://www.proxylists.net/proxylists.xml"
    $FileName1 = @TempDir & "\proxylists"
    $Down = _DownloadProgress($FileURL1, $FileName1)
    If $Down = 404 Then
        GUICtrlSetData($Label1, "Error: Connection lost..")
        Return
    EndIf
    $m = _StringBetween(FileRead($FileName1), "<prx:proxy><prx:ip>", "</prx:check_timestamp></prx:proxy>")
    _GUICtrlListView_BeginUpdate($ListView1) ; <<<<<<<<<<<<<<<<<< makes updating the ListView faster
    GUISetState(@SW_HIDE, $Form1) ; <<<<<<<<<<<<<<<<<<< Hide the main GUI while updating
    Local $ProgressGUI = _ProgressGUI("Processing, please wait", 1)
    For $i = 1 To UBound($m) - 1
        Local $rep
        $rep = StringReplace($m[$i], "</prx:ip><prx:port>", "_")
        $rep = StringReplace($rep, "</prx:port><prx:type>", "_")
        $rep = StringReplace($rep, "</prx:type><prx:country>", "_")
        $rep = StringReplace($rep, "</prx:country><prx:check_timestamp>", "_")
        $FIN = StringSplit($rep, "_")
        If $FIN[3] = "Transparent" Then
            Sleep(1)
            $COUNT = $COUNT + 1
            GUICtrlSetData($Label1, "Proxies N° " & $COUNT)
            GUICtrlSetData($ProgressGUI[2], "Processing, please wait" & @CRLF & "Proxies N° " & $COUNT)
            $Lister[$COUNT][1] = GUICtrlCreateListViewItem($FIN[1] & ":" & $FIN[2] & "|" & $FIN[3] & "|" & $FIN[4] & "|" & $FIN[5], $ListView1)
        EndIf
;~      GUICtrlSetData($ProgressGUI[1], ($i / (UBound($m) - 1)) * 100) ; <<<<<<<<< Progress bar fills up
        GUICtrlSetData($ProgressGUI[1], 100 - ($i / (UBound($m) - 1)) * 100) ; <<<<<<<<<< Progress bar moves down
    Next
    _GUICtrlListView_EndUpdate($ListView1) ; <<<<<<<<<<<<<< added
    GUIDelete($ProgressGUI[0]) ; <<<<<<<<<<<< deletes the Progress bar GUI
    GUISetState(@SW_SHOW, $Form1) ; <<<<<<<<<<< Shows your original GUI when it's all done.
EndFunc   ;==>GETPROXY
Func SELECTED()
    If GUICtrlRead($Checkbox3) = 1 Then
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyOverride", "REG_SZ", "<local>")
        DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
    Else
        RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyOverride")
        DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
    EndIf
    If GUICtrlRead($Tab1) Then
        Call("favo")
        Return
    EndIf
    If GUICtrlRead($Checkbox1) = 1 Then
        If GUICtrlRead($Checkbox2) = 1 Then
            GUICtrlSetData($Label2, "")
            $Random = Random(1, $COUNT, 1)
            $selected = GUICtrlRead($Lister[$Random][1])
            If Not $selected <> "" Then Return
            GUICtrlSetBkColor($Lister[$Random][1], 0xCCFFCC)
            GUICtrlSendMsg($ListView1, 0x1013, $Random - 1, 1)
        Else
            $selected = GUICtrlRead(GUICtrlRead($ListView1))
            If Not $selected <> "" And StringInStr(GUICtrlRead($Label1), "Please wait ... ") > 0 Or StringInStr(GUICtrlRead($Label1), "Error: Connection lost..") > 0 Then
                GUICtrlSetData($Label2, "")
                Return
            ElseIf Not $selected <> "" Then
                GUICtrlSetData($Label2, "Please select proxy first.")
                Return
            EndIf
        EndIf
        $StringSplit = StringSplit($selected, "|", 1)
        $IP = StringLeft($StringSplit[1], StringInStr($StringSplit[1], ":") - 1)
        $ping = Ping($IP, 9999)
        GUICtrlSetData($Label2, " Your current ip " & $IP & " from " & $StringSplit[3] & " Ping: " & $ping)
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "1")
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyserver", "REG_SZ", $StringSplit[1])
        DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
    Else
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "0")
        DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
        GUICtrlSetData($Label2, " Your current proxy is Default !")
    EndIf
EndFunc   ;==>SELECTED
; #FUNCTION# ====================================================================================================================
; Name...........: _ProgressGui
; Description ...: A small splash screen type GUI with a progress bar and a configurable label
; Syntax.........: _ProgressGUI($MsgText = "Text Message"[, $_MarqueeType = 0[, $_iFontsize = 14[, $_sFont = "Arial"[, $_iXSize = 290[, $_iYSize = 100[, $_GUIColor = 0x00080FF[, $_FontColor = 0x0FFFC19]]]]]]])
; Parameters ....: $MsgText      - Text to display on the GUI
;                  $_MarqueeType - [optional] Style of Progress Bar you want to use:
;                  |0 - Marquee style [default]
;                  |1 - Normal Progress Bar style
;                  $_iFontsize   - [optional] The font size that you want to display the $MsgText at [default = 14]
;                  $_sFont       - [optional] The font you want the message to use [default = "Arial"]
;                  $_iXSize      - [optional] Width of the GUI [Default = 290] - Minimum size is 80
;                  $_iYSize      - [optional] Height of the GUI [Default = 100]
;                  $_GUIColor    - [optional] Background color of the GUI [default = 0x00080FF = Blue]
;                  $_sFontColor  - [optional] Color of the text message [default = 0x0FFFC19 = Yellow]
; Return values .: Success - Returns an array of the Control IDs created in the format:
;                  |array[0] = The handle of the GUI
;                  |array[1] = The handle of the Progress bar
;                  |array[2] = The handle of the label
;                  Failure - 0 and @error to 1 if the GUI couldn't be created
; Author ........: Bob Marotte (BrewManNH)
; Modified.......:
; Remarks .......: This will create a customizable GUI with a progress bar. The default style of the progress bar
;                  using this function is the Marquee style of progress bar. If you call this function with any
;                  positive, non-zero number it will use the normal progress bar style. All optional parameters
;                  will accept the Default keyword, an empty string "", or -1 if passed to the function, except
;                  the color parameters which will not accept the Default keyword.
;                  Use the array[0] return value to delete the GUI when you're done using it (ex. GUIDelete($Returnvalue[0])
; Related .......: None
; Link ..........:
; Example .......: No
; ===============================================================================================================================

Func _ProgressGUI($MsgText = "Text Message", $_MarqueeType = 0, $_iFontsize = 14, $_sFont = "Arial", $_iXSize = 290, $_iYSize = 100, $_GUIColor = 0x00080FF, $_FontColor = 0x0FFFC19)
    Local $PBMarquee[3]
    ; bounds checking/correcting
    If $_iFontsize = "" Or $_iFontsize = "Default" Or $_iFontsize = "-1" Then $_iFontsize = 14
    If $_iFontsize < 1 Then $_iFontsize = 1
    If $_iXSize = "" Or $_iXSize = "-1" Or $_iXSize = Default Then $_iXSize = 290
    If $_iXSize < 80 Then $_iXSize = 80
    If $_iXSize > @DesktopWidth - 50 Then $_iXSize = @DesktopWidth - 50
    If $_iYSize = "" Or $_iYSize = "-1" Or $_iYSize = Default Then $_iYSize = 100
    If $_iYSize > @DesktopHeight - 50 Then $_iYSize = @DesktopHeight - 50
    If $_GUIColor = "" Or $_GUIColor = "-1" Then $_GUIColor = 0x00080FF
    If $_sFont = "" Or $_sFont = "-1" Or $_sFont = "Default" Then $_sFont = "Arial"
    ;create the GUI
    $PBMarquee[0] = GUICreate("", $_iXSize, $_iYSize, -1, -1, BitOR(0x00400000, 0x80000000))
    If @error Then Return SetError(@error, 0, 0) ; if there's any error with creating the GUI, return the error code
    GUISetBkColor($_GUIColor, $PBMarquee[0])
    ;   Create the progressbar
    If $_MarqueeType < 1 Then ; if $_MarqueeType < 1 then use the Marquee style progress bar
        $PBMarquee[1] = GUICtrlCreateProgress(20, $_iYSize - 20, $_iXSize - 40, 15, 9) ; uses the $PBS_SMOOTH and $PBS_MARQUEE style
        GUICtrlSendMsg($PBMarquee[1], 1034, True, 20)
    Else ; If $_MarqueeType > 0 then use the normal style progress bar
        $PBMarquee[1] = GUICtrlCreateProgress(20, $_iYSize - 20, $_iXSize - 40, 15, 1) ; Use the $PBS_SMOOTH style
    EndIf
    $PBMarquee[2] = GUICtrlCreateLabel($MsgText, 20, 20, $_iXSize - 40, $_iYSize - 45) ; create the label for the GUI
    GUICtrlSetFont(-1, $_iFontsize, 400, Default, $_sFont)
    GUICtrlSetColor(-1, $_FontColor)
    GUISetState()
    Return SetError(0, 0, $PBMarquee) ;Return the ControlIDs of the GUI and the Progress bar
EndFunc   ;==>_ProgressGUI
Edited by BrewManNH
  • Like 1

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Celtic88

AA I understand ^_^ BrewManNH Thank you very much :ILA2:

Share this post


Link to post
Share on other sites
Nessie

Try this, much more faster than your original code:

#NoTrayIcon
#include <GUILIstview.au3> ;  <<<<<<<<<<<< added
Opt("GUIOnEventMode", 1)
Global $Lister[9999][2]
$COUNT = 0
;~ $LVM_SETCOLUMNWIDTH = (4096 + 30) ; <<<<<<<<<< not needed now
$Form1 = GUICreate("Hello " & @ComputerName, 609, 480, 302, 273)
GUISetOnEvent(-3, "__Exit")
$Tab1 = GUICtrlCreateTab(8, 49, 593, 393)
$TabSheet1 = GUICtrlCreateTabItem("         Liste proxy         ")
$ListView1 = GUICtrlCreateListView("IP:PORT|TYPE|COUNTRY|TIME", 8, 75, 591, 366)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150)
$settings = GUICtrlCreateContextMenu($ListView1)
$SENDS = GUICtrlCreateMenuItem("add to favoris", $settings)
GUICtrlSetOnEvent(-1, "add")
$Checkbox1 = GUICtrlCreateCheckbox("Use a proxy", 104, 8, 97, 17)
GUICtrlSetOnEvent(-1, "Checkbox")
$Checkbox2 = GUICtrlCreateCheckbox("Rendom proxy", 104, 24, 97, 17)
GUICtrlSetState(-1, 129)
$Checkbox3 = GUICtrlCreateCheckbox("Bypass proxy server for local addresses", 224, 8, 217, 17)
GUICtrlSetState(-1, 129)
$TabSheet2 = GUICtrlCreateTabItem("         favoris         ")
$ListView2 = GUICtrlCreateListView("IP:PORT|TYPE|COUNTRY|TIME", 8, 75, 591, 366)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 150)
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("Set proxy", 8, 8, 75, 33)
GUICtrlSetOnEvent(-1, "SELECTED")
$Label1 = GUICtrlCreateLabel("", 16, 453, 111, 17)
$Label2 = GUICtrlCreateLabel("", 133, 453, 464, 17)
$Group1 = GUICtrlCreateGroup("", 8, 440, 593, 33)
GUISetState()
GETPROXY()
Do
    Sleep(10000)
Until False
Func __Exit()
    Exit
EndFunc   ;==>__Exit
Func _DownloadProgress($FileURL, $FileSave)
    $FileSize = InetGetSize($FileURL)
    If $FileSize = 0 Then Return 404
    $FileDownload = InetGet($FileURL, $FileSave, 0, 1)
    Do
        $Percentage = InetGetInfo($FileDownload, 0) * 100 / $FileSize
        GUICtrlSetData($Label1, "Please wait ... " & Round($Percentage, 0) & " % ")
        Sleep(200)
    Until InetGetInfo($FileDownload, 2)
EndFunc   ;==>_DownloadProgress

Func _StringBetween($s_String, $s_Start, $s_End, $v_Case = -1)
    Local $s_case = ""
    If $v_Case = Default Or $v_Case = -1 Then $s_case = "(?i)"
    Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
    $s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1")
    $s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1")
    If $s_Start = "" Then $s_Start = "\A"
    If $s_End = "" Then $s_End = "\z"
    Local $a_ret = StringRegExp($s_String, "(?s)" & $s_case & $s_Start & "(.*?)" & $s_End, 3)
    If @error Then Return SetError(1, 0, 0)
    Return $a_ret
EndFunc   ;==>_StringBetween
Func add()
    $selected = GUICtrlRead(GUICtrlRead($ListView1))
    If Not $selected <> "" And StringInStr(GUICtrlRead($Label1), "Please wait ... ") > 0 Or StringInStr(GUICtrlRead($Label1), "Error: Connection lost..") > 0 Then
        GUICtrlSetData($Label2, "")
        Return
    ElseIf Not $selected <> "" Then
        GUICtrlSetData($Label2, "Please select proxy first.")
        Return
    EndIf
    $StringSplit = StringSplit($selected, "|", 1)
    GUICtrlCreateListViewItem($StringSplit[1] & "|" & $StringSplit[2] & "|" & $StringSplit[3] & "|" & $StringSplit[4], $ListView2)
EndFunc   ;==>add
Func Checkbox()
    If GUICtrlRead($Checkbox1) = 1 Then
        GUICtrlSetState($Checkbox2, 64)
        GUICtrlSetState($Checkbox3, 64)
    Else
        GUICtrlSetState($Checkbox2, 128)
        GUICtrlSetState($Checkbox3, 128)
    EndIf
EndFunc   ;==>Checkbox
Func favo()
    $selected = GUICtrlRead(GUICtrlRead($ListView2))
    If Not $selected <> "" Then
        GUICtrlSetData($Label2, "Please select proxy first.!!!")
        Return
    EndIf
    $StringSplit = StringSplit($selected, "|", 1)
    $IP = StringLeft($StringSplit[1], StringInStr($StringSplit[1], ":") - 1)
    $ping = Ping($IP, 9999)
    GUICtrlSetData($Label2, " Your current ip " & $IP & " from " & $StringSplit[3] & " Ping: " & $ping)
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "1")
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyserver", "REG_SZ", $StringSplit[1])
    DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
EndFunc   ;==>favo
Func GETPROXY()
;~  RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "0")
    DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
    GUICtrlSetData($Label1, "Please wait ...")
    $FileURL1 = "http://www.proxylists.net/proxylists.xml"
    $FileName1 = @TempDir & "\proxylists"
    $Down = _DownloadProgress($FileURL1, $FileName1)
    If $Down = 404 Then
        GUICtrlSetData($Label1, "Error: Connection lost..")
        Return
    EndIf

    $File_Open = FileOpen($FileName1, 0)
    $File_Read = FileRead($File_Open)
    FileClose($File_Open)

    $Regex_IP = StringRegExp($File_Read, "<prx:ip>(.*?)</prx:ip>", 3)
    $Regex_Port = StringRegExp($File_Read, "<prx:port>(.*?)</prx:port>", 3)
    $Regex_Type = StringRegExp($File_Read, "<prx:type>(.*?)</prx:type>", 3)
    $Regex_Country = StringRegExp($File_Read, "<prx:country>(.*?)</prx:country>", 3)
    $Regex_Time = StringRegExp($File_Read, "<prx:check_timestamp>(.*?)</prx:check_timestamp>", 3)

    $n_IP = UBound($Regex_IP)
    $n_Port = UBound($Regex_Port)
    $n_Type = UBound($Regex_Type)
    $n_Country = UBound($Regex_Country)
    $n_Time = UBound($Regex_Time)
    If $n_IP <> $n_Port Or $n_Port <> $n_Type Or $n_Type <> $n_Country Or $n_Country <> $n_Time Then
        MsgBox(0,"Error", "Something goes wrong")
    EndIf

    Dim $aResult[$n_IP][4]

    For $i = 0 To $n_IP - 1
        $aResult[$i][0] = $Regex_IP[$i] & ":" & $Regex_Port[$i]
        $aResult[$i][1] = $Regex_Type[$i]
        $aResult[$i][2] = $Regex_Country[$i]
        $aResult[$i][3] = $Regex_Time[$i]
    Next

    _GUICtrlListView_AddArray($ListView1, $aResult)
    GUISetState(@SW_SHOW, $Form1) ; <<<<<<<<<<< Shows your original GUI when it's all done.
EndFunc   ;==>GETPROXY


Func SELECTED()
    If GUICtrlRead($Checkbox3) = 1 Then
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyOverride", "REG_SZ", "<local>")
        DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
    Else
        RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "ProxyOverride")
        DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
    EndIf
    If GUICtrlRead($Tab1) Then
        Call("favo")
        Return
    EndIf
    If GUICtrlRead($Checkbox1) = 1 Then
        If GUICtrlRead($Checkbox2) = 1 Then
            GUICtrlSetData($Label2, "")
            $Random = Random(1, $COUNT, 1)
            $selected = GUICtrlRead($Lister[$Random][1])
            If Not $selected <> "" Then Return
            GUICtrlSetBkColor($Lister[$Random][1], 0xCCFFCC)
            GUICtrlSendMsg($ListView1, 0x1013, $Random - 1, 1)
        Else
            $selected = GUICtrlRead(GUICtrlRead($ListView1))
            If Not $selected <> "" And StringInStr(GUICtrlRead($Label1), "Please wait ... ") > 0 Or StringInStr(GUICtrlRead($Label1), "Error: Connection lost..") > 0 Then
                GUICtrlSetData($Label2, "")
                Return
            ElseIf Not $selected <> "" Then
                GUICtrlSetData($Label2, "Please select proxy first.")
                Return
            EndIf
        EndIf
        $StringSplit = StringSplit($selected, "|", 1)
        $IP = StringLeft($StringSplit[1], StringInStr($StringSplit[1], ":") - 1)
        $ping = Ping($IP, 9999)
        GUICtrlSetData($Label2, " Your current ip " & $IP & " from " & $StringSplit[3] & " Ping: " & $ping)
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "1")
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyserver", "REG_SZ", $StringSplit[1])
        DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
    Else
        RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "0")
        DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
        GUICtrlSetData($Label2, " Your current proxy is Default !")
    EndIf
EndFunc   ;==>SELECTED

When you have a lot of item use _GUICtrlListView_AddArray insted of add one item to time, as you can see you will populate your listview much faster.

Hi!

Edited by Nessie

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Share this post


Link to post
Share on other sites
BrewManNH

_GUICtrlListView_AddArray isn't any faster, it's just doing the same thing, splitting the array up, inside the function. Plus, if he ever decides to add sortting of the listview, that function will not allow the ListView items to be sortable.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Celtic88

I have found the solution Thank you for your help :)

#NoTrayIcon
Opt("GUIOnEventMode", 1)
Global $COUNT
Global $REG = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
GUICreate("Hello " & @ComputerName, 509, 480, 302, 273)
GUISetOnEvent(-3, "__Exit")
$Checkbox1 = GUICtrlCreateCheckbox("Use a proxy", 104, 9, 97, 17)
GUICtrlSetOnEvent(-1, "Checkbox")
GUICtrlSetState(-1, 1)
$ListView1 = GUICtrlCreateListView("IP:PORT|COUNTRY|TIME", 6, 75, 497, 366)
GUICtrlSendMsg(-1, 4096 + 30, 0, 160)
GUICtrlSendMsg(-1, 4096 + 30, 1, 160)
GUICtrlSendMsg(-1, 4096 + 30, 2, 150)
$Tab1 = GUICtrlCreateTab(6, 47, 499, 25)
GUICtrlSetOnEvent(-1, "_On_Tab")
GUICtrlCreateTabItem("        Liste proxy         ")
$settings = GUICtrlCreateContextMenu($ListView1)
$SENDS = GUICtrlCreateMenuItem("add to favorites", $settings)
GUICtrlSetOnEvent(-1, "add")
$Checkbox2 = GUICtrlCreateCheckbox("Rendom proxy", 104, 25, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Bypass proxy server for local addresses", 224, 9, 217, 17)
GUICtrlSetState(-1, 1)
GUICtrlCreateTabItem("        Favorites       ")
$ListView2 = GUICtrlCreateListView("IP:PORT|COUNTRY|TIME", 6, 75, 497, 366)
GUICtrlSendMsg(-1, 4096 + 30, 0, 160)
GUICtrlSendMsg(-1, 4096 + 30, 1, 160)
GUICtrlSendMsg(-1, 4096 + 30, 2, 150)
GUICtrlCreateTabItem("")
GUICtrlCreateButton("Set proxy", 8, 7, 75, 33)
GUICtrlSetOnEvent(-1, "SELECTED")
$Label1 = GUICtrlCreateLabel("", 13, 453, 111, 17)
$Label2 = GUICtrlCreateLabel("", 128, 453, 464, 17)
GUICtrlCreateGroup("", 8, 440, 493, 33)
GUISetState()

GETPROXY()

Do
    Sleep(10000)
Until False

Func GETPROXY()
    RegWrite($REG, "Proxyenable", "REG_DWORD", "0")
    DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
    GUICtrlSetData($Label1, "Please wait ...")
    Local $file = FileOpen(@ScriptDir & "\FAV")
    If $file <> -1 Then
        While 1
            Local $line = FileReadLine($file)
            If @error = -1 Then ExitLoop
            GUICtrlCreateListViewItem($line, $ListView2)
        WEnd
        FileClose($file)
    EndIf
    $FileURL1 = "http://www.proxylists.net/proxylists.xml"
    $FileName1 = @TempDir & "\proxylists"
    $Down = _DownloadProgress($FileURL1, $FileName1)
    If $Down = 404 Then
        GUICtrlSetData($Label1, "Error: Connection lost..")
        Return
    EndIf
    Local $Proxy = FileOpen($FileName1)
    If $Proxy = -1 Then
        GUICtrlSetData($Label1, "Error: ¨Proxy list..")
        Return
    EndIf
    Local $ReadProxy = FileRead($Proxy)
    FileClose($Proxy)
    $m = StringRegExp($ReadProxy, "<prx:proxy>(.*?)</prx:proxy>", 3)
    Global $Lister[UBound($m)][2]
    $COUNT = 0
    Dim $rep
    For $i = 0 To UBound($m) - 1
        $array = StringRegExp($m[$i], '>(.*?)<', 3)
        If $array[4] = "Transparent" Then
            $COUNT = $COUNT + 1
            GUICtrlSetData($Label1, "Proxies N° " & $COUNT)
            $Lister[$COUNT][1] = GUICtrlCreateListViewItem($array[0] & ":" & $array[2] & "|" & $array[6] & "|" & $array[8], $ListView1)
        EndIf
    Next
EndFunc   ;==>GETPROXY

Func SELECTED()
    If GUICtrlRead($Checkbox3) = 1 Then
        RegWrite($REG, "ProxyOverride", "REG_SZ", "<local>")
        InternetSetOption()
    Else
        RegDelete($REG, "ProxyOverride")
        InternetSetOption()
    EndIf
    If GUICtrlRead($Checkbox1) = 1 Then
        If GUICtrlRead($Tab1) Then
            favo()
            Return
        EndIf
        If GUICtrlRead($Checkbox2) = 1 Then
            GUICtrlSetData($Label2, "")
            $Random = Random(1, $COUNT, 1)
            $selected = GUICtrlRead($Lister[$Random][1])
            If Not $selected <> "" Then Return
            GUICtrlSetBkColor($Lister[$Random][1], 0xCCFFCC)
            GUICtrlSendMsg($ListView1, 0x1013, $Random - 1, 1)
        Else
            $selected = GUICtrlRead(GUICtrlRead($ListView1))
            If Not $selected <> "" And StringInStr(GUICtrlRead($Label1), "Please wait ... ") > 0 Or StringInStr(GUICtrlRead($Label1), "Error: Connection lost..") > 0 Then
                GUICtrlSetData($Label2, "")
                Return
            ElseIf Not $selected <> "" Then
                GUICtrlSetData($Label2, "Please select proxy first.")
                Return
            EndIf
        EndIf
        $StringSplit = StringSplit($selected, "|", 1)
        $IP = StringLeft($StringSplit[1], StringInStr($StringSplit[1], ":") - 1)
        $ping = Ping($IP, 9999)
        GUICtrlSetData($Label2, " Your current ip " & $IP & " from " & $StringSplit[2] & " Ping: " & $ping)
        RegWrite($REG, "Proxyenable", "REG_DWORD", "1")
        RegWrite($REG, "proxyserver", "REG_SZ", $StringSplit[1])
        InternetSetOption()
    EndIf
EndFunc   ;==>SELECTED

Func Checkbox()
    If GUICtrlRead($Checkbox1) = 1 Then
        GUICtrlSetState($Checkbox2, 64)
        GUICtrlSetState($Checkbox3, 64)
    Else
        RegWrite($REG, "Proxyenable", "REG_DWORD", "0")
        InternetSetOption()
        GUICtrlSetData($Label2, " Your current proxy is Default !")
        GUICtrlSetState($Checkbox2, 128)
        GUICtrlSetState($Checkbox3, 128)
    EndIf
EndFunc   ;==>Checkbox

Func _DownloadProgress($FileURL, $FileSave)
    $FileSize = InetGetSize($FileURL)
    If $FileSize = 0 Then Return 404
    If FileGetSize($FileSave) = $FileSize Then Return
    $FileDownload = InetGet($FileURL, $FileSave, 1, 1)
    Do
        $Percentage = InetGetInfo($FileDownload, 0) * 100 / $FileSize
        GUICtrlSetData($Label1, "Please wait ... " & Round($Percentage, 0) & " % ")
        Sleep(200)
    Until InetGetInfo($FileDownload, 2)
EndFunc   ;==>_DownloadProgress

Func __Exit()
    Exit
EndFunc   ;==>__Exit

Func favo()
    $selected = GUICtrlRead(GUICtrlRead($ListView2))
    If Not $selected <> "" Then
        GUICtrlSetData($Label2, "Please select proxy first.!!!")
        Return
    EndIf
    $StringSplit = StringSplit($selected, "|", 1)
    $IP = StringLeft($StringSplit[1], StringInStr($StringSplit[1], ":") - 1)
    $ping = Ping($IP, 9999)
    GUICtrlSetData($Label2, " Your current ip " & $IP & " from " & $StringSplit[2] & " Ping: " & $ping)
    RegWrite($REG, "Proxyenable", "REG_DWORD", "1")
    RegWrite($REG, "proxyserver", "REG_SZ", $StringSplit[1])
    InternetSetOption()
EndFunc   ;==>favo

Func add()
    $selected = GUICtrlRead(GUICtrlRead($ListView1))
    If Not $selected <> "" And StringInStr(GUICtrlRead($Label1), "Please wait ... ") > 0 Or StringInStr(GUICtrlRead($Label1), "Error: Connection lost..") > 0 Then
        GUICtrlSetData($Label2, "")
        Return
    ElseIf Not $selected <> "" Then
        GUICtrlSetData($Label2, "Please select proxy first.")
        Return
    EndIf
    $StringSplit = StringSplit($selected, "|", 1)
    GUICtrlCreateListViewItem($StringSplit[1] & "|" & $StringSplit[2] & "|" & $StringSplit[3], $ListView2)
    Local $fav = FileOpen(@ScriptDir & "\FAV", 1)
    If $fav = -1 Then
        GUICtrlSetData($Label1, "Error: ¨favorites file..")
        Return
    EndIf
    Local $Writefav = FileWrite($fav, $StringSplit[1] & "|" & $StringSplit[2] & "|" & $StringSplit[3] & @CRLF)
    FileClose($fav)
EndFunc   ;==>add

Func InternetSetOption()
    DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0)
EndFunc   ;==>InternetSetOption

Func _On_Tab()
    Switch GUICtrlRead($Tab1)
        Case 0
            GUICtrlSetState($ListView1, 16)
        Case 1
            GUICtrlSetState($ListView1, 32)
    EndSwitch
EndFunc   ;==>_On_Tab
Edited by yacmacdc
Added tags

Share this post


Link to post
Share on other sites
Melba23

yacmacdc,

When you post code please use Code tags - put [autoit] before and [/autoit] after your posted code. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Celtic88

yacmacdc,

When you post code please use Code tags - put

before and
after your posted code. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

M23

aa oky Melba23 Thank you for helping us :wub:

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  

×