Sign in to follow this  
Followers 0
Galstaph

Closing Modal Forms

9 posts in this topic

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.

Share this post


Link to post
Share on other sites



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]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Mecrazycoder

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

Share this post


Link to post
Share on other sites

Oh...then you want to close all the child windows and finally parent window. Is my understanding right?

Correct.

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 :D )

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 :D )

M23

Thanks for that, it worked wonderfully. That was exactly what I needed.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0