Solved

Force key imput on a DXInput program

Posted on 2003-10-24
6
265 Views
Last Modified: 2011-08-18
I was trying to press a key using keybd_event on a program using DXInput than i discoreverd that this method wont work. Here what i am trying to do:

I made program that read one memory value from another program. When this value is X the program press a key that, on the main program, provides a determined action who change the value memory again. But the main program is a game and it runs DXInput. Well... i cant use keybd_event on my program cuz it wont work for DXInput so this is the question : Does anyone knows how my program can press one key to the mais program ( who uses DXInput ) undestand the command ? ( Remember, the main program is aways running in full screnn ).

This is the OnTimer Event ( Maybe it heps.... )

procedure TForm1.Timer1Timer(Sender: TObject);
var
ready : cardinal;
pi : ^integer;
i1 : integer;
begin
  GetMem(buf,4);
  If ReadProcessMemory(HandleWindow,ptr($5D461C),buf,4,ready) then
  begin end;
  pi:=buf;
  i1:=pi^;
  //edit1.Text := inttostr(i1);
  FreeMem(buf);
  if i1 < 110 then
  begin
    beep;
    keybd_event( Ord('1'), MapvirtualKey( Ord('1'), 0), 0, 0 );
  end;
end;

Thx guys...
0
Comment
Question by:furmiga
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 250 total points
ID: 9613914
Hi,

Would you try sending KEYUP as well? Perhaps that is the reason.

...
 begin
    beep;
    keybd_event( Ord('1'), 0, 0, 0 ); // keydown event
    keybd_event( Ord('1'), 0, KEYEVENTF_KEYUP, 0 ); // keyup event
 end;
...

Regards, Geo
0
 
LVL 7

Author Comment

by:furmiga
ID: 9614030
Nop... Didnt work I am almost sure that the problem is the DXInput. Everything is going fine ( the beep stuff ) But on the game the keybd_event does not work. If I Alt+tab the main app when if is true, when I alt+tab again the keybd_event  does his job but just when I alt+tab (even using the old code).... Weird.... :) Thx anyway
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9614071
DirectX goes down to very low level hardware, probably below even the keybd_event level. DX also doesn't receive messages in the normal way so I suspect this may be a lost cause.

Geoff M.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Author Comment

by:furmiga
ID: 9614183
gmayo i hope.... i really hope that u r wrong :) If not, omg....

Well, maybe another instance of DXInput can self activate the key. Since i am on the main program what this action can make ? I mean if my program, using DXInput, can activate the key for the main program. Is it possible ? Damn i am getting crazy.....


Thx guys
0
 
LVL 11

Assisted Solution

by:robert_marquardt
robert_marquardt earned 250 total points
ID: 9615063
DirectInput reads below keybd_event level only for Win 9x.
For Win 2000 and XP keybd_event works.
Please contact me directly (robert_marquardt@gmx.de) and i can help you with a VxD driverfor Win 9x which squeezes the keys down the real keyboard buffer which is hidden deep inside Win 9x.
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9615202
I did wonder about opening your own DirectInput but would it work in parallel with the other app? Because normally one app would "own" the device at a time - switch focus from one app to the other and the new app now "owns" it temporarily.

I just did a search on Google for DirectInput and keybd_event - Robert, you get around a bit, don't you! ;-) So at least I was right, on Win9x systems anyway.

Geoff M.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question