Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing for an open window/app and minimizing it

Status
Not open for further replies.

imjbhowe

IS-IT--Management
Jul 26, 2001
18
0
0
US
I am trying to have some vb code that will minimize an app if it is open. The title of the app is consistent and I don't necessarily need to test for it because it will be open, I just need to minimize it.

Thanks in advance.
 
You can use the API:
Code:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long


Sub HideWindow()
  Dim sAppTitle As String
  sAppTitle = "Title in window goes here"
  hwnd = FindWindow(vbNullString, sAppTitle)          
  If hwnd <> 0 Then Call ShowWindow(hwnd, vbMinimizedFocus)
End Sub
 
Thanks for the help but I am still having some issues.

I am always getting a number for the handle, I did a test for window name &quot;Minesweeper&quot; and even if it isn't open it still gives a handle value and not a 0 like I am assuming it should.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top