01 Using Simple Scripts to send FSX Events
Posted: 29 Nov 2011, 22:55
We all know that we can easily assign an FSX event to a key by selecting "Send Simconnect Event (FSX)" and picking the event we want from the dropdown box. But many of us (myself included) were a bit confused and intimidated at the thought of trying to figure out how to "Script" an event to take place. So today I want to talk a bit about the most basic "scripting" for HID macros... The "one liners" if you will...
Take the following example:
I have a hotkey linked to the TOGGLE_ALTERNATOR1 event. it looks like this...
But now what if I want to do the same thing using a script instead? Easy... It's a one liner... literally.. the one line is
Which Looks like...
Not for the real question... Why in the world would I want to do that in the first place?
Simple... I fly multi-engine planes...
Which makes it look like this...
Of course that is by no means the only reason for using the script rather than the "Send Simconnect Event (FSX)" dropdown box. In the same way you can send multiple events for whatever reason you like... For example the plane that I like to fly the most has it's left and right landing lights set to different switches... which for cockpit builders is a dream... but while I was still using keyboards to control the lights rather than switches, I needed the following code in order to turn them both on and off with a single keypress so I didn't overload what was already two full keyboards (not counting my regular windows keyboard).
At any rate I hope this gets you started with some simple "one liner" scripting..
Take the following example:
I have a hotkey linked to the TOGGLE_ALTERNATOR1 event. it looks like this...
But now what if I want to do the same thing using a script instead? Easy... It's a one liner... literally.. the one line is
Code: Select all
HIDMacros.FSXEvent "TOGGLE_ALTERNATOR1", 0
Not for the real question... Why in the world would I want to do that in the first place?
Simple... I fly multi-engine planes...
Code: Select all
HIDMacros.FSXEvent "TOGGLE_ALTERNATOR1", 0
HIDMacros.FSXEvent "TOGGLE_ALTERNATOR2", 0
HIDMacros.FSXEvent "TOGGLE_ALTERNATOR3", 0
HIDMacros.FSXEvent "TOGGLE_ALTERNATOR4", 0
Which makes it look like this...
Of course that is by no means the only reason for using the script rather than the "Send Simconnect Event (FSX)" dropdown box. In the same way you can send multiple events for whatever reason you like... For example the plane that I like to fly the most has it's left and right landing lights set to different switches... which for cockpit builders is a dream... but while I was still using keyboards to control the lights rather than switches, I needed the following code in order to turn them both on and off with a single keypress so I didn't overload what was already two full keyboards (not counting my regular windows keyboard).
Code: Select all
HIDMacros.FSXEvent "TOGGLE_LOGO_LIGHTS", 0
HIDMacros.FSXEvent "LANDING_LIGHTS_TOGGLE", 0
At any rate I hope this gets you started with some simple "one liner" scripting..