wuruoyu Posted May 11, 2020 Share Posted May 11, 2020 (edited) I'm trying to create reusable GUI, there will be situation that multiple GUIs are opened in parallel. To reproduce the issue 1. click on the "button" a few times to create multiple GUIs 2. When using the input to filter name list, it will only works on last created GUI. Thank you in advance expandcollapse popup#AutoIt3Wrapper_Res_HiDpi=y #AutoIt3Wrapper_Run_Tidy=y #NoTrayIcon #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <GuiTab.au3> #include <EditConstants.au3> #include <Misc.au3> Opt("GUIOnEventMode", 1) Global $prepareDataFlg, $prepareDataButton, $title, $Main, $filterInput, $aKeyWords, $nameList, $shlist Func _GetDPI() Local $hDC = _WinAPI_GetDC(0) Local $DPI = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSY) _WinAPI_ReleaseDC(0, $hDC) Select Case $DPI = 0 $DPI = 1 Case $DPI < 84 $DPI /= 105 Case $DPI < 121 $DPI /= 96 Case $DPI < 145 $DPI /= 95 Case Else $DPI /= 94 EndSelect Return Round($DPI, 2) EndFunc ;==>_GetDPI $DPI = _GetDPI() _main() Func _main() $Main = GUICreate("main", 250 * $DPI, 50 * $DPI, -1, -1, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") $prepareDataButton = GUICtrlCreateButton("Button", 20 * $DPI, 10 * $DPI, 100 * $DPI, 27 * $DPI, -1, -1) GUICtrlSetOnEvent(-1, "_prepareData") GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND') While 1 Sleep(100) Select Case $prepareDataFlg = True _prepareDataAction() $prepareDataFlg = False EndSelect WEnd EndFunc ;==>_main Func _exit() Exit EndFunc ;==>_exit Func _prepareData() Switch @GUI_CtrlId Case $prepareDataButton $prepareDataFlg = True EndSwitch EndFunc ;==>_prepareData Func _prepareDataAction() Local $iRandom = Random(10, 10000) $title = $iRandom $listString = "OLIVIA|RUBY|EMILY|GRACE|JESSICA|CHLOE|SOPHIE|LILY|" $aKeyWords = StringSplit(StringTrimRight($listString, 1), "|", 2) _createPCMembershipGUI($title, $listString) EndFunc ;==>_prepareDataAction Func _createPCMembershipGUI($title, $list) Local $g_hGUI2 = GUICreate($title, 400 * $DPI, 400 * $DPI) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Secondary") $filterInput = GUICtrlCreateInput("", 12 * $DPI, 40 * $DPI, 310 * $DPI, 20 * $DPI, -1, $WS_EX_CLIENTEDGE) $nameList = GUICtrlCreateList("", 12 * $DPI, 68 * $DPI, 376 * $DPI, 316 * $DPI, $WS_VSCROLL) GUICtrlSetData($nameList, $list) GUISetState() EndFunc ;==>_createPCMembershipGUI Func On_Close_Secondary() GUIDelete(@GUI_WinHandle) EndFunc ;==>On_Close_Secondary Func Keywords($sFilter) Local $shlist = '|' For $1 = 0 To UBound($aKeyWords) - 1 If $sFilter = '' Then $shlist &= $aKeyWords[$1] & '|' ContinueLoop Else If StringInStr($aKeyWords[$1], $sFilter) > 0 Then $shlist &= $aKeyWords[$1] & '|' EndIf Next GUICtrlSetData($nameList, $shlist) EndFunc ;==>Keywords Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) $hCtrl = $lParam $nNotifyCode = BitShift($wParam, 16) Switch BitAND($wParam, 0xFFFF) Case $filterInput Switch $nNotifyCode Case $EN_CHANGE Keywords(GUICtrlRead($filterInput)) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Edited May 11, 2020 by wuruoyu Link to comment Share on other sites More sharing options...
ripdad Posted May 11, 2020 Share Posted May 11, 2020 (edited) My opinion. You could add buttons or some other control to the main GUI to show or hide other GUI's. This would make them available whenever you needed them. You would have much better control with something like this... expandcollapse popupGlobal $hGUI1 = GUICreate() ; add controls here Global $hGUI2 = GUICreate() ; add controls here Global $hGUI3 = GUICreate() ; add controls here Global $hGUI4 = GUICreate() ; add controls here ; add events here for each gui and control ; examples: GUISetOnEvent(-3, '_GUI_CtrlMgr', $hGUI1); $GUI_EVENT_CLOSE GUICtrlSetOnEvent($myControl, '_GUI_CtrlMgr') ; show main GUI GUISetState(@SW_SHOW, $hGUI1) ; activate events Opt("GUIOnEventMode", 1) ; loop While 1 Sleep(10) WEnd Func _GUI_CtrlMgr() Switch @GUI_CtrlId Case -3 Switch @GUI_WinHandle Case $hGUI2 GUISetState(@SW_HIDE, $hGUI2) Return Case $hGUI3 GUISetState(@SW_HIDE, $hGUI3) Return Case $hGUI4 GUISetState(@SW_HIDE, $hGUI4) Return Case Else; $hGUI1 (main gui) GUIDelete($hGUI1) GUIDelete($hGUI2) GUIDelete($hGUI3) GUIDelete($hGUI4) Exit EndSwitch Case $hControl1 GUISetState(@SW_SHOW, $hGUI2) ; do something Case $myControl ; do something else EndSwitch EndFunc Edited May 11, 2020 by ripdad adjusted a few lines "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
wuruoyu Posted May 11, 2020 Author Share Posted May 11, 2020 Thank you for your reply @ripdad, the purpose is to keep all windows running in parallel for data comparison (by design every time the button is clicked on, different information will be displayed), hide/show window wouldn't work in my situation. Link to comment Share on other sites More sharing options...
ripdad Posted May 11, 2020 Share Posted May 11, 2020 Okay. You can still use the method in the script I posted to accomplish your needs. I have a huge script that runs on this method and it works very well. Good luck! "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
wuruoyu Posted May 11, 2020 Author Share Posted May 11, 2020 Thanks, the script you posted can only show one window at a time, without having 2 or more child windows opened at the same time I don't how see how it would work in my case, correct me if I am wrong tho @ripdad Link to comment Share on other sites More sharing options...
ripdad Posted May 11, 2020 Share Posted May 11, 2020 In the script I mentioned that I run that method on, I have 6 GUI's open at one time. I could have as many as I wanted. Each has their own controls. Each one runs independently of the others. Give me about 30 to 45 minutes and I'll get you a "working" example, if you would like? "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
ripdad Posted May 11, 2020 Share Posted May 11, 2020 Well, that took sooner than I thought. Here it is... expandcollapse popupGlobal $hGUI1 = GUICreate('GUI #1', 150, 150, 10, 10) Global $hButton1 = GUICtrlCreateButton('OK', 5, 110, 140, 25) Global $hGUI2 = GUICreate('GUI #2', 150, 150, 170, 10) Global $hButton2 = GUICtrlCreateButton('OK', 5, 110, 140, 25) Global $hGUI3 = GUICreate('GUI #3', 150, 150, 330, 10) Global $hButton3 = GUICtrlCreateButton('OK', 5, 110, 140, 25) Global $hGUI4 = GUICreate('GUI #4', 150, 150, 490, 10) Global $hButton4 = GUICtrlCreateButton('OK', 5, 110, 140, 25) ; examples: GUISetOnEvent(-3, '_GUI_CtrlMgr', $hGUI1); $GUI_EVENT_CLOSE GUISetOnEvent(-3, '_GUI_CtrlMgr', $hGUI2); $GUI_EVENT_CLOSE GUISetOnEvent(-3, '_GUI_CtrlMgr', $hGUI3); $GUI_EVENT_CLOSE GUISetOnEvent(-3, '_GUI_CtrlMgr', $hGUI4); $GUI_EVENT_CLOSE GUICtrlSetOnEvent($hButton1, '_GUI_CtrlMgr') GUICtrlSetOnEvent($hButton2, '_GUI_CtrlMgr') GUICtrlSetOnEvent($hButton3, '_GUI_CtrlMgr') GUICtrlSetOnEvent($hButton4, '_GUI_CtrlMgr') ; show GUI's GUISetState(@SW_SHOW, $hGUI1) GUISetState(@SW_SHOW, $hGUI2) GUISetState(@SW_SHOW, $hGUI3) GUISetState(@SW_SHOW, $hGUI4) ; activate events Opt("GUIOnEventMode", 1) ; loop While 1 Sleep(10) WEnd Func _GUI_CtrlMgr() Switch @GUI_CtrlId Case -3 Switch @GUI_WinHandle Case $hGUI1; main gui closes all GUI's GUIDelete($hGUI1) GUIDelete($hGUI2) GUIDelete($hGUI3) GUIDelete($hGUI4) Exit Case $hGUI2; OR you can close them independently with additional code. GUIDelete($hGUI2) Case $hGUI3 GUIDelete($hGUI3) Case $hGUI4 GUIDelete($hGUI4) Case Else EndSwitch Case $hButton1 MsgBox(8256, '', 'You Pressed OK on GUI #1') Case $hButton2 MsgBox(8256, '', 'You Pressed OK on GUI #2') Case $hButton3 MsgBox(8256, '', 'You Pressed OK on GUI #3') Case $hButton4 MsgBox(8256, '', 'You Pressed OK on GUI #4') Case Else EndSwitch EndFunc "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
wuruoyu Posted May 11, 2020 Author Share Posted May 11, 2020 (edited) @ripdad Thank you for your inputs, unfortunately, it won’t work, the GUI needs to be reusable, and created for unlimited number of times, thus manually creating GUI defects the purpose. I got a solution to utilize the controlID via wm_command, not the greatest, but will see if some guru here could come up with a better one. Edited May 11, 2020 by wuruoyu Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 11, 2020 Moderators Share Posted May 11, 2020 (edited) wuruoyu, Your problem was that you were overwriting the ControlIDs of the input and list with each GUI you created - so only the last created GUI worked. You need to store the details of each GUI in an array and then work out which GUI is active so that the filter function know which input and list to use. I have simplified your script a little to make the process clearer and added comments for each bit of code I added: expandcollapse popup;#AutoIt3Wrapper_Res_HiDpi=y ;#AutoIt3Wrapper_Run_Tidy=y ;#NoTrayIcon #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <GuiTab.au3> #include <EditConstants.au3> #include <Misc.au3> Opt("GUIOnEventMode", 1) ; Declare array to hold data on each GUI Global $aGUI_ID[1][4] = [[0]] Global $prepareDataFlg, $prepareDataButton, $title, $Main, $filterInput, $aKeyWords, $nameList, $shlist $DPI = 94 GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND') _main() Func _main() $Main = GUICreate("main", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") $prepareDataButton = GUICtrlCreateButton("Button", 10, 10, 80, 30) GUICtrlSetOnEvent(-1, "_prepareData") GUISetState(@SW_SHOW) While 1 Sleep(100) Select Case $prepareDataFlg = True _prepareDataAction() $prepareDataFlg = False EndSelect WEnd EndFunc ;==>_main Func _exit() Exit EndFunc ;==>_exit Func _prepareData() Switch @GUI_CtrlId Case $prepareDataButton $prepareDataFlg = True EndSwitch EndFunc ;==>_prepareData Func _prepareDataAction() Local $iRandom = Random(10, 10000) $title = $iRandom $listString = "OLIVIA|RUBY|EMILY|GRACE|JESSICA|CHLOE|SOPHIE|LILY|" $aKeyWords = StringSplit(StringTrimRight($listString, 1), "|", 2) _createPCMembershipGUI($title, $listString) EndFunc ;==>_prepareDataAction Func _createPCMembershipGUI($title, $list) ; Increase GUI count $aGUI_ID[0][0] += 1 $iIndex = $aGUI_ID[0][0] ; Increase array size ReDim $aGUI_ID[$iIndex + 1][4] ; Save details of each handle/ControlID related to the GUI $aGUI_ID[$iIndex][0] = GUICreate($title, 200, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Secondary") $aGUI_ID[$iIndex][1] = GUICtrlCreateInput("", 10, 10, 100, 20, -1, $WS_EX_CLIENTEDGE) $aGUI_ID[$iIndex][2] = GUICtrlGetHandle($aGUI_ID[$iIndex][1]) $aGUI_ID[$iIndex][3] = GUICtrlCreateList("", 10, 40, 150, 150, $WS_VSCROLL) GUICtrlSetData(-1, $list) GUISetState() EndFunc ;==>_createPCMembershipGUI Func On_Close_Secondary() GUIDelete(@GUI_WinHandle) EndFunc ;==>On_Close_Secondary Func Keywords($iIndex) ; In this function we use the passed index to identify the GUI ; and so which elements of the array we need to use Local $sFilter = GUICtrlRead($aGUI_ID[$iIndex][1]) Local $shlist = '|' For $1 = 0 To UBound($aKeyWords) - 1 If $sFilter = '' Then $shlist &= $aKeyWords[$1] & '|' ContinueLoop Else If StringInStr($aKeyWords[$1], $sFilter) > 0 Then $shlist &= $aKeyWords[$1] & '|' EndIf Next GUICtrlSetData($aGUI_ID[$iIndex][3], $shlist) EndFunc ;==>Keywords Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) $hCtrl = $lParam $nNotifyCode = BitShift($wParam, 16) ; See which GUI holds the input For $iIndex = 1 To $aGUI_ID[0][0] If $aGUI_ID[$iIndex][2] = $hCtrl Then Switch $nNotifyCode Case $EN_CHANGE ; And pass the index number of the GUI to the filter function so it knows which GUI is active Keywords($iIndex) ExitLoop EndSwitch EndIf Next Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND All clear now? Please ask if not. M23 Edited May 11, 2020 by Melba23 Speeling! Skysnake 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...
wuruoyu Posted May 11, 2020 Author Share Posted May 11, 2020 @Melba23 Thank you! My workaround was at right direction, but your code is way more elegant! Thanks again! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 11, 2020 Moderators Share Posted May 11, 2020 wuruoyu, Delighted I could help. 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...
wuruoyu Posted May 12, 2020 Author Share Posted May 12, 2020 (edited) @Melba23 Sorry forgot to ask this, it's probably not that important, but in a perfect scenario, do I need to keep track of the data that are being added to $aGUI_ID and remove them once window is closed, so that in an extreme case when a lot of GUIs are created and closed, the memory will be released? Edited May 12, 2020 by wuruoyu Link to comment Share on other sites More sharing options...
ripdad Posted May 12, 2020 Share Posted May 12, 2020 wuruoyu, I guess I didn't understand what you meant by reusable GUI's. It would be better worded as on demand GUI's. In any case, I'm glad you got it worked out with Melba23 . "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
wuruoyu Posted May 17, 2020 Author Share Posted May 17, 2020 Hi @Melba23, may I trouble again regarding how to correctly remove the element in array “$aGUI_ID” when a GUI is closed, current the memory usage increases when a new GUI is created and closed. Thanks Link to comment Share on other sites More sharing options...
Gianni Posted May 18, 2020 Share Posted May 18, 2020 (edited) if @Melba23 agrees I would propose this modification on the On_Close_Secondary() function: Func On_Close_Secondary() GUIDelete(@GUI_WinHandle) For $iIndex = 1 To $aGUI_ID[0][0] If $aGUI_ID[$iIndex][0] = @GUI_WinHandle Then ; search the position of the deleted window For $i = 0 To UBound($aGUI_ID, 2) - 1 ; move data from the top of the stack to the deleted slot $aGUI_ID[$iIndex][$i] = $aGUI_ID[$aGUI_ID[0][0]][$i] Next $aGUI_ID[0][0] -= 1 ; adjust array counter ReDim $aGUI_ID[$aGUI_ID[0][0] + 1][UBound($aGUI_ID, 2)] ; redim array by decrease one element ExitLoop EndIf Next EndFunc ;==>On_Close_Secondary Edited May 18, 2020 by Chimp added some comments in the listing Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
wuruoyu Posted May 18, 2020 Author Share Posted May 18, 2020 Func On_Close_Secondary() For $iIndex = 1 To $aGUI_ID[0][0] If $aGUI_ID[$iIndex][0] = @GUI_WinHandle Then _ArrayDelete($aGUI_ID, $iIndex) $aGUI_ID[0][0] -= 1 ExitLoop EndIf Next GUIDelete(@GUI_WinHandle) EndFunc Thanks @Chimp, I had a similar approach. Will see what @Melba23 would suggest Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 18, 2020 Moderators Share Posted May 18, 2020 Hi, This is how I deal with a similar very large array (there are lots of other large arrays stored inside its elements) within my GUIListViewEx UDF: expandcollapse popup; Declare initial array with defaults ###################################################### Global $aGLVEx_Data[1][26] = [[0, 0, -1, "", -1, -1, -1, -1, _WinAPI_GetSystemMetrics(2), False, _ -1, -1, False, "", 0, True, 0, -1, -1, 0, 0, 0, 0, "08"]] ; Creation of a new element ################################################################ Local $iLV_Index = 0 ; See if there is a blank line available in the array For $i = 1 To $aGLVEx_Data[0][0] If $aGLVEx_Data[$i][0] = 0 Then $iLV_Index = $i ExitLoop EndIf Next ; If no blank line found then increase array size If $iLV_Index = 0 Then $aGLVEx_Data[0][0] += 1 ReDim $aGLVEx_Data[$aGLVEx_Data[0][0] + 1][UBound($aGLVEx_Data, 2)] $iLV_Index = $aGLVEx_Data[0][0] EndIf ; Removal of an element #################################################################### If $iLV_Index = 0 Then ; Reinitialise data array - retaining selected edit key $iEditKeyCode = $aGLVEx_Data[0][23] Global $aGLVEx_Data[1][UBound($aGLVEx_Data, 2)] = [[0, 0, -1, "", -1, -1, -1, -1, _WinAPI_GetSystemMetrics(2), False, _ -1, -1, False, "", 0, True, 0, -1, -1, 0, 0, 0, 0, $iEditKeyCode]] ; Note delimiter character reset when ListView next initialised Else ; Reset all data for ListView For $i = 0 To UBound($aGLVEx_Data, 2) - 1 $aGLVEx_Data[$iLV_Index][$i] = 0 Next ; Cancel active index if set to this ListView If $aGLVEx_Data[0][1] = $iLV_Index Then $aGLVEx_Data[0][1] = 0 EndIf EndIf As you can see I start by creating the array with some default values. Then when adding an element I look for any blank elements within the array where a previous element has been deleted - if there are none then a new element is created. When deleting an element I leave a "hole" in the array for a new element use if required. Finally I reset the whole array if there are no elements left at any point to minimize the memory used. That seems to me to be the best solution - and incidentally is how AutoIt manages its ControlIDs internally, so it must have some merit! 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...
Skysnake Posted May 19, 2020 Share Posted May 19, 2020 Dear @Melba23, very clever as always, thank you. I had wondered about this before, but as I have never had the need to use this kind of implementation, I never pursued it. However, I can see the value, and this implementation may even satisfy the needs of many who inquire about multi threading --- I think many of those requests are in fact more concerned with multiple simultaneous instances of the (same) GUI than anything else. Can this be expanded? Used as the basis for a UDF or a tutorial? And specifically how to use the control array NOT in Global ? Skysnake Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 19, 2020 Moderators Share Posted May 19, 2020 Skysnake, I am not at all sure about this method being useful to those who are looking for multi-threading - that usually means sharing out workload between the threads rather than having multiple instances of similar GUIs/controls. But I will think about how the explanation above might be expanded into a tutorial - however I do not see how it could be made into a UDF as the specific implementation would likely be very different in each case. What exactly do you mean by "NOT in Global"? 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...
Gianni Posted May 19, 2020 Share Posted May 19, 2020 (edited) hi @Skysnake, The main "array" here is used by the script to track the many open GUIs generated by the script itself. The only script that uses that array is the main one (which is also the only script involved). If multiple scripts were running, only the script that owns that array could access it. To do what I think you mean, you should take a look at this very interesting thread by @LarsJ (https://www.autoitscript.com/forum/topic/202618-implementing-irunningobjecttable-interface/ With that you can "share" an object, for example a script.dictionary and through it have access to an array contained in it between multiple scripts. The interesting concept published here by @Melba23 avoids using a matrix as if it were an "accordion", that is, lengthening and shortening it for each insertion or deletion of an element. It would be interesting to have it as a general purpose function where you can store or recall the elements as you wish, leaving the function itself to manage the "re/size" of the array and the "garbage collection" task ... Edited May 19, 2020 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... 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