Jump to content
The simFlight Network Forums

keystrokes or comand to FS


Recommended Posts

Morning to all,

using my app (write in VB.net), i'm trying to send a simple CTRL+SHIFT+D to FS.

On first attempt, i've tried to use, via code, an AppActivate("Microsoft Flight Simulator X") to get the focus on FS

and then an SendKeys.Send("^(+D)").

No success. :(

On second attempt, i've, i've tried to use 3200 fsuipc's offset but i'm not able to undestood how 12 byte offset works.

Can you suggest me a simple way?

Thanks in advance

emanuele

Link to comment
Share on other sites

On first attempt, i've tried to use, via code, an AppActivate("Microsoft Flight Simulator X") to get the focus on FS

and then an SendKeys.Send("^(+D)").

Not knowing VB.Net at all, I don't really know what those do.

On second attempt, i've, i've tried to use 3200 fsuipc's offset but i'm not able to undestood how 12 byte offset works.

That method merely sends the raw WM_KEYDOWN or WM_KEYUP commands with appropriate parameters supplied by you. It's the most basic and probably most complicated way -- but standard Windows. Maybe in VB.Net you never actually come against the actual Windows messages? I don't know how much you are insulated from all that.

Can you suggest me a simple way?

Easiest way by far is to use the built-in FSUIPC control to press and release a key -- see the Advanced User's manual. It's number 1070 in the list of Additional "FS" Controls. you can send any of those except the offset controls) by number, using offset 3110 with the parameter already placed in 3114.

Pete

Link to comment
Share on other sites

Thanks Pete!

So, if i understood well, to send a keystroke to FS i must use 3110 offset with main value set to 1070 and parameter using the formula Keycode + 256 * shift code.

An example: CTRL + SHIFT + d = 100 (d key code) + 256 * 3 (CTRL + SHIFT shift code) = 868 it's correct?

while for a simple "l" send to FS i'm not able to understood if the correct way is

a ) 76 (l key code) + 256 * 8 ("normal") = 2124

b ) 76 (l key code) + 256 * 1 (???) = 332

Emanuele

Link to comment
Share on other sites

So, if i understood well, to send a keystroke to FS i must use 3110 offset with main value set to 1070 and parameter using the formula Keycode + 256 * shift code.

An example: CTRL + SHIFT + d = 100 (d key code) + 256 * 3 (CTRL + SHIFT shift code) = 868 it's correct?

No. Where do you get 100 as the keycode for the D key? 100 is the keycode for the Numpaad 4 key when numlock in on. D's keycode is 68. I think you must be looking in the wrong place!

The shift code is okay, but when programming it's easier to understand the format when you consider the keycode is the byte in x3114 and the shift code is the byte in x3115. The "formula" 256*s + k is for folks needing a single decimal number to enter in the parameter field of the assignments.

868 = 0x0364 i.e 3 in the high byte, 100 in the low byte. Look at it that way, it is easier to see.

You must also either write the whole 8 bytes as one FSUPC_Write (so use a structure or array), OR, possibly easier, write the 32 bit word at 3114 first then the 3110 value. But both before the next Process call.

... while for a simple "l" send to FS i'm not able to understood if the correct way is

a ) 76 (l key code) + 256 * 8 ("normal") = 2124

b ) 76 (l key code) + 256 * 1 (???) = 332

76 is the keycode for L. Is that what you wanted? If you meant I (the letter beteween H and J in the alphabest) then it is 73.

The latter is Shift+L, i.e. two keys, not just the L key. You are confusing characters, which have lower and upper cases, and keystrokes which do not.

The former is okay, just the L keystroke, but a shift code of 0 is the same. You don't need the 8. That's optional and a result only of how Windows works. FSUIPC assumes the 8 if no other codes are set.

Pete

Link to comment
Share on other sites

No. Where do you get 100 as the keycode for the D key? 100 is the keycode for the Numpaad 4 key when numlock in on. D's keycode is 68. I think you must be looking in the wrong place!

The shift code is okay, but when programming it's easier to understand the format when you consider the keycode is the byte in x3114 and the shift code is the byte in x3115. The "formula" 256*s + k is for folks needing a single decimal number to enter in the parameter field of the assignments.

868 = 0x0364 i.e 3 in the high byte, 100 in the low byte. Look at it that way, it is easier to see.

You must also either write the whole 8 bytes as one FSUPC_Write (so use a structure or array), OR, possibly easier, write the 32 bit word at 3114 first then the 3110 value. But both before the next Process call.

76 is the keycode for L. Is that what you wanted? If you meant I (the letter beteween H and J in the alphabest) then it is 73.

The latter is Shift+L, i.e. two keys, not just the L key. You are confusing characters, which have lower and upper cases, and keystrokes which do not.

The former is okay, just the L keystroke, but a shift code of 0 is the same. You don't need the 8. That's optional and a result only of how Windows works. FSUIPC assumes the 8 if no other codes are set.

Pete

Yeah Pete!

I'm trying to write a simple code to send a "L" to an standard FSX's plane such as the trike

and, if not make an misunderstood, sending an L will turn on the LIGHTS (standard command) in the same way as if I had pressed the "L" key on keyboard.

It's correct?

Link to comment
Share on other sites

and, if not make an misunderstood, sending an L will turn on the LIGHTS (standard command) in the same way as if I had pressed the "L" key on keyboard.

Yes, if the L is assigned to all lights in FS. More often it is better to send the actual FS control instead. Any FS control can be sent by its number via offset 3110. The one "L" is normally assigned to is "All lights toggle". There's a complete list of the FS control numbers installed in your FSUIPC documents folder.

By sending FS a "psuedo control" which tells it to send FS a keystroke which FS in turn looks up in its list and sends itself "All lights toggle" you are making things much less efficient than they need to be. Send the control you want instead.

Regards

Pete

Link to comment
Share on other sites

Dear Pete

Yes, if the L is assigned to all lights in FS. More often it is better to send the actual FS control instead. Any FS control can be sent by its number via offset 3110. The one "L" is normally assigned to is "All lights toggle". There's a complete list of the FS control numbers installed in your FSUIPC documents folder.

By sending FS a "psuedo control" which tells it to send FS a keystroke which FS in turn looks up in its list and sends itself "All lights toggle" you are making things much less efficient than they need to be. Send the control you want instead.

Regards

Pete

yes, i know.

Mine it's only a brain excercise to better learn FSUIPC.

At this point, I suspect, that there is a little/big problem because:

using FSinterrogate, i read on 3114 the value 76 and in 3110 the value 1070

and on IPC writes LOG i read

529592 WRITE0 3114, 4 bytes: 4C 00 00 00 L...

529592 WRITE0 3110, 4 bytes: 2E 04 00 00 ....

but the lights don't turn on or off

Same case for "S"

FSinterrogate, i read on 3114 the value 83 and in 3110 the value 1070

and on IPC writes LOG i read

637466 WRITE0 3114, 4 bytes: 53 00 00 00 S...

637466 WRITE0 3110, 4 bytes: 2E 04 00 00 ....

but the visual don't change. (Both L and S are correctly setted on FS)

Why?

Thanks for your help

Link to comment
Share on other sites

Why?

One of three things:

1. You are using an out-of-date version of FSUIPC (the ability to send the FSUIPC-added controls via 3110 was a later addition)

2. Those keys are being intercepted by something else, or

3. Those keys aren't correctly assigned.

Please also use the Button and Key logging option in FSUIPC to track these things down.

BTW the only supported versions of FSUIPC from today are 3.999z1 and 4.88.

I still think you should send the FS controls, not keystrokes.

Pete

Link to comment
Share on other sites

One of three things:

1. You are using an out-of-date version of FSUIPC (the ability to send the FSUIPC-added controls via 3110 was a later addition)

2. Those keys are being intercepted by something else, or

3. Those keys aren't correctly assigned.

Please also use the Button and Key logging option in FSUIPC to track these things down.

BTW the only supported versions of FSUIPC from today are 3.999z1 and 4.88.

I still think you should send the FS controls, not keystrokes.

Pete

********* FSUIPC4, Version 4.88 by Pete Dowson *********

FSUIPC4 Key is provided

74460 WRITE0 3114, 4 bytes: 53 00 00 00 S...

74460 WRITE0 3110, 4 bytes: 2E 04 00 00 ....

74460 FSUIPC Control Action: Ctrl=1070, Param=83

74460 SendKeyToFS(00000053=, KEYDOWN) ctr=0

74460 Sending WM_KEYDOWN, Key=83 (Scan code 31), Ctr=1

74585 SendKeyToFS(00000053=, KEYUP) ctr=0

74600 Sending WM_KEYUP, Key=83 (Scan code 31), Ctr=1

S Key assigned to change visual (standard)

But the visual dont't change :(

While if i press the S on keyboard, the visual change.

Link to comment
Share on other sites

But the visual dont't change :(

While if i press the S on keyboard, the visual change.

Strange then, because FSUIPC is doing exactly the right thing, and it works fine here. Sorry, I've no idea what's wrong on your PC.

There is some more logging you can enable to see what happens after the messages are sent, but i can't look them up right now -- just going out. Sorry.

What's wrong with using controls anyway?

Pete

Link to comment
Share on other sites

Sorry, I've no idea what's wrong on your PC.

One thing occurred to me. When your program is running and sending these keystrokes, FS does have the focus, doesn't it? It cannot receive the keystrokes if not. The way the facilities work is by using the "SendInput" Windows API, which emulates the actual keyboard. That way the correct processing of the KEYDOWN and KEYUP messages is performed by Windows, resulting, for instance, in WM_CHAR messages when these are a result.

This also applies to the separate WM_KEYDOWN / UP sending facility at offset 3200. It too uses SendInput.

As I've said, in any case, if the actions you want in FS are those performed by normal key assignment in FS, then you'll be far better off sending the controls themselves. FS doesn't have to have keyboard focus for those.

Regards

Pete

Link to comment
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

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy 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.