첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

▶ Module

Public Const NV_CLOSEMSGBOX As Long = &H5000&

Public MessageTitle As String

Declare Function SetForegroundWindow Lib "user32" (ByVal pWindowHandle As Long) As Long

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal strClassName As String, ByVal strWindowName As String) As Long

Declare Function SetTimer Lib "user32" (ByVal pWindowHandle As Long, ByVal lIDEvent As Long, ByVal lElapse As Long, ByVal lTimerFunction As Long) As Long

Declare Function KillTimer Lib "user32" (ByVal pWindowHandle As Long, ByVal lIDEvent As Long) As Long

Public Sub TimerProcedure(ByVal pWindowHandle As Long, ByVal lMessage As Long, ByVal lIDEvent As Long, ByVal lTime As Long)
    
    Dim lMessageBoxHandle As Long
    
    KillTimer pWindowHandle, lIDEvent
    
    lMessageBoxHandle = FindWindow("#32770", MessageTitle)
    
    If lMessageBoxHandle Then
        
        Call SetForegroundWindow(lMessageBoxHandle)
        
        SendKeys "{enter}"
    
    End If

End Sub

 

728x90

 

▶ Form

Private Sub Command1_Click()
    
    Dim pWindowHandle As Long
    
    SetTimer pWindowHandle, NV_CLOSEMSGBOX, 3000, AddressOf TimerProcedure

    MessageTitle = "메세지박스 자동 종료"
    
    MsgBox "3초후 메세지박스가 종료됩니다", vbInformation, MessageTitle
    
End Sub

 

728x90
그리드형(광고전용)
Posted by icodebroker
,