public bool Connect() { Console.WriteLine("Connect SimConnect"); try { _simConnect = new SimConnect("Touch Portal Plugin", GetConsoleWindow(), WM_USER_SIMCONNECT, _scReady, 0); _connected = true; // System Events _simConnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen); _simConnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit); _simConnect.OnRecvException += new SimConnect.RecvExceptionEventHandler(simconnect_OnRecvException); // Sim mapped events _simConnect.OnRecvEvent += new SimConnect.RecvEventEventHandler(simconnect_OnRecvEvent); // simconnect.OnRecvAssignedObjectId += new SimConnect.RecvAssignedObjectIdEventHandler(simconnect_OnRecvAssignedObjectId); // Sim Data _simConnect.OnRecvSimobjectData += new SimConnect.RecvSimobjectDataEventHandler(simconnect_OnRecvSimObjectData); _simConnect.OnRecvSimobjectDataBytype += new SimConnect.RecvSimobjectDataBytypeEventHandler(simconnect_OnRecvSimobjectDataBytype); _simConnect.ClearNotificationGroup(Groups.System); _simConnect.SetNotificationGroupPriority(Groups.System, NOTIFICATION_PRIORITY); _simConnect.ClearNotificationGroup(Groups.AutoPilot); _simConnect.SetNotificationGroupPriority(Groups.AutoPilot, NOTIFICATION_PRIORITY); _simConnect.ClearNotificationGroup(Groups.Fuel); _simConnect.SetNotificationGroupPriority(Groups.Fuel, NOTIFICATION_PRIORITY); _simConnect.Text(SIMCONNECT_TEXT_TYPE.PRINT_BLACK, 5, Events.StartupMessage, "TouchPortal Connected"); // Invoke Handler OnConnect(); return(true); } catch (COMException ex) { Console.WriteLine("Connection to Sim failed: " + ex.Message); } return(false); }