DigDeep Posted September 20, 2017 Share Posted September 20, 2017 Hi, I hope I would not sound confusing. I have a huge script which is divided into multiple au3 files. I have added all child Au3 files inside the include and calling them in the Parent GUI. It's all good except I ran into an issue now. Due to various functions running, all my child au3 have lables and buttons but I have removed the GUICreate from them. 1. When Button 1 is pressed in Parent GUI (Test1.au3), it calls the Test2.au3. 2. From the Test2.au3, if button 2 is pressed, it should Hide the Test2(). And here is the issue I am finding. Because I have removed the GUICreate from the child GUIs', though I am able to get the Lables and buttons displayed from TES2() but if I press the Button2, it does not do anything. As an example, ; Test1.au3 *********************************************** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 530, 580, 734, 184) $Label1 = GUICtrlCreateLabel(@CRLF & @CRLF & @CRLF & "Lable 1", 80, 40, 353, 196, $SS_CENTER) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Go to Lable 2", 224, 192, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; Preseeing this button will call Test2.au3 Test2() Case $Button2 ; Pressing this button will hide Test2.au3 GUICtrlSetState($Label2, $GUI_Hide) GUICtrlSetState($Button2, $GUI_Hide) EndSwitch WEnd *********************************************** ; Test 2.au3 ; This file is saved as custom includes *********************************************** Func Test2() #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Label2 = GUICtrlCreateLabel(@CRLF & @CRLF & @CRLF & "Label2", 80, 264, 356, 204, $SS_CENTER) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Go to Lable 1", 224, 432, 75, 25) *********************************************** EndFunc Test2() Link to comment Share on other sites More sharing options...
InunoTaishou Posted September 21, 2017 Share Posted September 21, 2017 I would highly recommend not doing exactly what you're doing, very very bad formatting of your code and anyone that sees it may get very confused (you might even confuse yourself in the future). A better idea be to create all the controls but hide the ones you don't want shown. But the way to do what you want is to create the $Button2 and $Label2 variables global first. $Form2 = GUICreate("Form2", 530, 580, 734, 184) $Label1 = GUICtrlCreateLabel("Lable 1", 80, 40, 353, 50, $SS_CENTER) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Go to Lable 2", 224, 192, 75, 25) Global $Button2 = 0, $Label2 = 0 Also, you can't click the buttons in your example because the label is on top of the button. So you can't click it Link to comment Share on other sites More sharing options...
DigDeep Posted September 21, 2017 Author Share Posted September 21, 2017 @InunoTaishou thanks for the inputs. Yeah, I understand and I realize with the button placement. My Parent application will be handling more than 30 applications and there are various reasons I do not want to write all those inside 1 AU3 file. So All applications have their own AU3 which I am making as custom includes and calling those includes in the Parent GUI. I have tried with your suggestion side too but I think I am still missing something. I will try to get you a test example of what I am trying to do here. Link to comment Share on other sites More sharing options...
DigDeep Posted September 21, 2017 Author Share Posted September 21, 2017 (edited) @InunoTaishou here is a sample of what I need. You can add the Application 2.au3 to your Include and then run the Parent Application.au3. Applicaiton2.au3 Parent Application.au3 Edited September 21, 2017 by DigDeep Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 21, 2017 Moderators Share Posted September 21, 2017 DigDeep, Adding the Application2 file as an include places that code in the Parent Application file at the point of the #include line. So all the code in that file is parsed before any of the code in the parent - hence you are calling the GUI2 function in the App2 file to create a button in a non-existent GUI. I have modified the files so that they work as you wish - please read the comments I have added: Parent Application.au3 Application2.au3 Note the requirement to put a placeholder value in the $Button2 variable - if you set it to 0 or leave it undeclared then the Case will file immediately you enter the idle loop as GUIGetMsg returns 0 as the default when no event has occurred. Please ask if you have any further questions. M23 DigDeep 1 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...
DigDeep Posted September 25, 2017 Author Share Posted September 25, 2017 (edited) @Melba23, thanks and yes, it worked so far. but here is one issue. I understand that we have to set a 'Placeholder value', else it will fire up the buttons when GUI launches. 1. Do we have to set all the buttons we will need in the AU3? 2. If I modify the code a little bit to add another button as $Button3, what happens is if I press Button 3 once, I cannot click on the button 2 any more. Or if I re-press the $FixedLable, I cannot click on any buttons. Providing the updated file here... Can you also suggest the best way to get these here? The reason I am getting multiple AU3 situated with the specific applications and which will be called within the Parent GUI, so that no matter how big my codes go, it will be easy for me to make changes / corrections within the specific application / AU3 itself. Instead of keeping all AU3 codes inside 1 Parent GUI. If this is not one of the best option, can you please help me in suggesting your recommendations as to set the lines written in the 2 files? That will be of great help from you. My Parent GUI will be holding around 18 different applications (18 different AU3 files) as per the current design. Parent Application.au3 Applicaiton2.au3 Edited September 25, 2017 by DigDeep Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 25, 2017 Moderators Share Posted September 25, 2017 DigDeep, I firmly believe that splitting the code between several files as you are doing is far from "one of the best option". My suggestion would be to use #region/#endregion directives within your code so that you can expand/contract the code within the regions as required. I have a close to 10,000 line script which can be contracted to a single line or can equally be expanded into several major sections, each of which can be further expanded into sub-sections, then smaller sub-sub-sections, etc. This allows me to keep everything easily accessible within the same SciTE editing pane. I will look at the new code when I have time - I am heavily into debugging another member's scrip tat the moment. 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...
DigDeep Posted September 25, 2017 Author Share Posted September 25, 2017 Thanks @Melba23 for your inputs. I'll try to look into getting my code as a single AU3 file with decisions and see how it goes too. Link to comment Share on other sites More sharing options...
DigDeep Posted September 25, 2017 Author Share Posted September 25, 2017 (edited) @Melba23, I worked on your suggestion and looks fine with me managing with multiple Regions too. Though I am still finding the same issue for 'if Application 2 is re-clicked when Button 2 and 3 are active both the buttons stop working'. Let me give you the updated 1 au3 file in sometime. Edited September 25, 2017 by DigDeep Link to comment Share on other sites More sharing options...
DigDeep Posted September 25, 2017 Author Share Posted September 25, 2017 @Melba23 Here is the updated single AU3 file clubbed in... Could you please help. Parent Application.au3 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 25, 2017 Moderators Share Posted September 25, 2017 DigDeep, Now you have al the code in one place I can see the problem - you are continually recreating controls in APP2 which, of course, overlap and hence do not fire when actioned. What exactly is the difference between $Button2 and $Button3? Why is $Button3 supposed to stay there when pressed - recreating that control each time in your major problem. Perhaps if you were to explain in a bit more detail exactly what is supposed to happen within your script I could suggest a script architecture which would simplify your task. 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...
DigDeep Posted September 25, 2017 Author Share Posted September 25, 2017 My application will be holding multiple Lables and Buttons which will Enable / Disable, Hide / Show at certain times. Button 2 is something to be used as Go Back option to the Default view when the application launches. Button 3 is something that will be used as to do some further activities. To explain better, GUI launches > APP2 2 clicked will launch Button 2 and Button 3 > If button 2 is pressed it will Hide everything Inside APP2() > If Button 3 is pressed, I will decide further what actions to take so only Button 2 will Hide. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 25, 2017 Moderators Share Posted September 25, 2017 DigDeep, You said earlier that you will have 30+ such "applications" - will each and every one of them have a similar set of buttons? If so, I foresee huge problems in keeping them in order and preventing total confusion. Might I suggest using my GUIExtender UDF? You can then have everything in a single GUI with a section for each "application" and just display the section required. This will allow you to create all the required controls at the beginning of the script (or at least those that need auctioning) which will greatly simplify the whole process. Take a look at the UDF (the link is in my sig) and I will try and write a short example which I hope will demonstrate how I think It might help you. 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...
DigDeep Posted September 25, 2017 Author Share Posted September 25, 2017 I have checked all the examples in GUIExtender. However, that's not what I am looking for. I am not sure as of now as I am still building the application but I believe the Button 2 and 3 will always be the 2 common buttons which will only show / hide when App1(), App2(), App3() will be clicked. Yes though there will be too many Lables that will show / hide. Can you check if the single AU3 I gave last can be adjusted? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 25, 2017 Moderators Share Posted September 25, 2017 DigDeep, Quote Can you check if the single AU3 I gave last can be adjusted? How can I adjust it when I have no idea of what is going on? You have given me no clear explanation of what is supposed to happen when all these various "applications" are started/hidden, so how can I code anything for you? What are the "applications"? Why do they need to appear and hide? Why do some buttons need to stay around even when the "application" is hidden? How are all these "permanent" buttons supposed to keep separate? Unless you can give me some clear instructions on exactly what is supposed to happen I am afraid I am going to have to bow out of the thread as I am just wasting my time at the moment. Sorry. Here is the GUIExtender example I have drawn up for you: expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIExtender.au3> ; Create array to hold application names and sections indices Global $aSections[][] = [["No APP", 0], ["APP 1", 0], ["APP 2", 0], ["APP 3", 0]] ; Currently displayed section - 9999 is a placeholder Global $iCurrSection = 9999 ; Create GUI $hGUI = GUICreate("Test", 500, 550) _GUIExtender_Init($hGUI) GUICtrlCreateLabel("Select APP to display", 10, 10, 200, 20) $cCombo = GUICtrlCreateCombo("", 10, 50, 200, 20) GUICtrlSetData($cCombo, "No APP|APP 1|APP 2|APP 3", "No APP") ; Create fixed section from 0-100 pixels _GUIExtender_Section_Create($hGUI, Default, 100) ; Now call your application functions to populate the rest of the GUI _APP1() _APP2() _APP3() ; Close section creation _GUIExtender_Section_Create($hGUI, -99) ; Close all sections _GUIExtender_Section_Action($hGUI, 0, 0) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cCombo ; Check combo selection $sSelApp = GUICtrlRead($cCombo) ; look in the data array for the appropriate section $iIndex = _ArraySearch($aSections, $sSelApp) If Not @error Then $iSelSection = $aSections[$iIndex][1] ; if no app selected If $iSelSection = 0 Then ; Close all sections _GUIExtender_Section_Action($hGUI, 0, 0) Else ; Close currently open section _GUIExtender_Section_Action($hGUI, $iCurrSection, 0) ; Open selected section _GUIExtender_Section_Action($hGUI, $iSelSection, 1) EndIf ; Store current selection $iCurrSection = $iSelSection EndIf Case $cButton_APP1 MsgBox($MB_SYSTEMMODAL, "APP 1", "Button Pressed") Case $cButton_APP2 MsgBox($MB_SYSTEMMODAL, "APP 2", "Button Pressed") Case $cButton_APP3 MsgBox($MB_SYSTEMMODAL, "APP 3", "Button Pressed") EndSwitch _GUIExtender_EventMonitor($hGUI, $nMsg) WEnd Func _APP1() ; Create an extendable section from 100-250 pixels $iSection = _GUIExtender_Section_Create($hGUI, Default, 150) ; Allow section to be actioned _GUIExtender_Section_Activate($hGUI, $iSection) ; Get top Y coord of the section $iBaseCoord = _GUIExtender_Section_BaseCoord($hGUI, $iSection) ; Create controls within the section GUICtrlCreateLabel("This is the APP1 label", 10, $iBaseCoord + 10, 480, 130) GUICtrlSetBkColor(-1, 0xFFCCCC) GUICtrlSetState(-1, $GUI_DISABLE) Global $cButton_APP1 = GUICtrlCreateButton("APP 1", 50, $iBaseCoord + 50, 80, 30) ; Not good coding practice but legal syntax ; Store section index with section name in the combo $aSections[1][1] = $iSection EndFunc Func _APP2() ; Create an extendable section from 250-400 pixels $iSection = _GUIExtender_Section_Create($hGUI, Default, 150) _GUIExtender_Section_Activate($hGUI, $iSection) $iBaseCoord = _GUIExtender_Section_BaseCoord($hGUI, $iSection) GUICtrlCreateLabel("This is the APP2 label", 10, $iBaseCoord + 10, 480, 130) GUICtrlSetBkColor(-1, 0xCCFFCC) GUICtrlSetState(-1, $GUI_DISABLE) Global $cButton_APP2 = GUICtrlCreateButton("APP 2", 50, $iBaseCoord + 50, 80, 30) $aSections[2][1] = $iSection EndFunc Func _APP3() ; Create an extendable section from 400-550 pixels $iSection = _GUIExtender_Section_Create($hGUI, Default, 150) _GUIExtender_Section_Activate($hGUI, $iSection) $iBaseCoord = _GUIExtender_Section_BaseCoord($hGUI, $iSection) GUICtrlCreateLabel("This is the APP3 label", 10, $iBaseCoord + 10, 480, 130) GUICtrlSetBkColor(-1, 0xCCCCFF) GUICtrlSetState(-1, $GUI_DISABLE) Global $cButton_APP3 = GUICtrlCreateButton("APP 3", 50, $iBaseCoord + 50, 80, 30) $aSections[3][1] = $iSection EndFunc Any use at all? 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...
DigDeep Posted September 25, 2017 Author Share Posted September 25, 2017 Attaching the updated AU3 of what I am looking for. It is working now except just that the Buttons 2 and 3 if placed after $Lable4 do not respond. Which as you have explained earlier might be going behind the Lable. But if placed Before that, works all good except just that the buttons only appear when mouse is placed on top of that location. If you could please help with the buttons placement. But it is doing the actions what I needed for. Case $Label2 GUICtrlSetState($FixedLable, $GUI_HIDE) ; Hide $FixedLable APP2() Case $Button2 ; place Button 2 Case here GUICtrlSetState($Label4, $GUI_HIDE) GUICtrlSetState($Button2, $GUI_HIDE) GUICtrlSetState($Button3, $GUI_HIDE) MsgBox(0, '', 'Taking back to Home screen') GUICtrlSetState($FixedLable, $GUI_SHOW) Case $Button3 GUICtrlSetState($Button2, $GUI_HIDE) MsgBox(0, '', 'Running further Actions...', 3) MsgBox(0, '', 'Actions completed.', 3) GUICtrlSetState($Label4, $GUI_HIDE) GUICtrlSetState($Button3, $GUI_HIDE) GUICtrlSetState($FixedLable, $GUI_SHOW) EndSwitch WEnd Sorry, as this has taken your long time and thank you for staying so long. Parent Application.au3 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 25, 2017 Moderators Share Posted September 25, 2017 DigDeep, Not the slightest explanation at all of what exactly is going on, so as I said earlier I am out of this thread - bye. 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...
DigDeep Posted September 26, 2017 Author Share Posted September 26, 2017 @Melba23, there are few applications which are not for fun or public purpose. They might be for internal or corporate applications which is why not everyone would like to disclose each and every aspect of the application. I think I had mentioned many times what am I expecting from the sample GUI. Clicking Lables will bring in more lables and Buttons and hide the previous ones. Next, new buttons will do the required actions they are meant for, Button 2 will get the Default view back in place and Button 3 will do whatever further actions. That's the only thing I needed, which I have but getting into some issues. No issues, I understand from your point of view too for staying long enough with this thread and thank you for the inputs and suggestions you have given. I think spending sometime myself will let me know what needs to be done. Just to let you know, within your GUIExtender, there is one of the example I liked and was something in my mind to get something similar. And I think I can use that in future stage on my other applications. Have a good day. 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