├── firectrl.au.txt ├── .gitignore ├── firectrl_b.png ├── firectrl_m.png ├── firectrl_p.png ├── README.md ├── README.txt ├── changelog.txt └── firectrl.ahk /firectrl.au.txt: -------------------------------------------------------------------------------- 1 | version=3.0.8 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.ini 2 | *.exe 3 | *.zip 4 | *.lnk -------------------------------------------------------------------------------- /firectrl_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilC/Fire-Control/HEAD/firectrl_b.png -------------------------------------------------------------------------------- /firectrl_m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilC/Fire-Control/HEAD/firectrl_m.png -------------------------------------------------------------------------------- /firectrl_p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilC/Fire-Control/HEAD/firectrl_p.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Instructions: https://github.com/evilC/Fire-Control/wiki 2 | Downloads: https://github.com/evilC/Fire-Control/releases 3 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Fire-Control 2 | ============ 3 | 4 | A multi-function macro for Mechwarrior Online 5 | 6 | For instructions, please see the wiki: 7 | 8 | https://github.com/evilC/Fire-Control/wiki -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | Fire Control Changelog 2 | 3 | Key: 4 | ! : Warning 5 | * : Comment 6 | = : Change / Fix 7 | + : Added feature 8 | 9 | 3.0.8 11th July 2022 10 | = evilC.com is down, so I moved update checking to GitHub 11 | 12 | 3.0.7 30th Jan 2017 13 | = Now uses {Blind} Send - should work better with foreign keyboards. 14 | Should also alleviate issues with CapsLock being on while keys are sent. 15 | This will also mean that multiple chars in Fire Sequence box (eg 11,22) will no longer work 16 | 17 | 3.0.6 16th July 2014 18 | ! If you previously used Arm Lock Toggle, please make sure Arm Lock Momentary is disabled! 19 | = Arm Lock Toggle is now Arm Lock Momentary 20 | PGI made Arm Lock Toggle a proper toggle, but did not also leave the old "Momentary" method in. 21 | So for those that preferred the old way, they can now use Fire Control to replicate the old behavior. 22 | 23 | 3.0.5 11th Apr 2014 24 | * "MWO Jump Jet Key" setting now actually takes effect 25 | 26 | 3.0.4 26th Feb 2014 27 | = Reorganize of the Main tab, things are now grouped by Action. 28 | + "Send key up on Fire" option added to Fire Timing 29 | This setting in effect alters the "pass-through" state of the button you bound to the Fire action. 30 | Please consult the documentation or the tooltip of this item for more info. 31 | = All items on the Main tab now have info tooltips. 32 | = Hotkeys should no longer fire on the MWO login screen. 33 | eg no more L in the login box if you use Shift! 34 | If this feature does not work for you (or all hotkeys stop working!),please let me know. 35 | 36 | 3.0.3 25th Feb 2014 37 | = Jump Jet Spam was not disabling on tab out. 38 | Fixed 39 | 40 | 3.0.2 25th Feb 2014 41 | = Timers etc disabled when you tab out of game. 42 | = If you have nothing in the Fire Sequence or a non-numeric entry in the Fire Rate box, but do have something bound to Fire... 43 | Nothing will now happen. 44 | = Fire Control is back to it's previous v2.x width 45 | 46 | 3.0.1 24th Feb 2014 47 | = Had left a debug message in ADHD, which was breaking stuff. 48 | Hotfix 49 | 50 | 3.0.0 24th Feb 2014 51 | + New in-app Instructions link to Wiki on GitHub. 52 | = NEW IMPROVED bindings tab with ADHD 3.0.0 53 | ! All your existing bindings will be lost. 54 | Sorry about that, gives you a chance to test the new bindings system though. 55 | = Arm lock toggle "L" setting now sends lowercase - "l". 56 | The uppercase L setting was also holding shift. 57 | = Fixed startup so firectrl_init only runs once. 58 | + Added Fire sequence subcommands: 59 | groupmode() 60 | reset 61 | stagger() 62 | See the new instructions link for info on usage 63 | 64 | 2.18 5th Jan 2014 65 | + Adjusted Jump Jet Spam timing. 66 | Jump Jets are now held for 100ms instead of 50. 67 | Default rate is now 250. 68 | 69 | 2.17 5th Jan 2014 70 | + Added "Jump Jet Spam" feature. 71 | This allows you to set a key that will spam the jump jets at a rate set by the user. 72 | Used when climbing hills or hugging terrain - avoids RSI through trying to spam key quickly. 73 | 74 | 2.16 20th Nov 2013 75 | = Now uses ADHD 2. No real changes, but now notifies of updates. 76 | 77 | 2.15 30th Oct 2013 78 | + Added 7-0 to list of options to Weapon Toggle. 79 | This is so that you can use weapon toggle as a generic toggle, 80 | Simply bind the thing you want to toggle to 7,8,9 or 0 81 | 82 | 2.14 25th Oct 2013 83 | = Made timings much more accurate. Previously in excess of 50ms was being lost per shot 84 | ! Due to the above change, you may need to increase all your Fire Rates by at least 50 85 | For example, with older versions of FC, you would use a Fire Rate of ~440 to get an AC2 to fire at max rate. 86 | The true figure (For Testing Grounds) is 500. As the new Fire Control works more accurately, old settings of 440 would no longer work properly. 87 | If you were previously using the correct value, you will now be firing faster - so watch that heat! 88 | 89 | 2.13 30th Sep 2013 90 | = Sorted a problem with toggles (Arm Lock and Weapon) - when you exited or tabbed out of MWO, the key you bound to this function would be "held". 91 | 92 | 2.12 20th Sep 2013 93 | * No real changes, just made UI bigger to accomodate "Functionality Toggle" which is now added to all macros by ADHD. 94 | 95 | 2.11 13th Sep 2013 96 | + Arm Lock now has it's own toggle. 97 | You no longer need to run two copies of Fire Control to have Arm Lock Toggle and Weapon Toggle at the same time. 98 | 99 | 2.10 6th Sep 2013 100 | + Added options 7-0 to Weapon Toggle group 101 | You can use this to allow "Weapon Toggle" to function as an "Arm Lock Toggle". 102 | eg program "Toggle Arm Lock" in MWO to 0 (Zero), replacing the shift binding. 103 | Then run a second copy of FC, and create a profile thus: 104 | Bindings - Weapon Toggle: Just tick the Shift box on the right - leave everything else on that row blank! 105 | Main - Set "Weapon Toggle Group" to 0, set "Scroll Lock Indicates..." option to NONE so it wont interfere with scroll lock light (Controlled by the 1st copy of FC). 106 | With that done, when you hit Shift in MWO, it will toggle arm lock status. 107 | + You can now run multiple copies of Fire Control by double clicking the icon twice. 108 | ! Do not try to have the same profile selected for both copies (The second copy will always start with the same profile selected, you need to change it) 109 | 110 | 2.9 30th Aug 2013 111 | = Fire Rate (And scroll lock state if that is enabled) is now reset on exit to mechlab like Weapon Toggle is 112 | 113 | 2.8 27th Aug 2013 114 | + Uses new ADHD "Run as Admin" feature to ensure script is always running as admin 115 | 116 | 2.7 15th Aug 2013 117 | + You can now select what the Scroll Lock light is used for (Weapon Toggle, Fire Rate, or None) 118 | Setting to None should alleviate compatibility issues with SweetFX 119 | 120 | 2.6 11th Aug 2013 121 | = If you bind fire to a keyboard button, it will no longer repeat if you hold the button down. 122 | If you had unexpected behaviour when firing with a keyboard key, this version may well fix things for you. 123 | ! The AHK version now defaults to including from the Autohotkey Lib folder (C:\Program Files\Autohokey\Lib by default) 124 | ! ADHD change: 125 | If none of the CTRL, Shift or Alt options in the Bindings tab are ticked for a binding, 126 | then it will work even if CTRL, Shift or Alt are held down 127 | 128 | 2.5 14th Jul 2013 129 | = Now supports a string in Fire Sequence 130 | So you could eg set fire sequence to hello,goodbye 131 | Please note that all keys in string will not be sent together. They will be sent with delay specified by SetKeyDelay 132 | Altering SetKeyDelay can affect whether the macro works in a game or not (eg less than 50ms wait before keyup does not work in MWO) 133 | 134 | 2.4 9th Jul 2013 135 | = Limit fire rate option now actually works - previously it was always on. 136 | 137 | 2.3 7th Jul 2013 138 | = Weapon Toggle now disables correctly again 139 | 140 | 2.2 7th Jul 2013 141 | + Now detects change of resolution and when it gets smaller, resets and shuts off all timers. 142 | In games that have a windowed mode lobby and a full-screen game - this should shut stuff off when you go back to the lobby. 143 | 144 | 2.1 7th Jul 2013 145 | = Fixed app detection. 146 | Will now disable timers and Weapon Toggle when the Limit App loses focus 147 | 148 | 2.0 6th Jul 2013 149 | * Initial Class Library version 150 | 151 | 1.x 152 | * Initial dev versions, not recorded -------------------------------------------------------------------------------- /firectrl.ahk: -------------------------------------------------------------------------------- 1 | ; Fire Control - Sample ADHD macro 2 | 3 | /* 4 | ToDo: 5 | * Disable hotkeys (eg Arm Lock Momentary) in login screen? Should be able to detect specific window size 6 | * Arm Lock Momentary option to hotkey box or plain edit box 7 | 8 | BUGS: 9 | 10 | Before next release: 11 | 12 | Features: 13 | 14 | Long-term: 15 | 16 | */ 17 | 18 | #SingleInstance Off 19 | 20 | ; Create an instance of the library 21 | ADHD := New ADHDLib 22 | 23 | ; Ensure running as admin 24 | ADHD.run_as_admin() 25 | 26 | ; ============================================================================================ 27 | ; CONFIG SECTION - Configure ADHD 28 | 29 | ; Authors - Edit this section to configure ADHD according to your macro. 30 | ; You should not add extra things here (except add more records to hotkey_list etc) 31 | ; Also you should generally not delete things here - set them to a different value instead 32 | 33 | ; You may need to edit these depending on game 34 | SendMode, Event 35 | SetKeyDelay, 0, 50 36 | 37 | ; Stuff for the About box 38 | 39 | ADHD.config_about({name: "Fire Control", version: "3.0.8", author: "evilC", link: "Website / Discussion Thread"}) 40 | ; The default application to limit hotkeys to. 41 | ; Starts disabled by default, so no danger setting to whatever you want 42 | ADHD.config_limit_app("CryENGINE") 43 | 44 | ; GUI size 45 | ADHD.config_size(375,320) 46 | 47 | ; Configure update notifications: 48 | ADHD.config_updates("https://raw.githubusercontent.com/evilC/Fire-Control/master/firectrl.au.txt") 49 | 50 | ; Defines your hotkeys 51 | ; subroutine is the label (subroutine name - like MySub: ) to be called on press of bound key 52 | ; uiname is what to refer to it as in the UI (ie Human readable, with spaces) 53 | ADHD.config_hotkey_add({uiname: "Fire", subroutine: "Fire"}) 54 | ADHD.config_hotkey_add({uiname: "Change Fire Rate", subroutine: "ChangeFireRate"}) 55 | ADHD.config_hotkey_add({uiname: "Weapon Toggle", subroutine: "WeaponToggle"}) 56 | ADHD.config_hotkey_add({uiname: "Arm Lock Momentary", subroutine: "ArmLockMomentary"}) 57 | ADHD.config_hotkey_add({uiname: "Fire Mode Toggle", subroutine: "FireModeToggle"}) 58 | ADHD.config_hotkey_add({uiname: "Jump Jet Spam", subroutine: "JumpJetSpam", tooltip: "Jump Jet spam will hit the Jump Jet key (Specified on the Main tab) quickly.`nThis helps prevent RSI when climbing hills etc."}) 59 | ;ADHD.config_hotkey_add({uiname: "Functionality Toggle", subroutine: "FunctionalityToggle"}) 60 | 61 | ; Hook into ADHD events 62 | ; First parameter is name of event to hook into, second parameter is a function name to launch on that event 63 | ADHD.config_event("option_changed", "option_changed_hook") 64 | ADHD.config_event("program_mode_on", "program_mode_on_hook") 65 | ADHD.config_event("program_mode_off", "program_mode_off_hook") 66 | ADHD.config_event("app_active", "app_active_hook") 67 | ADHD.config_event("app_inactive", "app_inactive_hook") 68 | ADHD.config_event("resolution_changed", "resolution_changed_hook") 69 | 70 | ADHD.init() 71 | ADHD.create_gui() 72 | 73 | ; The "Main" tab is tab 1 74 | Gui, Tab, 1 75 | ; ============================================================================================ 76 | ; GUI SECTION 77 | 78 | ; Create your GUI here 79 | ; If you want a GUI item's state saved in the ini file, create it like this: 80 | ; ADHD.gui_add("ControlType", "MyControl", "MyOptions", "Param3", "Default") 81 | ; eg ADHD.gui_add("DropDownList", "MyDDL", "xp+120 yp W120", "1|2|3|4|5", "3") 82 | ; The order is Control Type,(Variable)Name, Options, Param3, Default Value 83 | ; the Format is basically the same as an AHK Gui, Add command 84 | ; DO NOT give a control the same name as one of your hotkeys (eg Fire, ChangeFireRate) 85 | 86 | ; Otherwise, for GUI items that do not need to be saved, create them as normal 87 | 88 | ; Create normal label 89 | fs_w := ADHD.private.gui_w - 135 90 | Gui, Add, GroupBox, x5 y30 w365 h90, Fire Timing 91 | 92 | Gui, Add, Text, x10 y45, Fire Sequence 93 | 94 | ; Create Edit box that has state saved in INI 95 | ADHD.gui_add("Edit", "FireSequence", "xp+115 yp-2 W" fs_w, "", "") 96 | ; Create tooltip by adding _TT to the end of the Variable Name of a control 97 | FireSequence_TT := "A comma separated list of keys to hit - eg 1,2,3,4" 98 | 99 | Gui, Add, Text, x10 yp+30, Fire Rate (ms) 100 | ADHD.gui_add("Edit", "FireRate", "xp+115 yp-2 W50", "", 100) 101 | FireRate_TT := "The rate at which to fire (in milliseconds)" 102 | 103 | ADHD.gui_add("CheckBox", "KeyupOnFire", "xp+80 yp+4", "Send key up on Fire", 0) 104 | KeyupOnFire_TT := "If enabled, when you press the key bound to the Fire action, an up event is sent for that key.`nThis has the effect of stopping it from triggering actions in MWO.`n`nFor example, If the Fire action was bound to Right Mouse (RMB)...`nOFF: When you press RMB, weapon group 2 will fire in addition to the Fire Sequence.`nON: When you press RMB, weapon group 2 will not fire, but the Fire Sequence will." 105 | 106 | ADHD.gui_add("CheckBox", "LimitFire", "x10 yp+21", "Limit fire rate to specified rate (Stop 'Over-Clicking')", 0) 107 | 108 | Gui, Add, GroupBox, x5 yp+30 w365 h70, Toggles 109 | 110 | Gui, Add, Text, x10 yp+15, Weapon Toggle group 111 | ADHD.gui_add("DropDownList", "WeaponToggle", "xp+130 yp-2 W50", "None|1|2|3|4|5|6|7|8|9|0", "None") 112 | WeaponToggle_TT := "The Weapon Group that contains the weapon you wish to toggle." 113 | 114 | Gui, Add, Text, x10 yp+30, Arm Lock Toggle key 115 | ADHD.gui_add("DropDownList", "ArmLockMomentary", "xp+130 yp-2 W50", "None|7|8|9|0|L", "None") 116 | ArmLockMomentary_TT := "The key that you bound to 'Arm Lock Toggle' in MWO. `nThis MUST be different to the key you bound to the 'Arm Lock Momentary' action on the Bindings tab." 117 | 118 | Gui, Add, GroupBox, x5 yp+35 w365 h40, Jump Jet Spam 119 | 120 | Gui, Add, Text, x10 yp+15, MWO Jump Jet key 121 | ADHD.gui_add("Edit", "JumpJetKey", "xp+95 yp-2 W50", "", "Space") 122 | JumpJetKey_TT := "The key bound to Jump Jets in MWO.`nOnly needed if you use the 'Jump Jet Spam' feature." 123 | 124 | Gui, Add, Text, xp+75 yp+2, Jump Jet Spam Rate (ms) 125 | ADHD.gui_add("Edit", "JumpJetRate", "xp+130 yp-2 W50", "", "250") 126 | JumpJetRate_TT := "The rate at which Jump Jet Spam hits the Jump Jet key (in ms).`nOnly needed if you use the 'Jump Jet Spam' feature." 127 | 128 | Gui, Add, Text, x5 yp+40, Scroll Lock indicates status of 129 | ADHD.gui_add("DropDownList", "ScrollLockSetting", "xp+150 yp-4", "None|Weapon Toggle|Arm Lock Momentary|Fire Rate|Fire Mode", "None") 130 | 131 | 132 | ;Gui, Add, Link, x5 yp+25, Works with many games, perfect for MechWarrior Online (FREE GAME!) 133 | 134 | ; End GUI creation section 135 | ; ============================================================================================ 136 | 137 | ADHD.finish_startup() 138 | fire_divider := 1 139 | last_divider := 1 140 | arm_lock_momentary_mode := false 141 | weapon_toggle_mode := false 142 | jj_active := 0 143 | disable_hotkeys := 0 144 | 145 | ; Turn off scroll lock if it is used to indicate a status 146 | if (ScrollLockSetting != "None"){ 147 | SetScrollLockState, Off 148 | } 149 | 150 | return 151 | 152 | ; ============================================================================================ 153 | ; CODE SECTION 154 | 155 | ; Place your hotkey definitions and associated functions here 156 | ; When writing code, DO NOT create variables or functions starting adhd_ 157 | 158 | 159 | 160 | ; Macro is trying to fire - timer label 161 | DoFire: 162 | now := A_TickCount 163 | out := fire_array[current_weapon] 164 | 165 | if FireRate is not integer 166 | return 167 | if (FireRate <= 0 || out == ""){ 168 | return 169 | } 170 | 171 | if (groupmode){ 172 | tmp := groupmode_array[1] 173 | if (tmp == ""){ 174 | return 175 | } 176 | Send % "{Blind}{" tmp " down}" 177 | } else { 178 | ; If it is the first shot, process stagger... 179 | if (fire_array_count == 1 && stagger_array[current_weapon] != ""){ 180 | nextfire := now + stagger_array[current_weapon] 181 | SetFireTimer(1,1) 182 | } else { 183 | nextfire := now + (FireRate / fire_divider) 184 | SetFireTimer(1,false) 185 | } 186 | Send % "{Blind}" out 187 | } 188 | /* 189 | ; If fire rate changes mid-fire, stop the timer and re-start it at new rate 190 | if (last_divider != fire_divider){ 191 | SetFireTimer(1,false) 192 | } 193 | */ 194 | 195 | fire_array_count++ 196 | current_weapon := current_weapon + 1 197 | if (current_weapon > fire_array.MaxIndex()){ 198 | current_weapon := 1 199 | } 200 | return 201 | 202 | ; used to start or stop the fire timer 203 | ; mode: 0|1 - Enables / Disables timer 204 | ; delay: 0 - next fire is FireRate ms from now 205 | ; delay: 1 - next fire is at nextfire ("Limit Fire Rate" is being used - schedule fire for when window is up) 206 | SetFireTimer(mode,delay){ 207 | global FireRate 208 | global nextfire 209 | global fire_divider 210 | global last_divider 211 | 212 | ; Set last_divider, so we tell when the fire_divider changes 213 | last_divider := fire_divider 214 | 215 | if(mode == 0){ 216 | Gosub, DisableTimers 217 | } else { 218 | tim := (FireRate / fire_divider) 219 | if (delay){ 220 | SetTimer, DoFire, % nextfire - A_TickCount 221 | } else { 222 | SetTimer, DoFire, %tim% 223 | } 224 | } 225 | } 226 | 227 | ; Turn the weapon toggle on 228 | EnableToggle: 229 | if (ScrollLockSetting == "Weapon Toggle"){ 230 | SetScrollLockState, On 231 | } 232 | weapon_toggle_mode := true 233 | StringLower, tmp, WeaponToggle 234 | Send % "{Blind}{" tmp " down}" 235 | return 236 | 237 | ; Turn the weapon toggle off 238 | DisableToggle: 239 | if (ScrollLockSetting == "Weapon Toggle"){ 240 | SetScrollLockState, Off 241 | } 242 | weapon_toggle_mode := false 243 | StringLower, tmp, WeaponToggle 244 | Send % "{Blind}{" tmp " up}" 245 | return 246 | 247 | ; Turn the Arm Lock Momentary on 248 | EnableArmLockMomentary: 249 | if (!arm_lock_momentary_mode){ 250 | if (ScrollLockSetting == "Arm Lock Momentary"){ 251 | SetScrollLockState, On 252 | } 253 | arm_lock_momentary_mode := true 254 | StringLower, tmp, ArmLockMomentary 255 | Send % "{Blind}{" tmp "}" 256 | } 257 | return 258 | 259 | ; Turn the arm lock off 260 | DisableArmLockMomentary: 261 | if (arm_lock_momentary_mode){ 262 | if (ScrollLockSetting == "Arm Lock Momentary"){ 263 | SetScrollLockState, Off 264 | } 265 | arm_lock_momentary_mode := false 266 | StringLower, tmp, ArmLockMomentary 267 | Send % "{Blind}{" tmp "}" 268 | } 269 | return 270 | 271 | ; Keep all timer disables in here so various hooks and stuff can stop all your timers easily. 272 | DisableTimers: 273 | SetTimer, DoFire, Off 274 | SetTimer, do_jj, Off 275 | return 276 | 277 | ; Hook functions. We declared these in the config phase - so make sure these names match the ones defined above 278 | 279 | ; This is fired when settings change (including on load). Use it to pre-calculate values etc. 280 | option_changed_hook(){ 281 | firectrl_init() 282 | return 283 | } 284 | 285 | firectrl_init(){ 286 | global ADHD 287 | global FireSequence 288 | global fire_array := [] 289 | global groupmode := 0 290 | global groupmode_array := [] 291 | global stagger_array := [] 292 | global fire_array_reset_on_release := 0 293 | global fire_array_count := 1 294 | global current_weapon := 1 295 | global fire_divider 296 | global nextfire := 0 ; A timer for when we are next allowed to press the fire button 297 | global weapon_toggle_mode 298 | global arm_lock_momentary_mode 299 | global fire_on := 0 300 | 301 | gosub, DisableTimers 302 | 303 | if (arm_lock_momentary_mode){ 304 | Gosub, DisableArmLockMomentary 305 | } 306 | if (weapon_toggle_mode){ 307 | Gosub, DisableToggle 308 | } 309 | 310 | ; This gets called in Program Mode, so now would be a good time to re-initialize 311 | 312 | ; Reset fire rate if on double rate 313 | if (fire_divider != 1){ 314 | Gosub, ChangeFireRate 315 | } 316 | 317 | ; Split FireSequence box from comma separated list to array 318 | ;StringSplit, tmp, FireSequence, `, 319 | ; Strip all spaces 320 | StringReplace, array_list, FireSequence, %A_SPACE%,, All 321 | StringLower, array_list, array_list 322 | array_list := RegExMatchGlobal(array_list, "(\w*\(\w*[,\w]*\)|[\w)]+)") 323 | ;array_list := RegExMatchGlobal(array_list, "(\w*\(\w*,\w*\)|[\w)]+)") 324 | ;array_list := RegExMatchGlobal(FireSequence, "\s*(\w*\(\s*\w*\s*,\s*\w*\s*\)|[\w)]+)\s*") 325 | array_ctr := 1 326 | Loop, % array_list.MaxIndex(){ 327 | array_item := array_list[A_Index].Value(0) 328 | ;msgbox % A_Index ": " array_item 329 | if (array_item != ""){ 330 | if (array_item == "reset"){ 331 | fire_array_reset_on_release := 1 332 | } else if (substr(array_item,1,7) == "stagger"){ 333 | ;remove brackets 334 | tmp := substr(array_item,8) 335 | tmp := substr(tmp,2,strlen(tmp)-2) 336 | ; split by commas 337 | StringSplit, tmp, tmp, `, 338 | stagger_array[tmp1] := tmp2 339 | } else if(substr(array_item,1,9) == "groupmode"){ 340 | ;remove brackets 341 | tmp := substr(array_item,10) 342 | tmp := substr(tmp,2,strlen(tmp)-2) 343 | groupmode_array[1] := tmp 344 | } else { 345 | fire_array[array_ctr] := array_item 346 | array_ctr ++ 347 | } 348 | } 349 | } 350 | return 351 | } 352 | 353 | ; Gets called when the "Limited" app gets focus 354 | app_active_hook(){ 355 | global ADHD 356 | global disable_hotkeys 357 | 358 | curr_size := ADHD.limit_app_get_size() 359 | if (curr_size.w == 1286 || curr_size.h == 748){ 360 | disable_hotkeys := 1 361 | } else { 362 | disable_hotkeys := 0 363 | } 364 | return 365 | } 366 | 367 | ; Gets called when the "Limited" app loses focus 368 | app_inactive_hook(){ 369 | firectrl_init() 370 | } 371 | 372 | 373 | ; Fired when the limited app changes resolution. Useful for some games that have a windowed matchmaker and fullscreen game 374 | resolution_changed_hook(){ 375 | global ADHD 376 | global disable_hotkeys 377 | 378 | curr_size := ADHD.limit_app_get_size() 379 | last_size := ADHD.limit_app_get_last_size() 380 | ADHD.debug("Res change: " curr_size.w "x" curr_size.h " --> " last_size.w "x" last_size.h) 381 | if (curr_size.w > last_size.w || curr_size.h > last_size.h){ 382 | ; Got larger - lobby to game 383 | ADHD.debug("FC: Res got bigger") 384 | ; enable hotkeys 385 | disable_hotkeys := 0 386 | } else { 387 | ; Got smaller 388 | ADHD.debug("FC: Res got smaller") 389 | ;firectrl_init() 390 | ;Gosub, DisableTimers 391 | } 392 | return 393 | } 394 | 395 | ; ========================================================================================== 396 | ; HOTKEYS SECTION 397 | 398 | ; This is where you define labels that the various bindings trigger Make sure you call them the same names as you set in the settings at the top of the file (eg Fire, FireRate) 399 | 400 | ; Set up HotKey 1 401 | 402 | ; Fired on key down 403 | Fire: 404 | if (disable_hotkeys){ 405 | return 406 | } 407 | ; This is a key that may be held down, so we need to handle keyboard repeat. 408 | ; If a keyboard key is held down - windows will repeat that character. 409 | if (fire_on == 0){ 410 | fire_on := 1 411 | } else { 412 | return 413 | } 414 | 415 | ; Many games do not work properly with autofire unless this is enabled. 416 | ; You can try leaving it out. 417 | ; MechWarrior Online for example will not do fast (<~500ms) chain fire with weapons all in one group without this enabled 418 | if (KeyupOnFire){ 419 | ADHD.send_keyup_on_press("Fire","unmodified") 420 | } 421 | 422 | 423 | ; If we clicked the button too early, play a sound and schedule a click when it is OK to fire 424 | ; If the user releases the button, the timer will terminate 425 | if (LimitFire && A_TickCount < nextfire){ 426 | soundplay, *16 427 | SetFireTimer(1,true) 428 | return 429 | } 430 | 431 | ; Fire Lazors !!! 432 | GoSub, DoFire 433 | 434 | return 435 | 436 | ; Fired on key up 437 | FireUp: 438 | if (fire_on){ 439 | ; Send up event for held key 440 | tmp := groupmode_array[1] 441 | Send % "{Blind}{" tmp " up}" 442 | } 443 | fire_on := 0 444 | ; Kill the timer when the key is released (Stop auto firing) 445 | SetFireTimer(0,false) 446 | if (fire_array_reset_on_release){ 447 | current_weapon := 1 448 | } 449 | fire_array_count := 1 450 | return 451 | 452 | ; Set up HotKey 2 453 | 454 | ; Fired on key down 455 | ChangeFireRate: 456 | ; More Lazors!! Toggles double speed fire! 457 | ; Toggle divider between 1 and 2 458 | fire_divider := 3 - fire_divider 459 | if (ScrollLockSetting == "Fire Rate"){ 460 | if (fire_divider == 1){ 461 | SetScrollLockState, Off 462 | } else { 463 | SetScrollLockState, On 464 | } 465 | } 466 | return 467 | 468 | ; Set up Hotkey 3 469 | WeaponToggle: 470 | if (disable_hotkeys){ 471 | return 472 | } 473 | if (weapon_toggle_mode){ 474 | Gosub, DisableToggle 475 | } else { 476 | Gosub, EnableToggle 477 | } 478 | return 479 | 480 | ArmLockMomentary: 481 | if (disable_hotkeys){ 482 | return 483 | } 484 | 485 | Gosub, EnableArmLockMomentary 486 | return 487 | 488 | ArmLockMomentaryUp: 489 | if (disable_hotkeys){ 490 | return 491 | } 492 | Gosub, DisableArmLockMomentary 493 | return 494 | 495 | JumpJetSpam: 496 | if (disable_hotkeys){ 497 | return 498 | } 499 | if (!jj_active){ 500 | jj_active := 1 501 | SetTimer, do_jj, %JumpJetRate% 502 | Gosub, do_jj 503 | } 504 | return 505 | 506 | JumpJetSpamUp: 507 | jj_active := 0 508 | SetTimer, do_jj, Off 509 | return 510 | 511 | do_jj: 512 | Send % "{Blind}{" JumpJetKey " down}" 513 | Sleep, 100 514 | Send % "{Blind}{" JumpJetKey " up}" 515 | return 516 | 517 | FireModeToggle: 518 | groupmode := 1-groupmode 519 | if (groupmode){ 520 | if (fire_on){ 521 | SetFireTimer(0,0) 522 | Gosub, DoFire 523 | } 524 | } else { 525 | if(fire_on){ 526 | ; Send up event for held key 527 | tmp := groupmode_array[1] 528 | Send % "{Blind}{" tmp " up}" 529 | Gosub, DoFire 530 | } 531 | } 532 | if (ScrollLockSetting == "Fire Mode"){ 533 | if (groupmode){ 534 | SetScrollLockState, On 535 | } else { 536 | SetScrollLockState, Off 537 | } 538 | } 539 | Return 540 | 541 | ; From http://www.autohotkey.com/board/topic/14817-grep-global-regular-expression-match/page-2#entry578137 542 | RegExMatchGlobal(ByRef Haystack, NeedleRegEx) { 543 | Static Options := "U)^[imsxACDJOPSUX`a`n`r]+\)" 544 | NeedleRegEx := (RegExMatch(NeedleRegEx, Options, Opt) ? (InStr(Opt, "O", 1) ? "" : "O") : "O)") . NeedleRegEx 545 | Match := {Len: {0: 0}}, Matches := [], FoundPos := 1 546 | While (FoundPos := RegExMatch(Haystack, NeedleRegEx, Match, FoundPos + Match.Len[0])) 547 | Matches[A_Index] := Match 548 | Return Matches 549 | } 550 | 551 | ; =================================================================================================== 552 | ; FOOTER SECTION 553 | 554 | ; KEEP THIS AT THE END!! 555 | ;#Include ADHDLib.ahk ; If you have the library in the same folder as your macro, use this 556 | #Include ; If you have the library in the Lib folder (C:\Program Files\Autohotkey\Lib), use this 557 | --------------------------------------------------------------------------------