Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) _
As Long
Enum ShoeHide
SH_HIDE = (0)
SH_SHOW = (1)
End Enum
Private Function GetHwndFromCursor() As Long
Dim p As POINTAPI, K$, j$
K = GetCursorPos(p)
GetHwndFromCursor = WindowFromPoint(p.X, p.Y)
End Function
Public Function SHProg(ByVal strName As String, SH As ShoeHide)
On Error Resume Next
Dim lngBuf As Long
lngBuf = FindWindow(vbNullString, strName)
Call ShowWindow(lngBuf, SH)
End Function
Private Sub Timer1_Timer()
Dim HwndControl As Long
Dim hWndParentA As Long
Dim hWndParent As Long
Dim CaptionWinLen As Long
Dim CaptionWin As String
Dim ClassWin As String
Dim ClassWinLen As Long
HwndControl = GetHwndFromCursor
hWndParent = HwndControl
Do
hWndParentA = hWndParent
hWndParent = GetParent(hWndParentA)
Loop Until hWndParent = 0
CaptionWinLen = (GetWindowTextLength(hWndParentA)) + 1
CaptionWin = String(CaptionWinLen, Chr(0))
Call GetWindowText(hWndParentA, CaptionWin, CaptionWinLen)
ClassWin = String$(32, Chr(0))
ClassWinLen = GetClassName(hWndParentA, ClassWin, 32)
ClassWin = Left(ClassWin, ClassWinLen)
'Program Manager
'NotesX
If CStr("InqSoft Window Scanner") = CStr(CaptionWin) Then MsgBox ("ggggg")
Text1.Text = Text1.Text + vbNewLine + CaptionWin
' Form1.Caption = CaptionWin
End Sub