Crescendo Posted October 23, 2013 Posted October 23, 2013 If you’re like me you miss the ability to use custom chaff and flare programs when flying the simplified FC3 aircraft. In this light, the goal of this thread is to demonstrate a simple means of creating custom countermeasures macros for use when flying FC3 aircraft. Please be aware that the following is just one simple method that I’ve found works for me – I’m sure there are any number of ways to achieve the same or better results. Here’s a YouTube video showing a flare script in action. All of this is being done with one keypress (I actually run the flare program twice, so two keypresses really): 1. First, download and install AutoHotKey (http://www.autohotkey.com/). AutoHotKey (AHK) is a small program that allows you to write and execute a script. In other words, you can use AHK to execute a set of commands at the press of a button, i.e. to dispense a specific amount of chaff or flares in a specific pattern. 2. After you have installed AHK, right-click on your desktop or in Windows explorer and create a new AHK file in your filesystem as per the screenshot below: 3. Right-click the newly created AHK file and select “Edit Script”. This will open the AHK script in your default text editor. You should now be presented with your text editor of choice displaying the contents of the AHK script, as per the following screenshot: The text in the file is inserted automatically by AHK whenever you create a new AHK script. In the interests of keeping this guide as simple as possible, suffice to say you can ignore it. 4. We can now begin creating a custom countermeasures macro. What we need to do is enter a set of commands for the AHK script to execute. For example, we can use AHK to automatically dispense 10 flares at a rate of 1 flare per second, all at the press of a single button. The example of this script is below: 1Joy16:: Loop,10 { Send, {DEL} Sleep 1000 } ReturnHere’s how it looks in the script editor: In this example, I have set my Joystick Button 16 (“1Joy16”) to execute a ‘loop’ command. Upon pressing my 1Joy16 button, AHK will take whatever commands are in the brackets and run them 10 times (“Loop,10”). The commands in the brackets are “Send, {DEL}”, which presses the DELETE key, and “Sleep 1000”, which waits for 1000ms (1 second). Because the “Send” and “Sleep” commands are within the loop structure they will be executed 10 times, after which the script will finish. Therefore, the above script works as follows: When I press 1Joy16, the AHK script will automatically press the DELETE key 10 times, pausing 1 second in between each keypress. Because the DELETE key is the default FC3 bind for dispensing flares, this means that whenever I press 1Joy16, 10 flares will be automatically released at a rate of 1 flare per second! (Note: if you want to dispense chaff, the default FC3 bind is INSERT, i.e. "{INS}". However, there is no reason why you can't set up your own key binds accordingly.) 5. To execute the AHK script, simply save and close the text editor, and then double-click the AHK file. If the script has compiled and executed properly, you will see a small green “H” symbol in the taskbar notification area, as per the following screenshot: If you see this “H” symbol the AHK script is running. As long as you have the script running in the background, whenever you press 1Joy16 (or whatever button you have selected) the countermeasures program will run. If you don't see this "H", the AHK script was unable to compile and execute because there is something wrong with your programming. Most likely you used an improper command, or forgot syntax such as a comma or bracket etc. If you have everything configured properly and the script is running in the background, you should see the following in-game when you press your countermeasure program button: 6. You can also write more complicated countermeasures programs. For example, the following script is the one I used in the YouTube video at the start of this thread. This script dispenses 4 bursts of 2 flares 100ms apart, with a 500ms pause between each burst. 1Joy16:: Loop,4 { Loop,2 { Send, {DEL} Sleep 100 } Sleep 500 } Return 7. Something to keep in mind is that if you place both your chaff and flare scripts in one AHK file, your inputs will likely get 'stepped on' whenever you activate one countermeasures program while the other is running, so it's best to have two separate AHK files (one for each program). Also, be aware that your joystick buttons will be different to mine. You will have to discover the joystick ID numbers on your own. The easiest way is to download a premade AHK script that when run will display the relevant joystick ID when you press a joystick button. You can download it here: http://www.autohotkey.com/docs/scripts/JoystickTest.ahk 8. Now experiment! AHK is a powerful tool. Your countermeasures programs can be as varied and as complicated as you can stand. I myself keep it pretty simple - I only use two AHK scripts: one for flares and one for chaff, each bound to a different button on my joystick. I tinker with them as I see fit and change the timings and burst quantities as desired. And just so we're clear, there's are no 'magic settings' here. Program what you think will be effective, or what you would have used manually anyway. Think of AHK scripts as a time / mental energy saver that lets you focus on actually flying the jet, rather than worrying about how many times you need to press a button - there's a reason why modern aircraft automate this stuff. ------ A final note, while the information I've provided here is very basic, it does represent essentially the entirety of my AHK programming knowledge. For me, there has been no reason to learn anything extra because the knowledge I do have is sufficient to configure things to my satisfaction. So, if you do have any programming questions beyond this guide I may not be the best person to ask. 1 . [sIGPIC][/sIGPIC]
Vedexent Posted October 23, 2013 Posted October 23, 2013 Very cool - we were discussing the rate of automatic flare dispensing on server the other night, and had talked about creating a macro; this does exactly that, complete with software suggestions, and script examples - thanks! :) One interesting thing to note - since this is merely emitting keyboard events - and that's the exact strategy used by the Saitek X52 Pro profiles software, you could use this to control much more than chaff and flares. I doubt you could program flight maneuvers, or anything like that, as the program can't "sense" the environment - but it opens up some interesting possibilities like "power up my Su-25, load my favorite weapons, set my running lights correctly, start up the engines, and contact the tower to taxi." :D That is - if there's keybinding to select weapon load outs - I just use mouse.
Crescendo Posted October 23, 2013 Author Posted October 23, 2013 I doubt you could program flight maneuvers, or anything like that, as the program can't "sense" the environment - but it opens up some interesting possibilities like "power up my Su-25, load my favorite weapons, set my running lights correctly, start up the engines, and contact the tower to taxi." :D All of the above can be done if you have the time and inclination, except for the GUI stuff, as you noted. I remember a while back someone posted an AHK script that they used to fully start-up the Ka-50, and it was more than a minute faster than the internal DCS start-up script. . [sIGPIC][/sIGPIC]
_Dredd Posted October 25, 2013 Posted October 25, 2013 Very nice, might also be be the way to get flashing wing tip light mode working also. Current Flight Rig i7 4960X @ 4.6Ghz ASUS Rampage IV Formula G.SKILL TridentX 2400Mhz 32GB DDR3 Crucial 1TB MX300 SSD MSI Gaming X 1080Ti Samsung 55" JS8000 SUHD 4K Windows 10 x64 TrackIR 5, Warthog HOTAS Saitek Pro Flight Combat Pedals Custom Akers-Barnes, MkI eyeball.
tjhowse Posted October 25, 2013 Posted October 25, 2013 Your examples are very good, however I think if you worked a little harder at it you might have arrived at the following: #singleinstance force #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; Modify these to suit your preferences: ; ################################### ; The joystick number of your Warthog. Can change depending on system configuration. joystickNumber = 1 ; The delay between each countermeasure. flareInterval = 1000 chaffInterval = 333 ; The number of countermeasures dispensed in one activation. flareCount = 10 chaffCount = 10 ; Adjust these to suit your keybindings. flareKey = {Del} chaffKey = {Ins} ; ################################### ; Don't touch these: ; The rate at which the scripts runs in milliseconds. checkRate = 50 flareCooldown = 0 chaffCooldown = 0 flareCounter = 0 chaffCounter = 0 Hotkey, %joystickNumber%Joy18, goFlares Hotkey, %joystickNumber%Joy16, goChaff Loop { if ((flareCounter > 0) && (flareCooldown <= 0)) { Send, %flareKey% flareCooldown := flareInterval flareCounter-- } if ((chaffCounter > 0) && (chaffCooldown <= 0)) { Send, %chaffKey% chaffCooldown := chaffInterval chaffCounter-- } if (flareCooldown > 0) flareCooldown -= checkRate if (chaffCooldown > 0) chaffCooldown -= checkRate Sleep, checkRate } goFlares: if (flareCounter == 0) flareCounter := flareCount Return goChaff: if (chaffCounter == 0) chaffCounter := chaffCount Return This allows for easier customisation, and enables concurrent countermeasure programs with only a single script. If you wished to challenge your AHK skills a little more, I suggest you attempt to modify my program to allow different cooldown times to be loaded from an array. It would not be hard to allow for arbitrary patterns of countermeasures, rather than regularly-spaced programs. Of course, this is largely academic, as DCS' modelling of the effect of countermeasures is unclear, and countermeasure patterns that are used in real life may simply waste resources in this sim. Keep trying! :pilotfly:
tjhowse Posted October 26, 2013 Posted October 26, 2013 I went ahead and did that for you. The string of numbers and commas denotes the delays between the countermeasures being dispensed. For example: flareIntervals = 50,50,1000,50,50,1000,50,50 Fires three bursts of three flares, each burst separated by one second. A delay of 0 signals the script to stop parsing the list, which is automatically added to the end. #singleinstance force #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; Modify these to suit your preferences: ; ################################### ; The joystick number of your Warthog. Can change depending on system configuration. joystickNumber = 1 ; The delay between each countermeasure. flareIntervals = 50,50,1000,50,50,1000,50,50 chaffIntervals = 500,500,500,500,500,500,500,500 ; Adjust these to suit your keybindings. flareKey = {Del} chaffKey = {Ins} ; ################################### ; Don't touch these: ; The rate at which the scripts runs in milliseconds. checkRate = 50 flareCooldown = 0 chaffCooldown = 0 flareCounter = 0 chaffCounter = 0 flareFlag = 0 chaffFlag = 0 flareIntervals := flareIntervals . ",0" chaffIntervals := chaffIntervals . ",0" StringSplit, flareIntervals, flareIntervals, `, StringSplit, chaffIntervals, chaffIntervals, `, Hotkey, %joystickNumber%Joy18, goFlares Hotkey, %joystickNumber%Joy16, goChaff Loop { if ((flareFlag == 1) && (flareCooldown <= 0)) { Send, %flareKey% flareCounter++ flareCooldown := flareIntervals%flareCounter% if (flareCooldown == 0) { flareFlag := 0 flareCounter := 0 } } if ((chaffFlag == 1) && (chaffCooldown <= 0)) { Send, %chaffKey% chaffCounter++ chaffCooldown := chaffIntervals%chaffCounter% if (chaffCooldown == 0) { chaffFlag := 0 chaffCounter := 0 } } if (flareCooldown > 0) flareCooldown -= checkRate if (chaffCooldown > 0) chaffCooldown -= checkRate Sleep, checkRate } goFlares: flareFlag = 1 Return goChaff: chaffFlag = 1 Return
_Dredd Posted October 26, 2013 Posted October 26, 2013 (edited) Very nice, can modifiers be used also? For instance I use warthog throttle mouse slew button as modifier and joystick CMS button forward and backwards as flare and chaff buttons. To use the script I'd like to use the modifier with CMS button for scripted countermeasures and standard CMS buttons as single flare/chaff. Edited October 26, 2013 by _Dredd Current Flight Rig i7 4960X @ 4.6Ghz ASUS Rampage IV Formula G.SKILL TridentX 2400Mhz 32GB DDR3 Crucial 1TB MX300 SSD MSI Gaming X 1080Ti Samsung 55" JS8000 SUHD 4K Windows 10 x64 TrackIR 5, Warthog HOTAS Saitek Pro Flight Combat Pedals Custom Akers-Barnes, MkI eyeball.
tjhowse Posted October 27, 2013 Posted October 27, 2013 I'm afraid not without significant effort. Unfortunately joystick buttons cannot be chorded in AHK. Workarounds are possible, but inelegant.
Crescendo Posted October 27, 2013 Author Posted October 27, 2013 #singleinstance force #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; Modify these to suit your preferences: ; ################################### ; The joystick number of your Warthog. Can change depending on system configuration. joystickNumber = 1 ; The delay between each countermeasure. flareIntervals = 50,50,1000,50,50,1000,50,50 chaffIntervals = 500,500,500,500,500,500,500,500 ; Adjust these to suit your keybindings. flareKey = {Del} chaffKey = {Ins} ; ################################### ; Don't touch these: ; The rate at which the scripts runs in milliseconds. checkRate = 50 flareCooldown = 0 chaffCooldown = 0 flareCounter = 0 chaffCounter = 0 flareFlag = 0 chaffFlag = 0 flareIntervals := flareIntervals . ",0" chaffIntervals := chaffIntervals . ",0" StringSplit, flareIntervals, flareIntervals, `, StringSplit, chaffIntervals, chaffIntervals, `, Hotkey, %joystickNumber%Joy18, goFlares Hotkey, %joystickNumber%Joy16, goChaff Loop { if ((flareFlag == 1) && (flareCooldown <= 0)) { Send, %flareKey% flareCounter++ flareCooldown := flareIntervals%flareCounter% if (flareCooldown == 0) { flareFlag := 0 flareCounter := 0 } } if ((chaffFlag == 1) && (chaffCooldown <= 0)) { Send, %chaffKey% chaffCounter++ chaffCooldown := chaffIntervals%chaffCounter% if (chaffCooldown == 0) { chaffFlag := 0 chaffCounter := 0 } } if (flareCooldown > 0) flareCooldown -= checkRate if (chaffCooldown > 0) chaffCooldown -= checkRate Sleep, checkRate } goFlares: flareFlag = 1 Return goChaff: chaffFlag = 1 Return Thanks for taking an interest. I tried your tweaked script and it worked great. Cheers buddy! :beer: . [sIGPIC][/sIGPIC]
Cali Posted October 29, 2013 Posted October 29, 2013 I just use my HOTAS software. i7-4820k @ 3.7, Windows 7 64-bit, 16GB 1866mhz EVGA GTX 970 2GB, 256GB SSD, 500GB WD, TM Warthog, TM Cougar MFD's, Saitek Combat Pedals, TrackIR 5, G15 keyboard, 55" 4K LED
Harker Posted January 30, 2015 Posted January 30, 2015 (edited) I devised a workaround for using modifiers. I use a joystick with far less buttons than the Warthog, so I improvise, setting the pinky switch as a modifier. Most Joysticks come with some sort of a programming software. So I used this to set Pinky+POVup as PgUp and Pinky+POVdown as PgDn. Beginning form the script provided by tjhowse, I tweaked to this: ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder) ; #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; Modify these to suit your preferences: ; ################################### ; The delay between each countermeasure. flareInterval = 1000 chaffInterval = 333 ; The number of countermeasures dispensed in one activation. flareCount = 10 chaffCount = 10 ; Adjust these to suit your keybindings. flareKey = {Del} chaffKey = {Ins} ; ################################### ; Don't touch these: ; The rate at which the scripts runs in milliseconds. checkRate = 50 flareCooldown = 0 chaffCooldown = 0 flareCounter = 0 chaffCounter = 0 Hotkey, PgDn, goFlares Hotkey, PgUp, goChaff Loop { if ((flareCounter > 0) && (flareCooldown <= 0)) { Send, %flareKey% flareCooldown := flareInterval flareCounter-- } if ((chaffCounter > 0) && (chaffCooldown <= 0)) { Send, %chaffKey% chaffCooldown := chaffInterval chaffCounter-- } if (flareCooldown > 0) flareCooldown -= checkRate if (chaffCooldown > 0) chaffCooldown -= checkRate Sleep, checkRate } goFlares: if (flareCounter == 0) flareCounter := flareCount Return goChaff: if (chaffCounter == 0) chaffCounter := chaffCount Return Hope it helps! Edited January 30, 2015 by Harker The vCVW-17 is looking for Hornet and Tomcat pilots and RIOs. Join the vCVW-17 Discord. F/A-18C, F-15E, AV-8B, F-16C, JF-17, A-10C/CII, M-2000C, F-14, AH-64D, BS2, UH-1H, P-51D, Sptifire, FC3 - i9-13900K, 64GB @6400MHz RAM, 4090 Strix OC, Samsung 990 Pro
USA_Recon Posted September 4, 2021 Posted September 4, 2021 On 10/26/2013 at 4:11 AM, tjhowse said: I went ahead and did that for you. The string of numbers and commas denotes the delays between the countermeasures being dispensed. For example: flareIntervals = 50,50,1000,50,50,1000,50,50 Fires three bursts of three flares, each burst separated by one second. A delay of 0 signals the script to stop parsing the list, which is automatically added to the end. #singleinstance force #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; Modify these to suit your preferences: ; ################################### ; The joystick number of your Warthog. Can change depending on system configuration. joystickNumber = 1 ; The delay between each countermeasure. flareIntervals = 50,50,1000,50,50,1000,50,50 chaffIntervals = 500,500,500,500,500,500,500,500 ; Adjust these to suit your keybindings. flareKey = {Del} chaffKey = {Ins} ; ################################### ; Don't touch these: ; The rate at which the scripts runs in milliseconds. checkRate = 50 flareCooldown = 0 chaffCooldown = 0 flareCounter = 0 chaffCounter = 0 flareFlag = 0 chaffFlag = 0 flareIntervals := flareIntervals . ",0" chaffIntervals := chaffIntervals . ",0" StringSplit, flareIntervals, flareIntervals, `, StringSplit, chaffIntervals, chaffIntervals, `, Hotkey, %joystickNumber%Joy18, goFlares Hotkey, %joystickNumber%Joy16, goChaff Loop { if ((flareFlag == 1) && (flareCooldown <= 0)) { Send, %flareKey% flareCounter++ flareCooldown := flareIntervals%flareCounter% if (flareCooldown == 0) { flareFlag := 0 flareCounter := 0 } } if ((chaffFlag == 1) && (chaffCooldown <= 0)) { Send, %chaffKey% chaffCounter++ chaffCooldown := chaffIntervals%chaffCounter% if (chaffCooldown == 0) { chaffFlag := 0 chaffCounter := 0 } } if (flareCooldown > 0) flareCooldown -= checkRate if (chaffCooldown > 0) chaffCooldown -= checkRate Sleep, checkRate } goFlares: flareFlag = 1 Return goChaff: chaffFlag = 1 Return So what setting on the flares is controlling how many are used with this script ? Thanks!
draconus Posted September 5, 2021 Posted September 5, 2021 Read again this part: On 10/26/2013 at 10:11 AM, tjhowse said: flareIntervals = 50,50,1000,50,50,1000,50,50 Fires three bursts of three flares, each burst separated by one second. A delay of 0 signals the script to stop parsing the list, which is automatically added to the end. Just add or subtract the delay times and commas. Win10 i7-10700KF 32GB RTX4070S Quest 3 T16000M VPC CDT-VMAX TFRP FC3 F-14A/B F-15E CA SC NTTR PG Syria
Recommended Posts