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. Mouse and Keyboard Scripting

Mouse and Keyboard Scripting

Scheduled Pinned Locked Moved C#
questioncsharprubygame-devtools
3 Posts 2 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.
  • M Offline
    M Offline
    Michael Fritzius
    wrote on last edited by
    #1

    Hello, I'd like to create a program in C# that "fakes" mouse movement, clicks, and key presses. There's a game I love playing called GemCraft that lets you throw gem bombs on the screen. The procedure is to press "1", click and drag a gem where you want it, then let go and it explodes. The gems are always in the same place on the screen. What I'd like to find is a way to script these actions, so that I can leave the mouse pointer where I want the bomb, and press a button on the keyboard, and it automatically drops a bomb at that location. Is there a way to do this? Also, as a bonus question, is there a way to tell what color pixel is under the mouse? Take care, Michael Fritzius

    C 1 Reply Last reply
    0
    • M Michael Fritzius

      Hello, I'd like to create a program in C# that "fakes" mouse movement, clicks, and key presses. There's a game I love playing called GemCraft that lets you throw gem bombs on the screen. The procedure is to press "1", click and drag a gem where you want it, then let go and it explodes. The gems are always in the same place on the screen. What I'd like to find is a way to script these actions, so that I can leave the mouse pointer where I want the bomb, and press a button on the keyboard, and it automatically drops a bomb at that location. Is there a way to do this? Also, as a bonus question, is there a way to tell what color pixel is under the mouse? Take care, Michael Fritzius

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      pixel color is easy, you can do a screenshot and check the pixel where the mouse is. Getting a C# program to run keyboard macros in another program, is not likely to happen. Especially a game where you're not recording actions to windows as such.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      M 1 Reply Last reply
      0
      • C Christian Graus

        pixel color is easy, you can do a screenshot and check the pixel where the mouse is. Getting a C# program to run keyboard macros in another program, is not likely to happen. Especially a game where you're not recording actions to windows as such.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        M Offline
        M Offline
        Michael Fritzius
        wrote on last edited by
        #3

        I found something here that uses keyboard and mouse hooks that shows how to intercept information from either the keyboard or mouse and do something to modify that information. Right now I have it so that when I press Enter, it moves the mouse down and to the right 50 units without my touching the mouse, and I don't even have to be focused on it. So maybe it has to do with hooks of some kind, but it's possible, just kind of tricky. I can't figure out how to simulate a dragging operation. Please take a look at the code and see if you can figure something out. It's got some kind of class that handles mouse motion, clicking and key presses, but nothing for dragging. The screenshot idea is pretty good too--I believe I could incorporate that. Thanks for your time, Michael Fritzius

        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