benners Posted March 25, 2008 Share Posted March 25, 2008 I am changing my code from GUIGetMsg to GUIOnEventMode and have come unstuck. The old code used to have a loop waiting for response from the 2nd GUI, but from that I have read here, 'There can be only 1'.... While loop that is and my old script used 2. what I want to do is pause the script , waiti for an action from the 2nd GUI then continue with the function. Is this possible?. A basic script here is similar to what I want to do expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) #Region ### Multiple INI sections GUI ### $Multi_GUI = GUICreate("Multiple Sections", 288, 162, 404, 313, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS)) $Multi_lv = GUICtrlCreateListView(" Select A Section", 8, 8, 270, 113, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, 0x101E, 0, 265) $MultiImport_btn = GUICtrlCreateButton("Import", 16, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') $MultiCancel_btn = GUICtrlCreateButton("Cancel", 104, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') $MultiDelete_btn = GUICtrlCreateButton("Delete", 192, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') #EndRegion ### Multiple INI sections GUI ### #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Dialog", 316, 233, 347, 263) GUISetIcon("D:\003.ico") $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 193) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("&OK", 65, 203, 75, 25, 0) GUICtrlSetOnEvent(-1, '_ShowGUI') $Button2 = GUICtrlCreateButton("&Cancel", 162, 203, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(10) WEnd Func _ShowGUI() GUISetState(@SW_DISABLE, $form1) GUISetState(@SW_SHOW, $Multi_GUI) ; GUI shows ; Wait for input\actions from 2nd GUI ; Where While loop used to be with Select case statements, waiting for button clicks. ; Wait until GUI closed and run next step MsgBox(0,'', 'Running Next Step when I should be waiting') EndFunc Func _multi() MsgBox(0,'', 'Performing desired action'); perform some action GUISetState(@SW_ENABLE, $form1) GUISetState(@SW_HIDE, $Multi_GUI) EndFunc Thanks Link to comment Share on other sites More sharing options...
Valuater Posted March 25, 2008 Share Posted March 25, 2008 (edited) You already have the answer.... expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) #Region ### Multiple INI sections GUI ### $Multi_GUI = GUICreate("Multiple Sections", 288, 162, 404, 313, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS)) $Multi_lv = GUICtrlCreateListView(" Select A Section", 8, 8, 270, 113, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, 0x101E, 0, 265) $MultiImport_btn = GUICtrlCreateButton("Import", 16, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') $MultiCancel_btn = GUICtrlCreateButton("Cancel", 104, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') $MultiDelete_btn = GUICtrlCreateButton("Delete", 192, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') GUISetState(@SW_HIDE) #EndRegion ### Multiple INI sections GUI ### #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Dialog", 316, 233, 347, 263) GUISetIcon("D:\003.ico") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exiter") $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 193) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("&OK", 65, 203, 75, 25, 0) GUICtrlSetOnEvent(-1, '_ShowGUI') $Button2 = GUICtrlCreateButton("&Cancel", 162, 203, 75, 25, 0) GUICtrlSetOnEvent(-1, '_Exiter') GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(10) WEnd Func _ShowGUI() GUISetState(@SW_HIDE, $form1) GUISetState(@SW_SHOW, $Multi_GUI) ; GUI shows ; Wait for input\actions from 2nd GUI ; Where While loop used to be with Select case statements, waiting for button clicks. ; Wait until GUI closed and run next step MsgBox(0,'', 'Just click the next button and things will be done like you want ', 2) EndFunc Func _multi() MsgBox(0,'', 'Performing desired action', 2); perform some action GUISetState(@SW_HIDE, $Multi_GUI) GUISetState(@SW_SHOW, $form1) EndFunc Func _Exiter() MsgBox(0x0, "", " ..... Good-Bye!. ", 2) Exit EndFunc 8) MINOR EDIT @ 9:20 Edited March 25, 2008 by Valuater Link to comment Share on other sites More sharing options...
benners Posted March 25, 2008 Author Share Posted March 25, 2008 You already have the answer.... expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) #Region ### Multiple INI sections GUI ### $Multi_GUI = GUICreate("Multiple Sections", 288, 162, 404, 313, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS)) $Multi_lv = GUICtrlCreateListView(" Select A Section", 8, 8, 270, 113, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, 0x101E, 0, 265) $MultiImport_btn = GUICtrlCreateButton("Import", 16, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') $MultiCancel_btn = GUICtrlCreateButton("Cancel", 104, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') $MultiDelete_btn = GUICtrlCreateButton("Delete", 192, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') GUISetState(@SW_HIDE) #EndRegion ### Multiple INI sections GUI ### #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Dialog", 316, 233, 347, 263) GUISetIcon("D:\003.ico") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exiter") $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 193) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("&OK", 65, 203, 75, 25, 0) GUICtrlSetOnEvent(-1, '_ShowGUI') $Button2 = GUICtrlCreateButton("&Cancel", 162, 203, 75, 25, 0) GUICtrlSetOnEvent(-1, '_Exiter') GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(10) WEnd Func _ShowGUI() GUISetState(@SW_HIDE, $form1) GUISetState(@SW_SHOW, $Multi_GUI) ; GUI shows ; Wait for input\actions from 2nd GUI ; Where While loop used to be with Select case statements, waiting for button clicks. ; Wait until GUI closed and run next step MsgBox(0,'', 'Just click the next button and things will be done like you want ', 2) EndFunc Func _multi() MsgBox(0,'', 'Performing desired action', 2); perform some action GUISetState(@SW_HIDE, $Multi_GUI) GUISetState(@SW_SHOW, $form1) EndFunc Func _Exiter() MsgBox(0x0, "", " ..... Good-Bye!. ", 2) Exit EndFunc 8) MINOR EDIT @ 9:20Hi Valuater I don't have the msgboxes in the script they are just for this problem. What should happen is the script pauses until the 2nd GUI (ini file imported) closes then run the next code (do actions based on info from the ini file). The 'Just click the next button ' was just to show that the function is not pausing, if that makes any sense. I am playing around with adding functions for the 2nd GUI to the while loop but with no success, is this the right method ?. Link to comment Share on other sites More sharing options...
benners Posted March 25, 2008 Author Share Posted March 25, 2008 MINOR EDIT @ 9:20 I keep the 1st GUI showing and just disable it, I think it looks better. Also do you need to add the GUISetState(@SW_HIDE), I mean is it good practice?. Link to comment Share on other sites More sharing options...
MHz Posted March 25, 2008 Share Posted March 25, 2008 MINOR EDIT @ 9:20I keep the 1st GUI showing and just disable it, I think it looks better. Also do you need to add the GUISetState(@SW_HIDE), I mean is it good practice?.Yeah, hiding is ok, saves recreating the Gui. You may need to look at using GuiSwitch() to change events from one Gui to the other. Link to comment Share on other sites More sharing options...
benners Posted March 25, 2008 Author Share Posted March 25, 2008 Yeah, hiding is ok, saves recreating the Gui. You may need to look at using GuiSwitch() to change events from one Gui to the other. I have looked at GUISwitch but that would create another loop like the While loop so I would expect the same result. I have tried playing around with the code and still cannot get it to work. Latest feeble attempt expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) #Region ### Multiple INI sections GUI ### $Multi_GUI = GUICreate("Multiple Sections", 288, 162, 404, 313) $Multi_lv = GUICtrlCreateListView(" Select A Section", 8, 8, 270, 113, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, 0x101E, 0, 265) $MultiImport_btn = GUICtrlCreateButton("Import", 16, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') $MultiCancel_btn = GUICtrlCreateButton("Cancel", 104, 128, 75, 25, 0) ;GUICtrlSetOnEvent(-1, '_multi') $MultiDelete_btn = GUICtrlCreateButton("Delete", 192, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') GUISetState(@SW_HIDE) #EndRegion ### Multiple INI sections GUI ### #Region ### START Koda GUI section ### $Form1 = GUICreate("Dialog", 316, 233, 347, 263) GUISetIcon("D:\003.ico") $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 193) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("&OK", 65, 203, 75, 25, 0) GUICtrlSetOnEvent(-1, '_ShowGUI') $Button2 = GUICtrlCreateButton("&Cancel", 162, 203, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### GUISetOnEvent($GUI_EVENT_CLOSE, 'DoExit') While 1 Sleep(10) WEnd Func _ShowGUI() GUISetState(@SW_DISABLE, $Form1) GUISetState(@SW_SHOW, $Multi_GUI) GUISwitch($Multi_GUI) Do $msg = GUIGetMsg(1) Until $msg[0] = $GUI_EVENT_CLOSE And $msg[0] = $Multi_GUI; Multi gui closed with 'X' ; GUI shows ; Wait for input\actions from 2nd GUI ; Where While loop used to be with Select case staements, waiting for button clicks. ; Wait until GUI closed and run next step MsgBox(0, '', 'Running Next Step when I should be waiting') EndFunc ;==>_ShowGUI Func _multi() MsgBox(0, '', 'Performing desired action'); perform some action GUISetState(@SW_ENABLE, $Form1) GUISetState(@SW_HIDE, $Multi_GUI) EndFunc ;==>_multi Func DoExit() Exit EndFunc ;==>DoExit Link to comment Share on other sites More sharing options...
MHz Posted March 26, 2008 Share Posted March 26, 2008 These may give you some kind of base to work with. I am not sure exactly what you want but your question in the 1st post would be possible depending how you want the script to work. Here is 2 Gui using OnEvent mode expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) Opt("TrayIconDebug", 1) #Region ### Multiple INI sections GUI ### $Multi_GUI = GUICreate("Multiple Sections", 288, 162, 404, 313) $Multi_lv = GUICtrlCreateListView(" Select A Section", 8, 8, 270, 113, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, 0x101E, 0, 265) $MultiImport_btn = GUICtrlCreateButton("Import", 16, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') $MultiCancel_btn = GUICtrlCreateButton("Cancel", 104, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') $MultiDelete_btn = GUICtrlCreateButton("Delete", 192, 128, 75, 25, 0) GUICtrlSetOnEvent(-1, '_multi') GUISetState(@SW_HIDE) GUISetOnEvent($GUI_EVENT_CLOSE, '_multi') #EndRegion ### Multiple INI sections GUI ### #Region ### START Koda GUI section ### $Form1 = GUICreate("Dialog", 316, 233, 347, 263) GUISetIcon("D:\003.ico") $GroupBox1 = GUICtrlCreateGroup("", 8, 1, 297, 193) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("&OK", 65, 203, 75, 25, 0) GUICtrlSetOnEvent(-1, '_ShowGUI') $Button2 = GUICtrlCreateButton("&Cancel", 162, 203, 75, 25, 0) GUICtrlSetOnEvent(-1, 'DoExit') GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, 'DoExit') #EndRegion ### START Koda GUI section ### While 1 Sleep(10) WEnd Func _ShowGUI() GUISetState(@SW_DISABLE, $Form1) GUISetState(@SW_SHOW, $Multi_GUI) GUISwitch($Multi_GUI) EndFunc ;==>_ShowGUI Func _multi() MsgBox(0, '', 'Performing desired action'); perform some action GUISetState(@SW_ENABLE, $Form1) GUISetState(@SW_HIDE, $Multi_GUI) GUISwitch($Form1) EndFunc ;==>_multi Func DoExit() Exit EndFunc ;==>DoExitoÝ÷ Øw«z+5讲)à:q/z{f¡×ÝFº+¬xzËâ袨u殶sb6æ6ÇVFRfÇC´'WGFöä6öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´uT6öç7FçG4WæS2fwC°¢6æ6ÇVFRfÇCµ7FF46öç7FçG2æS2fwC°¢6æ6ÇVFRfÇCµvæF÷w46öç7FçG2æS2fwC°¢6æ6ÇVFRfÇC´wVÆ7EfWræS2fwC° ¤÷BgV÷C´uTöäWfVçDÖöFRgV÷C²Â¤÷BgV÷CµG&6öäFV'VrgV÷C²Â ¢5&Vvöâ222×VÇFÆRä6V7Föç2uT220¢b33c´×VÇFôuTÒuT7&VFRgV÷C´×VÇFÆR6V7Föç2gV÷C²Â#Âc"ÂCBÂ32¢b33c´×VÇFöÇbÒuT7G&Ä7&VFTÆ7EfWrgV÷C²6VÆV7B6V7FöâgV÷C²ÂÂÂ#sÂ2Â&Dõ"b33c´Åe5õ$Uõ%BÂb33c´Åe5õ4õu4TÄÅt2Â&Dõ"b33cµu5ôUô4ÄTåDTDtRÂb33c´Åe5ôUôu$DÄäU2Âb33c´Åe5ôUôeTÄÅ$õu4TÄT5B¤uT7G&Å6VæD×6rÓÂRÂÂ#cR¢b33c´×VÇF×÷'Eö'FâÒuT7G&Ä7&VFT'WGFöâgV÷C´×÷'BgV÷C²ÂbÂ#ÂsRÂ#R¢b33c´×VÇF6æ6VÅö'FâÒuT7G&Ä7&VFT'WGFöâgV÷C´6æ6VÂgV÷C²ÂBÂ#ÂsRÂ#R¢b33c´×VÇFFVÆWFUö'FâÒuT7G&Ä7&VFT'WGFöâgV÷C´FVÆWFRgV÷C²Â"Â#ÂsRÂ#R¤uT6WE7FFR5uôDR¢4VæE&Vvöâ222×VÇFÆRä6V7Föç2uT220 ¢5&Vvöâ2225D%B¶öFuT6V7Föâ220¢b33c´f÷&ÓÒuT7&VFRgV÷C´FÆörgV÷C²Â3bÂ#32Â3CrÂ#c2¤uT6WD6öâgV÷C´C¢b3#²b3C³2æ6ògV÷C²¢b33c´w&÷W&÷ÒuT7G&Ä7&VFTw&÷WgV÷C²gV÷C²ÂÂÂ#rÂ2¤uT7G&Ä7&VFTw&÷WgV÷C²gV÷C²ÂÓÂÓ¢b33c´'WGFöãÒuT7G&Ä7&VFT'WGFöâgV÷C²f×´ô²gV÷C²ÂcRÂ#2ÂsRÂ#R¤uT7G&Å6WDöäWfVçBÓÂb33µõ6÷tuTb33²¢b33c´'WGFöã"ÒuT7G&Ä7&VFT'WGFöâgV÷C²f×´6æ6VÂgV÷C²Âc"Â#2ÂsRÂ#R¤uT7G&Å6WDöäWfVçBÓÂb33´FôWBb33²¤uT6WE7FFR5uõ4õr¤uT6WDöäWfVçBb33c´uTôUdTåEô4Äõ4RÂb33´FôWBb33²¢4VæE&Vvöâ2225D%B¶öFuT6V7Föâ220 ¥vÆR¢6ÆVW¥tVæ@ ¤gVæ2õ6÷tuT ²7vF6Fò×VÇFwV¢uT6WE7FFR5uôD4$ÄRÂb33c´f÷&Ó¢uT6WE7FFR5uõ4õrÂb33c´×VÇFôuT¢uT7vF6b33c´×VÇFôuT ÷BgV÷C´uTöäWfVçDÖöFRgV÷C²Â¢Fð¢b33c¶×6rÒuTvWD×6r 7vF6b33c¶×6u³Ð 66Rb33c´×VÇF×÷'Eö'Fà ö×VÇF WDÆö÷ 66Rb33c´×VÇF6æ6VÅö'Fà ö×VÇF WDÆö÷ 66Rb33c´×VÇFFVÆWFUö'Fà ö×VÇF WDÆö÷ VæE7vF6¢VçFÂb33c¶×6u³ÒÒb33c´uTôUdTåEô4Äõ4P ²7vF6Fòf÷&Ó ÷BgV÷C´uTöäWfVçDÖöFRgV÷C²Â uT7vF6b33c´f÷&Ó uT6WE7FFR5uôTä$ÄRÂb33c´f÷&Ó¢uT6WE7FFR5uôDRÂb33c´×VÇFôuT¤VæDgVæ2³ÓÒfwCµõ6÷tuT ¤gVæ2ö×VÇF¢×6t&÷Âb33²b33²Âb33µW&f÷&ÖærFW6&VB7Föâb33²²W&f÷&Ò6öÖR7Föà¤VæDgVæ2³ÓÒfwCµö×VÇF ¤gVæ2FôWB¢W@¤VæDgVæ2³ÓÒfwC´FôW Link to comment Share on other sites More sharing options...
benners Posted March 26, 2008 Author Share Posted March 26, 2008 These may give you some kind of base to work with. I am not sure exactly what you want but your question in the 1st post would be possible depending how you want the script to work. Here is 1 Gui using OnEvent mode and 1 Gui using MessageLoop mode Hi MHz Thanks for the reply. the 1 Gui using OnEvent mode and 1 Gui using MessageLoop mode code worked best. I changed the check for exiting the loop and added the rest of the code and the loop works as desired, I was trying to use the Adlibenable functionality without minimal success until your code. The final piece is below expandcollapse popupDo $msg = GUIGetMsg(1) $win = WinGetState('Multiple Sections'); Get the status of the Multiple Sections window. Switch $msg[0] Case $MultiImport_btn If _GUICtrlListView_GetSelectedIndices($Multi_lv) <> '' Then; Import button pressed and item selected. $CurIndex = _GUICtrlListView_GetSelectedIndices($Multi_lv, True); Get the indexes of the selected items. If $CurIndex[0] > 1 Then; More than 1 name seleted. MsgBox(16, 'Greedy', 'Please select only one Section to import.') Else $Section = _GUICtrlListView_GetItemText($Multi_lv, $CurIndex[1]); Set the first selected section name. Switch_gui() Check_INI($Section) ExitLoop EndIf EndIf Case $MultiCancel_btn Switch_gui() ExitLoop Case $MultiDelete_btn $var = _GUICtrlListView_GetSelectedIndices($Multi_lv, True) If $var[0] = 0 Then; No items selected. MsgBox(16, 'Make A Selection', 'There are no items selected for deletion', 3) Else; Items sre selected For $i = 1 To $var[0]; Delete selected sections from the ini. IniDelete($OI_INI, _GUICtrlListView_GetItemText($Multi_lv, $var[$i])) Next _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($Multi_lv)); Delete selected items from the listview. EndIf If _GUICtrlListView_GetItemCount($Multi_lv) = 0 Then; File has no sections. FileDelete($OI_INI); Delete the ini (easy clear of blank lines). FileClose(FileOpen($OI_INI, 2)); Create a blank one. Switch_gui() ExitLoop EndIf EndSwitch Until Not BitAND(WinGetState("Multiple Sections"), 2); loop until the window is not visible. 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