Solved

Retreive hWnd without FindWindow?

Posted on 2007-04-09
6
733 Views
Last Modified: 2013-11-27
I swear I was using a built-in VBA function last week to find out if an application was already running before launching it with the shell function.
The problem is I've lost that work and I can't remember what the function was called.

It's not FindWindow

And as I recall it was a simple built-in VBA function that returned the hWnd of a window as long, by any portion of the application's caption.

That is, it would return a hWnd for the application "Mainframe Session 3 - Microsoft Internet Explorer" if you did function("mainframe session 3")

All I really need to do is find out if an application is already running based on the title bar text, if it is make it active, if it isn't launch it and make it active.
0
Comment
Question by:efedora
[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
  • 3
  • 3
6 Comments
 
LVL 38

Accepted Solution

by:
Jim P. earned 500 total points
ID: 18876160
This it?
-----------------------------------------
Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
        ByVal lpClassName As Any, _
        ByVal lpWindowName As Any) As Long
0
 
LVL 1

Author Comment

by:efedora
ID: 18876207
no it was a function you can call directly in vba.

using findwindow in a module doesn't appear to work with only part of a caption
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 18876224
It won't -- you have to have an exact match.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:efedora
ID: 18876234
ok.
so I know I can activate an app with a partial title string using AppActivate(), is there a comparable function to retreive a handle or title string from a partial title string?

0
 
LVL 1

Author Comment

by:efedora
ID: 18876452
oh well i guess it can't be done more simply. i am just going to use findwindow. thanks
0
 
LVL 38

Expert Comment

by:Jim P.
ID: 18876574
Glad to be of assistance. May all your days get brighter and brighter.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

749 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