LordVicy Posted August 2, 2012 Share Posted August 2, 2012 Hey recently i've been finding some problems in my latest program wich i have no idea how to fix.Basically what i needed it to read coordinates from a txt file and execute mouseclicking events based on the current coordinates.What I did is, read line by line and then use StringExplode to split the X from Y and use them in my MouseClick functions, however (after finishing all the coordinates, i needed to restart the process so i added a Loop outside as you can see, but I've been having some troubles with the array wich holds the StringExplode for the coordinates, basically what i needed to do is reset the given array to receive the first line of the file again.My problem is, when it gets to EOF and try to restart the process i get the error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.the coords.txt855,321 892,322 859,350 656,401 854,318 886,317 891,353 655,401 855,321 886,321 925,348 655,398the functionFunc _start() Local $i = 0 $fileRead = FileOpen("coords.txt", 0) If $fileRead = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf Do While 1 $lineRead = FileReadLine($fileRead) ;START ITERATION $n = $n + 1 Local $array1 = _StringExplode($lineRead, ",", 0) If Mod($n, 4) = 0 Then MouseClick("Left",$array1[0],$array1[1],$NrClicks,$speed) Sleep($LeDelay) MouseClick("Left",$array1[0],$array1[1],$NrClicks,$speed) Else MouseClick("Right",$array1[0],$array1[1],$NrClicks,$speed) EndIf ;END ITERATION If @error = -1 Then ExitLoop Wend $i = $i + 1 Until $i = 15 FileClose($fileRead) EndFuncThanks in advance. Link to comment Share on other sites More sharing options...
Spiff59 Posted August 2, 2012 Share Posted August 2, 2012 (edited) When you hit EOF you execute an ExitLoop which busts you out of the While/Wend loop, but still leaves you in the Do/Until loop for 15 iterations. Of course, the second time in, it tries to read beyond EOF, resulting in no input for the StringExplode() statement. Not sure what the 15 loop thing is all about. There is a parameter for ExitLoop to break you out of multiple levels of loops, like ExitLoop(2). Edit: Actually, in my rush to get an answer in quickly, I neglected to mention you should test the @error condition immediately after the read and bust out of the loop if needed. Where it's positioned now, you try to process a line when none was read, and the distant placement of the test of the @error variable creates opportunities for other functions to overwrite @error. Edited August 2, 2012 by Spiff59 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 2, 2012 Moderators Share Posted August 2, 2012 LordVicy,Welcome to the AutoIt forum. I would do it like this - a bit simpler as you do not need so many internal counts. Please not that this is not tested: Func _start() ; Read the file into an array $aLines = _FileReadToArray("coords.txt") ; We do this 15 times For $j = 1 To 15 ; Loop through the array For $i = 1 To $aLines[0] ; Split the line on the comma Local $array1 = StringSplit($aLines[$i], ",") ; This line might need adjusting as I am not sure if the count value will be identical If Mod($i, 4) = 0 Then MouseClick("Left", $array1[0], $array1[1], $NrClicks, $speed) Sleep($LeDelay) MouseClick("Left", $array1[0], $array1[1], $NrClicks, $speed) Else MouseClick("Right", $array1[0], $array1[1], $NrClicks, $speed) EndIf Next Next EndFunc ;==>_startYou will need to add #include File.au3 to the top of your script. Please ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LordVicy Posted August 2, 2012 Author Share Posted August 2, 2012 (edited) Hi Melba23Thanks for your reply in first case.I used the code given and now I came up with the error "Incorrect number of parameters in function call"Basically what im trying to do is read my coords.txt to EOF and then start reading again with a nested Loop, repeating the same process for a X amount of times like 15. Starting reading from the first line to EOF again likeStartread 1...okread 2...okread 3...okEOF so cont + 1and keep reading until cont = 15This is my whole code:expandcollapse popupGlobal $NrClicks = 2 Global $speed = 12 Global $n = 0 Global $LeDelay = 5000 Global $LeGrade = 2 Global $WeapN = 0 Global $currentGrade = 0 Global $Begin = 0 Global $current = 0 $file = FileOpen("coords.txt", 2) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf #include #include #include #include #include #include #include #include #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("Lucky 20's v1.0", 228, 251, 192, 124) $Label1 = GUICtrlCreateLabel("Lucky 20's v1.0", 64, 8, 111, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Delay after Start:", 8, 48, 83, 17) $Button1 = GUICtrlCreateButton("Set", 32, 192, 163, 41) $Input1 = GUICtrlCreateInput("5000", 96, 40, 121, 21) $Label3 = GUICtrlCreateLabel("1000 = 1sec", 16, 64, 63, 17) $Input2 = GUICtrlCreateInput("15", 96, 88, 121, 21) $Label4 = GUICtrlCreateLabel("Refining grade +:", 8, 96, 85, 17) $Label5 = GUICtrlCreateLabel("Moving Speed:", 16, 128, 76, 17) $Label6 = GUICtrlCreateLabel("Clicks:", 56, 160, 35, 17) $Input3 = GUICtrlCreateInput("12", 96, 120, 121, 21) $Input4 = GUICtrlCreateInput("2", 96, 152, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 HotKeySet("{HOME}","_start") HotKeySet("{END}","_Quit") HotKeySet("{F10}","_CoordsSave") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $LeDelay = GUICtrlRead($Input1) $speed = GUICtrlRead($Input3) $NrClicks = GUICtrlRead($Input4) MsgBox(0, "Success!", "Configurations saved successfully.") EndSwitch WEnd Func _CoordsSave() ; THE COORDINATES SAVING FUNCTION $current = $current + 1 $pos = MouseGetPos() FileWriteLine($file, $pos[0] & "," & $pos[1]) If Mod($current, 4) = 0 Then MsgBox(0, "Saved", "Coordinate was saved.") EndIf EndFunc Func _start() ; Read the file into an array $aLines = _FileReadToArray("coords.txt") ; We do this 15 times For $j = 1 To 15 ; Loop through the array For $i = 1 To $aLines[0] ; Split the line on the comma Local $array1 = StringSplit($aLines[$i], ",") ; This line might need adjusting as I am not sure if the count value will be identical If Mod($i, 4) = 0 Then MouseClick("Left", $array1[0], $array1[1], $NrClicks, $speed) Sleep($LeDelay) MouseClick("Left", $array1[0], $array1[1], $NrClicks, $speed) Else MouseClick("Right", $array1[0], $array1[1], $NrClicks, $speed) EndIf Next Next EndFunc Func _Quit() MsgBox(0,"Quitting.", "Quitting Forced. Exiting Program!") Exit EndFunc Edited August 2, 2012 by LordVicy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 2, 2012 Moderators Share Posted August 2, 2012 LordVicy,And "Lucky Puta 20" is what exactly? You have read the Forum Rules, I hope? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LordVicy Posted August 2, 2012 Author Share Posted August 2, 2012 Well, actually I'm making this for a friend who needs to automate clicking events for transitions between his presentations, however he needs to open more than 1 file in diferent locations, thats why i used this method. About the ridiculous name of the program, was his idea. Just ignore it. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 3, 2012 Moderators Share Posted August 3, 2012 LordVicy,Sounds entirely reasonable. I screwed up the syntax for _FileReadToArray - I forgot it needs a predeclared array. Try this version: ; Read the file into an array Local $aLines _FileReadToArray("coords.txt", $aLines )I tested the rest of the sscript and it works for me now the array is properly created. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LordVicy Posted August 4, 2012 Author Share Posted August 4, 2012 Hmm cool, it worked for me Melba, thanks.Now I've got into another dead end. As you noticed there, i work with HotKeySet functions to start my desired function, thing is this: I want to make another form and there i want to give the capability to change the Hotkeys, but in a different way.You know those buttons where you click on them and they wait to receive a key to register...something like#include #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 251, 185, 192, 124) $Button1 = GUICtrlCreateButton("Key One", 24, 24, 75, 25) $Label1 = GUICtrlCreateLabel("Label1", 136, 32, 36, 17) $Label2 = GUICtrlCreateLabel("Label2", 136, 64, 36, 17) $Label3 = GUICtrlCreateLabel("Label3", 136, 96, 36, 17) $Button2 = GUICtrlCreateButton("Key Two", 24, 56, 75, 25) $Button3 = GUICtrlCreateButton("Key Three", 24, 88, 75, 25) $Button4 = GUICtrlCreateButton("Apply", 88, 136, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndBasically what I want is: When you click Key One it changes the label text to "Press the New Key" ( change the label text i know how to do ) and the program keep listening for a key to be pressed, and when the user does, the label text changes to the chosen key for example LCONTROL and when the user press Apply then the key is really applied to the program.Melba tbh i wanted to do this using a .ini parse but i have no clue what to do with the HotKeySet and the "Listen for a Key" thing.Could you help me with this?I really rather do this with .ini so it keep the key configs even after closing the program.Thanks for your support! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2012 Moderators Share Posted August 4, 2012 LordVicy, the "Listen for a Key" thingThere is problem with that part of your new request - read this to understand why. If you wanted to limit the number of possible keys to only a few then you could use _IsPressed in a loop to look for them, but please do not post any code which uses that function to watch the entire keyboard. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LordVicy Posted August 4, 2012 Author Share Posted August 4, 2012 (edited) Oh, I understand. Then lets try another way around this, what About, I show a combobox will the possible keys like F1 to F10, and when the user choses a key and click on Apply it sets the Key to the .ini, and then retrives it back on HotKeySet. This sounds legit. Is it possible? Edited August 4, 2012 by LordVicy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2012 Moderators Share Posted August 4, 2012 LordVicy, More than happy with that as a plan. Are you going to give it go yourself first? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LordVicy Posted August 4, 2012 Author Share Posted August 4, 2012 (edited) Well this is what I got so far, but theres a problem with my _Settings function, I cant open it somehow, it says Im using a not declared variable, but all the used ones are declared inside of the functions O.o Am I missing something? expandcollapse popup#include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Main", 242, 237, 192, 124) $Button1 = GUICtrlCreateButton("Settings", 80, 168, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 HotKeySet("{F5}","_MyFunc") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUISetState(@SW_DISABLE,$Form1) _Settings() GUISetState(@SW_ENABLE,$Form1) WinActivate($Form1) EndSwitch WEnd Func _Settings() Local $Form2, $Combo1, $Button2 Local $Out = False $Setgs = GUICreate("Settings", 242, 237, 456, 125) $Combo1 = GUICtrlCreateCombo("Select One Key", 48, 40, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "F1|F2|F3|F4|F5") $Button2 = GUICtrlCreateButton("Apply", 80, 80, 75, 25) GUISetState(@SW_SHOW) While Not $Out $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $Out = True EndSwitch WEnd GUIDelete($Setgs) EndFunc Func _MyFunc() MsgBox(0,"Some Text", "This is the testing box.") EndFunc PS: Im using another example form due organizational purposes. Edited August 4, 2012 by LordVicy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2012 Moderators Share Posted August 4, 2012 LordVicy,This is how I would go about it: expandcollapse popup#include <GUIConstantsEx.au3> ; this is the initial HotKey Global $sHotKey = "F5" ; Which we set HotKeySet("{" & $sHotKey & "}", "_MyFunc") $Form1 = GUICreate("Main", 242, 237, 192, 124) $Button1 = GUICtrlCreateButton("Settings", 80, 168, 75, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 GUISetState(@SW_DISABLE, $Form1) ; No need to disable if we use the advance GUIGetMsg but you can if you wish ; Get the new choice returned from the settings GUI $sChosen = _Settings() ConsoleWrite($sChosen & @CRLF) GUISetState(@SW_ENABLE, $Form1) WinActivate($Form1) ; If the chosen key is not the current selection If $sChosen <> $sHotKey Then ; Unset the current key HotKeySet("{" & $sHotKey & "}") ; Change the current value $sHotKey = $sChosen ; Set the new HotKey HotKeySet("{" & $sHotKey & "}", "_MyFunc") EndIf EndSwitch WEnd Func _Settings() Local $Form2, $Combo1, $Button2, $sChoice = "" Local $Out = False $Setgs = GUICreate("Settings", 242, 237, 456, 125) GUICtrlCreateLabel("Select One Key", 48, 15, 145, 25) $Combo1 = GUICtrlCreateCombo("", 48, 40, 145, 25) GUICtrlSetData(-1, "F1|F2|F3|F4|F5") $Button2 = GUICtrlCreateButton("Apply", 80, 80, 75, 25) GUISetState(@SW_SHOW) While 1 ; use teh advanced GUIGetMsg to distinguish between GUIs $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $Setgs Switch $aMsg[0] Case $Button2 $sChoice = GUICtrlRead($Combo1) ContinueCase Case $GUI_EVENT_CLOSE ExitLoop EndSwitch EndSwitch WEnd GUIDelete($Setgs) Return $sChoice EndFunc ;==>_Settings Func _MyFunc() MsgBox(0, "Some Text", "This is the testing box.") EndFunc ;==>_MyFuncSee if you can follow it - you might like to read the Managing Multiple GUIs tutorial in the Wiki as well. When you are happy about this part we can start thinking about the ini file section. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LordVicy Posted August 4, 2012 Author Share Posted August 4, 2012 What if I want more than one return on that function, for example a checkbox returning a value 0 or 1, how should i return the hotkey and the checkbox value to different variables? Sorry for those simple questions but talking about VB programming is all a little bit new for me since i work more with C# Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2012 Moderators Share Posted August 4, 2012 LordVicy,talking about VB programming is all a little bit new for meMe too! This is Autoit not VB. As to additional return values from the function - either return an array with the different values in separate elements or declare Global variables which can be changed from anaywhere in the script. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LordVicy Posted August 6, 2012 Author Share Posted August 6, 2012 (edited) Hmm, I undestand now. What if for instance, I want to return multiple values to the first form, like so: #include #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 226, 232, 393, 212) $Combo1 = GUICtrlCreateCombo("Choose an Option", 48, 24, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $Combo2 = GUICtrlCreateCombo("Choose an Option", 48, 56, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $Combo3 = GUICtrlCreateCombo("Choose an Option", 48, 88, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $Checkbox1 = GUICtrlCreateCheckbox("Enable/Disable", 24, 128, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Enable/Disable", 24, 152, 97, 17) $Button1 = GUICtrlCreateButton("Apply", 72, 192, 83, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd How could I sort them out in the first form on distinct variables? Thanks once again! Edited August 6, 2012 by LordVicy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 6, 2012 Moderators Share Posted August 6, 2012 LordVicy, Perhaps this will give you the idea: expandcollapse popup#include <GUIConstantsEx.au3> $Form1 = GUICreate("Main", 242, 237, 192, 124) $Button1 = GUICtrlCreateButton("Settings", 80, 168, 75, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 GUISetState(@SW_DISABLE, $Form1) ; No need to disable if we use the advance GUIGetMsg but you can if you wish ; Get the new choices returned from the settings GUI $aChosen = _Settings() ; If an array was returned then we have valid choices If IsArray($aChosen) Then MsgBox(0, "Choices", $aChosen[0] & @CRLF & $aChosen[1] & @CRLF & $aChosen[2] & @CRLF & $aChosen[3] & @CRLF & $aChosen[4]) Else MsgBox(0, "Ooops", "Nothing chosen") EndIf GUISetState(@SW_ENABLE, $Form1) WinActivate($Form1) EndSwitch WEnd Func _Settings() Local $Form2, $Combo1, $Button2, $aChoice ; Declare the returned variable as a simple variable Local $Out = False $Setgs = GUICreate("Settings", 242, 237, 456, 125) $Combo1 = GUICtrlCreateCombo("Choose an Option", 48, 24, 145, 25) $Combo2 = GUICtrlCreateCombo("Choose an Option", 48, 56, 145, 25) $Combo3 = GUICtrlCreateCombo("Choose an Option", 48, 88, 145, 25) $Checkbox1 = GUICtrlCreateCheckbox("Enable/Disable", 24, 128, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Enable/Disable", 24, 152, 97, 17) $Button2= GUICtrlCreateButton("Apply", 72, 192, 83, 25) GUISetState(@SW_SHOW) While 1 ; Use the advanced GUIGetMsg to distinguish between GUIs $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $Setgs Switch $aMsg[0] Case $Button2 ; Make the variable an array Local $aChoice[5] ; And fill it $aChoice[0] = GUICtrlRead($Combo1) $aChoice[1] = GUICtrlRead($Combo1) $aChoice[2] = GUICtrlRead($Combo1) $aChoice[3] = GUICtrlRead($Checkbox1) $aChoice[4] = GUICtrlRead($Checkbox2) ContinueCase Case $GUI_EVENT_CLOSE ExitLoop EndSwitch EndSwitch WEnd GUIDelete($Setgs) Return $aChoice EndFunc ;==>_Settings M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now