Jump to content

Problems with GUICtrlRead


Chobby
 Share

Recommended Posts

Well, I cant get this working ... :)

I want it to add the given inputs to the right columns - but it aint working for me ;)

Heres my code:

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

 AutoIt Version: 3.2.10.0
 Author:         Chob

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

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

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

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

$linksmenu = GUICtrlCreateMenu ("Links")
$weblink = GUICtrlCreateMenuItem ("Clan Website",$linksmenu)
$forumlink = GUICtrlCreateMenuItem ("Clan forums",$linksmenu)
GUICtrlCreateMenuItem ("",$linksmenu)
$serverlink = GUICtrlCreateMenuItem ("Clan server statistics",$linksmenu)
GUICtrlCreateMenuItem ("",$linksmenu)
$jk2files = GUICtrlCreateMenuItem ("Jedi Knight II files",$linksmenu)

$aboutmenu = GUICtrlCreateMenu ("Help")
$aboutitem = GUICtrlCreateMenuItem ("About",$aboutmenu)

; 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)

$readsub = GUICtrlRead($addIP) & "|" & GUICtrlRead($addName) & "|" & GUICtrlRead($addCountry) & "|" & GUICtrlRead($addClan) & "|" & GUICtrlRead($addBan)

$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("$readsub",$listview); Not working :(
                
    Case $msg = $resbrn             ; Done
        $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 = $aboutitem          ; Done
        MsgBox(0,"About..","Clan Apathys Server Tool is created by <Ca>Chobby" & @LF & @LF & "                        Copyright © 2008", 15)
        
    Case $msg = $weblink            ; Done
        _IECreate ("http://www.clan-apathy.net")
        
    Case $msg = $forumlink          ; Done
        _IECreate ("http://www.even-flow.dk/test/")
    
    Case $msg = $serverlink         ; Done
        _IECreate ("http://www.serverspy.net/site/search/server.html?a=72.5.248.18:28070&g=5")
    
    Case $msg = $jk2files           ; Done
        _IECreate ("http://jediknight3.filefront.com/")
                
    Case $msg = $GUI_EVENT_CLOSE    ; Done
        Exitloop
    
    Case $msg = $exititem           ; Done
        ExitLoop
    
    EndSelect
Wend
Link to comment
Share on other sites

First off, when using GUICtrlRead, you want to make it read at the right time, if you make it read before you set the GUI state then that means its reading nothing since theresnothing to read.

Thats all I could see that was off. I'll read through a couple more times.

Edited by uPod
Link to comment
Share on other sites

I got it working .. :) Added DIM infront of the inputs..

Now I got another problem, kinda.. Can someone tell me how to save the listview into any kind of file? Or at least where I can see examples or similiar? ;)

This is my script now:

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

 AutoIt Version: 3.2.10.0
 Author:         Chob

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

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

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

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

$linksmenu = GUICtrlCreateMenu ("Links")
$weblink = GUICtrlCreateMenuItem ("Clan Website",$linksmenu)
$forumlink = GUICtrlCreateMenuItem ("Clan forums",$linksmenu)
GUICtrlCreateMenuItem ("",$linksmenu)
$serverlink = GUICtrlCreateMenuItem ("Clan server statistics",$linksmenu)
GUICtrlCreateMenuItem ("",$linksmenu)
$jk2files = GUICtrlCreateMenuItem ("Jedi Knight II files",$linksmenu)

$aboutmenu = GUICtrlCreateMenu ("Help")
$aboutitem = GUICtrlCreateMenuItem ("About",$aboutmenu)

; 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)
Dim $addIP=GUICtrlCreateInput("",375,90,100,17)
GUICtrlCreateLabel("Name:",310,110,30,17)
Dim $addName=GUICtrlCreateInput("",375,110,100,17)
GUICtrlCreateLabel("Country:",310,130,45,17)
Dim $addCountry=GUICtrlCreateInput("",375,130,100,17)
GUICtrlCreateLabel("Clan:",310,150,30,17)
Dim $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)

;$readsub = GUICtrlRead($addIP) & "|" & GUICtrlRead($addName) & "|" & GUICtrlRead($addCountry) & "|" & GUICtrlRead($addClan) & "|" & GUICtrlRead($addBan)

$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(GUICtrlRead($addIP) & "|" & GUICtrlRead($addName) & "|" & GUICtrlRead($addCountry) & "|" & GUICtrlRead($addClan) & "|" & GUICtrlRead($addBan),$listview)
        Sleep(10)
        $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 = $resbrn             ; Done
        $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 = $aboutitem          ; Done
        MsgBox(0,"About..","Clan Apathys Server Tool is created by <Ca>Chobby" & @LF & @LF & "                        Copyright © 2008", 15)
        
    Case $msg = $weblink            ; Done
        _IECreate ("http://www.clan-apathy.net")
        
    Case $msg = $forumlink          ; Done
        _IECreate ("http://www.even-flow.dk/test/")
    
    Case $msg = $serverlink         ; Done
        _IECreate ("http://www.serverspy.net/site/search/server.html?a=72.5.248.18:28070&g=5")
    
    Case $msg = $jk2files           ; Done
        _IECreate ("http://jediknight3.filefront.com/")
                
    Case $msg = $GUI_EVENT_CLOSE    ; Done
        Exitloop
    
    Case $msg = $exititem           ; Done
        ExitLoop
    
    EndSelect
Wend
Link to comment
Share on other sites

Well ... Maybe I can use those functions, but I dont know quite how to use it I guess!!

I tried, but the only thing it writes is '3434'... :/

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

 AutoIt Version: 3.2.10.0
 Author:         Chob

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

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

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

; TOP MENU
$filemenu = GUICtrlCreateMenu ("Files")
$saveitem = GUICtrlCreateMenuItem ("Save IP list",$filemenu)
GUICtrlCreateMenuItem("",$filemenu)
$exititem = GUICtrlCreateMenuItem ("Quit",$filemenu)


$linksmenu = GUICtrlCreateMenu ("Links")
$weblink = GUICtrlCreateMenuItem ("Clan Website",$linksmenu)
$forumlink = GUICtrlCreateMenuItem ("Clan forums",$linksmenu)
GUICtrlCreateMenuItem ("",$linksmenu)
$serverlink = GUICtrlCreateMenuItem ("Clan server statistics",$linksmenu)
GUICtrlCreateMenuItem ("",$linksmenu)
$jk2files = GUICtrlCreateMenuItem ("Jedi Knight II files",$linksmenu)

$aboutmenu = GUICtrlCreateMenu ("Help")
$aboutitem = GUICtrlCreateMenuItem ("About",$aboutmenu)

; 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)
Dim $addIP=GUICtrlCreateInput("",375,90,100,17)
GUICtrlCreateLabel("Name:",310,110,30,17)
Dim $addName=GUICtrlCreateInput("",375,110,100,17)
GUICtrlCreateLabel("Country:",310,130,45,17)
Dim $addCountry=GUICtrlCreateInput("",375,130,100,17)
GUICtrlCreateLabel("Clan:",310,150,30,17)
Dim $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)

$newline = GUICtrlRead($addIP) & "|" & GUICtrlRead($addName) & "|" & GUICtrlRead($addCountry) & "|" & GUICtrlRead($addClan) & "|" & GUICtrlRead($addBan)

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

; FILE OPEN/SAVE

$file = FileOpen("list.txt",1)


GUICtrlCreateTabitem ("") 

GUISetState ()

While 1
    $msg = GUIGetMsg()
    
    Select
        
    Case $msg = $subbtn
        GUICtrlCreateListViewItem(GUICtrlRead($addIP) & "|" & GUICtrlRead($addName) & "|" & GUICtrlRead($addCountry) & "|" & GUICtrlRead($addClan) & "|" & GUICtrlRead($addBan),$listview)
        
    Case $msg = $resbrn             ; Done
        $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 = $aboutitem          ; Done
        MsgBox(0,"About..","Clan Apathys Server Tool is created by <Ca>Chobby" & @LF & @LF & "                        Copyright © 2008", 15)
        
    Case $msg = $weblink            ; Done
        _IECreate ("http://www.clan-apathy.net")
        
    Case $msg = $forumlink          ; Done
        _IECreate ("http://www.even-flow.dk/test/")
    
    Case $msg = $serverlink         ; Done
        _IECreate ("http://www.serverspy.net/site/search/server.html?a=72.5.248.18:28070&g=5")
    
    Case $msg = $jk2files           ; Done
        _IECreate ("http://jediknight3.filefront.com/")
                
    Case $msg = $saveitem
        FileWrite($file,$listview)
        FileClose($file)

    Case $msg = $GUI_EVENT_CLOSE    ; Done
                
        Exitloop
    
    Case $msg = $exititem           ; Done
        ExitLoop
    
    EndSelect
Wend
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...