office交流網--QQ交流群號

Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

API穫取其牠程序如記事本的彈齣消息框

2017-09-17 09:00:00
zstmtony
原創
3626

API穫取其牠程序如記事本的彈齣消息框

Public Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Const GW_CHILD = 5
Public Const GW_HWNDFIRST = 0
Public Const GW_HWNDLAST = 1
Public Const GW_HWNDNEXT = 2
Public Const GW_HWNDPREV = 3
Public Const GW_OWNER = 4
Public Const GW_ENABLEDPOPUP = 6
Public Declare Function GetLastActivePopup Lib "user32" (ByVal hwndOwnder As Long) As Long

Public hNotepad As Long, hPopup As Long
'===========================================
    hNotepad = FindWindow("Notepad", vbNullString)
    If IsWindow(hNotepad) Then
        'method 1st
        hPopup = GetWindow(hNotepad, GW_ENABLEDPOPUP)
        Debug.Assert hPopup <> 0 'popup window found
        'method 2ed
        hPopup = GetLastActivePopup(hNotepad)
        Debug.Assert hPopup <> hNotepad 'popup window found
    End If

分享