• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 742
  • Last Modified:

Retreive hWnd without FindWindow?

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
efedora
Asked:
efedora
  • 3
  • 3
1 Solution
 
Jim P.Commented:
This it?
-----------------------------------------
Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
        ByVal lpClassName As Any, _
        ByVal lpWindowName As Any) As Long
0
 
efedoraAuthor Commented:
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
 
Jim P.Commented:
It won't -- you have to have an exact match.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
efedoraAuthor Commented:
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
 
efedoraAuthor Commented:
oh well i guess it can't be done more simply. i am just going to use findwindow. thanks
0
 
Jim P.Commented:
Glad to be of assistance. May all your days get brighter and brighter.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now