Solved

Retreive hWnd without FindWindow?

Posted on 2007-04-09
6
717 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
  • 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…

706 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

14 Experts available now in Live!

Get 1:1 Help Now