Jump to content
Sign in to follow this  
dreamzboy

List Box Static Word Wrap and Indent

Recommended Posts

dreamzboy

I have a list box control that allows me to see the output as the script runs.  Since I control those outputs, I want the message to display neatly inside the list box without scrolling all the way to the right to read the text.  I don't need anything fancy that calculates the length as I can just send a message from a new line.  Sound simple enough but I'm having trouble getting the function to issue @CRLF and indent properly.  I've already read through >this thread but it's not what I was looking for.

This line did not enter a new line.

GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  Error - One or more fields doesn't match!" & @CRLF & "  Remove white space and/or extra entry before trying again." & @CRLF)

While this line only gave me 1 tab.

GUICtrlSetData ($log_label, @TAB & @TAB & @TAB & "  Remove white space and/or extra entry before trying again." & @CRLF)

Also tried the below but no help either.  It complained about the $aTabs.  I declared $aTabs[1] = [100] at the top (commented out) when trying this method.

GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  Error - One or more fields doesn't match!" & @CRLF)
_GUICtrlListBox_SetTabStops ($log_label, $aTabs)
_GUICtrlListBox_AddString ($log_label, @TAB & "  Remove white space and/or extra entry before trying again." & @CRLF)

Here's my code.  All you have to do is click on the "Generate" button and you'll see what I mean.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <GuiListBox.au3>
#include <array.au3>
#include <constants.au3>

Opt ("TrayIconDebug", 1)

Local $ribcl_temp = '', $xml_temp, $i, $j
Local $hn_input, $ip_input, $pw_input
Local $host_Count, $ip_Count, $pw_Count
Local $msg, $success, $password, $hostname, $ip_address
Local $log_label, $generate_btn, $clrLog_btn
Local $test_str0 = "dl360g7-25" & @CRLF & "dl360g7-26"
Local $test_str1 = "10.112.15.22" & @CRLF & "10.112.15.23" & @CRLF & "10.112.15.24"
Local $test_str2 = "pass1" & @CRLF & "pass2" & @CRLF & "pass3"
;Local $aTabs[1] = [100]

GUICreate ("Test", 600, 450)

GUICtrlCreateLabel ("1.  Enter hostname (ex: dl360g7-25):", 30, 70, 250, 20)
GUICtrlSetFont (-1, 10)
$hn_input = GUICtrlCreateEdit ("", 30, 90, 215, 70)
GUICtrlSetData ($hn_input, $test_str0)
GUICtrlCreateLabel ("2.  Enter iLO static IP address:", 30, 180, 250, 20)
GUICtrlSetFont (-1, 10)
$ip_input = GUICtrlCreateEdit ("", 30, 200, 215, 70)
GUICtrlSetData ($ip_input, $test_str1)
GUICtrlCreateLabel ("3.  Enter iLO default password:", 30, 290, 200, 20)
GUICtrlSetFont (-1, 10)
$pw_input = GUICtrlCreateEdit ("", 30, 310, 215, 70)
GUICtrlSetData ($pw_input, $test_str2)
$log_label = GUICtrlCreateList ("", 300, 90, 270, 292, BitOR($WS_BORDER, $WS_VSCROLL, $WS_HSCROLL))
$generate_btn = GUICtrlCreateButton ("Generate XML File", 55, 400, 150, 30)
GUICtrlSetFont (-1, 10)
GUICtrlCreateLabel ("version 2.0", 530, 425, 70)
GUICtrlSetColor (-1, 0x0000cd)
$clrLog_btn = GUICtrlCreateButton ("Clear Log", 385, 400, 100, 30)
GUICtrlSetFont (-1, 10)

GUISetState ()

Do
   $msg = GUIGetMsg()

   Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $generate_btn

        ; Check entry simliarity on all fields
        $hostname = StringSplit (GUICtrlRead ($hn_input), @CRLF, 3)
        ;MsgBox (0, "Before", $hostname)
        $hostname = StringStripWS ($hostname, 3)
        ;MsgBox (0, "After", $hostname)
        $host_Count = UBound ($hostname)
        $ip_address = StringSplit (GUICtrlRead ($ip_input), @CRLF, 3)
        $ip_Count = UBound ($ip_address)
        $password = StringSplit (GUICtrlRead ($pw_input), @CRLF, 3)
        $pw_Count = UBound ($password)

        If ($host_Count = $ip_Count And $ip_Count = $pw_Count And $host_Count = $pw_Count) Then
            ;Msgbox($mb_ok,'TRUE', $ip_Count & @crlf & $host_Count & @crlf & $pw_Count)
            GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  It works!")
            For $i = 0 To $host_Count - 1
                ;MsgBox (0, "", $hostname[$i]
                GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  " & $hostname[$i] & @CRLF)
                GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  " & $ip_address[$i] & @CRLF)
                GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  " & $password[$i] & @CRLF)
            Next
        Else
            ;Msgbox($mb_ok,'FALSE', $ip_Count & @crlf & $host_Count & @crlf & $pw_Count)
            GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  Error - One or more fields doesn't match!" & @CRLF & "  Remove white space and/or extra entry before trying again." & @CRLF)
            GUICtrlSetData ($log_label, @TAB & @TAB & @TAB & "  Remove white space and/or extra entry before trying again." & @CRLF)
        Endif

#cs
        Else
            GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  Error - One or more fields doesn't match!")
            MsgBox (48, "Error", "One or more fields does not match!  Please check the entries and try again.")
        EndIf
#ce

        _GUICtrlListBox_UpdateHScroll ($log_label)
        Sleep (1000)

    Case $msg = $clrLog_btn
        GUICtrlSetData ($log_label, "") ; Clear log file
   EndSelect
Until 0

Cheers,

Dreamzboy

Edited by dreamzboy

Share this post


Link to post
Share on other sites
Melba23

dreamzboy,

Listbox is a single line control - you need to use an Edit control if you want multiple line entries. And if a line is too long for the control you need scrollbars to see it. :)

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
dreamzboy

Doh!  :mad2:

If you can elaborate on how to use these 2 codes, it would do what I need.  I'm mainly interested in getting the tab to work.  I can manually enter a new line by coding another "_GuiCtrlListBox_AddString" or "GuiCtrlSetData".

From the GUICtrlListBox example, the columns are evenly distributed by the tab stop.  I'd like to set up that tab stop.

Edit:  I already have my horizontal and vertical scroll in place and that is working.

_GUICtrlListBox_SetTabStops ($log_label, $aTabs)
_GUICtrlListBox_AddString ($log_label, @TAB & " Remove white space and/or extra entry before trying again." & @CRLF)
Edited by dreamzboy

Share this post


Link to post
Share on other sites
dreamzboy

I somewhat figured it out.

I need to declare 4 elements array to be used with _GUICtrlListBox_SetTabStops; however, when that function is called, it looks like this:

Local $aTabs[4] = [3, 30, 0, 0]

_GUICtrlListBox_SetTabStops ($log_label, $aTabs)
_GUICtrlListBox_AddString ($log_label, @HOUR & ":" & @MIN & ":" & @SEC  & "  Error - One or more fields doesn't match!")
_GUICtrlListBox_AddString ($log_label, @TAB & "  Remove white space and/or extra entry before trying again.")

- Output -

 

Remove white space and/or extra entry before trying again.

12:16:52  Error - One or more fields doesn't match!

I wonder why the order flipped?

Edited by dreamzboy

Share this post


Link to post
Share on other sites
dreamzboy

Figured it out.  Here's a working code in case anyone need to refer to it in the future.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <GuiListBox.au3>
#include <array.au3>
#include <constants.au3>

Opt ("TrayIconDebug", 1)

Local $ribcl_temp = '', $xml_temp, $i, $j
Local $hn_input, $ip_input, $pw_input
Local $host_Count, $ip_Count, $pw_Count
Local $msg, $success, $password, $hostname, $ip_address
Local $log_label, $generate_btn, $clrLog_btn
Local $test_str0 = "dl360g7-25" & @CRLF & "dl360g7-26" & @CRLF & "dl360g7-27"
Local $test_str1 = "10.112.15.22" & @CRLF & "10.112.15.23" & @CRLF & "10.112.15.24"
Local $test_str2 = "pass1" & @CRLF & "pass2" & @CRLF & "pass3"
Local $aTabs[4] = [3, 29, 0, 0] ; Define your tab stop

GUICreate ("Test", 600, 450)

GUICtrlCreateLabel ("1.  Enter hostname (ex: dl360g7-25):", 30, 70, 250, 20)
GUICtrlSetFont (-1, 10)
$hn_input = GUICtrlCreateEdit ("", 30, 90, 215, 70)
GUICtrlSetData ($hn_input, $test_str0)
GUICtrlCreateLabel ("2.  Enter iLO static IP address:", 30, 180, 250, 20)
GUICtrlSetFont (-1, 10)
$ip_input = GUICtrlCreateEdit ("", 30, 200, 215, 70)
GUICtrlSetData ($ip_input, $test_str1)
GUICtrlCreateLabel ("3.  Enter iLO default password:", 30, 290, 200, 20)
GUICtrlSetFont (-1, 10)
$pw_input = GUICtrlCreateEdit ("", 30, 310, 215, 70)
GUICtrlSetData ($pw_input, $test_str2)
$log_label = GUICtrlCreateList ("", 300, 90, 270, 292, BitOR($WS_BORDER, $WS_VSCROLL, $WS_HSCROLL, $LBS_USETABSTOPS)) ; Add option $LBS_USETABSTOPS to enable tab stop
$generate_btn = GUICtrlCreateButton ("Generate XML File", 55, 400, 150, 30)
GUICtrlSetFont (-1, 10)
GUICtrlCreateLabel ("version 2.0", 530, 425, 70)
GUICtrlSetColor (-1, 0x0000cd)
$clrLog_btn = GUICtrlCreateButton ("Clear Log", 385, 400, 100, 30)
GUICtrlSetFont (-1, 10)

GUISetState ()

Do
   $msg = GUIGetMsg()

   Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $generate_btn

        ; Check entry simliarity on all fields
        $hostname = StringSplit (GUICtrlRead ($hn_input), @CRLF, 3)
        $host_Count = UBound ($hostname)
        ; MsgBox (0, "", $host_Count)
        $ip_address = StringSplit (GUICtrlRead ($ip_input), @CRLF, 3)
        $ip_Count = UBound ($ip_address)
        ; MsgBox (0, "", $ip_Count)
        $password = StringSplit (GUICtrlRead ($pw_input), @CRLF, 3)
        $pw_Count = UBound ($password)
        ; MsgBox (0, "", $pw_Count)

        If ($host_Count = $ip_Count And $ip_Count = $pw_Count And $host_Count = $pw_Count) Then
            ;Msgbox($mb_ok,'TRUE', $ip_Count & @crlf & $host_Count & @crlf & $pw_Count)
            GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  It works!")
            For $i = 0 To $host_Count - 1
                ;MsgBox (0, "", $hostname[$i]
                GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  " & $hostname[$i] & @CRLF)
                GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  " & $ip_address[$i] & @CRLF)
                GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  " & $password[$i] & @CRLF)
            Next
        Else
            ;Msgbox($mb_ok,'FALSE', $ip_Count & @crlf & $host_Count & @crlf & $pw_Count)
            ;_GUICtrlListBox_SetTabStops ($log_label, $aTabs)
            GUICtrlSetData ($log_label, @HOUR & ":" & @MIN & ":" & @SEC & "  Error - One or more fields doesn't match!" & @CRLF)
            _GUICtrlListBox_SetTabStops ($log_label, $aTabs)
            _GUICtrlListBox_AddString ($log_label, @TAB & "  Remove white space and/or extra entry ")
            _GUICtrlListBox_AddString ($log_label, @TAB & "  before trying again.")
            ;GUICtrlSetData ($log_label, @TAB & "  Remove white space and/or extra entry before trying again." & @CRLF)
        Endif

        _GUICtrlListBox_UpdateHScroll ($log_label)
        Sleep (1000)

    Case $msg = $clrLog_btn
        GUICtrlSetData ($log_label, "") ; Clear log file
   EndSelect
Until 0
Edited by dreamzboy

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  

  • Similar Content

    • Ascer
      By Ascer
      1. Description.
      Udf working with MSDN System.Collections.ArrayList. Allow you to make fast operations on huge arrays, speed is even x10 better than basic _ArrayAdd.  Not prefered for small arrays < 600 items. 2. Requirements
      .NET Framework 1.1 - 4.5 (on this version Microsoft destroy old rules) System Windows 3. Possibilities.
      ;=============================================================================================================== ; UDF Name: List.au3 ; ; Date: 2018-02-17, 10:52 ; Description: Simple udf to create System Collections as ArrayList and make multiple actions on them. ; ; Function(s): _ListCreate -> Creates a new list ; _ListCapacity -> Gets a list size in bytes ; _ListCount -> Gets items count in list ; _ListIsFixedSize -> Get bool if list if fixed size ; _ListIsReadOnly -> Get bool if list is read only ; _ListIsSynchronized -> Get bool if list is synchronized ; _ListGetItem -> Get item on index ; _ListSetItem -> Set item on index ; ; _ListAdd -> Add item at end of list ; _ListClear -> Remove all list items ; _ListClone -> Duplicate list in new var ; _ListContains -> Get bool if item is in list ; _ListGetHashCode -> Get hash code for list ; _ListGetRange -> Get list with items between indexs ; _ListIndexOf -> Get index of item ; _ListInsert -> Insert a new item on index ; _ListInsertRange -> Insert list into list on index ; _ListLastIndexOf -> Get index last of item ; _ListRemove -> Remove first found item ; _ListRemoveAt -> Remove item in index ; _ListRemoveRange -> Remove items between indexs ; _ListReverse -> Reverse all items in list ; _ListSetRange -> Set new value for items in range ; _ListSort -> Sort items in list (speed of reading) ; _ListToString -> Get list object name ; _ListTrimToSize -> Remove unused space in list ; ; Author(s): Ascer ;=============================================================================================================== 4. Downloads
      List.au3 5. Examples
      SpeedTest _ArrayAdd vs ListAdd SpeedTest ArraySearch vs ListIndexOf Basic usage - crating guild with members  
    • nacerbaaziz
      By nacerbaaziz
      can we  create a list box with  Columns?
      welcome everybody
      Dears I have a question if you let me
      can we  create a list box with  Columns?
      i know we can create a list view with Columns
      but my question is about the list box
      I'm waiting your responses
      Thank you in advance
    • argumentum
      By argumentum
      I'd like to add tab Stops to a previously created listbox. Maybe use a GUICtrlSendMsg() or _SendMessage() but I don't know. Help 
      #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WinAPI.au3> Example() Func Example() Local $aTabs[4] = [3, 100, 200, 300], $idListBox ; Create GUI GUICreate("List Box Set Tab Stops", 400, 296) $idListBox = GUICtrlCreateList("", 2, 2, 396, 296) ;, BitOR($LBS_STANDARD, $LBS_USETABSTOPS)) GUISetState(@SW_SHOW) Local $Style = _WinAPI_GetWindowLong(GUICtrlGetHandle($idListBox), $GWL_STYLE) ;Capture Existing Style ;~ Local $ExStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($idListBox), $GWL_EXSTYLE) ;Capture Existing ExStyle ConsoleWrite("- before $Style = 0x" & Hex($Style) & @CRLF) ;~ ConsoleWrite("- before $ExStyle = 0x" & Hex($ExStyle) & @CRLF) GUICtrlSetStyle($idListBox, BitOR($Style, $LBS_USETABSTOPS)) ; change the Style $Style = _WinAPI_GetWindowLong(GUICtrlGetHandle($idListBox), $GWL_STYLE) ;~ $ExStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($idListBox), $GWL_EXSTYLE) ConsoleWrite("- after $Style = 0x" & Hex($Style) & @CRLF) ; updated style but is not reflected in it's behaviour ;~ ConsoleWrite("- after $ExStyle = 0x" & Hex($ExStyle) & @CRLF) ; Set tab stops _GUICtrlListBox_SetTabStops($idListBox, $aTabs) ; Add tabbed string _GUICtrlListBox_AddString($idListBox, "Column 1" & @TAB & "Column 2" & @TAB & "Column 3") ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example  
    • dascondor
      By dascondor
      So I having issues with this GUI/Listview. My main GUI works like it needs to but the ListView GUIs don't. The exit buttons do not work on them and om have a hard time getting them to work. And I'm trying to make the  listview GUI resizeable. But I'm not sure how to fix either of these issues any thoughts.
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <ScreenCapture.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <ListviewConstants.au3> #include 'MultiPing.au3' Opt("GUIOnEventMode", 1) #Region ;Declares ; Reads text file for the base list of IP's Global $aBase_IPlist = _FileReadToArray_mod(".\IP_List.txt") Global $replace2 = "Second" Global $replace3 = "Thrid" ;Global $userdata1 = GUICtrlRead($data1) ;Global $userdata2 = GUICtrlRead($data2) Global $savefolder = "C:\Users\" Global $paths = "\Desktop\PingChecks" Global $1stpaths = "\~~~Store" Global $2ndpaths = "~~~" Global $results = FileExists($savefolder & @UserName & $paths) ;Global $foldercheck = FileExists($savefolder & @UserName & $paths & $1stpaths & $userdata1 & $userdata2 & $2ndpaths) ;Global $savefile = "C:\Users\" & @UserName & "\Desktop\PingChecks\~~~Store" & $userdata1 & $userdata2 & "~~~\" #EndRegion ;Declares #Region ### START Koda GUI section ### Form= $IPMonkey = GUICreate("IP Monkey", 573, 254, -1, -1) GUISetIcon("C:\Users\Dlex\Pictures\monkeyicon.ico", -1) GUISetFont(16, 800, 0, "Arial") GUISetBkColor(0xFFFFFF) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") $data1 = GUICtrlCreateInput("1", 184, 120, 89, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetColor(-1, 0x000000) $data2 = GUICtrlCreateInput("23", 280, 120, 89, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetColor(-1, 0x000000) $GOButton = GUICtrlCreateButton("GO", 80, 192, 75, 25) GUICtrlSetFont(-1, 10, 800, 0, "Arial") GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetTip(-1, "Runs A Live Continuous Ping" & @CRLF & _ "Until Told Other Wise") GUICtrlSetOnEvent(-1, "GOButtonClick") $quickscan = GUICtrlCreateButton("Quick Scan", 224, 192, 107, 25) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlSetOnEvent(-1, "quickscanClick") GUICtrlSetTip(-1, "Quickly Scans, Then Saves" & @CRLF & _ "Results In Your 'PingChecks' " & @CRLF & _ "Folder Under Your Store Number Folder") Global $exitbutton = GUICtrlCreateButton("Exit", 416, 192, 75, 25) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetTip(-1, "What Do You Think This Button Does?") GUICtrlSetOnEvent(-1, "exitbuttonClick") $titlebar = GUICtrlCreateLabel("IP Monkey", 16, 120, 107, 28) GUICtrlSetColor(-1, 0x000000) $Pic1 = GUICtrlCreatePic("C:\Users\Dlex\Pictures\monkeyicon-0.jpg", 16, 16, 100, 100) GUICtrlSetOnEvent(-1, "Pic1Click") $infobutton = GUICtrlCreateButton("?", 536, 8, 27, 25) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFF8000) GUICtrlSetTip(-1, "Unsure what to do?" & @CRLF & _ "This will get give you " & @CRLF & _ "the help for IP Monkey") GUICtrlSetOnEvent(-1, "infobuttonClick") $Whatstorelabel = GUICtrlCreateLabel("What Store?", 208, 56, 130, 28) GUICtrlSetColor(-1, 0x000000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ;ping gui ; ------ pinger GUI ------------------- Global $StopPing = 0 Local $Win_X = 1200, $Win_Y = 880 ; dimension of window Global $PingGui = GUICreate("IP Monkey", $Win_X, $Win_Y, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") Global $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40) GUICtrlSetFont(-1, 8) $button1 = GUICtrlCreateLabel("Hit Exit To Quit", 10, $Win_Y - 25, $Win_X - 20, 20, -1,$ES_CENTER) GUICtrlSetFont(-1, 10, 800) GUICtrlSetTip(-1, "exit") GUICtrlSetOnEvent(-1, 'SpecialEvents') GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP) GUISetState(@SW_HIDE) ; hidden at startup ; --------- end of pinger gui ------------- #EndRegion ;ping gui ; Generate colored square images $hImage = _GUIImageList_Create(30, 30) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green _GUICtrlListView_SetImageList($listview, $hImage, 0) While 1 Sleep(100) WEnd Func exitbuttonClick() MsgBox(0,'0','0') Exit EndFunc ;==>exitbuttonClick Func GOButtonClick() $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) ; pass the wanted new octet replace_And_Go($userdata1, $userdata2) ; generate a list of new IP and Go EndFunc ;==>GOButtonClick Func infobuttonClick() EndFunc ;==>infobuttonClick Func Pic1Click() EndFunc ;==>Pic1Click Func quickscanClick() $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) replace_And_Go2($userdata1, $userdata2) EndFunc ;==>quickscanClick Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE _button1() Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE Case @GUI_CtrlId = $GUI_EVENT_MAXIMIZE EndSelect EndFunc ;==>SpecialEvents #Region ; Main_GO/Replace_and_GO #cs ############################## second script ############################################# ; this is to ping continuously a list of IP addresses, get and display ping result "live" ; it simulates the dos "ping -t" command but performed simultaneously on many IP ; presenting the results in a ListView highlighting not responding devices with a red box #ce Func replace_And_Go($s_2, $s_3) ; Create a new array wit a new list of IP according to passed second and third octet Local $aNew_IPlist = $aBase_IPlist For $i = 0 To UBound($aNew_IPlist) - 1 $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3) Next GUISetState(@SW_HIDE, $IPMonkey) GUISetState(@SW_SHOW, $PingGui) ; pass the new list to the pinger Main_GO($aNew_IPlist) GUISetState(@SW_HIDE, $PingGui) GUISetState(@SW_SHOW, $IPMonkey) EndFunc ;==>replace_And_Go Func Main_GO($IPlist) HotKeySet("{esc}", "exitbuttonClick") $StopPing = 0 ; $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's ; ; the above command, it loads in the $IPlist array the values contained in the file IP_List.txt ; values in the file should be separated by a semicolon, something like in the following example: ; ; hostname1;192.168.0.1 ; hostname2;192.168.0.5 ; hostnameX;10.59.7.200 ; etc.... ; ; if values in the file are not separated by a semicolon, but another char is used, for example a comma, ; then just pass it as second parameter of the function: $IPlist = _FileReadToArray_mod(".\IP_List.txt", ",") ; _GUICtrlListView_BeginUpdate($listview) _GUICtrlListView_DeleteAllItems($listview) _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView _GUICtrlListView_EndUpdate($listview) While Not $StopPing ; 1 ; continuously ping addresses of the previously loaded file (IP_List.txt) Sleep(10) ; ; $IPlist is the array loaded with all the IP to be pinged (a 2d array in this case) ; | ; | 1 means the IP are in the second column of the $IPlist array (first colun is nr. 0) ; | | ; | | +--> 0 means return back an array loaded with results from all pinged addresses (responding and not responding) ; | | | if you use 1 then only responding addresses are loaded in the returned array [default] ; | | | if you use 2 then only NOT responding addresses are loaded in the returned array ; | | | In this case we do not need an array to be returned, we only need to perform all pings and pass results ; | | | directly (on the fly) to the "_refresh" callback function that will refresh the listview ; | | | ; | | | 0 means NO lookup name resolution must be performed ; | | | | ; | | | | +--> this is the callback function to be called for each pinged address each time the ping has finished ; | | | | | (see the MultiPing.au3 file for info on all passed params) ; | | | | | 6 parameters are passed to this function, but only 2 are used by the called function in this case: ; | | | | | [4] roundtrip of the responding ping or -1 if IP is down ; | | | | | [5] Index (position) of this IP within the caller's passed array ; | | | | | ; v v v v v _nPing($IPlist, 1, 0, 0, "_refresh") WEnd EndFunc ;==>Main_GO #EndRegion ; Main_GO/Replace_and_GO #Region ; QuickScan/Replace_and_GO2 Func replace_And_Go2($s_2, $s_3) ; Create a new array wit a new list of IP according to passed second and third octet Local $aNew_IPlist = $aBase_IPlist For $i = 0 To UBound($aNew_IPlist) - 1 $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3) Next GUISetState(@SW_HIDE, $IPMonkey) GUISetState(@SW_SHOW, $PingGui) ; pass the new list to the pinger QuickRun($aNew_IPlist) GUISetState(@SW_HIDE, $PingGui) GUISetState(@SW_SHOW, $IPMonkey) EndFunc ;==>replace_And_Go2 Func QuickRun($IPlist) $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) HotKeySet("{esc}", "_button1") Local $Win_X = 1200, $Win_Y = 880 ; dimension of window $PingGui = GUICreate("IP Monkey" & "~~~" & @UserName & "~~~" & "Store" & $userdata1 & $userdata2 & "~~~" & @MON & "." & @MDAY & "." & @YEAR & "~~~" & @HOUR & "." & @MIN, $Win_X, $Win_Y, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui) $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40) GUICtrlSetFont(-1, 8) GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP) ; Generate colored square images $hImage = _GUIImageList_Create(30, 30) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green _GUICtrlListView_SetImageList($listview, $hImage, 0) $button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20) GUICtrlSetTip(-1, "End of program") GUICtrlSetOnEvent(-1, "exitbuttonClick") GUISetState(@SW_SHOW) ;~ $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's _GUICtrlListView_BeginUpdate($listview) _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView _GUICtrlListView_EndUpdate($listview) ;While 1 ; perform Pings and update ListView by the "_refresh" callback function $aFinalResult = _nPing($IPlist, 1, 0, 0, "_refresh") ;~ _ArrayDisplay($aFinalResult) ;DirCheck() EndFunc ;==>QuickRun #EndRegion ; QuickScan/Replace_and_GO2 #Region ; Misc Funcs (network) Func _refresh($Params) ; this receive ping results and displays them in the ListView _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow Sleep(50) ; a little wait If $Params[4] = -1 Then ; Device not responding to ping _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item Else ; Device responds to ping _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN EndIf EndFunc ;==>_refresh Func _button1() ; Button 1 clicked ;~ $StopPing = 1 Exit EndFunc ;==>_button1 #EndRegion ; Misc Funcs (network)  
      MultiPing.au3
      IP_List.txt
    • hcI
      By hcI
      Hello everyone !
      I was looking for a parameter to set a List. Not a ComboList in ReadOnly.
      I've already found a topic about The readonly on a ComboList :
      But nothing on List
      Does someone know how to ?..
×