SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
Option Explicit
' funciones Api
Private Declare Function SendMessageAsLong Lib "user32" _
Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long _
) As Long
Private Declare Function SendMessageAsString Lib "user32" _
Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String _
) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
' Constante para los mensajes
' Recupera en un buffer el texto de la linea
Private Const EM_GETLINE As Long = &HC4
' Recupera la cantidad de lineas
Private Const EM_GETLINECOUNT As Long = &HBA
' Hwnd de la ventana
Dim ret As Long
Public Function Obtener_Texto(Hwnd_Ventana As Long) As String
Dim i As Long
Dim n As Long
Dim temp As String
' Cantidad de lineas
n = SendMessageAsLong(Hwnd_Ventana, EM_GETLINECOUNT, 0, 0)
' Recorre todas las lineas y obtiene el texto de _
la linea actual con la función Leer_Linea
For i = 1 To n
temp = temp & Leer_Linea(Hwnd_Ventana, i - 1) & vbCrLf
Next
Obtener_Texto = temp
End Function
' Retorna el texto de la linea indicada
Private Function Leer_Linea(Hwnd_Ventana As Long, Numero_Linea As Long) As String
Const MAX_CHAR_PER_LINE As Long = 80
Dim Lo As Integer
Dim Hi As Integer
Dim ret As Long
Dim Buffer As String
Lo = MAX_CHAR_PER_LINE And (255)
Hi = Int(MAX_CHAR_PER_LINE / 256)
Buffer = Chr$(Lo) + Chr$(Hi) + Space$(MAX_CHAR_PER_LINE - 2)
' Recupera el texto en el Buffer, de la linea indicada en Numero_Linea.
ret = SendMessageAsString(Hwnd_Ventana, EM_GETLINE, Numero_Linea, Buffer)
' Retorna la linea
Leer_Linea = Left$(Buffer, ret)
End Function
' Botón para recuperar el hwnd
Private Sub Command1_Click()
' Recupera el Hwnd del bloc de notas ( Handle del Edit )
ret = FindWindowEx(FindWindow(vbNullString, "Sin título - bloc de notas"), _
0, "Edit", vbNullString)
If ret = 0 Then
MsgBox "Error. El Hwnd es 0 ", vbCritical
Else
MsgBox "Hwnd del Edit del Notepad es: " & ret, vbInformation
Command2.Enabled = True
Command1.Enabled = False
End If
End Sub
' Botón que recupera el texto
Private Sub Command2_Click()
If ret = 0 Then
MsgBox "error. El Hwnd es 0", vbCritical
Else
' Muestra el texto del otepad en el textbox
Text1 = Obtener_Texto(ret)
End If
End Sub
Private Sub Form_Load()
Command1.Caption = " Obtener Hwnd del bloc de notas "
Command2.Caption = " Obtener el Texto "
Command2.Enabled = False
MsgBox " 1 - Abrir el Bloc de notas. " & vbNewLine & _
" 2 - Dejarle el caption -->> Sin Título - Bloc de notas " & vbNewLine &
_
" 3 - Escribir algún texto y luego presionar el botón [ Obtener Hwnd del
bloc de notas ]" & vbNewLine & _
" 4 - Presionar el botón [ Obtener texto ]", vbInformation
End Sub

Más contenido relacionado

Destacado

F 0796 nishit
F 0796 nishitF 0796 nishit
F 0796 nishit9nishit
 
台灣省政府中興新村
台灣省政府中興新村台灣省政府中興新村
台灣省政府中興新村family
 
心臟血管通暢
心臟血管通暢心臟血管通暢
心臟血管通暢family
 
豆漿的好處與禁忌
豆漿的好處與禁忌豆漿的好處與禁忌
豆漿的好處與禁忌family
 

Destacado (6)

F 0796 nishit
F 0796 nishitF 0796 nishit
F 0796 nishit
 
De les van de vlinder
De les van de vlinderDe les van de vlinder
De les van de vlinder
 
Wa Pcc En
Wa Pcc EnWa Pcc En
Wa Pcc En
 
台灣省政府中興新村
台灣省政府中興新村台灣省政府中興新村
台灣省政府中興新村
 
心臟血管通暢
心臟血管通暢心臟血管通暢
心臟血管通暢
 
豆漿的好處與禁忌
豆漿的好處與禁忌豆漿的好處與禁忌
豆漿的好處與禁忌
 

Similar a Documento sin título

Similar a Documento sin título (17)

Practicas
PracticasPracticas
Practicas
 
Fonciones de cadenas
Fonciones de cadenasFonciones de cadenas
Fonciones de cadenas
 
Funciones de cadena
Funciones de cadenaFunciones de cadena
Funciones de cadena
 
Fonciones de cadenas
Fonciones de cadenasFonciones de cadenas
Fonciones de cadenas
 
Funciones
FuncionesFunciones
Funciones
 
Funciones
FuncionesFunciones
Funciones
 
Funciones propias de visual basic
Funciones propias de visual basicFunciones propias de visual basic
Funciones propias de visual basic
 
Codigo proceso
Codigo procesoCodigo proceso
Codigo proceso
 
Codigo proceso
Codigo procesoCodigo proceso
Codigo proceso
 
Unidad6 funciones
Unidad6 funcionesUnidad6 funciones
Unidad6 funciones
 
Comandos de Raptor, Java y C# Sharp
Comandos de Raptor, Java y C# SharpComandos de Raptor, Java y C# Sharp
Comandos de Raptor, Java y C# Sharp
 
Python3000
Python3000Python3000
Python3000
 
Ejercicios resueltos con Python
Ejercicios resueltos con PythonEjercicios resueltos con Python
Ejercicios resueltos con Python
 
Cristinagananparedes
CristinagananparedesCristinagananparedes
Cristinagananparedes
 
Separata java script
Separata java scriptSeparata java script
Separata java script
 
Computacion funciones definidas por el programador
Computacion funciones definidas por el programadorComputacion funciones definidas por el programador
Computacion funciones definidas por el programador
 
Funciones de cadenas
Funciones de cadenasFunciones de cadenas
Funciones de cadenas
 

Último

Qué es la Inteligencia artificial generativa
Qué es la Inteligencia artificial generativaQué es la Inteligencia artificial generativa
Qué es la Inteligencia artificial generativaDecaunlz
 
GUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdf
GUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdfGUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdf
GUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdfPaolaRopero2
 
FORTI-MAYO 2024.pdf.CIENCIA,EDUCACION,CULTURA
FORTI-MAYO 2024.pdf.CIENCIA,EDUCACION,CULTURAFORTI-MAYO 2024.pdf.CIENCIA,EDUCACION,CULTURA
FORTI-MAYO 2024.pdf.CIENCIA,EDUCACION,CULTURAEl Fortí
 
Dinámica florecillas a María en el mes d
Dinámica florecillas a María en el mes dDinámica florecillas a María en el mes d
Dinámica florecillas a María en el mes dstEphaniiie
 
Planificacion Anual 2do Grado Educacion Primaria 2024 Ccesa007.pdf
Planificacion Anual 2do Grado Educacion Primaria   2024   Ccesa007.pdfPlanificacion Anual 2do Grado Educacion Primaria   2024   Ccesa007.pdf
Planificacion Anual 2do Grado Educacion Primaria 2024 Ccesa007.pdfDemetrio Ccesa Rayme
 
ACUERDO MINISTERIAL 078-ORGANISMOS ESCOLARES..pptx
ACUERDO MINISTERIAL 078-ORGANISMOS ESCOLARES..pptxACUERDO MINISTERIAL 078-ORGANISMOS ESCOLARES..pptx
ACUERDO MINISTERIAL 078-ORGANISMOS ESCOLARES..pptxzulyvero07
 
TEMA 13 ESPAÑA EN DEMOCRACIA:DISTINTOS GOBIERNOS
TEMA 13 ESPAÑA EN DEMOCRACIA:DISTINTOS GOBIERNOSTEMA 13 ESPAÑA EN DEMOCRACIA:DISTINTOS GOBIERNOS
TEMA 13 ESPAÑA EN DEMOCRACIA:DISTINTOS GOBIERNOSjlorentemartos
 
Ejercicios de PROBLEMAS PAEV 6 GRADO 2024.pdf
Ejercicios de PROBLEMAS PAEV 6 GRADO 2024.pdfEjercicios de PROBLEMAS PAEV 6 GRADO 2024.pdf
Ejercicios de PROBLEMAS PAEV 6 GRADO 2024.pdfMaritzaRetamozoVera
 
origen y desarrollo del ensayo literario
origen y desarrollo del ensayo literarioorigen y desarrollo del ensayo literario
origen y desarrollo del ensayo literarioELIASAURELIOCHAVEZCA1
 
TECNOLOGÍA FARMACEUTICA OPERACIONES UNITARIAS.pptx
TECNOLOGÍA FARMACEUTICA OPERACIONES UNITARIAS.pptxTECNOLOGÍA FARMACEUTICA OPERACIONES UNITARIAS.pptx
TECNOLOGÍA FARMACEUTICA OPERACIONES UNITARIAS.pptxKarlaMassielMartinez
 
Heinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativoHeinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativoFundación YOD YOD
 
Sesión de aprendizaje Planifica Textos argumentativo.docx
Sesión de aprendizaje Planifica Textos argumentativo.docxSesión de aprendizaje Planifica Textos argumentativo.docx
Sesión de aprendizaje Planifica Textos argumentativo.docxMaritzaRetamozoVera
 
La empresa sostenible: Principales Características, Barreras para su Avance y...
La empresa sostenible: Principales Características, Barreras para su Avance y...La empresa sostenible: Principales Características, Barreras para su Avance y...
La empresa sostenible: Principales Características, Barreras para su Avance y...JonathanCovena1
 
Ley 21.545 - Circular Nº 586.pdf circular
Ley 21.545 - Circular Nº 586.pdf circularLey 21.545 - Circular Nº 586.pdf circular
Ley 21.545 - Circular Nº 586.pdf circularMooPandrea
 
OCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VS
OCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VSOCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VS
OCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VSYadi Campos
 
Éteres. Química Orgánica. Propiedades y reacciones
Éteres. Química Orgánica. Propiedades y reaccionesÉteres. Química Orgánica. Propiedades y reacciones
Éteres. Química Orgánica. Propiedades y reaccionesLauraColom3
 
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...Carlos Muñoz
 
CALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDADCALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDADauxsoporte
 

Último (20)

Qué es la Inteligencia artificial generativa
Qué es la Inteligencia artificial generativaQué es la Inteligencia artificial generativa
Qué es la Inteligencia artificial generativa
 
GUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdf
GUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdfGUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdf
GUIA DE CIRCUNFERENCIA Y ELIPSE UNDÉCIMO 2024.pdf
 
FORTI-MAYO 2024.pdf.CIENCIA,EDUCACION,CULTURA
FORTI-MAYO 2024.pdf.CIENCIA,EDUCACION,CULTURAFORTI-MAYO 2024.pdf.CIENCIA,EDUCACION,CULTURA
FORTI-MAYO 2024.pdf.CIENCIA,EDUCACION,CULTURA
 
Dinámica florecillas a María en el mes d
Dinámica florecillas a María en el mes dDinámica florecillas a María en el mes d
Dinámica florecillas a María en el mes d
 
Planificacion Anual 2do Grado Educacion Primaria 2024 Ccesa007.pdf
Planificacion Anual 2do Grado Educacion Primaria   2024   Ccesa007.pdfPlanificacion Anual 2do Grado Educacion Primaria   2024   Ccesa007.pdf
Planificacion Anual 2do Grado Educacion Primaria 2024 Ccesa007.pdf
 
Fe contra todo pronóstico. La fe es confianza.
Fe contra todo pronóstico. La fe es confianza.Fe contra todo pronóstico. La fe es confianza.
Fe contra todo pronóstico. La fe es confianza.
 
ACUERDO MINISTERIAL 078-ORGANISMOS ESCOLARES..pptx
ACUERDO MINISTERIAL 078-ORGANISMOS ESCOLARES..pptxACUERDO MINISTERIAL 078-ORGANISMOS ESCOLARES..pptx
ACUERDO MINISTERIAL 078-ORGANISMOS ESCOLARES..pptx
 
TEMA 13 ESPAÑA EN DEMOCRACIA:DISTINTOS GOBIERNOS
TEMA 13 ESPAÑA EN DEMOCRACIA:DISTINTOS GOBIERNOSTEMA 13 ESPAÑA EN DEMOCRACIA:DISTINTOS GOBIERNOS
TEMA 13 ESPAÑA EN DEMOCRACIA:DISTINTOS GOBIERNOS
 
Medición del Movimiento Online 2024.pptx
Medición del Movimiento Online 2024.pptxMedición del Movimiento Online 2024.pptx
Medición del Movimiento Online 2024.pptx
 
Ejercicios de PROBLEMAS PAEV 6 GRADO 2024.pdf
Ejercicios de PROBLEMAS PAEV 6 GRADO 2024.pdfEjercicios de PROBLEMAS PAEV 6 GRADO 2024.pdf
Ejercicios de PROBLEMAS PAEV 6 GRADO 2024.pdf
 
origen y desarrollo del ensayo literario
origen y desarrollo del ensayo literarioorigen y desarrollo del ensayo literario
origen y desarrollo del ensayo literario
 
TECNOLOGÍA FARMACEUTICA OPERACIONES UNITARIAS.pptx
TECNOLOGÍA FARMACEUTICA OPERACIONES UNITARIAS.pptxTECNOLOGÍA FARMACEUTICA OPERACIONES UNITARIAS.pptx
TECNOLOGÍA FARMACEUTICA OPERACIONES UNITARIAS.pptx
 
Heinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativoHeinsohn Privacidad y Ciberseguridad para el sector educativo
Heinsohn Privacidad y Ciberseguridad para el sector educativo
 
Sesión de aprendizaje Planifica Textos argumentativo.docx
Sesión de aprendizaje Planifica Textos argumentativo.docxSesión de aprendizaje Planifica Textos argumentativo.docx
Sesión de aprendizaje Planifica Textos argumentativo.docx
 
La empresa sostenible: Principales Características, Barreras para su Avance y...
La empresa sostenible: Principales Características, Barreras para su Avance y...La empresa sostenible: Principales Características, Barreras para su Avance y...
La empresa sostenible: Principales Características, Barreras para su Avance y...
 
Ley 21.545 - Circular Nº 586.pdf circular
Ley 21.545 - Circular Nº 586.pdf circularLey 21.545 - Circular Nº 586.pdf circular
Ley 21.545 - Circular Nº 586.pdf circular
 
OCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VS
OCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VSOCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VS
OCTAVO SEGUNDO PERIODO. EMPRENDIEMIENTO VS
 
Éteres. Química Orgánica. Propiedades y reacciones
Éteres. Química Orgánica. Propiedades y reaccionesÉteres. Química Orgánica. Propiedades y reacciones
Éteres. Química Orgánica. Propiedades y reacciones
 
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
Plan Refuerzo Escolar 2024 para estudiantes con necesidades de Aprendizaje en...
 
CALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDADCALENDARIZACION DE MAYO / RESPONSABILIDAD
CALENDARIZACION DE MAYO / RESPONSABILIDAD
 

Documento sin título

  • 1. Option Explicit ' funciones Api Private Declare Function SendMessageAsLong Lib "user32" _ Alias "SendMessageA" ( _ ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long _ ) As Long Private Declare Function SendMessageAsString Lib "user32" _ Alias "SendMessageA" ( _ ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As String _ ) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long ' Constante para los mensajes ' Recupera en un buffer el texto de la linea Private Const EM_GETLINE As Long = &HC4 ' Recupera la cantidad de lineas Private Const EM_GETLINECOUNT As Long = &HBA ' Hwnd de la ventana Dim ret As Long Public Function Obtener_Texto(Hwnd_Ventana As Long) As String Dim i As Long Dim n As Long Dim temp As String ' Cantidad de lineas n = SendMessageAsLong(Hwnd_Ventana, EM_GETLINECOUNT, 0, 0) ' Recorre todas las lineas y obtiene el texto de _ la linea actual con la función Leer_Linea For i = 1 To n temp = temp & Leer_Linea(Hwnd_Ventana, i - 1) & vbCrLf Next
  • 2. Obtener_Texto = temp End Function ' Retorna el texto de la linea indicada Private Function Leer_Linea(Hwnd_Ventana As Long, Numero_Linea As Long) As String Const MAX_CHAR_PER_LINE As Long = 80 Dim Lo As Integer Dim Hi As Integer Dim ret As Long Dim Buffer As String Lo = MAX_CHAR_PER_LINE And (255) Hi = Int(MAX_CHAR_PER_LINE / 256) Buffer = Chr$(Lo) + Chr$(Hi) + Space$(MAX_CHAR_PER_LINE - 2) ' Recupera el texto en el Buffer, de la linea indicada en Numero_Linea. ret = SendMessageAsString(Hwnd_Ventana, EM_GETLINE, Numero_Linea, Buffer) ' Retorna la linea Leer_Linea = Left$(Buffer, ret) End Function ' Botón para recuperar el hwnd Private Sub Command1_Click() ' Recupera el Hwnd del bloc de notas ( Handle del Edit ) ret = FindWindowEx(FindWindow(vbNullString, "Sin título - bloc de notas"), _ 0, "Edit", vbNullString) If ret = 0 Then MsgBox "Error. El Hwnd es 0 ", vbCritical Else MsgBox "Hwnd del Edit del Notepad es: " & ret, vbInformation Command2.Enabled = True Command1.Enabled = False End If End Sub ' Botón que recupera el texto Private Sub Command2_Click() If ret = 0 Then MsgBox "error. El Hwnd es 0", vbCritical Else ' Muestra el texto del otepad en el textbox Text1 = Obtener_Texto(ret) End If End Sub Private Sub Form_Load()
  • 3. Command1.Caption = " Obtener Hwnd del bloc de notas " Command2.Caption = " Obtener el Texto " Command2.Enabled = False MsgBox " 1 - Abrir el Bloc de notas. " & vbNewLine & _ " 2 - Dejarle el caption -->> Sin Título - Bloc de notas " & vbNewLine & _ " 3 - Escribir algún texto y luego presionar el botón [ Obtener Hwnd del bloc de notas ]" & vbNewLine & _ " 4 - Presionar el botón [ Obtener texto ]", vbInformation End Sub