Jump to content
xisto Community
KDEWolf

Keyboard Simulation Low-level / Pascal / Delphi / Keyboard input simulation

Recommended Posts

I'm trying to simulate a key press in an external program (actually a game).Using the keybd_event does work for regular Windows programs (like Notepad, for example), but not for the game. I suppose this happens because it uses DirectX libraries, and also this simulation provided by keybd_event isn't, let's say, low-level enough. Would someone be able to help me on this?I'm using currently Delphi (Pascal), but if needed I suppose I can manage to apply some assembly code or something. Thanks in advance.

Share this post


Link to post
Share on other sites

Looks like I missed this one....I have done this for Age Of Empires 2, to automatically enter cheats very fast to get resources up alot quicker (for my younger brother) in Delphi 7.Not sure why you are having problems with keybd_event, but don't forget about SendMessage and PostMessage API's.Which is most likely how I managed to get it done. Unfortunately the old Age Of Empires 2 project is long gone with an old crash of my older pc which I lost alot of good old Delphi projects (should have backed em up eh).

Share this post


Link to post
Share on other sites

Not at all, I provided two alternatives to sending key presses which are the SendMessage and PostMessage API's.They are both fairly much the same except that SendMessage will wait until it's done where as PostMessage will just send it and come back not worrying about whether it got to it's location or not.

Share this post


Link to post
Share on other sites

I believe you are actually looking for the SendKeys API call (https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx). I work with Visual Basic.NET all the time and this works for me. Some additional Delphi samples can be found below.

http://www.delphi3000.com/=
http://www.festra.com/wwwboard/messages/6475.html
http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.