HOME       >>       Programming

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


KDEWolf

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.


Chesso

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).


yordan

huh ? did you really post here in order to explain that you had the solution of the problem and you don't have it any more so no more need for posting an answer ?


Chesso

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.


tansqrx

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/



VIEW ORIGINAL REGISTER GET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.