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. keybd_event for .NET?

keybd_event for .NET?

Scheduled Pinned Locked Moved C#
csharphtmlcomjsonquestion
8 Posts 5 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.
  • A Offline
    A Offline
    Alvaro Mendez
    wrote on last edited by
    #1

    What's the equivalent of the Win32 API keybd_event (or SendInput) for .NET? Thanks, Alvaro


    When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com

    J K 2 Replies Last reply
    0
    • A Alvaro Mendez

      What's the equivalent of the Win32 API keybd_event (or SendInput) for .NET? Thanks, Alvaro


      When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      I don't know, but there is no rule that you can't use API's in .NET! :)

      "Do unto others as you would have them do unto you." - Jesus
      "An eye for an eye only makes the whole world blind." - Mahatma Gandhi

      A 1 Reply Last reply
      0
      • A Alvaro Mendez

        What's the equivalent of the Win32 API keybd_event (or SendInput) for .NET? Thanks, Alvaro


        When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com

        K Offline
        K Offline
        Katalyst
        wrote on last edited by
        #3

        I had a similar question that I posted a couple of days ago, with mixed results. See thread: http://www.codeproject.com/script/comments/forums.asp?msg=466571&forumid=1649#xx466571xx I tried calling keybd_event from C# through an extern declaration, like this: [DllImport("User32.dll")] private unsafe static extern void keybd_event(byte bVk, byte bScan, uint dwflags, ulong* dwExtraInfo); For me, this works the first time but is flaky after that. I'm not sure why, but it's possible that the last two parameter types are off -- I wasn't exactly sure what to use there.

        A 2 Replies Last reply
        0
        • K Katalyst

          I had a similar question that I posted a couple of days ago, with mixed results. See thread: http://www.codeproject.com/script/comments/forums.asp?msg=466571&forumid=1649#xx466571xx I tried calling keybd_event from C# through an extern declaration, like this: [DllImport("User32.dll")] private unsafe static extern void keybd_event(byte bVk, byte bScan, uint dwflags, ulong* dwExtraInfo); For me, this works the first time but is flaky after that. I'm not sure why, but it's possible that the last two parameter types are off -- I wasn't exactly sure what to use there.

          A Offline
          A Offline
          Alvaro Mendez
          wrote on last edited by
          #4

          It's amazing that there isn't something equivalent to this in .NET already! I'm still hopeful that it's in there somewhere, but we just haven't located it. Anyway, I did a search using Google and got to this link: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=keybd_event&btnG=Google+Search&meta=group%3Dmicrosoft.public.dotnet.languages.csharp[^] The second link there shows one way to declare keybd_event inside the program: http://groups.google.com/groups?q=keybd_event+group:microsoft.public.dotnet.languages.csharp&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=1DQ6HJ7VCHA.1780%40cpmsftngxa10&rnum=2[^] I'll give that a shot, and I'll also dig a little more slowly into the .NET library to see if I can spot it. You'd have thought the Application class would have been the place, but nope. Thanks for your help, Alvaro


          When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com

          1 Reply Last reply
          0
          • J J Dunlap

            I don't know, but there is no rule that you can't use API's in .NET! :)

            "Do unto others as you would have them do unto you." - Jesus
            "An eye for an eye only makes the whole world blind." - Mahatma Gandhi

            A Offline
            A Offline
            Alvaro Mendez
            wrote on last edited by
            #5

            I know, but why reinvent the wheel? You'd think that something like this would already be there, somewhere... :~ Thanks, Alvaro


            When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com

            1 Reply Last reply
            0
            • K Katalyst

              I had a similar question that I posted a couple of days ago, with mixed results. See thread: http://www.codeproject.com/script/comments/forums.asp?msg=466571&forumid=1649#xx466571xx I tried calling keybd_event from C# through an extern declaration, like this: [DllImport("User32.dll")] private unsafe static extern void keybd_event(byte bVk, byte bScan, uint dwflags, ulong* dwExtraInfo); For me, this works the first time but is flaky after that. I'm not sure why, but it's possible that the last two parameter types are off -- I wasn't exactly sure what to use there.

              A Offline
              A Offline
              Alvaro Mendez
              wrote on last edited by
              #6

              My digging payed off!! :-) I found a class called SendKeys class in the System.Windows.Forms namespace. Not the most intuitive name, but hey, it's a lot better than that awful keybd_event. Regards, Alvaro


              When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com

              P L 2 Replies Last reply
              0
              • A Alvaro Mendez

                My digging payed off!! :-) I found a class called SendKeys class in the System.Windows.Forms namespace. Not the most intuitive name, but hey, it's a lot better than that awful keybd_event. Regards, Alvaro


                When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com

                P Offline
                P Offline
                Paresh Gheewala
                wrote on last edited by
                #7

                cool enjoy :laugh:

                1 Reply Last reply
                0
                • A Alvaro Mendez

                  My digging payed off!! :-) I found a class called SendKeys class in the System.Windows.Forms namespace. Not the most intuitive name, but hey, it's a lot better than that awful keybd_event. Regards, Alvaro


                  When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com

                  L Offline
                  L Offline
                  Leon van Wyk
                  wrote on last edited by
                  #8

                  I had a quick look at the SendKeys class but can you use that to send it remotely, I think that was what you wanted to do. I am also looking for remote components to can control terminals across a tellephone line, I found some cool stuff, but not key strokes or mouse events... Let me know if you need any other stuff... Leon v Wyk

                  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