August 8, 201213 yr I'm using this code for some KEY_EVENTS: Class Form1 Dim fsx_simconnect As SimConnect Const WM_USER_SIMCONNECT As Integer = &H402 .... Public Enum hSimconnect group1 End Enum Private Enum INPUT_ID 'should be used for sending Keyboard Input ? INPUT0 End Enum .... Private Enum EVENT_ID EVENT_APon EVENT_APoff EVENT_FLAPSup EVENT_FLAPSdn EVENT_ALTOnOff End Enum .... <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> _ Structure Struct1 . '0 . . Public aponoffx As Single '7 <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Titlex As String End Structure .... Private Enum DEFINITIONS Struct1 End Enum Private Enum DATA_REQUESTS REQUEST_1 End Enum Enum UPEVENT 'should be used for sending Keyboard Input ? WHATEVER End Enum Enum DOWNEVENT 'should be used for sending Keyboard Input ? WHATEVER End Enum ..... Private Sub btnconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnconnect.Click 'EXAMPLE fsx_simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_APOnOff, "AP_MASTER") fsx_simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_APon, "AUTOPILOT_ON") fsx_simconnect.MapClientEventToSimEvent(EVENT_ID.EVENT_APoff, "AUTOPILOT_OFF") . . fsx_simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "AUTOPILOT MASTER", "Bool", SIMCONNECT_DATATYPE.FLOAT32, 0, 7) . . . fsx_simconnect.RegisterDataDefineStruct(Of Struct1)(DEFINITIONS.Struct1) AddHandler fsx_simconnect.OnRecvSimobjectData, New SimConnect.RecvSimobjectDataEventHandler(AddressOf simconnect_OnRecvSimobjectData) fsx_simconnect.RequestDataOnSimObject(DATA_REQUESTS.REQUEST_1, DEFINITIONS.Struct1, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.VISUAL_FRAME, 0, 0, 0, 0) End Sub Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If aponoff = 0 Then fsx_simconnect.TransmitClientEvent(DEFINITIONS.Struct1, EVENT_ID.EVENT_APon, 0, hSimconnect.group1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY) If aponoff = 1 Then fsx_simconnect.TransmitClientEvent(DEFINITIONS.Struct1, EVENT_ID.EVENT_APoff, 0, hSimconnect.group1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY) End Sub Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ' Here should be the Transmit Key Event to the AUTOPILOT MASTER as a Example End Sub --------------------------------------- Everything is working OK. Several trials with different Forums explanations for sending Keystrokes via Simconnect unfortunately without success. I would need a precise Example how to implement the KEYSTROKE "Z" for the "AP MASTER" for example. I think it is also possible to send a combination of Keystrokes like "shift+h". Many thanks in advance. regards,
August 13, 201213 yr Friedrich, As that as I know, there is no API in SimConnect that you can use to send a key stroke. What is possible is to detect (in your program) that a key was activated in FSX and to send back an event to fSX in order to trigger some process. You can find an example (C++) here : http://msdn.microsoft.com/en-us/library/cc730335.aspx Patrick.
August 14, 201213 yr Author Friedrich, As that as I know, there is no API in SimConnect that you can use to send a key stroke. What is possible is to detect (in your program) that a key was activated in FSX and to send back an event to fSX in order to trigger some process. You can find an example (C++) here : http://msdn.microsof...y/cc730335.aspx Patrick. Hi, thanks for your comment. In fact it seems not possibile. Maybe the only way around is to send a Keystroke via the programmer software to the Window/Program that has the focus. This is possible but i believe not very save with FSX. regards
August 14, 201213 yr The usual logic with simConnect is generally not to send a key but an event. For instance, if you want to turn on / off the AP Master, send an event AP_MASTER using the API SimConnect_TransmitClientEvent. You will find the list of events in the SDK documentation also samples. Patrick.
August 17, 201213 yr Author The usual logic with simConnect is generally not to send a key but an event. For instance, if you want to turn on / off the AP Master, send an event AP_MASTER using the API SimConnect_TransmitClientEvent. You will find the list of events in the SDK documentation also samples. Patrick. Hi, in fact that is what i'm doeing as explained above with my first Post. Anyway i will check some different possibility and revert if successfull. regards,
Create an account or sign in to comment