Sign in to follow this  
Followers 0
mbkowns

GUICtrlSetData Help with adding file directory

2 posts in this topic

I am trying to add batch files to a listview and then I want to be able to move the ones i select to the right side. Then I want to hit install and have it install each one. That hit install part is easy but I am have problems with it adding the files to the list. It seems like it only wants to add etheir the first file or the last one. I know my code is a bit of a mess but you understand where I am trying to go here...

thanks

-KYLE

#include <GUIConstants.au3>
;~ Global $x 

global $file, $search, $c, $radd, $section

; Shows the filenames of all files in the current directory.

$search = FileFindFirstFile("c:\a\*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
;~ $section = IniReadSection("c:\a.ini", '')
$c = $c + 1
iniwrite("c:\a.ini", "Scripts", $c, $file)
;~ MsgBox(4096, "File:", $file)
;~ $List1 = GuiCtrlCreateList("List", 10, 10, 370, 305)
;~ $List1 = GuiCtrlCreateList($file, 10, 10, 370, 305)
;~ $radd = IniReadSectionNames("c:\a.ini")
;~ MsgBox(4096, "go", $file)
;~ GUICtrlSetData(-1, $iadd, "")
;~ GUICtrlSetData('List', "", $iadd)
;~ GuiCtrlSetData($file,"List")


;~ MsgBox(4096, "33", $section)




;~ $x = 0
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Choices Dialog", 353, 263, 303, 219)
GUISetIcon("C:\Program Files\MagicISO\cdburner.ico")
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm2Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "AForm2Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "AForm2Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "AForm2Restore")
$ListBox1 = GUICtrlCreateList("", 8, 8, 137, 201)
GUICtrlSetData(-1, $file & '|' & $section, "")                                  
;~ GUICtrlSetData(-1, $x & "|"  &  $iadd + 100 & "|Item2|Item3|Item4|Item5")
;~ GUICtrlSetData(-1, $x & $x)

;Close the search handle
WEnd
FileClose($search)

GUICtrlSetOnEvent(-1, "ListBox1Click")
$Button1 = GUICtrlCreateButton(">", 156, 15, 30, 25, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton(">>", 156, 48, 31, 25, 0)
GUICtrlSetOnEvent(-1, "Button2Click")
$Button3 = GUICtrlCreateButton("<", 157, 81, 31, 25, 0)
GUICtrlSetOnEvent(-1, "Button3Click")
GUICtrlSetState(-1, $GUI_DISABLE)
$Button4 = GUICtrlCreateButton("<<", 157, 114, 32, 25, 0)
GUICtrlSetOnEvent(-1, "Button4Click")
$ListBox2 = GUICtrlCreateList("", 200, 8, 137, 201)
;~ GUICtrlSetData(-1, $x & "|"  &  $x + 100 & "|Item2|Item3|Item4|Item5")   

GUICtrlSetOnEvent(-1, "ListBox2Click")
$Button5 = GUICtrlCreateButton("&OK", 104, 225, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button5Click")
$Button6 = GUICtrlCreateButton("&Cancel", 184, 225, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button6Click")
$Button7 = GUICtrlCreateButton("&Help", 264, 225, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button7Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###




While 1
    Sleep(100)
WEnd
        
    
        
Func AForm2Close()
Exit
EndFunc

        
Func AForm2Maximize()

EndFunc

        
Func AForm2Minimize()

EndFunc

        
Func AForm2Restore()

EndFunc

        
Func Button1Click()
;~ MsgBox(4096, "1", "1")

EndFunc

        
Func Button2Click()
MsgBox(4096, "2", "2")
EndFunc

        
Func Button3Click()
MsgBox(4096, "3", "3")
EndFunc

        
Func Button4Click()
MsgBox(4096, "4", "4")
EndFunc

        
Func Button5Click()
MsgBox(4096, "5", "5")
EndFunc

        
Func Button6Click()
;~ MsgBox(4096, "6", "6")
Exit
EndFunc

        
Func Button7Click()
MsgBox(4096, "7", "7")
EndFunc

        
Func ListBox1Click()
MsgBox(4096, "list1", "click")
EndFunc

        
Func ListBox2Click()
MsgBox(4096, "list2", "click")
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Your code was really totally messed up :whistle:

Main problems:

- iniwrite("c:\a.ini", "Scripts", $c, $file) -> overwrites file names (write info to 1 key in Loop)

- GUICreate stuff was in LOOP!!

Here is corrected your existing code.

Note that I only corrected your code and didn't add any new code for your buttons.

#include <GUIConstants.au3>

global $file, $files, $search, $c, $radd, $section

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Choices Dialog", 353, 263, 303, 219)
GUISetIcon("C:\Program Files\MagicISO\cdburner.ico")
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm2Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "AForm2Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "AForm2Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "AForm2Restore")
$ListBox1 = GUICtrlCreateList("", 8, 8, 137, 201)
GUICtrlSetOnEvent(-1, "ListBox1Click")
$Button1 = GUICtrlCreateButton(">", 156, 15, 30, 25, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton(">>", 156, 48, 31, 25, 0)
GUICtrlSetOnEvent(-1, "Button2Click")
$Button3 = GUICtrlCreateButton("<", 157, 81, 31, 25, 0)
GUICtrlSetOnEvent(-1, "Button3Click")
GUICtrlSetState(-1, $GUI_DISABLE)
$Button4 = GUICtrlCreateButton("<<", 157, 114, 32, 25, 0)
GUICtrlSetOnEvent(-1, "Button4Click")
$ListBox2 = GUICtrlCreateList("", 200, 8, 137, 201)
;~ GUICtrlSetData(-1, $x & "|"  &  $x + 100 & "|Item2|Item3|Item4|Item5")   
GUICtrlSetOnEvent(-1, "ListBox2Click")
$Button5 = GUICtrlCreateButton("&OK", 104, 225, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button5Click")
$Button6 = GUICtrlCreateButton("&Cancel", 184, 225, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button6Click")
$Button7 = GUICtrlCreateButton("&Help", 264, 225, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button7Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; Shows the filenames of all files in the current directory.

$search = FileFindFirstFile("c:\a\*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $files &= $file & '|'
WEnd
FileClose($search)
$files = StringTrimRight($files,1)

; set all file names at once
GUICtrlSetData($ListBox1, $files)                                  

While 1
    Sleep(100)
WEnd
    
    
        
Func AForm2Close()
Exit
EndFunc

        
Func AForm2Maximize()

EndFunc

        
Func AForm2Minimize()

EndFunc

        
Func AForm2Restore()

EndFunc

        
Func Button1Click()
;~ MsgBox(4096, "1", "1")

EndFunc

        
Func Button2Click()
MsgBox(4096, "2", "2")
EndFunc

        
Func Button3Click()
MsgBox(4096, "3", "3")
EndFunc

        
Func Button4Click()
MsgBox(4096, "4", "4")
EndFunc

        
Func Button5Click()
MsgBox(4096, "5", "5")
EndFunc

        
Func Button6Click()
;~ MsgBox(4096, "6", "6")
Exit
EndFunc

        
Func Button7Click()
MsgBox(4096, "7", "7")
EndFunc

        
Func ListBox1Click()
MsgBox(4096, "list1", "click")
EndFunc

        
Func ListBox2Click()
MsgBox(4096, "list2", "click")
EndFunc
Edited by Zedna

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