Guest Posted September 4, 2013 Share Posted September 4, 2013 (edited) Hello, Please look at the following ultra bugged code: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $timer = TimerInit() , $a = 1 , $GuiExists = 0 While 1 If TimerDiff($timer) > 3000 Then $Form1 = GUICreate("TEST", 318, 200, 413, 233) $Label1 = GUICtrlCreateLabel("GUI "&$a, 88, 40, 140, 61) GUICtrlSetFont(-1, 35, 400, 0, "Tahoma") $Button1 = GUICtrlCreateButton("Close GUI", 96, 136, 137, 49) GUISetState(@SW_SHOW) If $GuiExists = 0 Then $GuiExists = 1 $timer = TimerInit() $a = $a+1 EndIf If $GuiExists = 1 Then $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form1) Case $Button1 GUIDelete($Form1) EndSwitch EndIf Sleep(10) WEnd If you run the script, after the first three seconds, you will see GUIs Windows.The problem in this code is that it is impossible to close the previous GUI windows.For example, if there are seven windows and I'm trying to close the "GUI 1" So GUI 1 not closed.Instead of this, the last GUI window closes. In addition, the "Close GUI" button does not work for some reason. What should I do to solve this problem? Edited September 4, 2013 by Guest Link to comment Share on other sites More sharing options...
TheSaint Posted September 4, 2013 Share Posted September 4, 2013 (edited) You are missing an ExitLoop after your GUIDelete. Without that, or an Exit command, you remain trapped in the While .... Wend. You are assigning the same variable to each GUI for starters, but you have other flaws in your logic too. You need to have a Loop for each GUI, so it requires much more complex code than you have realized. And sorry, but I'm too tired tonight to get that deep, so perhaps someone else might help if you cannot wrestle the dilemma through yourself? EDIT Just passing by on my way to bed, I noticed this topic was in the wrong part of the Forum, for which I was gonna comment, then noticed it looked simple, so thought I'd reply, then realized there was more to it after my initial reply, then after some corrections, I finally wised up to my state. The moral of the story .... don't program when you are tired. Edited September 4, 2013 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Danyfirex Posted September 4, 2013 Share Posted September 4, 2013 Good examples on wiki http://www.autoitscript.com/wiki/Managing_Multiple_GUIs saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 4, 2013 Moderators Share Posted September 4, 2013 gil900,You are continually overwriting the GUI handle when you create the GUIs. If you use GUIGetMsg with the advanced parameter, you can tell which GUI sent the "close" message: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $timer = TimerInit() , $a = 1 , $GuiExists = 0 While 1 If TimerDiff($timer) > 3000 Then $Form1 = GUICreate("TEST", 318, 200, 413, 233) $Label1 = GUICtrlCreateLabel("GUI "&$a, 88, 40, 140, 61) GUICtrlSetFont(-1, 35, 400, 0, "Tahoma") $Button1 = GUICtrlCreateButton("Close GUI", 96, 136, 137, 49) GUISetState(@SW_SHOW) If $GuiExists = 0 Then $GuiExists = 1 $timer = TimerInit() $a = $a+1 EndIf If $GuiExists = 1 Then $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($aMsg[1]) EndSwitch EndIf ;Sleep(10) Not needed as GUIGetMsg has its own internal Sleep WEndThe buttons will not work for the same reason - the variable only holds the last button created. You could use the same trick as above, but it would be better to put the button ControlIDs into an array and then check which was pressed. 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...
Guest Posted September 4, 2013 Share Posted September 4, 2013 For a minute there, I thought you were talking about running more than one GUI. You are missing an ExitLoop after your GUIDelete. Without that, or an Exit command, you remain trapped in the While .... Wend. it this test i don't want to exit froum the loop. i want to close each gui window properly. for example, i wan't that when i click on the close button in "GUI 3" while there is 10 GUIs then only the "GUI 3" windowwill close Link to comment Share on other sites More sharing options...
TheSaint Posted September 4, 2013 Share Posted September 4, 2013 And while my tired brain was writing, low and behold. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Guest Posted September 4, 2013 Share Posted September 4, 2013 gil900, You are continually overwriting the GUI handle when you create the GUIs. If you use GUIGetMsg with the advanced parameter, you can tell which GUI sent the "close" message: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $timer = TimerInit() , $a = 1 , $GuiExists = 0 While 1 If TimerDiff($timer) > 3000 Then $Form1 = GUICreate("TEST", 318, 200, 413, 233) $Label1 = GUICtrlCreateLabel("GUI "&$a, 88, 40, 140, 61) GUICtrlSetFont(-1, 35, 400, 0, "Tahoma") $Button1 = GUICtrlCreateButton("Close GUI", 96, 136, 137, 49) GUISetState(@SW_SHOW) If $GuiExists = 0 Then $GuiExists = 1 $timer = TimerInit() $a = $a+1 EndIf If $GuiExists = 1 Then $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($aMsg[1]) EndSwitch EndIf ;Sleep(10) Not needed as GUIGetMsg has its own internal Sleep WEnd The buttons will not work for the same reason - the variable only holds the last button created. You could use the same trick as above, but it would be better to put the button ControlIDs into an array and then check which was pressed. M23 Thank you very much!It works!Can you please make the button "Close GUI" to work?I'm just afraid I did not understand how to do it ..Your example will serve me a lot.Thank you Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 4, 2013 Moderators Share Posted September 4, 2013 gil900,Feeling particularly lazy today? Here you go: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $timer = TimerInit() , $a = 1 , $GuiExists = 0 Global $aButton[1] = [0] While 1 If TimerDiff($timer) > 5000 Then $Form1 = GUICreate("TEST", 318, 200, 413, 233) $Label1 = GUICtrlCreateLabel("GUI "&$a, 88, 40, 140, 61) GUICtrlSetFont(-1, 35, 400, 0, "Tahoma") ; Increase the array count $aButton[0] += 1 ; And its size ReDim $aButton[$aButton[0] + 1] ; Now create the button and store its controlID $aButton[$aButton[0]] = GUICtrlCreateButton("Close GUI", 96, 136, 137, 49) GUISetState(@SW_SHOW) If $GuiExists = 0 Then $GuiExists = 1 $timer = TimerInit() $a = $a+1 EndIf If $GuiExists = 1 Then $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($aMsg[1]) Case Else ; Search the array for a matching button ControlID For $iIndex = 1 To $aButton[0] If $aMsg[0] = $aButton[$iIndex] Then ; Found it - so delete the GUI GUIDelete($aMsg[1]) ;Remove the button from the array _ArrayDelete($aButton, $iIndex) ; And finally reduce the array count $aButton[0] -= 1 ; No point in looking further ExitLoop EndIf Next EndSwitch EndIf ;Sleep(10) Not needed as GUIGetMsg has its own internal Sleep WEndM23 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...
Guest Posted September 4, 2013 Share Posted September 4, 2013 gil900, Feeling particularly lazy today? Here you go: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $timer = TimerInit() , $a = 1 , $GuiExists = 0 Global $aButton[1] = [0] While 1 If TimerDiff($timer) > 5000 Then $Form1 = GUICreate("TEST", 318, 200, 413, 233) $Label1 = GUICtrlCreateLabel("GUI "&$a, 88, 40, 140, 61) GUICtrlSetFont(-1, 35, 400, 0, "Tahoma") ; Increase the array count $aButton[0] += 1 ; And its size ReDim $aButton[$aButton[0] + 1] ; Now create the button and store its controlID $aButton[$aButton[0]] = GUICtrlCreateButton("Close GUI", 96, 136, 137, 49) GUISetState(@SW_SHOW) If $GuiExists = 0 Then $GuiExists = 1 $timer = TimerInit() $a = $a+1 EndIf If $GuiExists = 1 Then $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($aMsg[1]) Case Else ; Search the array for a matching button ControlID For $iIndex = 1 To $aButton[0] If $aMsg[0] = $aButton[$iIndex] Then ; Found it - so delete the GUI GUIDelete($aMsg[1]) ;Remove the button from the array _ArrayDelete($aButton, $iIndex) ; And finally reduce the array count $aButton[0] -= 1 ; No point in looking further ExitLoop EndIf Next EndSwitch EndIf ;Sleep(10) Not needed as GUIGetMsg has its own internal Sleep WEnd M23 Thank you very much!Greatly helped me.In return, I contribute to the community (in Example Scripts) when I can. Link to comment Share on other sites More sharing options...
Guest Posted September 5, 2013 Share Posted September 5, 2013 (edited) Ok ..I thought your example good enough .But my software structure is more complex and your example does not match to the structure of what I'm building.I wrote a sample code that demonstrates how my program works.this Is the code: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Main() ;GUI1() Func Main() SubMain(1) While 1 SubMain() ; <= Operations that must always occur Sleep(10) WEnd EndFunc Func SubMain($SubMainStart = 0) If $SubMainStart = 1 Then Global $timer = TimerInit() ElseIf $SubMainStart = 0 Then Global $TimerDiff = Int(TimerDiff($timer)) ToolTip($TimerDiff) If $TimerDiff > 10000 Then GUI1() Global $timer = TimerInit() EndIf EndIf EndFunc Func GUI1() $Form1 = GUICreate("input test", 207, 175, 541, 193) $Radio1 = GUICtrlCreateRadio("Radio1", 32, 16, 57, 25) $Radio2 = GUICtrlCreateRadio("Radio2", 32, 45, 57, 25) $Radio3 = GUICtrlCreateRadio("Radio3", 32, 72, 57, 25) $Input1 = GUICtrlCreateInput("Input1", 88, 19, 65, 21) $Input2 = GUICtrlCreateInput("Input2", 88, 48, 65, 21) $Input3 = GUICtrlCreateInput("Input3", 88, 75, 65, 21) $Button1 = GUICtrlCreateButton("Test Input", 48, 112, 105, 41) GUISetState(@SW_SHOW) SubMain(1) ; WORNING: Do not delete it! If you delete it, you may not have a way back and will have to restart the computer :). I do not know why this is happening .. From what I understand, it's not supposed to happen ... But it happens. If you can prevent this from happening without that line, then I would be most grateful. While 1 SubMain() ; <= Operations that must always occur $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form1) ExitLoop Case $Button1 $Radio1Read = GUICtrlRead($Radio1) $Radio2Read = GUICtrlRead($Radio2) $Radio3Read = GUICtrlRead($Radio3) If $Radio1Read <> 1 And $Radio2Read <> 1 And $Radio3Read <> 1 Then MsgBox(0,"ERROR","no radio selected") Else If $Radio1Read = 1 Then MsgBox(0,"input for radio1",GUICtrlRead($Input1)) ElseIf $Radio2Read = 1 Then MsgBox(0,"input for radio2",GUICtrlRead($Input2)) ElseIf $Radio3Read = 1 Then MsgBox(0,"input for radio3",GUICtrlRead($Input3)) EndIf GUIDelete($Form1) ExitLoop EndIf EndSwitch WEnd EndFunc I do not know where to start ...My writing skills for writing working GUIs are poor EDIT: Line 43 in the script does not represent a problem is my software.I have no such problem in my software.So you do not have to solve it ... It does not really matter. this is what i tried so far: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Main() ;GUI1() Func Main() Global $aButton[1] = [0] SubMain(1) While 1 SubMain() ; <= Operations that must always occur Sleep(10) WEnd EndFunc Func SubMain($SubMainStart = 0) If $SubMainStart = 1 Then Global $timer = TimerInit() ElseIf $SubMainStart = 0 Then Global $TimerDiff = Int(TimerDiff($timer)) ToolTip($TimerDiff) If $TimerDiff > 10000 Then ; Increase the array count $aButton[0] += 1 ; And its size ReDim $aButton[$aButton[0] + 1] ; Now create the button and store its controlID GUI1() Global $timer = TimerInit() EndIf EndIf EndFunc Func GUI1() $Form1 = GUICreate("input test", 207, 175, 541, 193) $Radio1 = GUICtrlCreateRadio("Radio1", 32, 16, 57, 25) $Radio2 = GUICtrlCreateRadio("Radio2", 32, 45, 57, 25) $Radio3 = GUICtrlCreateRadio("Radio3", 32, 72, 57, 25) $Input1 = GUICtrlCreateInput("Input1", 88, 19, 65, 21) $Input2 = GUICtrlCreateInput("Input2", 88, 48, 65, 21) $Input3 = GUICtrlCreateInput("Input3", 88, 75, 65, 21) $aButton[$aButton[0]] = GUICtrlCreateButton("Test Input", 48, 112, 105, 41) GUISetState(@SW_SHOW) SubMain(1) ; WORNING: Do not delete it! If you delete it, you may not have a way back and will have to restart the computer :). I do not know why this is happening .. From what I understand, it's not supposed to happen ... But it happens. If you can prevent this from happening without that line, then I would be most grateful. While 1 SubMain() ; <= Operations that must always occur $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($aMsg[1]) ExitLoop Case Else ;$Radio1Read = GUICtrlRead($Radio1) ;$Radio2Read = GUICtrlRead($Radio2) ;$Radio3Read = GUICtrlRead($Radio3) ;If $Radio1Read <> 1 And $Radio2Read <> 1 And $Radio3Read <> 1 Then ; MsgBox(0,"ERROR","no radio selected") ;Else ;If $Radio1Read = 1 Then ; MsgBox(0,"input for radio1",GUICtrlRead($Input1)) ;ElseIf $Radio2Read = 1 Then ; MsgBox(0,"input for radio2",GUICtrlRead($Input2)) ;ElseIf $Radio3Read = 1 Then ; MsgBox(0,"input for radio3",GUICtrlRead($Input3)) ;EndIf ;GUIDelete($Form1) ;ExitLoop ;EndIf For $iIndex = 1 To $aButton[0] If $aMsg[0] = $aButton[$iIndex] Then ; Found it - so delete the GUI GUIDelete($aMsg[1]) ;Remove the button from the array _ArrayDelete($aButton, $iIndex) ; And finally reduce the array count $aButton[0] -= 1 ; No point in looking further ExitLoop EndIf Next EndSwitch WEnd EndFunc it is not working.. Edited September 5, 2013 by Guest Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 5, 2013 Moderators Share Posted September 5, 2013 gil900,That script is massively recursive - that means that you call functions again without returning from them first. For example, you are calling GUI1 from within SubMain and then calling SubMain from within GUI1 and then calling GUI1 from within SubMain and........ This will lead to a crash very quickly. How about you explain what you want to do rather than just post a script with no comments and then assumimg we will be able to get it to jump through whatever hoops you think it should. 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...
Guest Posted September 5, 2013 Share Posted September 5, 2013 (edited) gil900, That script is massively recursive - that means that you call functions again without returning from them first. For example, you are calling GUI1 from within SubMain and then calling SubMain from within GUI1 and then calling GUI1 from within SubMain and........ This will lead to a crash very quickly. How about you explain what you want to do rather than just post a script with no comments and then assumimg we will be able to get it to jump through whatever hoops you think it should. M23 For example, you are calling GUI1 from within SubMain and then calling SubMain from within GUI1 and then calling GUI1 from within SubMain and........ This will lead to a crash very quickly. and why it is a problem? it is my solution to the problem that the script can not do some processes in parallel.In autoit multithread is impossible. So my solution is that certain code that must work always, will be shared in each while loop. and the example you saw is the way of my solution. it is working very good in my software.. like a magic! do you have a better idea? How about you explain what you want to do rather than just post a script with no comments and then assumimg we will be able to get it to jump through whatever hoops you think it should. Oh yeahI want that buttons in GUIs work properly .. 1) When I select a particular GUI window and enter the data and then select "Test Input", I want to see in the msgbox that script got the right data froum the right Gui window. after that the right gui will close. 2) When i select the X button in some GUI window then the right GUI window will close Edited September 5, 2013 by Guest Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 5, 2013 Moderators Share Posted September 5, 2013 gil900,Then increase the size of the array and store more info for each GUI: expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> Global $nTimer = 0, $a = 1 Global $aControls[1][8] = [[0]] ; 0 = button ; 1-3 = radios ; 4-6 = Inputs ; 7 = GUI ID While 1 If TimerDiff($nTimer) > 10000 Then ; Increase the array count $aControls[0][0] += 1 ; And its size ReDim $aControls[$aControls[0][0] + 1][8] ; Now create the GUI and controls and store the ControlIDs $Form1 = GUICreate("INPUT TEST " & $a, 300, 200, 400, 250) $aControls[$aControls[0][0]][0] = GUICtrlCreateButton("Test Input", 48, 112, 105, 41) GUIStartGroup() $aControls[$aControls[0][0]][1] = GUICtrlCreateRadio("Radio 1", 30, 10, 60, 25) $aControls[$aControls[0][0]][2] = GUICtrlCreateRadio("Radio 2", 30, 40, 60, 25) $aControls[$aControls[0][0]][3] = GUICtrlCreateRadio("Radio 3", 30, 70, 60, 25) GUIStartGroup() $aControls[$aControls[0][0]][4] = GUICtrlCreateInput("Input 1", 100, 10, 200, 25) $aControls[$aControls[0][0]][5] = GUICtrlCreateInput("Input 2", 100, 40, 200, 25) $aControls[$aControls[0][0]][6] = GUICtrlCreateInput("Input 3", 100, 70, 200, 25) GUISetState(@SW_SHOW) $aControls[$aControls[0][0]][7] = $a $a += 1 $nTimer = TimerInit() EndIf $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($aMsg[1]) Case Else ; Search the array for a matching button ControlID For $iIndex = 1 To $aControls[0][0] If $aMsg[0] = $aControls[$iIndex][0] Then ; Found it - so do what needs doing $Radio1Read = GUICtrlRead($aControls[$iIndex][1]) $Radio2Read = GUICtrlRead($aControls[$iIndex][2]) $Radio3Read = GUICtrlRead($aControls[$iIndex][3]) If $Radio1Read <> 1 And $Radio2Read <> 1 And $Radio3Read <> 1 Then MsgBox(0, "ERROR in GUI " & $aControls[$iIndex][7], "no radio selected") Else If $Radio1Read = 1 Then MsgBox(0, "Input 1 in GUI " & $aControls[$iIndex][7], GUICtrlRead($aControls[$iIndex][4])) ElseIf $Radio2Read = 1 Then MsgBox(0, "Input 2 in GUI " & $aControls[$iIndex][7], GUICtrlRead($aControls[$iIndex][5])) ElseIf $Radio3Read = 1 Then MsgBox(0, "Input 3 in GUI " & $aControls[$iIndex][7], GUICtrlRead($aControls[$iIndex][6])) EndIf EndIf ; Delete the GUI GUIDelete($aMsg[1]) ;Remove the button from the array _ArrayDelete($aControls, $iIndex) ; And finally reduce the array count $aControls[0][0] -= 1 ; No point in looking further ExitLoop EndIf Next EndSwitch WEndM23 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...
Guest Posted September 5, 2013 Share Posted September 5, 2013 (edited) gil900, Then increase the size of the array and store more info for each GUI: expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> Global $nTimer = 0, $a = 1 Global $aControls[1][8] = [[0]] ; 0 = button ; 1-3 = radios ; 4-6 = Inputs ; 7 = GUI ID While 1 If TimerDiff($nTimer) > 10000 Then ; Increase the array count $aControls[0][0] += 1 ; And its size ReDim $aControls[$aControls[0][0] + 1][8] ; Now create the GUI and controls and store the ControlIDs $Form1 = GUICreate("INPUT TEST " & $a, 300, 200, 400, 250) $aControls[$aControls[0][0]][0] = GUICtrlCreateButton("Test Input", 48, 112, 105, 41) GUIStartGroup() $aControls[$aControls[0][0]][1] = GUICtrlCreateRadio("Radio 1", 30, 10, 60, 25) $aControls[$aControls[0][0]][2] = GUICtrlCreateRadio("Radio 2", 30, 40, 60, 25) $aControls[$aControls[0][0]][3] = GUICtrlCreateRadio("Radio 3", 30, 70, 60, 25) GUIStartGroup() $aControls[$aControls[0][0]][4] = GUICtrlCreateInput("Input 1", 100, 10, 200, 25) $aControls[$aControls[0][0]][5] = GUICtrlCreateInput("Input 2", 100, 40, 200, 25) $aControls[$aControls[0][0]][6] = GUICtrlCreateInput("Input 3", 100, 70, 200, 25) GUISetState(@SW_SHOW) $aControls[$aControls[0][0]][7] = $a $a += 1 $nTimer = TimerInit() EndIf $aMsg = GUIGetMsg(1) Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($aMsg[1]) Case Else ; Search the array for a matching button ControlID For $iIndex = 1 To $aControls[0][0] If $aMsg[0] = $aControls[$iIndex][0] Then ; Found it - so do what needs doing $Radio1Read = GUICtrlRead($aControls[$iIndex][1]) $Radio2Read = GUICtrlRead($aControls[$iIndex][2]) $Radio3Read = GUICtrlRead($aControls[$iIndex][3]) If $Radio1Read <> 1 And $Radio2Read <> 1 And $Radio3Read <> 1 Then MsgBox(0, "ERROR in GUI " & $aControls[$iIndex][7], "no radio selected") Else If $Radio1Read = 1 Then MsgBox(0, "Input 1 in GUI " & $aControls[$iIndex][7], GUICtrlRead($aControls[$iIndex][4])) ElseIf $Radio2Read = 1 Then MsgBox(0, "Input 2 in GUI " & $aControls[$iIndex][7], GUICtrlRead($aControls[$iIndex][5])) ElseIf $Radio3Read = 1 Then MsgBox(0, "Input 3 in GUI " & $aControls[$iIndex][7], GUICtrlRead($aControls[$iIndex][6])) EndIf EndIf ; Delete the GUI GUIDelete($aMsg[1]) ;Remove the button from the array _ArrayDelete($aControls, $iIndex) ; And finally reduce the array count $aControls[0][0] -= 1 ; No point in looking further ExitLoop EndIf Next EndSwitch WEnd M23 Thank you.I need time to understand what you did there and I have no time now ..In the future I'll try to figure it out ..The main reason I do not understand what you did is that it looks like it is written in another language.Things like: += , aControls[1][8] = [[0]] , $aControls[0][0]Not familiar to me at all ... If you can translate it into something more regular (as $a = $a+1 , _ArrayAdd() , _ArrayDelete() , UBound($Array)-1 ) then I think it would help a lot. Edited September 5, 2013 by Guest Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 5, 2013 Moderators Share Posted September 5, 2013 gil900,I cannot simplify the code much, it needs this complex bits to work! But once you have looked in detail at the code, please ask if you have specific questions.For example: $a +=1 is just shorthand for $a = $a + 1 - look here or in the Help file under <Language Reference - Operators>. As for $aControls[1][8], that is a 2D array - think of it as a grid:0 1 0 A X 1 B Y 2 C ZSo [0][0] = A, [2][1] = Z. Easy really! Perhaps the Arrays tutorial in the Wiki might be a good read. But as I said, please do ask any specific questions once you have had time to read (and hopefully understand) the code. 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...
Guest Posted September 5, 2013 Share Posted September 5, 2013 gil900, I cannot simplify the code much, it needs this complex bits to work! But once you have looked in detail at the code, please ask if you have specific questions. For example: $a +=1 is just shorthand for $a = $a + 1 - look here or in the Help file under <Language Reference - Operators>. As for $aControls[1][8], that is a 2D array - think of it as a grid: 0 1 0 A X 1 B Y 2 C Z So [0][0] = A, [2][1] = Z. Easy really! Perhaps the Arrays tutorial in the Wiki might be a good read. But as I said, please do ask any specific questions once you have had time to read (and hopefully understand) the code. M23 ok.. i don't know how to create 2D array. I always wanted to know .. But I did not find any information about it in UDF. Anyway, I'm almost sure you can do the same with 1D array and with StringSplit .. i use StringSplit() a lot! But do not bother to write it with StringSplit() because I want right now learn this way.. Only if i will not understand the code, so i will ask you to write it with StringSplit() and 1D array Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 5, 2013 Moderators Share Posted September 5, 2013 gil900, i will ask you to write it with StringSplit() and 1D arrayNot a chance! You learn about 2D arrays instead - they are very simple once you get the hang of them. 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