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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. C# key/mouse detection

C# key/mouse detection

Scheduled Pinned Locked Moved C#
csharpgame-devjson
7 Posts 3 Posters 1 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.
  • W Offline
    W Offline
    weizur1
    wrote on last edited by
    #1

    Hello everyone. I am writing a bot for a game ( the game runs in windowed mode so I think what I need is possible ) anyway I need some way to detect key presses or mouse clicks when my program doesn't have focus. To make macros and what not ( I'll also need a way to send key and mouse clicks ), I figure this is probably in user32.dll or something but I can't find any good API documentation and was hoping someone could point me in the right direction for this. Thanks in advance!

    R 1 Reply Last reply
    0
    • W weizur1

      Hello everyone. I am writing a bot for a game ( the game runs in windowed mode so I think what I need is possible ) anyway I need some way to detect key presses or mouse clicks when my program doesn't have focus. To make macros and what not ( I'll also need a way to send key and mouse clicks ), I figure this is probably in user32.dll or something but I can't find any good API documentation and was hoping someone could point me in the right direction for this. Thanks in advance!

      R Offline
      R Offline
      Robin Panther
      wrote on last edited by
      #2

      check this out. Hope it helps. Robin Panther http://www.robinland.com

      W 1 Reply Last reply
      0
      • R Robin Panther

        check this out. Hope it helps. Robin Panther http://www.robinland.com

        W Offline
        W Offline
        weizur1
        wrote on last edited by
        #3

        Hey thanks this looks great for the detection of events. Any ideas on how to create and send my own events from the program. ( Even better if I can send just those events to a process without having to have that process in focus but that I'm not sure is possible )

        A R 2 Replies Last reply
        0
        • W weizur1

          Hey thanks this looks great for the detection of events. Any ideas on how to create and send my own events from the program. ( Even better if I can send just those events to a process without having to have that process in focus but that I'm not sure is possible )

          A Offline
          A Offline
          Allah On Acid
          wrote on last edited by
          #4

          Just my opinion, but C++/Win32 would probably be better suited to this project. I have recently began to program in C++, and it is alot more flexible than C#. In C++, you could get the handle to the game window, and send messages directly to the program, such as key press, mouse, etc... There is an article on that here: http://www.codeproject.com/threads/sendmsg.asp And there is a free C++/Win32 IDE here: http://www.borland.com/downloads/download\_cbuilderx.html Good luck with your bot! What game are you making it for?

          W 1 Reply Last reply
          0
          • A Allah On Acid

            Just my opinion, but C++/Win32 would probably be better suited to this project. I have recently began to program in C++, and it is alot more flexible than C#. In C++, you could get the handle to the game window, and send messages directly to the program, such as key press, mouse, etc... There is an article on that here: http://www.codeproject.com/threads/sendmsg.asp And there is a free C++/Win32 IDE here: http://www.borland.com/downloads/download\_cbuilderx.html Good luck with your bot! What game are you making it for?

            W Offline
            W Offline
            weizur1
            wrote on last edited by
            #5

            Thanks for the response, the bot is a trading bot for Magic Online. C++ is my primary languange anyway so I'll look into that. I was mainly going for c# since it's quicker and easier to make interfaces ( I hate MFC ) I suppose I could write it in both and have the c# run the c++ program which I've done in the past but it seems like most things one can do in c++ should be possible in c# I'll have to do a bit more research.

            A 1 Reply Last reply
            0
            • W weizur1

              Hey thanks this looks great for the detection of events. Any ideas on how to create and send my own events from the program. ( Even better if I can send just those events to a process without having to have that process in focus but that I'm not sure is possible )

              R Offline
              R Offline
              Robin Panther
              wrote on last edited by
              #6

              take a look at this function: SendMessage and examine related functions - PostMessage, SendNotifyMessage etc. ____________________________________________ Robin Panther http://www.robinland.com

              1 Reply Last reply
              0
              • W weizur1

                Thanks for the response, the bot is a trading bot for Magic Online. C++ is my primary languange anyway so I'll look into that. I was mainly going for c# since it's quicker and easier to make interfaces ( I hate MFC ) I suppose I could write it in both and have the c# run the c++ program which I've done in the past but it seems like most things one can do in c++ should be possible in c# I'll have to do a bit more research.

                A Offline
                A Offline
                Allah On Acid
                wrote on last edited by
                #7

                Maybe it would be easier to write a C++ dll that the C# program can use.

                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