Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Runtime.InteropServices
- Public Class Form1
- Declare Function FindWindowA Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr 'Int32
- Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
- Declare Function SendMessage Lib "user32.dll" Alias "SendMessageW" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
- Public Const WM_GETTEXT = &HD
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim ParentHWND As IntPtr = FindWindowA("Notepad", Nothing) ' جلب مقبض نافذة الرئسية او النافذة الأب
- Dim ChildHWND = FindWindowEx(ParentHWND, Nothing, "Edit", Nothing) 'جلب مقبض الليست فيو عن طريق الكلاس نايم الخاص بها
- Dim StringAddress = Marshal.AllocHGlobal(255) 'حجز مساحة 255 بايت في الذاكرة لوضع النص فيها
- Dim pp = SendMessage(ChildHWND, WM_GETTEXT, 255, StringAddress) ' ارسال الرسالة
- Dim text As String = Marshal.PtrToStringUni(StringAddress) ' جلب النص من العنوان الذي في الذاكرة
- MsgBox(text) 'عرض الرسالة
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement