Galstaph Posted September 28, 2009 Share Posted September 28, 2009 I am currently writing a script that will close an open application. There are multiple modal forms that this application can pop open (about 60) and if any of the forms are popped then my close script fails to close the application. What I am looking for is help in determining a relationship between the Parent window and the child modal form, and how I would go about to select the modal (child) form to close it. Thanks in advance for your help. Link to comment Share on other sites More sharing options...
Mecrazycoder Posted September 28, 2009 Share Posted September 28, 2009 I am currently writing a script that will close an open application. There are multiple modal forms that this application can pop open (about 60) and if any of the forms are popped then my close script fails to close the application. What I am looking for is help in determining a relationship between the Parent window and the child modal form, and how I would go about to select the modal (child) form to close it. Thanks in advance for your help.I am not sure, but did you try ProcessClose() [size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent] Link to comment Share on other sites More sharing options...
Galstaph Posted September 28, 2009 Author Share Posted September 28, 2009 Yes, that would work, but I would like to exit the application somewhat gracefully and just closing the application with a kill could corrupt the database. Link to comment Share on other sites More sharing options...
Mecrazycoder Posted September 28, 2009 Share Posted September 28, 2009 (edited) Yes, that would work, but I would like to exit the application somewhat gracefully and just closing the application with a kill could corrupt the database.Oh...then you want to close all the child windows and finally parent window. Is my understanding right? Edited September 28, 2009 by Mecrazycoder [size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent] Link to comment Share on other sites More sharing options...
Galstaph Posted September 28, 2009 Author Share Posted September 28, 2009 Oh...then you want to close all the child windows and finally parent window. Is my understanding right?Correct. Link to comment Share on other sites More sharing options...
Mecrazycoder Posted September 28, 2009 Share Posted September 28, 2009 Correct.Can you please look into WinExists,WinKill in help file. [size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent] Link to comment Share on other sites More sharing options...
Galstaph Posted September 28, 2009 Author Share Posted September 28, 2009 Yes, those work quite well, but as I said, there are some 60 forms to check for that are modally displayed for the WinExists. WinKill would work, but again I do not want to just terminate the process. Is there some way to check through the displayed forms and strike !{F4} on each of the ones that are children of an existing application? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 28, 2009 Moderators Share Posted September 28, 2009 Galstaph ,I have used something like this before to kill multiple children before ending the main app gracefully. It might help:; get process ID and main window handle for the app $iApp_Process = WinGetProcess("The_App_You_Are_Using") $iApp_Window = WinGetHandle("The_App_You_Are_Using") ; List all windows $aWinList = WinList() ; See which windows are linked to your process For $i = 1 To $aWinList[0][0] $iProcess = WinGetProcess($aWinList[$i][1]) If $iProcess = $iMy_Process Then ; Kill all except the main window If $aWinList[$i][0] <> $iApp_Window Then WinKill($aWinList[$i][0]) EndIf Next ; Close app normallyI did have problems with apps that opened a lot of windows on start - the app crashed when any of them were closed. The solution was to run an earlier WinList and then check against all of those found when killing extras at the end. (I hope that is clear )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...
Galstaph Posted September 29, 2009 Author Share Posted September 29, 2009 Galstaph , I have used something like this before to kill multiple children before ending the main app gracefully. It might help: ; get process ID and main window handle for the app $iApp_Process = WinGetProcess("The_App_You_Are_Using") $iApp_Window = WinGetHandle("The_App_You_Are_Using") ; List all windows $aWinList = WinList() ; See which windows are linked to your process For $i = 1 To $aWinList[0][0] $iProcess = WinGetProcess($aWinList[$i][1]) If $iProcess = $iMy_Process Then ; Kill all except the main window If $aWinList[$i][0] <> $iApp_Window Then WinKill($aWinList[$i][0]) EndIf Next ; Close app normally I did have problems with apps that opened a lot of windows on start - the app crashed when any of them were closed. The solution was to run an earlier WinList and then check against all of those found when killing extras at the end. (I hope that is clear ) M23 Thanks for that, it worked wonderfully. That was exactly what I needed. 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