Que tal,
Estoy buscando un codigo que al abrir una ventana.. me cierre la misma ventana despues de cierto tiempo por ejemplo 10seg.
Espero y me puedan ayudar...
saludos.
Que tal,
Estoy buscando un codigo que al abrir una ventana.. me cierre la misma ventana despues de cierto tiempo por ejemplo 10seg.
Espero y me puedan ayudar...
saludos.
Prueba con esto, solo necesitas agregar un timer al formulario
Este ejemplo te abre la calculadora y transcurridos 10 segundos la cierra
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const SC_CLOSE = &HF060&
Private Const WM_SYSCOMMAND = &H112
Private Sub Form_Load()
Shell "calc.exe"
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim hWnd As Long
Static Segundos As Integer 'Variable del contador de segundos
Segundos = Segundos + 1
If Segundos = 10 Then
hWnd = FindWindow(vbNullString, "Calculadora") 'Calculadora es el titulo de la ventana
Call SendMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, ByVal 0&)
End If
End Sub
Perdona que te rectifique, pero se me antoja mas simple hacer End dentro del timer con un intervalo de 10000
Código:
Private Sub Timer1_Timer() End End Sub