1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("User32.dll")> _
Public Shared Function SendMessage(hWnd As IntPtr, uMsg%, wParam%, lParam$) As Integer
End Function
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
<DllImport("user32.dll")> _
Public Shared Function FindWindowEx(hwndParent As IntPtr, hwndChildAfter As IntPtr, lpszClass$, lpszWindow$) As IntPtr
End Function
Public Const WM_SETTEXT = 12
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim lpszParentClass As String = "Notepad"
Dim lpszParentWindow As String = "Nouveau document texte.txt - Bloc-notes"
Dim lpszClass As String = "Edit"
Dim ParenthWnd As New IntPtr(0)
Dim hWnd As New IntPtr(0)
ParenthWnd = FindWindow(lpszParentClass, lpszParentWindow)
If Not ParenthWnd.Equals(IntPtr.Zero) Then
hWnd = FindWindowEx(ParenthWnd, hWnd, lpszClass, "")
If Not hWnd.Equals(IntPtr.Zero) Then
SendMessage(hWnd, WM_SETTEXT, 0, "Ceci est 1 test !")
End If
End If
End Sub
End Class |
Partager