Previous Thread
Next Thread
Print Thread
Page 1 of 2 1 2
Simulating key presses from an external app #40488
04/26/08 08:15 PM
04/26/08 08:15 PM
Joined: Apr 2008
Posts: 11
A
AAG Offline OP
Member
AAG  Offline OP
Member
A
Joined: Apr 2008
Posts: 11
Hi

It's my first post - so appologies if this has been asked before!

Is it possible to send fake key presses into MESS - from Windows XP (Pro)?

Eg using the Acorn Electron emulator, you need to type "OK" to get past the "..sound isn't 100% accurate" and then you need to type the "chain" command.

I believe the "dragon32" also needs extra keyboard commands to start loading disks/tapes.

I've tried writing a simple app which finds the main MessGui window, SetForegroundWindow and then sends keybrd_event.

I've also tried posting wm_keyup/down messages.

I've also tried a keyboard hook.

None worked!

I've also tried using SendInput. Using spy++ I can't see any difference between the messages originating from a physical keyboard, vs SendInput - yet all my attempts to simulate key inputs have failed.

There appears to be many conflicting advice about DirectInput and faking keys - as to what actually works.

I know I've got the right handle, because if I post a wm_quit - messgui does exit.

Any help/pointers would be great.

Looking through the code - there appaesr to be several debug outputs - maybe a debug messgui.exe would help see what keys have been posted in?

Thanks in advance


Re: Simulating key presses from an external app [Re: AAG] #40490
04/26/08 09:13 PM
04/26/08 09:13 PM
Joined: Nov 1999
Posts: 627
Lexington, MA
B
Bletch Offline

Senior Member
Bletch  Offline

Senior Member
B
Joined: Nov 1999
Posts: 627
Lexington, MA
WM_CHAR will work when natural keyboard is enabled. When natural keyboard is not enabled, MESS uses DirectInput.

As for needing "extra keyboard commands to start loading disk/tapes", it is unclear what you mean.

Also just out of curiosity, what are you trying to do?

Re: Simulating key presses from an external app [Re: Bletch] #40498
04/27/08 07:29 AM
04/27/08 07:29 AM
Joined: Oct 2006
Posts: 969
S
Stiletto Offline
Senior Member
Stiletto  Offline
Senior Member
S
Joined: Oct 2006
Posts: 969
It sounds like he wants to "console-ize" computer emulation. Insert the disk image and play! wink

Re: Simulating key presses from an external app [Re: Stiletto] #40499
04/27/08 11:58 AM
04/27/08 11:58 AM
Joined: Mar 2001
Posts: 16,070
USA
R
R. Belmont Offline
Very Senior Member
R. Belmont  Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,070
USA
Actually it sounds like he wants to cabinetize it, possibly with a working coin slot if you know what I mean. Or at least that's what this question has historically meant for MAME.

Re: Simulating key presses from an external app [Re: R. Belmont] #40500
04/27/08 12:18 PM
04/27/08 12:18 PM
Joined: Nov 1999
Posts: 627
Lexington, MA
B
Bletch Offline

Senior Member
Bletch  Offline

Senior Member
B
Joined: Nov 1999
Posts: 627
Lexington, MA
Perhaps, but the Dragon 32 and the Acorn Electron are generally not the usual fodder for the cabinet people.

Re: Simulating key presses from an external app [Re: Bletch] #40502
04/27/08 12:50 PM
04/27/08 12:50 PM
Joined: Jan 2006
Posts: 3,687
Trondheim, Norway
etabeta78 Offline
Very Senior Member
etabeta78  Offline
Very Senior Member
Joined: Jan 2006
Posts: 3,687
Trondheim, Norway
yet, sometimes people would only like to add a computer they used as child (e.g. c64, or dragon 32), on their private cabinet, with no money involved...

and the ability to make automatic every loading procedure is something that could help in this case (e.g. to avoid the need of a keyboard connected to the cab)

of course, on the MAME side, evil uses would probably be more common...

Re: Simulating key presses from an external app [Re: etabeta78] #40520
04/27/08 08:11 PM
04/27/08 08:11 PM
Joined: Apr 2008
Posts: 11
A
AAG Offline OP
Member
AAG  Offline OP
Member
A
Joined: Apr 2008
Posts: 11
Hi

I haven't quite gotten around to building a cab (although I do have the ultimarc avga card connected to a RGB Scart tv - and the dual x-arcade joystick!)

What I'm really wanting to do is connected to Gamebase - (http://www.bu22.com/). This windows generic emulator front end holds a load of additional info in an access databse (publisher, genre etc). Optionally has extras (screen shots, box scans, instructions etc). It also has it own scripting language and ability to hold custom data in that database.

What I was hoping to do was to write a "proxy" exe - which started mess (via createprocess - save the processid off). Then call enumWindows, finding the visiable windows for that processid. (There are user defined sleeps in there - so the screens are as expected). The proxy would then fire the keys as passed into it from gamesbase's acces database.

Ie for BBC disks - send SHIFT - BREAK
For Electron, send chiain "" - etc.

I haven't tried toggling the "keyboard type" - but for bbc/electron only the "emulated" option is available. (Natural is greyed out).

I can send the spy++ logs for physical keys vs SendInput keys if that would help? (Or would a debug mess build say which key was being pressed (ie I'd be able to tell if my keys were being read but then ignored for some other reason) ? If so, anyone any ideas of how to get a pre-built debug build?)

Any help -much apprecaited!

Thanks!

Re: Simulating key presses from an external app [Re: AAG] #40521
04/27/08 08:26 PM
04/27/08 08:26 PM
Joined: Nov 1999
Posts: 627
Lexington, MA
B
Bletch Offline

Senior Member
Bletch  Offline

Senior Member
B
Joined: Nov 1999
Posts: 627
Lexington, MA
While I don't know much about GameBase, I am skeptical about how well your approach could work satisfactorily. Pumping keystrokes into random apps, even when the apps do directly respond to WM_KEYDOWN/WM_CHAR, doesn't work that well.

All that said, if you propose reasonable ways to enhance MESS that make sense, I might be able to help you.

Re: Simulating key presses from an external app [Re: Bletch] #40621
04/30/08 07:54 PM
04/30/08 07:54 PM
Joined: Apr 2008
Posts: 11
A
AAG Offline OP
Member
AAG  Offline OP
Member
A
Joined: Apr 2008
Posts: 11
A few ideas do spring to mind :-

*) custom wm_user+xxx message (taking a virtual_key code and a up/down modifier for the params)

*) Use of wm_copydata - (great for printable chars - noot no use for shift/reak combinations unless we start with escaped strings! ie [SHIFT][BREAK])


However before that - I'm interested in Finding out what's happened to my key (if anything) - as from spy++ it looks like it should be ok.

I've downloaded the mess source code, and a debug build - and started sysinternals debugview - in the hopeing to see the various dprintf's there are in the code (eg winui.c/KeyboardKeyDown) - but I'm not seeing them.

I'm not a C developer (don't laught but delphi and MS C# is what pays the mortgage (but I have "dabbled" with C/c++ before)- and I haven't downloaded the mame compilation tools - is there anything else which needs setting up in order to see these dprintf's?

Thanks again!

Re: Simulating key presses from an external app [Re: AAG] #40622
04/30/08 08:00 PM
04/30/08 08:00 PM
Joined: Mar 2001
Posts: 16,070
USA
R
R. Belmont Offline
Very Senior Member
R. Belmont  Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,070
USA
MAME/MESS use DirectInput on Windows, which means they're well below the WM_xxx layer in USER32 (exception: natural keyboard mode *only* in MESS uses WM_CHAR). AFAIK it's not possible to reliably inject keypresses into them, and at least for MAME that's considered to be a feature :-)

Last edited by R. Belmont; 04/30/08 08:02 PM.
Page 1 of 2 1 2

Who's Online Now
3 registered members (ted, Vas Crabb, robcfg), 119 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Shout Box
Forum Statistics
Forums9
Topics8,606
Posts112,515
Members4,827
Most Online296
Dec 5th, 2018
Powered by UBB.threads™ PHP Forum Software 7.6.1.1
(Release build 20180111)
Page Time: 0.025s Queries: 15 (0.008s) Memory: 5.7202 MB (Peak: 5.9394 MB) Zlib enabled. Server Time: 2018-12-15 14:48:35 UTC