Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need a way to auto. answer a msgbox

Posted on 2004-09-07
3
Medium Priority
?
264 Views
Last Modified: 2006-11-17
hello again all, Im writing a program that interacts with professional software to fix an error we are experiencing with the  current version.  My fix calls the FindWindow function in combination with Sendmessage to close a window given its specific application handle.  The problem is, while running this fix I discovered that the professional software I am trying to close through my "fix" requires secondary close confirmation via a popup window upon termination.  I could theoretically use the same process to close this new window as I did the origional, unfortunately the handle name does not appear in the task list.  Does anyone out there know how to either i, write an intstruction that tells the popup window to automatically click "Yes" to close the app or ii, find a way to address this window without knowing its name?  The problem is I have multiple (sometimes) other processes running in the background that would cause me other problems if they were accidentally closed by a close-all type function.  
P.S. I should mention that this fix of mine is written in VB6

 here is the FindWindow and Sendmessage code:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Function CloseApp()
Dim m As Long
    m = FindWindow(vbNullString, ApplicationName)
    SendMessage m, WM_CLOSE, 0, 0
End Function


Thanks in advance for any help/advice received
0
Comment
Question by:gwosgood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 750 total points
ID: 12001504
This sample may be what you are looking for:

"Safely Shut Down a Running Application"
http://www.thescarms.com/vbasic/StopProcess.asp
0
 
LVL 2

Author Comment

by:gwosgood
ID: 12006591
does anyone know if WM_DESTROY releases the applications resources upon execution?
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12006921
It's up to the application to free memory objects and tidy up before terminating.  This is usually done in the WM_DESTROY message handler.

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question