api captura ventana error???
Publicado por felo (8 intervenciones) el 16/04/2010 14:16:10
hola a todos, tengo este error y me pregunto si me pudieran dar una ayuda
Option Explicit
Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (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 GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wFlag As Long) As Long
Private Const GW_HWNDFIRST = 0&
Private Const GW_HWNDNEXT = 2&
Private Const GW_CHILD = 5&
Private Sub CommandButton1_Click()
Dim buf As Long, handle As Long, titulo As String, lenT As Long, ret As Long
handle = GetWindow(hWnd, GW_HWNDFIRST)
lenT = GetWindowTextLength(handle)
titulo = String$(lenT, 0)
ret = GetWindowText(handle, titulo, lenT + 1)
titulo$ = Left$(titulo, ret)
Application.Dialogs(xlDialogSendMail).Show
AppActivate titulo$
SendKeys "NOMBRE"
End Sub
resumiendo lo que intento hacer es capturar el nombre de la ventana que en ese momento tiene el foco, o esta activa, asi como esta el codigo, cuando lo ejecuto me dice que la variable hWnd no esta declarada, sera que tengo que activar alguna referencia, me pueden ayudar, en access si me funciona pero no en excell, muchas gracias y saludos
Option Explicit
Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (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 GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wFlag As Long) As Long
Private Const GW_HWNDFIRST = 0&
Private Const GW_HWNDNEXT = 2&
Private Const GW_CHILD = 5&
Private Sub CommandButton1_Click()
Dim buf As Long, handle As Long, titulo As String, lenT As Long, ret As Long
handle = GetWindow(hWnd, GW_HWNDFIRST)
lenT = GetWindowTextLength(handle)
titulo = String$(lenT, 0)
ret = GetWindowText(handle, titulo, lenT + 1)
titulo$ = Left$(titulo, ret)
Application.Dialogs(xlDialogSendMail).Show
AppActivate titulo$
SendKeys "NOMBRE"
End Sub
resumiendo lo que intento hacer es capturar el nombre de la ventana que en ese momento tiene el foco, o esta activa, asi como esta el codigo, cuando lo ejecuto me dice que la variable hWnd no esta declarada, sera que tengo que activar alguna referencia, me pueden ayudar, en access si me funciona pero no en excell, muchas gracias y saludos
Valora esta pregunta


0