Solved

Closing a window based on caption

Posted on 2004-08-11
2
342 Views
Last Modified: 2010-04-17
I need a clean way of closing a window based on the caption of the window.
For instance, if I want to close a window that has the word "DELETE" in it, how do I set that up?
0
Comment
Question by:robbperk
2 Comments
 
LVL 4

Accepted Solution

by:
cg_medistox earned 50 total points
ID: 11778886
Dim lHandle As Long
Dim lRez As Long

   Do
         ' Find the Menu window id.
      lHandle = FindWindow(vbNullString, "*Microsoft Outlook*")
         ' Kill it once
      If lHandle Then
         lRez = SendMessage(lHandle, WM_CLOSE, 0, 0)
         ' Kill it again in case didnt close
         lRez = SendMessage(lHandle, WM_DESTROY, 0, 0)
      End If 'lHandle
   Loop While lHandle <> 0

Change the Microsoft Outlook with what you need in there. This code is based on VB6 SP6
0
 
LVL 22

Expert Comment

by:cookre
ID: 11779860
You may need:

Private Const WM_DESTROY = &H02
Private Const WM_CLOSE = &H10
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now