|
-
Apr 24th, 2006, 01:32 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Find window state of another application
Hi,
I would like to find whether another application (third party application) is in which state?
Whether it is hidden or minimized or maximized or normal, etc.
Thanks in advance.
-
Apr 24th, 2006, 02:56 PM
#2
Re: Find window state of another application
There may be other ways, but this should work:
VB Code:
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function GetWindowPlacement Lib "user32" ( _
ByVal hWnd As Long, _
lpwndpl As WINDOWPLACEMENT) As Long
Private Const SW_NORMAL As Long = 1
Private Const SW_MINIMIZE As Long = 6
Private Const SW_MAXIMIZE As Long = 3
Private Function GetWindowState(ByVal lhWnd As Long) As FormWindowStateConstants
Dim winPLACE As WINDOWPLACEMENT
winPLACE.Length = Len(winPLACE)
GetWindowPlacement lhWnd, winPLACE
Select Case winPLACE.showCmd
Case SW_MINIMIZE
GetWindowState = vbMinimized
Case SW_MAXIMIZE
GetWindowState = vbMaximized
End Select
End Function
-
Apr 14th, 2013, 05:09 AM
#3
Lively Member
Re: Find window state of another application
Ok, I am a little late for this question, I know...
But it might help all, who find this thead via a web search. 
 Originally Posted by bushmobile
There may be other ways
Yes, the most simple way would probably to use following API functions:
Code:
Private Declare Function IsZoomed Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Declare Function IsIconic Lib "user32.dll" (ByVal hWnd As Long) As Long
-
Apr 14th, 2013, 09:32 AM
#4
Re: [RESOLVED] Find window state of another application
Yet another way is by checking the Window Style bits:
Code:
Private Const GWL_STYLE As Long = (-16&) 'Retrieves the window styles.
Private Const WS_MAXIMIZE As Long = &H1000000 'The window is initially maximized.
Private Const WS_MINIMIZE As Long = &H20000000 'The window is initially minimized.
Private Const WS_VISIBLE As Long = &H10000000 'The window is initially visible.
Private Declare Function GetWindowLongW Lib "user32.dll" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Function IsIconic(ByVal hWnd As Long) As Boolean
IsIconic = ((GetWindowLongW(hWnd, GWL_STYLE) And WS_MINIMIZE) = WS_MINIMIZE)
End Function
Private Function IsWindowVisible(ByVal hWnd As Long) As Boolean
IsWindowVisible = ((GetWindowLongW(hWnd, GWL_STYLE) And WS_VISIBLE) = WS_VISIBLE)
End Function
Private Function IsZoomed(ByVal hWnd As Long) As Boolean
IsZoomed = ((GetWindowLongW(hWnd, GWL_STYLE) And WS_MAXIMIZE) = WS_MAXIMIZE)
End Function
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|