Sign in to follow this  
Followers 0
Chobby

Listview help

3 posts in this topic

#1 ·  Posted (edited)

Hi guys,

I need some help, allready, and im not that far in my program yet, even..

I am creating a ip list program for my gaming clans server.. We log peoples IP, their names and everything (we dont misuse it of course, but we use it as references to know if someone is comming on a regular basis and not behaving well in our server - its easier to identify them, then..) ..

What I am trying to do is a way to search among the listview items, like, search for an IP and the name and the rest of the info appears, in some way.. The problem is, that I dont quite know and cant find out how the _GUICtrlListView_FindInText function works :)

I also would love to hear if you have any ideas for adding IPs and such .. And in the end to sort them after IP, so 83.41.0.0 is, even though added earlier, listed after 83.43.0.0..

Thanks a lot,

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

 AutoIt Version: 3.2.10.0
 Author:         Chob

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstants.au3>
#include <GuiListView.au3>
#NoTrayIcon

; GUI
GUICreate("Clan Apathy Server Tool",520,450)

; TOP MENU
$filemenu = GUICtrlCreateMenu ("Files")
$exititem = GUICtrlCreateMenuItem ("Quit",$filemenu)

; TABS
$tab=GUICtrlCreateTab (10,10,505,410)

; IP-LIST TAB
$tabb0=GUICtrlCreateTabItem ("IP List")

; SEARCH
GUICtrlCreateLabel("Search for a match", 360,35)
$search=GUICtrlCreateInput( "IP",310,50,100,17)
$sbtn=GUICtrlCreateButton("Search",420,50,70,17)

; ADD
GUICtrlCreateLabel("Add a new entry", 370,70)
GUICtrlCreateLabel("IP:",310,90,30,17)
$addIP=GUICtrlCreateInput("",375,90,100,17)
GUICtrlCreateLabel("Name:",310,110,30,17)
$addName=GUICtrlCreateInput("",375,110,100,17)
GUICtrlCreateLabel("Country:",310,130,45,17)
$addCountry=GUICtrlCreateInput("",375,130,100,17)
GUICtrlCreateLabel("Clan:",310,150,30,17)
$addClan=GUICtrlCreateInput("",375,150,40,17)
GUICtrlCreateLabel("Ban?:",310,170,30,17)
$addBan=GUICtrlCreateInput("",375,170,40,17)
$subbtn=GUICtrlCreateButton("Add",330,200,70,17)
$resbrn=GUICtrlCreateButton("Reset",410,200,70,17)

$listview = GUICtrlCreateListView("IP                   |Name|Country|Clan|Ban?",17,35,285,378)
$item1=GUICtrlCreateListViewItem("83.111.111.198|Achilles|Sweden|Ca| ",$listview)



GUICtrlCreateTabitem ("") 

GUISetState ()

While 1
    $msg = GUIGetMsg()
    
    Select
        
    Case $msg = $subbtn
        GUICtrlCreateListViewItem("$addIP|$addName|$addCountry|$addClan|$addBan" ,$listview); How to?
        
    Case $msg = $resbrn
        $addIP=GUICtrlCreateInput("",375,90,100,17)
        $addName=GUICtrlCreateInput("",375,110,100,17)
        $addCountry=GUICtrlCreateInput("",375,130,100,17)
        $addClan=GUICtrlCreateInput("",375,150,40,17)
        $addBan=GUICtrlCreateInput("",375,170,40,17)
                
    Case $msg = $GUI_EVENT_CLOSE 
        Exitloop
    
    Case $msg = $exititem
        ExitLoop
    
    EndSelect
Wend

Edit1: Updated code..

Edit2: Updated code..

Edited by Chobby

Share this post


Link to post
Share on other sites



Hi guys,

I need some help, allready, and im not that far in my program yet, even..

I am creating a ip list program for my gaming clans server.. We log peoples IP, their names and everything (we dont misuse it of course, but we use it as references to know if someone is comming on a regular basis and not behaving well in our server - its easier to identify them, then..) ..

What I am trying to do is a way to search among the listview items, like, search for an IP and the name and the rest of the info appears, in some way.. The problem is, that I dont quite know and cant find out how the _GUICtrlListView_FindInText function works :)

I also would love to hear if you have any ideas for adding IPs and such .. And in the end to sort them after IP, so 83.41.0.0 is, even though added earlier, listed after 83.43.0.0..

Thanks a lot,

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

 AutoIt Version: 3.2.10.0
 Author:         Chob

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstants.au3>
#include <GuiListView.au3>
#NoTrayIcon

; GUI
GUICreate("Clan Apathy Server Tool",520,450)

; TOP MENU
$filemenu = GUICtrlCreateMenu ("Files")
$exititem = GUICtrlCreateMenuItem ("Quit",$filemenu)

; TABS
$tab=GUICtrlCreateTab (10,10,505,410)

; IP-LIST TAB
$tabb0=GUICtrlCreateTabItem ("IP List")

; SEARCH
GUICtrlCreateLabel("Search for a match", 360,35)
$search=GUICtrlCreateInput( "IP",310,50,100,17)
$sbtn=GUICtrlCreateButton("Search",420,50,70,17)

; ADD
GUICtrlCreateLabel("Add a new entry", 370,70)
GUICtrlCreateLabel("IP:",310,90,30,17)
$addIP=GUICtrlCreateInput("",375,90,100,17)
GUICtrlCreateLabel("Name:",310,110,30,17)
$addName=GUICtrlCreateInput("",375,110,100,17)
GUICtrlCreateLabel("Country:",310,130,45,17)
$addCountry=GUICtrlCreateInput("",375,130,100,17)
GUICtrlCreateLabel("Clan:",310,150,30,17)
$addClan=GUICtrlCreateInput("",375,150,40,17)
GUICtrlCreateLabel("Ban?:",310,170,30,17)
$addBan=GUICtrlCreateInput("",375,170,40,17)
$subbtn=GUICtrlCreateButton("Add",330,200,70,17)
$resbrn=GUICtrlCreateButton("Reset",410,200,70,17)

$listview = GUICtrlCreateListView("IP                   |Name|Country|Clan|Ban?",17,35,285,378)
$item1=GUICtrlCreateListViewItem("83.111.111.198|Achilles|Sweden|Ca| ",$listview)



GUICtrlCreateTabitem ("") 

GUISetState ()

While 1
    $msg = GUIGetMsg()
    
    Select
        
    Case $msg = $subbtn
        GUICtrlCreateListViewItem("$addIP|$addName|$addCountry|$addClan|$addBan" ,$listview); How to?
        
    Case $msg = $resbrn
        $addIP=GUICtrlCreateInput("",375,90,100,17)
        $addName=GUICtrlCreateInput("",375,110,100,17)
        $addCountry=GUICtrlCreateInput("",375,130,100,17)
        $addClan=GUICtrlCreateInput("",375,150,40,17)
        $addBan=GUICtrlCreateInput("",375,170,40,17)
                
    Case $msg = $GUI_EVENT_CLOSE 
        Exitloop
    
    Case $msg = $exititem
        ExitLoop
    
    EndSelect
Wend

Edit1: Updated code..

Edit2: Updated code..

The explanations of the functions can be found in the include file.

I changed some things in your code and added some things. I hope it makes sense.

#include <GUIConstants.au3>
#include <GuiListView.au3>
#NoTrayIcon

; GUI
GUICreate("Clan Apathy Server Tool", 520, 450)

; TOP MENU
$filemenu = GUICtrlCreateMenu("Files")
$exititem = GUICtrlCreateMenuItem("Quit", $filemenu)

; TABS
$tab = GUICtrlCreateTab(10, 10, 505, 410)

; IP-LIST TAB
$tabb0 = GUICtrlCreateTabItem("IP List")

; SEARCH
GUICtrlCreateLabel("Search for a match", 360, 35)
$search = GUICtrlCreateInput("IP", 310, 50, 100, 17)
$sbtn = GUICtrlCreateButton("Search", 420, 50, 70, 17)

; ADD
GUICtrlCreateLabel("Add a new entry", 370, 70)
GUICtrlCreateLabel("IP:", 310, 90, 30, 17)
$addIP = GUICtrlCreateInput("", 375, 90, 100, 17)
GUICtrlCreateLabel("Name:", 310, 110, 30, 17)
$addName = GUICtrlCreateInput("", 375, 110, 100, 17)
GUICtrlCreateLabel("Country:", 310, 130, 45, 17)
$addCountry = GUICtrlCreateInput("", 375, 130, 100, 17)
GUICtrlCreateLabel("Clan:", 310, 150, 30, 17)
$addClan = GUICtrlCreateInput("", 375, 150, 40, 17)
GUICtrlCreateLabel("Ban?:", 310, 170, 30, 17)
$addBan = GUICtrlCreateInput("", 375, 170, 40, 17)
$subbtn = GUICtrlCreateButton("Add", 330, 200, 70, 17)
$resbrn = GUICtrlCreateButton("Reset", 410, 200, 70, 17)

$listview = GUICtrlCreateListView("IP                   |Name|Country|Clan|Ban?", 17, 35, 285, 378)
$item1 = GUICtrlCreateListViewItem("83.111.111.198|Achilles|Sweden|Ca| ", $listview)



GUICtrlCreateTabItem("")

GUISetState()

While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $sbtn
            Local $tofind = GUICtrlRead($search)
            If $tofind <> '' Then
                
                Local $found = _GUICtrlListView_FindInText ($listview, $tofind)
                If $found > -1 Then
                    MsgBox(0, "Found text", "the text" & @CR & $tofind & @CR & "is in item " & $found + 1)
                EndIf;else not found etc
            EndIf
            
        Case $msg = $subbtn
            
            Local $sortAsc = False
            GUICtrlCreateListViewItem(GUICtrlRead($addIP) & '|' & GUICtrlRead($addCountry) & '|' & GUICtrlRead($addClan) & '|' & GUICtrlRead($addBan), $listview)
            _GUICtrlListView_SimpleSort ($listview, $sortAsc, 0)
            ClearIps()
        Case $msg = $resbrn
            ClearIps()
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop

        Case $msg = $exititem
            ExitLoop

    EndSelect
WEnd

Func ClearIps()
;don't create the controls again to clear them
    GUICtrlSetData($addIP, "")
    GUICtrlSetData($addName, "")
    GUICtrlSetData($addCountry, '')
    GUICtrlSetData($addClan, '')
    GUICtrlSetData($addBan, '')
EndFunc  ;==>ClearIps

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Wow, thanks a lot - that works like a charm!!

Then, I got a couple of more questions :)

Would it be possible, when you search for an entry, then it goes and selects that given line in the listview, instead of creating a msgbox?

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  
Followers 0