Bonjour,

voilà j’aurais besoins d'utiliser la fonction API SendMessage, toutefois j'ai de gros souci je sort en erreur à chaque fois.

je précise que je suis sous Seven 32b.

ci-dessous mon code (pour test)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
Declare Auto Function FindWindow Lib "USER32.DLL" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
    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 SendMessage 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 SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal WMSG As Long, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Long
    Declare Auto Function SetForegroundWindow Lib "USER32.DLL" (ByVal hWnd As IntPtr) As Boolean
    Private Const EM_REPLACESEL = &HC2
    Declare Auto Function BringWindowToTop Lib "USER32.DLL" (ByVal hWnd As IntPtr) As Boolean
    Private Const WM_COPY = &H301
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
        Dim startInfo As New ProcessStartInfo("notepad.exe")
        Dim notepad As Process = Process.Start(startInfo)
        System.Threading.Thread.Sleep(100)
 
        Dim lpszParentClass As String = notepad.ProcessName
        Dim lpszParentWindow As String = notepad.MainWindowTitle
        Dim lpszClass As String = "Edit"
 
        Dim ParenthWnd As New IntPtr(0)
        Dim hWnd As New IntPtr(0)
 
        ParenthWnd = FindWindow(lpszParentClass, lpszParentWindow)
 
        SendMessage(ParenthWnd, 100, &H43, 0)
        SendMessage(ParenthWnd, WM_COPY, IntPtr.Zero, IntPtr.Zero)
que ce soit sur l'un ou l'autre j'ai cette erreur récurrente
pInvokestackImbalance

dans l'attente de vous lire, cordialement