Sign in to follow this  
Followers 0
Roofel

GuiCtrlRead in List:S

3 posts in this topic

I currently got a program that sets the data you write into the input to a list. Then when the Program closes it is supposed to write what is in the list to a IniFile(All good with IniWrite function)

The problem lies in the GuiCtrlRead($List)..

I looked in the helpfile under GuiCtrlRead and found this..

Combo, List | The value selected

#include <Constants.au3>
#include <IE.au3>
#include <GUIListbox.au3>

Opt("TrayMenuMode",1)
Opt("GUIDataSeparatorChar",2)
HotKeySet("{Esc}", "Close");For use while testing:)


$Iniload=IniRead(@ScriptDir & "\" & "Search.ini", "Main", "Data", "")
$Form1= GUICreate("Find Airlines!", 403, 251, 616, 455)
$Group1= GUICtrlCreateGroup("Search", 8, 8, 385, 233)
$Button1= GUICtrlCreateButton("Google", 72, 72, 81, 49, 0)
$Button2= GUICtrlCreateButton("Yahoo!", 160, 72, 81, 49, 0)
$Button3= GUICtrlCreateButton("Kvasir", 248, 72, 81, 49, 0)
$Label2= GUICtrlCreateLabel("With", 20, 87, 52, 25)
$List1= GUICtrlCreateList("", 32, 123, 337, 71)
$Input1= GUICtrlCreateInput("", 80, 39, 193, 21)
$Label1= GUICtrlCreateLabel("Search for", 16, 40, 52, 17)
$Listbtn=GUICtrlCreateButton("Add search to list", 280, 30, 100, 40)
$Writebtn=GUICtrlCreateButton("Save searches", 32, 200, 169, 30)
$Remove=GUICtrlCreateButton("Remove selected", 202, 200, 169, 30)
$Menu=GUICtrlCreateContextMenu($List1)
$Item1=GUICtrlCreateMenuItem("Add to search bar", $Menu)
$Item2=GUICtrlCreateMenuItem("Remove from list", $Menu)
$Restore=TrayCreateItem("Restore Window")
$Nothing=TrayCreateItem("")
$About=TrayCreateItem("About")
$Exit=TrayCreateItem("Exit program")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
GUICtrlSetData($List1, $Iniload)


While 1
    $nMsg = GUIGetMsg()
    WinSetOnTop($Form1, "", 1)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE, $Form1)
        Case $Listbtn
            GUICtrlSetData($List1,Guictrlread($Input1))
        Case $Remove
            _GUICtrlListBox_GetCurSel($List1)
            _GUICtrlListBox_DeleteString($List1,-0)
        Case $Writebtn
            IniWrite("Search.ini", "Main", "Data", GUICtrlRead($Input1))
        Case $Button1
            _IECreate('http://www.google.com/search?q='&GUICtrlRead($Input1),1,1,0)
        Case $Button2
            _IECreate("http://www.kvasir.no/nettsok/searchResult.html?searchExpr="&GuiCtrlRead($Input1), 1,1,0)
        Case $Button3
            _IECreate("http://search.yahoo.com/search;_ylt=A0geu9fhcrlHOHUB1JxXNyoA?p="&GUICtrlRead($Input1), 1,1,0)
        Case $Item1
            GUICtrlSetData($Input1, GuictrlRead($List1))
        Case $Item2
            _GUICtrlListBox_GetCurSel($List1)
            _GUICtrlListBox_DeleteString($List1,1)
    EndSwitch
    $Msg=TrayGetMsg()
    Select
        Case $Msg=$Restore
            GUISetState(@SW_SHOW, $Form1)
        Case $Msg=$About
            MsgBox(64, "about:", "This program was created by Roofel using the amazing software AutoIt")
        Case $Msg=$Exit
            Exit
    EndSelect
WEnd

Func Close()
    Exit
EndFunc
Func Add()
    GUICtrlSetData($List1, GUICtrlRead($Input1))
EndFunc

Meaning the GuiCtrlRead only works when I write GuiCtrlRead($Input1) and not when i write GuiCtrlRead($List1)

Any way to go around this? Since using the $Input1 way wont work with my ideas:(

Sorry if I make way to many topics around my project:)


Never argue with an idiot, he will just bring you down to his own level and beat you with experience! :D

Share this post


Link to post
Share on other sites



Is this what you had in mind?

#include <IE.au3>
#include <GUIListbox.au3>

Opt("TrayMenuMode",1)
Opt("GUIDataSeparatorChar",2)
HotKeySet("{Esc}", "Close");For use while testing:)


$Iniload=IniRead(@ScriptDir & "\" & "Search.ini", "Main", "Data", "")
$Form1= GUICreate("Find Airlines!", 403, 251, 616, 455)
$Group1= GUICtrlCreateGroup("Search", 8, 8, 385, 233)
$Button1= GUICtrlCreateButton("Google", 72, 72, 81, 49, 0)
$Button2= GUICtrlCreateButton("Yahoo!", 160, 72, 81, 49, 0)
$Button3= GUICtrlCreateButton("Kvasir", 248, 72, 81, 49, 0)
$Label2= GUICtrlCreateLabel("With", 20, 87, 52, 25)
$List1= GUICtrlCreateList("", 32, 123, 337, 71)
$Input1= GUICtrlCreateInput("", 80, 39, 193, 21)
$Label1= GUICtrlCreateLabel("Search for", 16, 40, 52, 17)
$Listbtn=GUICtrlCreateButton("Add search to list", 280, 30, 100, 40)
$Writebtn=GUICtrlCreateButton("Save searches", 32, 200, 169, 30)
$Remove=GUICtrlCreateButton("Remove selected", 202, 200, 169, 30)
$Menu=GUICtrlCreateContextMenu($List1)
$Item1=GUICtrlCreateMenuItem("Add to search bar", $Menu)
$Item2=GUICtrlCreateMenuItem("Remove from list", $Menu)
$Restore=TrayCreateItem("Restore Window")
$Nothing=TrayCreateItem("")
$About=TrayCreateItem("About")
$Exit=TrayCreateItem("Exit program")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
GUICtrlSetData($List1, $Iniload)


While 1
    $nMsg = GUIGetMsg()
    WinSetOnTop($Form1, "", 1)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE, $Form1)
        Case $Listbtn
            GUICtrlSetData($List1,Guictrlread($Input1))
        Case $Remove
            _GUICtrlListBox_GetCurSel($List1)
            _GUICtrlListBox_DeleteString($List1,-0)
        Case $Writebtn
            IniWrite("Search.ini", "Main", "Data", GUICtrlRead($Input1))
        Case $Button1
            _IECreate('http://www.google.com/search?q='&GUICtrlRead($Input1),1,1,0)
        Case $Button2
            _IECreate("http://www.kvasir.no/nettsok/searchResult.html?searchExpr="&GuiCtrlRead($Input1), 1,1,0)
        Case $Button3
            _IECreate("http://search.yahoo.com/search;_ylt=A0geu9fhcrlHOHUB1JxXNyoA?p="&GUICtrlRead($Input1), 1,1,0)
        Case $Item1
            GUICtrlSetData($Input1, GuictrlRead($List1))
        Case $Item2
            _GUICtrlListBox_GetCurSel($List1)
            _GUICtrlListBox_DeleteString($List1,1)
        Case $list1
            GUICtrlSetData($Input1, GuictrlRead($List1))
    EndSwitch
    $Msg=TrayGetMsg()
    Select
        Case $Msg=$Restore
            GUISetState(@SW_SHOW, $Form1)
        Case $Msg=$About
            MsgBox(64, "About:", "This program was created by Roofel using the amazing software AutoIt")
        Case $Msg=$Exit
            Exit
    EndSelect
WEnd

Func Close()
    Exit
EndFunc
Func Add()
    GUICtrlSetData($List1, GUICtrlRead($Input1))
EndFunc

Share this post


Link to post
Share on other sites

Cant see any difference tbh:S

What is different?:)


Never argue with an idiot, he will just bring you down to his own level and beat you with experience! :D

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