Jump to content

Closing Modal Forms


Galstaph
 Share

Recommended Posts

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

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

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]

Link to comment
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?

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...