IniRead array and pass to download function with progress bar - autoit

so i'm trying to work out how to get a downloader function working in a tool i'm working on, basically theres a tab with 3 download buttons, based on what button is clicked in the tab i'd like it to pass to one function, the downloder that will read the links from the ini file, with a progress bar in the tab I'll post the code bellow so you'll get an understanding
So it will download the files absolutely fine the only problem is when I start the app the download for the first file in the array starts automatically even though I didn't click the label in the tab, nor does the rest of the GUI function, I can't switch tabs as it just "freezes" then the download starts all over again if i comment out the case dwitch for $modlabel1 like so ";Case $modlabel1" it allows me to switch tabs etc just fine and I can switch tabs and click on the other 2 buttons and they will download as intended but the GUI stays on the mod tab till its finished, another small issue I have is i need the files to download with the same as the source file name, is that possible to do with InetGet?
Downloads Tab
Func _mods_gui()
$modsgui = GUICreate("Mods", 1270, 610, 5, 105, BitOR($ws_popup, $ws_border), $ws_ex_mdichild, $maingui)
GUISetBkColor(3487029)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $setgui, "int", 250, "long", 524288)
$progressbar1 = GUICtrlCreateProgress(10, 200, 1250, 50, $PBS_MARQUEE)
$modlabel1 = GUICtrlCreateLabel("Download" & #CRLF & "DayZ Epoch 1.0.5.1", 50, 50, 350, 100, $ss_center)
GUICtrlSetFont(-1, 30, 700, 0, "Segeo UI", 4)
GUICtrlSetBkColor(-1, 3825)
GUICtrlSetColor(-1, 16777215)
_guictrl_setonhover(-1, "_Hover", "_Hover_Leave")
$modlabel2 = GUICtrlCreateLabel("Download" & #CRLF & "DayZ Overwatch 0.2.5", 450, 50, 350, 100, $ss_center)
GUICtrlSetFont(-1, 30, 700, 0, "Segeo UI", 4)
GUICtrlSetBkColor(-1, 3825)
GUICtrlSetColor(-1, 16777215)
_guictrl_setonhover(-1, "_Hover", "_Hover_Leave")
$modlabel3 = GUICtrlCreateLabel("Download" & #CRLF & "Namalsk 0.75", 850, 50, 350, 100, $ss_center)
GUICtrlSetFont(-1, 30, 700, 0, "Segeo UI", 4)
GUICtrlSetBkColor(-1, 3825)
GUICtrlSetColor(-1, 16777215)
_guictrl_setonhover(-1, "_Hover", "_Hover_Leave")
$modsgr2 = GUICtrlCreateGraphic(0, 25, 1270, 250)
GUICtrlSetState(-1, $gui_disable)
GUICtrlSetGraphic(-1, $gui_gr_color, 0, 2368548)
GUICtrlSetGraphic(-1, $gui_gr_rect, 0, 0, 1270, 250)
GUISetState(#SW_SHOW, $modsgui)
EndFunc
While Switch Case
Case $modsgui
Switch $nmsg[0]
Case $modlabel1
_downloadmod(0)
Case $modlabel2
_downloadmod(1)
Case $modlabel3
_downloadmod(2)
EndSwitch
Download Array
Func _downloadmod($mod)
$modarrayread[3] = [IniRead(#ScriptDir & "\LauncherFiles\data\XGLConfig.cfg", "mod_links", "mod_epoch", Default), IniRead(#ScriptDir & "\LauncherFiles\data\XGLConfig.cfg", "mod_links", "mod_overwatch", Default), IniRead(#ScriptDir & "\LauncherFiles\data\XGLConfig.cfg", "mod_links", "mod_namalsk", Default)]
$dwnmod = InetGet($modarrayread[$mod], #ScriptDir & "\Mods\$name.zip", 1, 1)
Do
Sleep(50)
$prc = Round(InetGetInfo($dwnmod, 0) / (InetGetInfo($dwnmod, 1)) * 100)
GUICtrlSetData($progressbar1, $prc)
Until InetGetInfo($dwnmod, $INET_DOWNLOADCOMPLETE)
EndFunc
INI
[mod_links]
mod_epoch=http://files.xexgaming.com/mods/#DayZ_Epoch1051.zip
mod_overwatch=http://files.xexgaming.com/mods/#DayZOverwatch.zip
mod_namalsk=http://files.xexgaming.com/mods/#Namalsk.zip
Credits to Trojan for the help with the array, worked out how to get the parameters using his example

I worked with the example script in the help for GUICtrlCreateProgress as base and wrote a script which hopefully does what u wanted it to do.
If you have any questions feel free to ask :)
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <MsgBoxConstants.au3>
#include <InetConstants.au3>
Example()
Func Example()
Local $progressbar1, $button1, $button2, $button3
Local $downarrayread[3] = [IniRead(#ScriptDir & "\Files\data\Config.cfg", "links", "link_1", Default), IniRead(#ScriptDir & "\Files\data\Config.cfg", "links", "link_2", Default), IniRead(#ScriptDir & "\Files\data\Config.cfg", "links", "link_3", Default)]
GUICreate("Downloads", 220, 100, 100, 200)
$progressbar1 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
$button1 = GUICtrlCreateButton("Start 1", 5, 70, 70, 20)
$button2 = GUICtrlCreateButton("Start 2", 75, 70, 70, 20)
$button3 = GUICtrlCreateButton("Start 3", 145, 70, 70, 20)
GUISetState(#SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $button1
$hDownload = InetGet($downarrayread[1], #ScriptDir & "/Downloads/File1", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
Do
Sleep(250)
GUICtrlSetData($progressbar1,((InetGetInfo($hDownload,$INET_DOWNLOADSIZE )/InetGetInfo($hDownload, $INET_DOWNLOADREAD))*100)/3)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
Case $button2
$hDownload = InetGet($downarrayread[2], #ScriptDir & "/Downloads/File2", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
Do
Sleep(250)
GUICtrlSetData($progressbar1,((InetGetInfo($hDownload,$INET_DOWNLOADSIZE )/InetGetInfo($hDownload, $INET_DOWNLOADREAD))*100)/3+33.33)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
Case $button3
$hDownload = InetGet($downarrayread[3], #ScriptDir & "/Downloads/File3", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
Do
Sleep(250)
GUICtrlSetData($progressbar1,((InetGetInfo($hDownload,$INET_DOWNLOADSIZE )/InetGetInfo($hDownload, $INET_DOWNLOADREAD))*100)/3+66.66)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
EndSwitch
WEnd
EndFunc ;==>Example

Related

Ask about Radio in Autoit

How to put $Day into $Radio1 , $Week into $Radio2, $Month into $Radio3
And - $Radio1,$Radio2,$Radio3 into $RadioCheck ?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
GUICreate("Example", 143, 103, 192, 124)
GUISetFont(12, 400, 0, "Open Sans")
$Radio1 = GUICtrlCreateRadio($Day, 24, 16, 113, 17)
$Radio2 = GUICtrlCreateRadio($Week, 24, 40, 113, 17)
$Radio3 = GUICtrlCreateRadio($Month, 24, 64, 113, 17)
GUISetState(#SW_SHOW)
#EndRegion ### END Koda GUI section ###
Local $RadioCheck = $Radio1,$Radio2,$Radio3 ; The problem is here
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func Example1()
Local $Day, $Week, $Month
$LimitTime = _DateDiff('s', "1970/01/01 00:00:00", _NowCalc()) ;Get the current time (convert to seconds)
$Day = 86400 ; total seconds a Day
$Week = 604800 ; total seconds a Week
$Month = 2592000 ; total seconds a Month
_Example2($Example3, $Example4, $Example5-$RadioCheck)
EndFunc
Your $Day, $Week and $Month are local variables (inaccessible from global scope). More importantly: you are trying to set the text of your radio controls before you have declared or initialized these variables.
So how do you solve that? You have (at least) three options:
Option 1
Change your local variables from your function Example1() to global scope.
So change: Local $Day, $Week, $Month to Global $Day, $Week, $Month,
put it on top of your script and then
call the function Example1() before you create the GUI!
This is probably the easiest, yet dirtiest way, since any function could at any time change the data of your variables. In general try not to use global variables if possible.
Option 2
Change your radio controls to global variables and then change their text inside your Example1() function. Like this:
$Radio1 = GUICtrlCreateRadio($Day, 24, 16, 113, 17)
$Radio2 = ...
to
Global $Radio1 = GUICtrlCreateRadio("", 24, 16, 113, 17)
Global $Radio2 = GUICtrlCreateRadio("", 24, 40, 113, 17)
Global $Radio3 = GUICtrlCreateRadio("", 24, 64, 113, 17)
Note that you have to remove your undeclared variables! Then change the text of the controls in your Example1() function using:
GUICtrlSetData($Radio1, $Day)
GUICtrlSetData($Radio2, $Month)
GUICtrlSetData($Radio3, $Week)
Option 3a
This is the safest way. Let Example1() return the variables, either ByRef, or create and return an array. As array (untested):
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
; We are now going to receive the return values (in this case an array) from our function:
Local $aDate = Example1() ; it is essential to call this function before we want to make use of $Date[0] to $Date[2].
; What happens is that the function (code block further down) named Example1() is being executed.
; This function will then RETURN us the array.
; Since Example1() returns an array, $aData will automatically become an array filled with the data of Example1()
#Region ### START Koda GUI section ### Form=
GUICreate("Example", 143, 103, 192, 124)
GUISetFont(12, 400, 0, "Open Sans")
$Radio1 = GUICtrlCreateRadio($aDate[0], 24, 16, 113, 17) ; we are now setting the data for the three controls returned by Example1()
$Radio2 = GUICtrlCreateRadio($aDate[1], 24, 40, 113, 17)
$Radio3 = GUICtrlCreateRadio($aDate[2], 24, 64, 113, 17)
GUISetState(#SW_SHOW)
#EndRegion ### END Koda GUI section ###
; Local $RadioCheck = $Radio1,$Radio2,$Radio3 ; The problem is here ---- You do not need that and PLEASE READ THE ABOUT LOCAL AND GLOBAL VARIABLES!
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func Example1()
Local $aReturn[3] ;create a (Local) Array
$LimitTime =_DateDiff('s', "1970/01/01 00:00:00", _NowCalc()) ; Get the current time (convert to seconds)
$aReturn[0] = 86400
$aReturn[1] = 604800
$aReturn[2] = 2592000
Return $aReturn ; return the Array
EndFunc
Option 3b
You could also return the values ByRef :
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $Day, $Week, $Month ; we have to declare the variables for our Example1() function BEFORE we use them
Example1($Day, $Week, $Month) ; we here call our function with the previously declared variables as parameter.
; The function will then fill in the data into our variables before we use them to set the radio text
GUICreate("Example", 143, 103, 192, 124)
GUISetFont(12, 400, 0, "Open Sans")
$Radio1 = GUICtrlCreateRadio($Day, 24, 16, 113, 17) ; set the data for the three controls
$Radio2 = GUICtrlCreateRadio($Week, 24, 40, 113, 17)
$Radio3 = GUICtrlCreateRadio($Month, 24, 64, 113, 17)
GUISetState(#SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func Example1(ByRef $Day, ByRef $Week, ByRef $Month) ; NOTE: ByRef means that the given variables will be OVERWRITTEN, that also means that the variables MUST EXIST before the function is called
$LimitTime = _DateDiff('s', "1970/01/01 00:00:00", _NowCalc()) ; Get the current time (convert to seconds)
$Day = 86400
$Week = 604800
$Month = 2592000
EndFunc
Sources
Local/Global keyword.
Using Global, Local, Static and ByRef.
Func keyword.

Radio Toggles not functioning correctly & unable to detect whole numbers and exit a while loop

I've tried to make a simple autoit script however I am having problems with the radio toggles not working correctly and unable to detect whole numbers.
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Local $InputListItems[3] = ["item 1", "item 2", "item 3"]
Local $test[1] = ["dog"]
Local $test1[1] = ["cat"]
$Form1 = GUICreate("Form1", 651, 250, 192, 124)
$InputMain = GUICtrlCreateGroup("Input Main", 8, 0, 137, 137)
$InputListMain = GUICtrlCreateList("", 16, 16, 121, 118)
GUICtrlSetData($InputListMain, _ArrayToString($InputListItems))
$InputAlt = GUICtrlCreateGroup("Input Alt", 151, 0, 137, 137)
$InputListAlt = GUICtrlCreateList("", 159, 16, 121, 118)
GUICtrlSetData($InputListAlt, _ArrayToString($InputListItems))
$Rates = GUICtrlCreateGroup("Rates", 6, 139, 281, 49)
$MainRateInput = GUICtrlCreateInput("1", 14, 155, 121, 21)
$AltRateInput = GUICtrlCreateInput("3", 158, 155, 121, 21)
$LeftOutputs = GUICtrlCreateGroup("Left Option", 296, 0, 169, 185)
$LeftOutputList = GUICtrlCreateList("", 304, 16, 153, 162)
GUICtrlSetData($LeftOutputList, _ArrayToString($test))
$RightOutputs = GUICtrlCreateGroup("Right Option", 472, 0, 169, 185)
$RightOutputList = GUICtrlCreateList("", 480, 16, 153, 162)
GUICtrlSetData($RightOutputList, _ArrayToString($test1))
$Output = GUICtrlCreateGroup("Main Output", 8, 192, 281, 49)
$OututInput = GUICtrlCreateInput("", 16, 208, 265, 21)
$Picker = GUICtrlCreateGroup("Option", 294, 192, 345, 49)
$Radio1 = GUICtrlCreateRadio("Left", 312, 216, 113, 17)
$Radio2 = GUICtrlCreateRadio("Right", 488, 216, 113, 17)
GUISetState(#SW_SHOW)
;GUICtrlSetState($Radio1, $GUI_CHECKED)
Func GenerateRates($MainRate, $AltRate)
Local $Start = $MainRate
Local $End = $AltRate
Local $PossibleValues[0] = []
Local $FloatTrigger = False
Local $PossibleValue = $Start & "/" & $End
_ArrayAdd($PossibleValues, $PossibleValue)
For $i = 1 To 29
$Start = $Start
$End = $End + 0.1
;If StringInStr(".", String($End)) Then
; ConsoleWrite($Start & #CRLF)
; $End = $End * 10
; $Start = $Start * 10
;EndIf
If IsInt(Number($End)) Then ; IsInt($End) <> $End ;Mod($End, 1) = 0 ;IsInt(Number($End))
$FloatTrigger = True
$StartEx = $Start
$EndEx = $End
Else
$FloatTrigger = False
EndIf
While $FloatTrigger = True
$StartEx = $StartEx + $MainRate
$EndEx = $EndEx + $AltRate + 0.1
ConsoleWrite($StartEx & #CRLF)
ConsoleWrite($EndEx & #CRLF)
Sleep(500)
If IsInt(Number($EndEx)) Then ; IsInt($EndEx) <> $End ;Mod($EndEx, 1) = 0 ;IsInt(Number($EndEx))
$FloatTrigger = True
Else
$FloatTrigger = False
EndIf
WEnd
If $FloatTrigger = True Then
$PossibleValue = $StartEx & "/" & $EndEx
Else
$PossibleValue = $Start & "/" & $End
EndIf
_ArrayAdd($PossibleValues, $PossibleValue)
Next
_ArrayDisplay($PossibleValues, "")
EndFunc ;==>GenerateRates
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $nMsg = $Radio1 = $GUI_CHECKED
If GUICtrlRead($OututInput) <> GUICtrlRead($LeftOutputList) Then
GUICtrlSetData($OututInput, GUICtrlRead($LeftOutputList))
EndIf
Case $nMsg = $Radio2 = $GUI_CHECKED
If GUICtrlRead($OututInput) <> GUICtrlRead($RightOutputList) Then
GUICtrlSetData($OututInput, GUICtrlRead($RightOutputList))
EndIf
; Working Start
Case $nMsg = $InputListMain
GUICtrlSetData($Radio1, "Left: " & GUICtrlRead($InputListMain))
Case $nMsg = $InputListAlt
GUICtrlSetData($Radio2, "Right: " & GUICtrlRead($InputListAlt))
; Working End
Case $nMsg = $MainRateInput
If GUICtrlRead($Radio1) = 1 Then
GenerateRates(GUICtrlRead($MainRateInput), GUICtrlRead($AltRateInput))
Else
GenerateRates(GUICtrlRead($AltRateInput), GUICtrlRead($MainRateInput))
EndIf
Case $nMsg = $AltRateInput
If GUICtrlRead($Radio1) = 1 Then
GenerateRates(GUICtrlRead($MainRateInput), GUICtrlRead($AltRateInput))
Else
GenerateRates(GUICtrlRead($AltRateInput), GUICtrlRead($MainRateInput))
EndIf
EndSwitch
WEnd
Problem 1:
Normally checking to see if a number is a whole number is fairly easy, you can usually use: IsInt(Number($value)) or Mod($value, 1) = 0 however in my script it's not working at all.
Problem 2:
The radio buttons aren't working, if I chose the left option and right options of "cat" and "dog" and then chose the radio button's associated with each side, the "dog" one (left) puts "dog" into the output box but the "cat" one (right) doesn't put "cat" into the output box...
I've tried tons of different ways of writing the case, including: Case $nMsg = GUICtrlRead($Radio1) = $GUI_CHECKED and Case $nMsg = $Radio1 And BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED
Re: Interger testing...
I've tried everything I know about to test the value including: ConsoleWrite(_WinAPI_FloatToInt($End) & #CRLF) to see if that helps, it doesn't. They all appear to be floats even though some numbers appear whole numbers (5) for example.
Currently, your while statement that deals with the GUI events has issues, because a statement like
Case $nMsg = $Radio1 = $GUI_CHECKED
seems to be interpreted as
Case $nMsg
Hence, just the first such statement will be triggered (since we must have that $nMsg==$nMsg). The only reason your program exited successfully is that the code for that was the first block in your switch statement. The fix is very easy, the GUI code for $Radio1 is just $Radio1
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Radio1
If GUICtrlRead($OututInput) <> GUICtrlRead($LeftOutputList) Then
GUICtrlSetData($OututInput, GUICtrlRead($LeftOutputList))
EndIf
Case $Radio2
If GUICtrlRead($OututInput) <> GUICtrlRead($RightOutputList) Then
GUICtrlSetData($OututInput, GUICtrlRead($RightOutputList))
EndIf
; Working Start
Case $InputListMain
GUICtrlSetData($Radio1, "Left: " & GUICtrlRead($InputListMain))
Case $InputListAlt
GUICtrlSetData($Radio2, "Right: " & GUICtrlRead($InputListAlt))
; Working End
Case $MainRateInput
If GUICtrlRead($Radio1) = 1 Then
GenerateRates(GUICtrlRead($MainRateInput), GUICtrlRead($AltRateInput))
Else
GenerateRates(GUICtrlRead($AltRateInput), GUICtrlRead($MainRateInput))
EndIf
Case $AltRateInput
If GUICtrlRead($Radio1) = 1 Then
GenerateRates(GUICtrlRead($MainRateInput), GUICtrlRead($AltRateInput))
Else
GenerateRates(GUICtrlRead($AltRateInput), GUICtrlRead($MainRateInput))
EndIf
EndSwitch
WEnd
Your issues with integer testing probably come down to floating point rounding. However, as your code is currently written, if $FloatTrigger is ever set to true, you'll end up in an infinite while loop

Autoit Add data instead of replace data

I start a server with:
$BungeeServer = Run("java -Xmx512M -jar " & '"' & $file0 & "\BungeeCord.jar" & '"', $file0, $Hide, $STDERR_MERGED)
Then I get the data from the server with(It's in a while loop):
Assign("sOutput", StdoutRead($BungeeServer, False, False) & #CRLF)
GUICtrlSetData($Edit1, $sOutput)
The problem is that It only returns the latest string of information. I need it to add instead of replace the values. Anybody know an easy way to do that?
Edit: When a server starts, you normally get a cmd window. I want to be able to have it in a Gui instead. Also I only want it to appear when I click a button, still it should start getting data when the server starts. The lines of text also went outside the box. I tried:
Do
$msg1 = GUIGetMsg()
$line1 = StdoutRead($BungeeServer, True)
$totalOutput1 &= $line1 & #CRLF
GUICtrlSetData($Edit1, $totalOutput1)
$line2 = StdoutRead($1, True)
$totalOutput2 &= $line2 & #CRLF
GUICtrlSetData($Edit2, $totalOutput2)
$line3 = StdoutRead($2, True)
$totalOutput3 &= $line3 & #CRLF
Until $msg = $GUI_EVENT_CLOSE
The edit boxes were made with:
$Form2 = GUICreate("Servers", #DesktopWidth - 15, #DesktopHeight - _GetTaskBarHeight() - 35, -1, -1)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 634, 334, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
Font()
$Edit2 = GUICtrlCreateEdit("", 635, 0, 634, 334, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
Font()
$Edit3 = GUICtrlCreateEdit("", 634 + 634, 0, 634, 334, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
Font()
GUISetState(#SW_SHOW)
Edit: I found a better way to do it where I made a child window and didn't need all the other stuff:
$GUI = GUICreate("Consoles", 1020, 600, 1282, 300, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
If GUICtrlRead($Bungee) = 1 Then
$BungeeServer = Run("java -Xmx512M -jar " & '"' & $file0 & "\BungeeCord.jar" & '"', $file0, $Hide)
If Not ProcessWait($BungeeServer) = 0 Then
WinSetTitle("C:\Windows\system32\java.exe", "", "Bungee")
WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Bungee")
Global $hwnd0 = WinGetHandle("Bungee")
EndIf
EndIf
_WinAPI_SetWindowLong($hwnd0, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd0, $GUI)
WinMove($hwnd0, "", 0, 0, 340, 300)
Still need to find a way to use ControlSend to the child windows :/
Use StdoutRead($BungeeServer, True)
StdoutRead ( process_id [, peek = false [, binary = false]] )
peek [optional] If true the function does not remove the read characters from the stream.
OR
Consider storing the previous data before getting the new one. Instead of assigning the new data to the variable, you can just add it.
eg.
$totalOutput &= $newOutput & #LF
About StdoutRead: In order to get all data, it must be called in a loop.
From the help file:
; Demonstrates StdoutRead()
#include <Constants.au3>
Local $foo = Run(#ComSpec & " /c dir foo.bar", #SystemDir, #SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
While 1
$line = StdoutRead($foo)
If #error Then ExitLoop
MsgBox(0, "STDOUT read:", $line)
WEnd
While 1
$line = StderrRead($foo)
If #error Then ExitLoop
MsgBox(0, "STDERR read:", $line)
WEnd
MsgBox(0, "Debug", "Exiting...")
Considering all above, StdoutRead should be used like this:
Local $sOutput
While 1
$line = StdoutRead($foo, True)
If #error Then ExitLoop
$sOutput = $line
WEnd
OR
Local $sOutput
While 1
$line = StdoutRead($foo)
If #error Then ExitLoop
$sOutput &= $line & #LF
WEnd

Dropdown list item selection in AutoIt

How do I get the following script to run my test.pdf file?
$Form1 = GUICreate("Form1", 413, 305, 302, 218)
$Combo1 = GUICtrlCreateCombo("Make Selection", 184, 48, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo1 = GUICtrlSetData(-1, "test1|test2|test3")
GUISetState(#SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
$nMsg2 = GUIGetMsg()
Switch $nMsg2
Case "test1"
ShellExecute("C:\test.pdf")
EndSwitch
EndSwitch
WEnd
I would try it like this:
$Form1 = GUICreate("Form1", 413, 305, 302, 218)
$Combo1 = GUICtrlCreateCombo("Make Selection", 184, 48, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "test1|test2|test3")
GUISetState(#SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
If GUICtrlRead($Combo1) = "Test2" Then
ShellExecute("C:\test.pdf")
EndIf
EndSwitch
WEnd
This is because GuiCtrlRead gives you back the Value which is selected. And if this Value is "Test2" it makes your shell execute.
The second thing is that you shouldn't do this:
$Combo1 = GUICtrlSetData(-1, "test1|test2|test3")
Because with this you're overriding the handle which you get from CuiGrtlCreateCombo and you need this handle that the switch case statement works properly.

Create list of files from a source folder

Please help me on how to create a list, possibly from an arrayList. An input box is the source of the folder and all its png files will be in the list of array, and display it in the GU. Thanks
#include <GuiConstantsEx.au3>
#include <File.au3>
#include <Array.au3>
;GUI
GUICreate("Automation", 300, 500)
$sourceFolder = GUICtrlCreateInput ("Source Folder" , 10, 10,280, 20 )
$add = GUICtrlCreateButton("Add", 10, 35, 75, 20)
$mylist = GUICtrlCreateList("", 10, 60, 280, 300)
$sourceFolder = ControlGetText("Automation", "", "Edit1")
Local $FileList = _FileListToArray($sourceFolder, "*.png")
$msg = 0
While $msg
$msg = GUIGetMsg()
Select
Case $msg = $add
GUICtrlSetData($mylist,$FileList)
Exit
EndSelect
WEnd
If $sourceFolder > 1 Then
If #error = 1 Then
MsgBox(0, "", "No Folders Found.")
Exit
EndIf
If #error = 4 Then
MsgBox(0, "", "No Files Found.")
Exit
EndIf
$arrayFileList = _ArrayDisplay($FileList)
EndIf
; GUI MESSAGE LOOP
GUISetState(#SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
A lot of problems in your code.
2 message loops is very bad practice
The first message loop never starts, because you have While $msg, and set $msg to 0 the line before.
You are reading the source folder control before the first message loop, so it's value will always be "Source Folder" rather than the directory like you want.
Even if the first message loop did run, the GUI wouldn't be shown yet.
In terms of what you want to do: it's just a For...Next loop over the returned array.
#include <GuiConstantsEx.au3>
#include <File.au3>
#include <Array.au3>
;GUI
GUICreate("Automation", 300, 500)
$sourceFolder = GUICtrlCreateInput("Source Folder", 10, 10, 280, 20)
$add = GUICtrlCreateButton("Add", 10, 35, 75, 20)
$mylist = GUICtrlCreateList("", 10, 60, 280, 300)
GUISetState(#SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $add
$sFolder = ControlGetText("Automation", "", "Edit1")
Local $FileList = _FileListToArray($sFolder, "*.*")
If #error = 1 Then
MsgBox(0, "", "No Folders Found.")
Exit
EndIf
If #error = 4 Then
MsgBox(0, "", "No Files Found.")
Exit
EndIf
For $i = 1 To $FileList[0]
GUICtrlSetData($mylist, $FileList[$i])
Next
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd

Resources