Hey.
I don't know if this is possible, but worth a shot. Say there's a third party racing game which doesn't use the mouse. Is there a way for me to create a Windows Form app which listens for mouse clicks and transfers a corresponding key to the game/active window (e.g. Left click would send the 'Up arrow' key to accelerate the Right click would decelerate by sending the 'Down arrow' key). I've looked at the SendKeys method, but it doesn't work once the game becomes the active window. Any ideas? Thanks
if the game uses DirectInput for reading the keys, then SendKeys wont work, as DI works at driver level, and SendKeys/SendInput works at API level, which may be too 'high' for the game to see. you can Hook into DirectInput, and send it commands, but its not going to be a one liner, and if you're new to DirectX, you're not going to find it fun.
I don't know if it would work, and if it is possible, but intuitively, I would check if there is some kind of AutoIt Library for C#.
As far as I know, AutoIt has no problems with sending key press events to games.
A couple of methods to integrate AutoIt to C# exist on the internet, but so far, I haven't tried one of them yet.
Still you could give it a shot
http://www.lancelarsen.com/Blog/tabid/72/EntryId/48/AutoIt-C-Helper-Library.aspx
Related
I'd like to create a simple application for Android that would automate some processes that happen in different applications that I don't have under my control at all. Is there any way to get pixel color and simulate screen touch while my application runs in background?
Let's say I want to wait for a certain pixel to turn red (#FF0000), can I use GetPixel(x,y) to get the color and then simulate a screen touch event such as a swipe across the screen?
I tried to Google this but I've got nothing useful at all and now I'm quite desperate about this.
I had to search a bit for this. I was also looking for this solution.
NO ROOTING REQUIRED FOR THIS:
If you want to repeat a sequence of steps like fill a form, repeat game steps because redoing is boring, You can try : FREP Android App from Play Store(Link).
If you want to add conditional scenarios like, when you play Clash of Clans with home Wifi, turn data automatically and disable wifi ( Because Airtel Wifi in India is unpredictable and can make you loose the clan war!!) use, Macro Droid from Play Store.
You can try these as well:
Mahiro
Many apps are available based on Tasker like, Auto Input. You can maybe code/write macro to make personal solution with this Tasker App.
I have a software installed on my system which basically peeks my activity during working hours. It send a report saying how much time i was away from my system etc.
Since i m .net c# developer hence trying to break this system through my programming skills.
I have basically written up a windows form application which opens up an notepad for me and start typing some random characters into it. simultaneously it also performs some random clicks and moves the mouse cursor to give a feel that some one is on system and working even when i am not :)
I also use "SetThreadExecutionState" Pinvoke calls to keep system awake.I have also observed the User idle time and last interactivity time through "GetLastInputInfo" PInvoke system call while my mouse/keyboard are in automation process and it is also fine.
But this is not working for me. It works perfectly till 5 mins and then somehow it detects that user is not present on system.
any suggestions for the same.
Get a decompiler, crack-open the spying application and see how it is working inside. Only knowing the internal workings, you can create a "workable" any-spying program. But I would not bother with emulation of the activity, but rather spoof the way it reports to the server.
However, depending on where you live, it might be illegal to do these things and I would not recommend cheating your employer. And if spying gets on your nerves I'd also suggest to brush up your CV and start searching for a new job.
I'm writing an app (in C#) which as a part of it must simulate and send some key strokes to another application. I'm using http://inputsimulator.codeplex.com/ project for simulating keys, and it works in many applications, but in some it doesn't - i.e. Mortal Combat 4.
I've googled about it, and found many answers varying from 'it's impossible' to 'you must use XXX library' etc. Those answered scared me a lot, and even nearly convinced I'm not able to do it at that time, BUT...
M$ Virtual Keyboard works. It works in ALL applications. So it IS possible... Does anyone of you, clever guys, know how can I achieve this?
Ok, I think I finally got it to work. I used API Monitor recommended by Neal P and it showed just minimal differences between OSK calls and mine. A bit later I've tried to make my calling thread sleep some time between sending messages with press and release key and that was it.
Although you were able to achieve your purpose, the way you achieved it does not fundamentally answer your question: How to simulate keyboard input in ALL applications?
There's a bunch of situations where the common user mode Microsoft API already mentioned does not work, like game applications that use the DirectInput API or protected games.
I have built a library that can help in this situations, it provides a simple C API that internally communicates with device filter drivers. It is able to send input for DirectInput based games and also is able to bypass some game protections. I have checked and it is still able to bypass some known game protections by using the x64 version of the library. Game protections commonly hook only the x86 system's api. Well, at last now, 18 February 2012, this is what I'm seeing happening.
Take a look at SendKeys on MSDN
After playing quite a bit of Bad Company 2 over the last month, I'm getting kind of tired of Alt+Tabbing out of my game to change the song on iTunes. I've got a fairly good iTunes controller library already built for a previous project I was working on, and I'd like to create a WPF application mimicking the BC2 UI that would overlay the game when pressing a shortcut key, much the same way as the Steam Community overlay.
The only problem I foresee is getting my application to overlay BC2 when the user presses a specified shortcut key in-game. Is there a way to intercept a keypress from BC2 (or, really, any Win32 application) and use it to bring my app to the foreground?
In order to have a global keyboard shortcut, you need to use a Hook.
Here is a tutorial showing how to do Keyboard Hooks in C#.
That being said, doing the overlay may be difficult, depending on how the game is written. Many full screen games cannot (easily) have other programs run in front of them. I'd play with making sure that works correctly in your specific game first.
i have an application that records a date/time when the space bar is pressed
unfortunately, the window doesn't always have focus, for various reasons. eg virus checker popup, itunes update, windows update, etc
so what i though would be a cool idea is to use a joystick button, then regardless of which window has focus, i can always detect the button press event and record the date/time it was pressed.
now i had a look at a few game tutorials, but they seem to have the joystick polling tied into the screen refresh event, because in a game i guess if the computer is slow and the screen doesn't refresh often, having the joystick button pressed is going to make no difference anyway.
That doesn't really suit my need, so i am looking at running a thread that will poll the joystick every so often
My questions are
is a background thread the best solution
how often should i poll the joystick
what kind of timer should i use to determine the polling frequency.
I would like the responses to be at least equivalent to a keyboard. also need to make sure it doesn't auto-repeat if trigger is held down.
any sample code (C#) appreciated
thanks
alex
If you want to go for polling the joystick just because you are not able to capture the keyboard event, I think you need to re-work your strategy.
Even if your form doesn't have the focus there are ways that you can make sure you know of the keyboard state.
You could set up a system wide keyboard hook which can be done in C# using the SetWindowsHookEx API call.
This is delving a little in unmanaged code and Windows API, but I think it's a better idea than polling a joystick cause you won't need to add a joystick to your computer just because you need to capture datetime at the press of a spacebar.
Do a little search on google for keyboard hooks in C#. It's easier than many people believe.
I don't think using a timer object to do this is a good idea at all. Cause I believe you said you need to do it at the press of a key.
Your best bet would be to create a Timer object on your form, and tie the joystick check to the Tick event.
I've also found that running simple stuff like this every 100ms (10 times a second) has a negligible effect on CPU usage.
Use something like AHK (Auto HotKey) it is a simple language that can be compiled to an EXE and is designed for automating the keyboard and mouse, I'm not 100% sure how well it works with a joystick, but I'm sure it's possible they managed to write some stuff for the wii remotes.
Also the IRC Channel and Forums always have people willing to help if need be.