Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. SendInput

SendInput

Scheduled Pinned Locked Moved C#
csharphtmlhelp
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    danzar
    wrote on last edited by
    #1

    Hi, I was woundering if some of the higher level C# programmers could help me with my code. I have read all the Doc. that i can find about it, But i still cant get it to fully work. If I comment out the keyboadx ref's the mouseclickx works fine. If I dont neather the mouseclickx nor the keyboardx works at all. I cant get the keyboardx to work in any fashion. I made a link to a paste it site because i didnt know how it it is looked at about paste long code in forums. http://rafb.net/p/bmuAVm81.html[^]

    L 1 Reply Last reply
    0
    • D danzar

      Hi, I was woundering if some of the higher level C# programmers could help me with my code. I have read all the Doc. that i can find about it, But i still cant get it to fully work. If I comment out the keyboadx ref's the mouseclickx works fine. If I dont neather the mouseclickx nor the keyboardx works at all. I cant get the keyboardx to work in any fashion. I made a link to a paste it site because i didnt know how it it is looked at about paste long code in forums. http://rafb.net/p/bmuAVm81.html[^]

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, the problem is with your INPUT struct; its original C definition has a union which puts MOUSEINPUT and KEYBDINPUT at the same location; yours has not, so the substructs are located sequentially. There is a way to mimic union behavior in C# using explicit offsets, but in this case it would be easier to come up with two different INPUT structs (say INPUTK and INPUTM), and two prototypes for SendInput accordingly. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


      A D 2 Replies Last reply
      0
      • L Luc Pattyn

        Hi, the problem is with your INPUT struct; its original C definition has a union which puts MOUSEINPUT and KEYBDINPUT at the same location; yours has not, so the substructs are located sequentially. There is a way to mimic union behavior in C# using explicit offsets, but in this case it would be easier to come up with two different INPUT structs (say INPUTK and INPUTM), and two prototypes for SendInput accordingly. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


        A Offline
        A Offline
        Anthony Mushrow
        wrote on last edited by
        #3

        And as usual, Luc has the answer. I wouldn't even have thought of checking the original structs.

        My current favourite word is: Waffle Cheese is still good though.

        L 1 Reply Last reply
        0
        • A Anthony Mushrow

          And as usual, Luc has the answer. I wouldn't even have thought of checking the original structs.

          My current favourite word is: Waffle Cheese is still good though.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          :rose: when it fails no part is beyond suspicion...

          Luc Pattyn [Forum Guidelines] [My Articles]


          this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


          1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, the problem is with your INPUT struct; its original C definition has a union which puts MOUSEINPUT and KEYBDINPUT at the same location; yours has not, so the substructs are located sequentially. There is a way to mimic union behavior in C# using explicit offsets, but in this case it would be easier to come up with two different INPUT structs (say INPUTK and INPUTM), and two prototypes for SendInput accordingly. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


            D Offline
            D Offline
            danzar
            wrote on last edited by
            #5

            Thank you for the reply. I have modifed my code serveral time to try to make the struct more like you said. but to no avail can i get it to work. this is the code I have this time. Let me know what you see wrong on this one.. Thank you very much Danzar http://rafb.net/p/uPx4EW73.html[^]

            L 1 Reply Last reply
            0
            • D danzar

              Thank you for the reply. I have modifed my code serveral time to try to make the struct more like you said. but to no avail can i get it to work. this is the code I have this time. Let me know what you see wrong on this one.. Thank you very much Danzar http://rafb.net/p/uPx4EW73.html[^]

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Hi danzar, the way I read the documentation on KEYBDINPUT structure, you must specify a valid dwExtraInfo "Specifies an additional value associated with the keystroke. Use the GetMessageExtraInfo function to obtain this information" so I think your zero value is not good enough. BTW: I noticed the mouse struct is smaller than the keyboard struct, but the original INPUT has a union, so its size must accomodate the largest of them (once you try my INPUTM, it would fail if you don't take care of that!). :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups