Nopers Posted December 12, 2012 Posted December 12, 2012 I'm trying to make an AHK (v1.1.09) script for DCS Black Shark v1.0.2 that automates engine start (much quicker than the LWin-Home command). But, I can't get AutoHotKey scripts to work with DCS BS at all. Here is a test script I used: -------------------------- #NoEnv #Warn SendMode Input SetWorkingDir %A_ScriptDir% #s:: SendEvent e return ---------------------------- I've tested this script with Notepad, MS Word, and IL2 1946, so I know this script works, just not with DCS Black Shark. Other things I've tried: SetKeyDelay, 100 SetKeyDelay, 1, -1 SendMode Play SetKeyDelay, 0, 50 SetKeyDelay, 0, 50, Play ControlSend Send (instead of SendEvent) Send (and SendEvent) {e down}{e up} Different HotKeys Setting the script (AutoHotKey) process to High priority Combinations of all of the above Any other ideas on how to get AutoHotKey scripts to work with DCS Black Shark v1.0.2? Thanks for any advice!
agrasyuk Posted December 12, 2012 Posted December 12, 2012 hi and welcome to the forums. I experienced the same thing. the only way I found to work around it is send commands in a manner listed below . cumbersome, but at least it works. perhaps others can give you a better suggestions. Send {Lctrl down} sleep, 10 send {Lshift down} sleep, 10 send {numpad6} sleep, 10 send {Lshift up} Sleep 10 send {Lctrl up} Anton. My pit build thread . Simple and cheap UFC project
Nopers Posted December 12, 2012 Author Posted December 12, 2012 Yep Thanks for the fast reply! Yeah, I tried sleep, but for some reason there was an issue with the hot key Win-S. I changed it to something like Win-1 and it worked!
Nopers Posted December 13, 2012 Author Posted December 13, 2012 Here is the script I made This script was used with DCS Blackshark 1.0.2 and AHK 1.1.09. It takes 1 minute 42 seconds to start and boot up all systems versus 2 minutes 35 seconds using the Win-Home cheat/shortcut. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Warn ; Recommended for catching common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #UseHook On ; Hootie's quick engine start script ; IMPORTANT NOTES: ; -assumes all KA-50 switches are in default position (mostly OFF) when a mission starts engine off on the ramp ; -assumes game is NOT paused ; -BlockInput will block your keyboard and mouse so you can't interrupt the script ; -DO NOT switch windows (minimize DCS BS, or switch to another app). AHK script acts on the active window. ^#!s:: ; Hotkey: Ctrl - Win - Alt - S ; give user time to release the keys Sleep, 200 BlockInput SendAndMouse SendEvent {Lctrl down}{Lshift down}{w 2}{Lshift up}{Lctrl up} ; Bat2 - ON SendEvent {Lctrl down}{Lshift down}{e 2}{Lshift up}{Lctrl up} ; Bat1 - ON SendEvent {Lctrl down}{Lshift down}{Lalt down}{w}{Lalt up}{Lshift up}{Lctrl up} ; Bat2 Cover - Down SendEvent {Lctrl down}{Lshift down}{Lalt down}{e}{Lalt up}{Lshift up}{Lctrl up} ; Bat1 Cover - Down SendEvent {Lctrl down}{Lshift down}{a}{Lshift up}{Lctrl up} ; Fwd Boost Pump - ON SendEvent {Lctrl down}{Lshift down}{d}{Lshift up}{Lctrl up} ; Aft Boost Pump - ON SendEvent {Rctrl down}{Rshift down}{l 2}{Rshift up}{Rctrl up} ; APU Fuel Shutoff - ON SendEvent {Lshift down}{r}{Lshift up} ; Rotor Brake - OFF SendEvent {Home} ; Start APU ; APU Starting... SendEvent {Rctrl down}{c}{Rctrl up} ; close door SendEvent {Rctrl down}{Rshift down}{j 2}{Rshift up}{Rctrl up} ; Left Eng Fuel Shutoff - ON SendEvent {Rctrl down}{Rshift down}{k 2}{Rshift up}{Rctrl up} ; Right Eng Fuel Shutoff - ON SendEvent {Rctrl down}{Rshift down}{Ralt down}{j}{Ralt up}{Rshift up}{Rctrl up} ; Left Eng Fuel Shutoff Cover - Down SendEvent {Rctrl down}{Rshift down}{Ralt down}{k}{Ralt up}{Rshift up}{Rctrl up} ; Left Eng Fuel Shutoff Cover - Down SendEvent {Rctrl down}{Home 2}{Rctrl up} ; EEG Left Eng - ON SendEvent {Rctrl down}{End 2}{Rctrl up} ; EEG Right Eng - ON SendEvent {Rctrl down}{Ralt down}{Home}{Ralt up}{Rctrl up} ; EEG Left Eng Cover - Down SendEvent {Rctrl down}{Ralt down}{End}{Ralt up}{Rctrl up} ; EEG Right Eng Cover - Down SendEvent {Rshift down}{0}{Rshift up} ; ABRIS Power - ON ; For some reason master warning needs to be held down for a second SendEvent {m down} ; Master Warning Light - Reset Sleep, 20 SendEvent {m up} ; Master Warning Light - Reset ; wait for APU to spin up before starting left engine... Sleep, 10000 ; 10 sec for APU to spin up SendEvent {e} ; Engine Selector - Select Left Engine SendEvent {Home} ; Start Left Engine Sleep, 1000 ; Wait a second before opening cut-off valve SendEvent {Rctrl down}{PgUp}{Rctrl up} ; Left Cut-off valve - OPEN ; Left Engine Starting... SendEvent {Lctrl down}{Lshift down}{z 2}{Lshift up}{Lctrl up} ; Fire Extinguishers - OPER SendEvent {Lctrl down}{Lshift down}{Lalt down}{z}{Lalt up}{Lshift up}{Lctrl up} ; Fire Extinguishers Cover - Down SendEvent {Lctrl down}{Lshift down}{h}{Lshift up}{Lctrl up} ; Fuel Meter Power - ON SendEvent {Lctrl down}{Lalt down}{z}{Lalt up}{Lctrl up} ; Intercom - ON SendEvent {Rctrl down}{Ralt down}{p}{Ralt up}{Rctrl up} ; VHF1 - ON SendEvent {Lctrl down}{Lalt down}{p}{Lalt up}{Lctrl up} ; VHF2 - ON SendEvent {Rshift down}{n}{Rshift up} ; SAI - ON SendEvent {Rshift down}{Ralt down}{i}{Ralt up}{Rshift up} ; INU Heat - ON SendEvent {Rctrl down}{Ralt down}{i}{Ralt up}{Rctrl up} ; INU Power - ON SendEvent {Lshift down}{d}{Lshift up} ; K-041 - ON ; wait for left engine to spin up before starting right engine... Sleep, 40000 ; 40 sec for Engine to spool up to IDLE SendEvent {e} ; Engine Selector - Select Right Engine SendEvent {Home} ; Start right Engine Sleep, 1000 ; Wait a second before opening cut-off valve SendEvent {Rctrl down}{PgDn}{Rctrl up} ; Right Cut-off valve - OPEN SendEvent {Lctrl down}{Lshift down}{y}{Lshift up}{Lctrl up} ; Left Generator - ON SendEvent {Lctrl down}{Lshift down}{u}{Lshift up}{Lctrl up} ; Right Generator - ON SendEvent {Lctrl down}{Lshift down}{o}{Lshift up}{Lctrl up} ; Data Link Equip Power - ON SendEvent {Lctrl down}{Lshift down}{p}{Lshift up}{Lctrl up} ; Data Link VHF TLK - ON SendEvent {Rshift down}{Ralt down}{e}{Ralt up}{Rshift up} ; Ejection System Power 1 - ON SendEvent {Rshift down}{Ralt down}{r}{Ralt up}{Rshift up} ; Ejection System Power 2 - ON SendEvent {Rshift down}{Ralt down}{t}{Ralt up}{Rshift up} ; Ejection System Power 3 - ON SendEvent {Rctrl down}{Rshift down}{Ralt down}{e}{Ralt up}{Rshift up}{Rctrl up} ; Ejection System Power Cover - Down SendEvent {Lshift down}{Lalt down}{d 2}{Lalt up}{Lshift up} ; Weapon Control System Power - ON SendEvent {Lctrl down}{Lshift down}{Lalt down}{d}{Lalt up}{Lshift up}{Lctrl up} ; Weapon Control System Power Cover - Down SendEvent {Lshift down}{Lalt down}{i 2}{Lalt up}{Lshift up} ; IFF - ON SendEvent {Lctrl down}{Lshift down}{Lalt down}{i}{Lalt up}{Lshift up}{Lctrl up} ; IFF Cover - Down ; By Default not going to turn on lights SendEvent {Rctrl down}{0}{Rctrl up} ; Signal Flares - ON SendEvent {Lctrl down}{n}{Lctrl up} ; LWS - ON SendEvent {Lctrl down}{Lshift down}{c}{Lshift up}{Lctrl up} ; CMD UV-26 - ON SendEvent {Lshift down}{Lalt down}{c}{Lalt up}{Lshift up} ; CMD UV-26 Cover - Down ; Uncage SAI by holding counter-clockwise turn for a specific amount of time SendEvent {Rshift down}{Ralt down}{a down} ; turn c-c...hold Sleep, 30 SendEvent {Ralt up}{Rshift up}{a up} ; stop turn, release SAI knob ; Clockwise a tad SendEvent {Rctrl down}{Rshift down}{a down} ; turn clockwise...hold Sleep, 5 SendEvent {Rshift up}{Rctrl up}{a up} ; stop turn, release SAI knob SendEvent {Ralt down}{b 3}{Ralt up} ; PVI Master Mode - OPER SendEvent {Rctrl down}{b}{Rctrl up} ; Datalink Power - ON SendEvent {Lshift down}{b}{Lshift up} ; Bank Autopilot Stability - ON SendEvent {Lshift down}{p}{Lshift up} ; Pitch Autopilot Stability - ON SendEvent {Lshift down}{h}{Lshift up} ; Heading/CRS Autopilot Stability - ON SendEvent {Lalt down}{i 2}{Lalt up} ; Dust Protection - ON Sleep, 39000 ; Wait 40 - 1 (39) sec for right engine to spool up to IDLE SendEvent {End} ; APU Shutoff (Stop) SendEvent {Rctrl down}{Rshift down}{l}{Rshift up}{Rctrl up} ; APU Fuel Shutoff - OFF SendEvent {Rctrl down}{Rshift down}{Ralt down}{l}{Ralt up}{Rshift up}{Rctrl up} ; APU Fuel Shutoff Cover - Down SendEvent {PgUp 2} ; Engine Power Levers - AUTO SendEvent 5,2,3,3,3 ; Set ABRIS to NAV, zoom in a couple times ; set ralt by holding knob down for a specific time SendEvent {Lshift down}{. down} ; set Ralt to about 50 ft Sleep, 290 ; hold it down for 1/2 sec SendEvent {Lshift up}{. up} ; release ralt set ; set HUD brightness by holding knob clockwise for a specific time SendEvent {Rctrl down}{Rshift down}{h down} ; rotate HUD bright knob clockwise and hold Sleep, 500 ; hold it down for 1/2 sec SendEvent {Rctrl up}{Rshift up}{h up} ; release hud brightness knob SendEvent {Rshift down}{o}{Rshift up} ; Laser Standby Sw - ARM SendEvent {Lalt down}{w}{Lalt up} ; Master Arm - Arm SendEvent {y} ; Select outward stations SendEvent {Lshift down}{w}{Lshift up} ; release parking brake ; Need to delay uncaging (until it turns on after both engines/generators online) Sleep, 4000 SendEvent {o} ; uncage SHKVAL BlockInput Default MsgBox Start Complete! return
Recommended Posts