Sendmessage problem help!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • paraidy

    #1

    Sendmessage problem help!

    Hi all, reading some examples in this group i'm trying to send a text
    to notepad, but it doesn't work, can someone to correct my code? Thx

    Private Declare Function FindWindow Lib "user32.dll " Alias
    "FindWindow A" (ByVal lpClassName As String, ByVal lpWindowName As
    String) As Long
    Declare Function SendMessage Lib "user32.dll " Alias "SendMessag eA"
    (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByRef
    lParam As String) As Int32
    Declare Function FindWindowEx Lib "user32.dll " Alias
    "FindWindow ExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal
    lpsz1 As String, ByVal lpsz2 As String) As Int32
    Const WM_GETTEXT As Int32 = &HD
    Const WM_GETTEXTLENGT H As Int32 = &HE
    Const WM_SETTEXT As Int32 = &HC

    Private Sub Button10_Click( ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button10.Click
    Dim Handle As Long
    Dim Handlex As Int32
    Handle = FindWindow("Not epad", "")
    Handlex = FindWindowEx(Ha ndle, 0, "Edit", "")
    SendMessage(Han dlex, WM_SETTEXT, 0, ("Hello!!"))
    End Sub

  • Claes Bergefall

    #2
    Re: Sendmessage problem help!

    See inline

    /claes

    "paraidy" <samoretta@tisc ali.itwrote in message
    news:1153129104 .098306.239270@ 75g2000cwc.goog legroups.com...
    Hi all, reading some examples in this group i'm trying to send a text
    to notepad, but it doesn't work, can someone to correct my code? Thx
    >
    Private Declare Function FindWindow Lib "user32.dll " Alias
    "FindWindow A" (ByVal lpClassName As String, ByVal lpWindowName As
    String) As Long
    Declare Auto Function FindWindow Lib "user32.dll " (ByVal lpClassName As
    String, ByVal lpWindowName As String) As IntPtr

    Declare Function SendMessage Lib "user32.dll " Alias "SendMessag eA"
    (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByRef
    lParam As String) As Int32
    Declare Auto Function SendMessage Lib "user32.dll " (ByVal hwnd As IntPtr,
    ByVal wMsg As IntPtr, ByVal wParam As Int32, ByVal lParam As String) As
    Int32

    Declare Function FindWindowEx Lib "user32.dll " Alias
    "FindWindow ExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal
    lpsz1 As String, ByVal lpsz2 As String) As Int32
    Declare Auto Function FindWindowEx Lib "user32.dll " (ByVal hWnd1 As IntPtr,
    ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As
    IntPtr

    Const WM_GETTEXT As Int32 = &HD
    Const WM_GETTEXTLENGT H As Int32 = &HE
    Const WM_SETTEXT As Int32 = &HC
    >
    Private Sub Button10_Click( ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button10.Click
    Dim Handle As Long
    Dim Handlex As Int32
    Handle = FindWindow("Not epad", "")
    Handlex = FindWindowEx(Ha ndle, 0, "Edit", "")
    SendMessage(Han dlex, WM_SETTEXT, 0, ("Hello!!"))
    End Sub

    Private Sub Button10_Click( ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button10.Click
    Dim Handle As IntPtr
    Dim Handlex As IntPtr
    Handle = FindWindow("Not epad", Nothing)
    Handlex = FindWindowEx(Ha ndle, 0, "EDIT", Nothing)
    SendMessage(Han dlex, WM_SETTEXT, 0, ("Hello!!"))
    End Sub




    Comment

    • paraidy

      #3
      Re: Sendmessage problem help!

      Great, it work, Thx a lot!, there is only a thing, why with Wordpad it
      doesn't work?

      Comment

      • Claes Bergefall

        #4
        Re: Sendmessage problem help!

        You need to change the class names:

        Handle = FindWindow("Wor dPadClass", Nothing)
        Handlex = FindWindowEx(Ha ndle, 0, "RICHEDIT50 W", Nothing)

        /claes

        "paraidy" <samoretta@tisc ali.itwrote in message
        news:1153148358 .177338.133000@ p79g2000cwp.goo glegroups.com.. .
        Great, it work, Thx a lot!, there is only a thing, why with Wordpad it
        doesn't work?
        >

        Comment

        • paraidy

          #5
          Re: Sendmessage problem help!


          Claes Bergefall wrote:
          You need to change the class names:
          >
          Handle = FindWindow("Wor dPadClass", Nothing)
          Handlex = FindWindowEx(Ha ndle, 0, "RICHEDIT50 W", Nothing)
          >
          /claes
          >
          "paraidy" <samoretta@tisc ali.itwrote in message
          news:1153148358 .177338.133000@ p79g2000cwp.goo glegroups.com.. .
          Great, it work, Thx a lot!, there is only a thing, why with Wordpad it
          doesn't work?
          Thx a lot, you helped me a lot :)

          Comment

          Working...