Computer Science Canada Sending KeyStrokes to another Application |
Author: | mirhagk [ Thu Mar 25, 2010 9:49 am ] |
Post subject: | Sending KeyStrokes to another Application |
Hello everyone, it's been a while since I've been here, mostly because it's been a while since I used Turing, and the dummies book for C++ was good enough for me.... until now. Basically what I'm trying to do is create a program that enters keystrokes into other applications (for instance notepad). It is not really something I need, more of a curiousity, and I will probably create an auto-typer just for fun. Can someone please help me, I'm using visual express C++ and I don't want to use the .NET framework unless I ABSOLUTELY have to (school computers don't support it). Another curiousity is how to check if a key is pressed into any application (ie don't need the window active in order for it to detect keys). I would very much appreciate any help you have for me. |
Author: | TheGuardian001 [ Thu Mar 25, 2010 12:32 pm ] |
Post subject: | Re: Sending KeyStrokes to another Application |
Well, provided that you only intend to develop this for Windows, you can use the either the keybd_event function, or the SendInput function, which supersedes keybd_event. I'm not sure how you would go about specifying what window to send the input to though... |
Author: | md [ Thu Mar 25, 2010 1:47 pm ] |
Post subject: | RE:Sending KeyStrokes to another Application |
Look into the Win32 API, or what used to be called OLE. Alas, I do not recall how to do either thing. |
Author: | DemonWasp [ Thu Mar 25, 2010 3:41 pm ] |
Post subject: | RE:Sending KeyStrokes to another Application |
You could try looking at the source of AutoHotKey if you're stuck; it does pretty much what you describe (picks up keystrokes, changes them before they get to the application, even the selected application). |
Author: | mirhagk [ Fri Mar 26, 2010 10:13 am ] |
Post subject: | RE:Sending KeyStrokes to another Application |
alright i'm looking at the send input right now, I'm still unsure of exactly how it works, but I'll fool around for a bit and *hopefully* get it. |