تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] استفسار :- بخصوص اخذ نص من برنامج اخر WM_GETTEXT
#1
السلام عليكم ورحمة الله

عندي استفسار بخصوص اخذ نص من برنامج اخر يعمل في نفس الوقت

الكود اللي عندي شغال تمام باخذ نص من برنامج ال Notepad

بس انا اريد اخذ نص من برنامج اخر 

مثلا  من برنامج Google Chrome

اخذ نص الرابط  

او اي برنامج اخر 



هذا الكود 

كود :
Imports System.Runtime.InteropServices
Public Class Form1
   Private Const WM_GETTEXT As Integer = &HD
   Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer,
   ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
   <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
   Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr,
                                        ByVal childAfter As IntPtr,
                                        ByVal lclassName As String,
                                        ByVal windowTitle As String) As IntPtr
   End Function

   Declare Auto Function FindWindow Lib "user32.dll" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       'Find the running notepad window
       Dim Hwnd As IntPtr = FindWindow(Nothing, "uuu.txt - Notepad")

       'Alloc memory for the buffer that recieves the text
       Dim Handle As IntPtr = Marshal.AllocHGlobal(100)

       'send WM_GWTTEXT message to the notepad window
       Dim NumText As Integer = SendMessage(Hwnd, WM_GETTEXT, 50, Handle)

       'copy the characters from the unmanaged memory to a managed string
       Dim Text As String = Marshal.PtrToStringUni(Handle)

       'Display the string using a label
       Label1.Text = Text

       'Find the Edit control of the Running Notepad
       Dim ChildHandle As IntPtr = FindWindowEx(Hwnd, IntPtr.Zero, "Edit", Nothing)

       'Alloc memory for the buffer that recieves the text
       Dim Hndl As IntPtr = Marshal.AllocHGlobal(200)

       'Send The WM_GETTEXT Message
       NumText = SendMessage(ChildHandle, WM_GETTEXT, 200, Hndl)

       'copy the characters from the unmanaged memory to a managed string
       Text = Marshal.PtrToStringUni(Hndl)

       'Display the string using a label
       Label2.Text = Text

   End Sub

End Class



الكود هذا شغال مثلا اذا فتحت   Notepad   اسمه  uuu.txt

هذا الكود يسحب النص الموجود في 


بس كيف اخذ  نص من برنامج اخر  

بارك الله فيكم وشكرا
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
استفسار :- بخصوص اخذ نص من برنامج اخر WM_GETTEXT - بواسطة dubai.eig - 24-12-18, 09:47 AM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
Information [VB.NET] مطلوب سورس برنامج من سيربح المليون بدر إشتية 7 6,725 30-11-25, 07:22 AM
آخر رد: Mr_limo
  فائدة بخصوص التعامل مع علامات التنصيص مع {سؤال} justforit 4 292 02-11-25, 11:19 PM
آخر رد: justforit
  برنامج نظام محل مواد غذائية crazykinko 0 157 17-10-25, 12:27 AM
آخر رد: crazykinko
  جهاز ارسال رسائل SMS من خلال برنامج فيجوال بيسك جيولوجي مبتدئ 4 1,025 05-09-25, 12:37 PM
آخر رد: جيولوجي مبتدئ
  [VB.NET] بخصوص تشفير FoxLearn.License h2551996 1 639 17-07-25, 09:18 PM
آخر رد: h2551996
  [VB.NET] استفسار بخصوص البحث في RichTextBox SerialPort dubai.eig 2 664 18-06-25, 11:09 AM
آخر رد: dubai.eig
  استفسار لو سمحتم خالد كامل1 3 830 04-06-25, 06:03 PM
آخر رد: Kamil
  استفسار عن حامية برنامج ahmedramy 2 589 27-04-25, 06:02 PM
آخر رد: princelovelorn
Lightbulb [مشروع] مطلوب برنامج نظام صيدليه بالفيجوال بيسك 2010 May-5 13 10,794 07-02-25, 07:55 PM
آخر رد: الورد2
  استفسار عن تنسيق الفورم في حالة تغيرالفورم من وضع العادي الي التكبير fireswored1 4 838 22-01-25, 09:04 PM
آخر رد: fireswored1

التنقل السريع :


يقوم بقرائة الموضوع: