Solved

Retreive hWnd without FindWindow?

Posted on 2007-04-09
6
736 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

752 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