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