• پایان فعالیت بخشهای انجمن: امکان ایجاد موضوع یا نوشته جدید برای عموم کاربران غیرفعال شده است

خواندن محتویلت نوت پد؟

sylvester

Registered User
تاریخ عضویت
26 مارس 2007
نوشته‌ها
526
لایک‌ها
89
محل سکونت
ترکیه
سلام
من با استفاده از تابع getwindowtext نمیتونم محتویات خیلی از عناثر را بگیرم مثل محتویات نوت پد یا نوشته های درون کمبو باکس ها!
یه گشتی هم زدم تو نت فهمیدم باید با send messege کار کنم ولی بازم نتونستم ! میشه کمک کنین

form1 code
کد:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () 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 Sub Command1_Click()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
Dim str As String * 50
List1.Clear
Dim fwh As Long
fwh = GetForegroundWindow
GetWindowText fwh, str, 50
Text1.Text = str

EnumChildWindows fwh, AddressOf EnumChildProc, ByVal 0&

End Sub

module code
کد:
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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long

Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
   Form1.List1.AddItem GetText(hwnd) & "   " & hwnd
    
    EnumChildProc = True
    
End Function

Public Function GetText(hwnd As Long)
 Dim buffer As String
  Dim lenCaption As Long
  lenCaption = GetWindowTextLength(hwnd)
  buffer = Space$(lenCaption + 1)
  GetWindowText hwnd, buffer, Len(buffer)
  GetText = Left$(buffer, Len(buffer) - 1)
End Function
 

ali32n70

کاربر تازه وارد
تاریخ عضویت
27 اکتبر 2008
نوشته‌ها
6
لایک‌ها
0
An application sends an EM_GETLINE message to copy a line of text from an edit control and place it in a specified buffer.
برای تکست از EM ها استفاده کن مرجع خوب WIN32.HLP
as like Em_getline
 
بالا