SendMessage(handle, WM_CHAR, VirtualKeys.VK_A, 0) does not trigger KeyDown...

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

    SendMessage(handle, WM_CHAR, VirtualKeys.VK_A, 0) does not trigger KeyDown...

    Hi All,

    maybe this is a sill question..but if i have TextBox and use the
    SendMessage(..) to send
    a character the control.. the KeyDown event is not triggered.... in would
    need to check in the WndProc(...) of the WM_CHAR event...

    Is there another way to send characters to the TextBox, when I'm only having
    the control's handle
    which does simulated the user typing in characters so the KeyDown event gets
    triggered?

    Cheers,

    Fred


  • Chris Dunaway

    #2
    Re: SendMessage(han dle, WM_CHAR, VirtualKeys.VK_ A, 0) does not trigger KeyDown...

    If you want the KeyDown event triggered, you need to send the
    WM_KEYDOWN message.

    Comment

    • Fred Heida

      #3
      Re: SendMessage(han dle, WM_CHAR, VirtualKeys.VK_ A, 0) does not trigger KeyDown...

      Hi Chris,

      thx...

      using the WM_KEYDOWN.. how can i send a control key + a letter.. e.g Ctrl+G
      ??

      Cheers,

      Fred

      "Chris Dunaway" <dunawayc@gmail .com> wrote in message
      news:1120139700 .753308.210880@ z14g2000cwz.goo glegroups.com.. .[color=blue]
      > If you want the KeyDown event triggered, you need to send the
      > WM_KEYDOWN message.
      >[/color]


      Comment

      • Chris Dunaway

        #4
        Re: SendMessage(han dle, WM_CHAR, VirtualKeys.VK_ A, 0) does not trigger KeyDown...

        It appears as if you have to send 5 messages to get a Ctrl+G:

        WM_KEYDOWN for the Ctrl key
        WM_KEYDOWN for the G key
        WM_CHAR for the Ctrl-G (7)
        WM_KEYUP for the G key
        WM_KEYUP for the Ctrl key

        I could be wrong, but that is how it looked in Spy++ when I pressed
        Ctrl+G on a textbox.

        Here is how I duplicated that in code:

        Dim GDownLParam As New IntPtr(&H220001 )
        Dim GUpLParam As New IntPtr(&HC02200 01)
        Dim CtrlDownLParam As New IntPtr(&H11D000 1)
        Dim CtrlUpLParam As New IntPtr(&HC11D00 01)
        Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYDOWN,
        &H11, CtrlDownLParam)
        Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYDOWN,
        &H47, GDownLParam)
        Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_C HAR,
        &H7, GDownLParam)
        Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYUP,
        &H47, GUpLParam)
        Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYUP,
        &H11, CtrlUpLParam)

        I have a set of classes that make it easy to call the Win32 API and
        that is what I am using in this code. If you're interested in those
        classes, I can send them.

        Chris

        Comment

        • Fred Heida

          #5
          Re: SendMessage(han dle, WM_CHAR, VirtualKeys.VK_ A, 0) does not trigger KeyDown...

          Hi Chris,

          that works great! Thx,

          Cheers,
          Fred

          "Chris Dunaway" <dunawayc@gmail .com> wrote in message
          news:1120228019 .009021.222290@ g43g2000cwa.goo glegroups.com.. .[color=blue]
          > It appears as if you have to send 5 messages to get a Ctrl+G:
          >
          > WM_KEYDOWN for the Ctrl key
          > WM_KEYDOWN for the G key
          > WM_CHAR for the Ctrl-G (7)
          > WM_KEYUP for the G key
          > WM_KEYUP for the Ctrl key
          >
          > I could be wrong, but that is how it looked in Spy++ when I pressed
          > Ctrl+G on a textbox.
          >
          > Here is how I duplicated that in code:
          >
          > Dim GDownLParam As New IntPtr(&H220001 )
          > Dim GUpLParam As New IntPtr(&HC02200 01)
          > Dim CtrlDownLParam As New IntPtr(&H11D000 1)
          > Dim CtrlUpLParam As New IntPtr(&HC11D00 01)
          > Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYDOWN,
          > &H11, CtrlDownLParam)
          > Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYDOWN,
          > &H47, GDownLParam)
          > Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_C HAR,
          > &H7, GDownLParam)
          > Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYUP,
          > &H47, GUpLParam)
          > Win32.User.Send Message(TextBox 1.Handle, Win32.User.WM_K EYUP,
          > &H11, CtrlUpLParam)
          >
          > I have a set of classes that make it easy to call the Win32 API and
          > that is what I am using in this code. If you're interested in those
          > classes, I can send them.
          >
          > Chris
          >[/color]


          Comment

          Working...