office交流网--QQ交流群号

Access培训群:792054000         Excel免费交流群群:686050929          Outlook交流群:221378704    

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

API获取其它程序如记事本的弹出消息框

2017-09-17 09:00:00
zstmtony
原创
3835

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

分享