Dachs Posted September 24, 2012 Posted September 24, 2012 Just found the great AHK scripts for VAC and TIR by Cubpilot, and now I want to see if I can make a simple script that sends the Eject command. I was hoping to just modify the VAC script, but I can't figure out how to send CTRL+E three times in a row? There should probably be a slight delay between the three key presses also..? Any hints and help appreciated! (I'm way better at woodworking than this blackmagic programming stuff) :cry::crash: System: Asus z270 A Prime, Intel i7-7700K 4.8GHz, 32GB DDR4, RTX2080, Samsung 500GB 850 EVO SSD. Valve Index VR, TM Warthog Throttle & Grip, Virpil MongoosT-50CM2 base, TM TPDR Rudders. OS: Win10 Home
PeterP Posted September 25, 2012 Posted September 25, 2012 (edited) Open the AHK Help and search for "sleep" . (running script in the notification tray > right-click on it > help) BTW : It isn not just 3x [Ctrl+E] , it is 3x [LCtrl]+E A working AHK sequence looks like this: $#e:: ; = [win+e] hotkey for following action Loop 3 { sendevent {LCtrl Down} {e Down} {e Up} {LCtrl Up} Sleep, 60 ; Sleep 60 milliseconds before next loop } return Edited September 25, 2012 by PeterP
Dachs Posted September 25, 2012 Author Posted September 25, 2012 Hi PeterP, thanks a bunch for helping me out here, and sending me in the right direction. Now, I probably mutilated your script, but after experimenting some I ended up with this: ;Ejection script for DCS A10C. ;Holds down Left Control, presses e three times and releases Left Control. #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. Process, Priority, , High 3Joy6:: ; = Controller ID3, Button6 triggers the following action: Send {Lctrl down} Loop 3 { send {e down}{e up} Sleep, 60 ; Sleep 60 milliseconds before next loop } Send {Lctrl up} return I haven't got the faintest idea if the #NoEnv line and the three lines under there are necessary, but Cubpilot's VAC script had it, so it seemed like a good idea to incorporate those. A quick question, the "up" and "down" is used to prevent stuck keys, right? System: Asus z270 A Prime, Intel i7-7700K 4.8GHz, 32GB DDR4, RTX2080, Samsung 500GB 850 EVO SSD. Valve Index VR, TM Warthog Throttle & Grip, Virpil MongoosT-50CM2 base, TM TPDR Rudders. OS: Win10 Home
PeterP Posted September 25, 2012 Posted September 25, 2012 (edited) ...Well, there are many ways to Rome...;) A quick question, the "up" and "down" is used to prevent stuck keys, right? Yes - "normally" not needed - but I had very few occasions that a script wasn't recognized ... - and only in DCS - probably because of the Heavy CPU load. So I got used to set a "up" and "down" command in time-sensitive scripts even for simple keys like "e". please also read about "sendevent" and the difference to "send" in the AHK help. You will learn that "sendevent" is much more reliable in Games/DX applications. So I recommend that you use it too when scripting for DCS. Edited September 25, 2012 by PeterP
Dachs Posted September 25, 2012 Author Posted September 25, 2012 ...Well, there are many ways to Rome... So true, actually I thought of exactly that phrase when I sat there trying out different things. :D There really is a lot of ways to reach the same goal with this AHK thing.. You will learn that "sendevent" is much more reliable in Games/DX applications.I just took a quick peek at the info on the Command List page for Send, but it seems like Sendinput or Sendplay is the recommended ways to send keystrokes? I did wonder if it was allright to just use Send, rather than SendEvent, but I couldn't see any difference in Foxy keytester. But, I do remember that Foxy and games didn't always "see" the same characters though.. System: Asus z270 A Prime, Intel i7-7700K 4.8GHz, 32GB DDR4, RTX2080, Samsung 500GB 850 EVO SSD. Valve Index VR, TM Warthog Throttle & Grip, Virpil MongoosT-50CM2 base, TM TPDR Rudders. OS: Win10 Home
Recommended Posts