Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Sending KeyStrokes to another Application
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mirhagk




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: 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...
md




PostPosted: 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.
DemonWasp




PostPosted: 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).
mirhagk




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: