So just imagine what together they can do for your flight simulator...
Remember in the last episode when we ran into difficulty processing certain hotkey combinations from the scripting portion of HID macros? Well what if it was as easy as
Code: Select all
Set WshShell = CreateObject("WScript.Shell") WshShell.Run ("nircmd.exe sendkeypress shift+ctrl+a+b")
Three things right off the bat...
First it's not a "one liner" there are two lines of code here!
Second, for those of you who already know better, there darn well should be three lines of code there!!
Third... What the hell is a+b doing in that last line of code???
Well first... Relax you had to move out of one liners eventually and It's a lot simpler than it may seem at first glance.
Second... I'll fix it in a minute, I just didn't want the people already upset over this not being a one liner to fall off their chairs and begin convulsing on the floor due to the sheer overwhelming nature of a third line of code. What do you mean it's not overwhelming? I have you know that just last week I saw the heads of three co workers literally explode at the very thought of switching to Office 2010 from Office 2007.
Finally... Third, If you don't know what it's doing there... you're in for a treat.
So onward to fix and explain as best I can... And don't be afraid to correct me. I'm just trying to get as much information out there in a way that people can learn from it as I can. The code should really look like this:
Code: Select all
Dim WshShell Set WshShell = CreateObject("WScript.Shell") WshShell.Run ("nircmd.exe sendkeypress shift+ctrl+a+b")
Line 02 Here we define what we want... an object named WshShell that we can boss around and we want that object to be a spacific type of object WScript.Shell
Line 3 Line three is the action script, where we get to boss our object around. We could make our object do lots of fun things, and different objects are able to do different kinds of things, but in this case we want it to run a little program called NirCmd.exe with a few command line parameters attached to it. That's right, the stuff inside the quotes. If I open up an command prompt and type in nircmd.exe sendkeypress shift+ctrl+a+b it would do the same thing as this scropt. The program we are running is NirCmd, the command we are giving that program (as per the programs design) is sendkeypress, and the keys to be pressed are shift+ctrl+a+b. The reason I don't have a path in front of the program is because I use it so much I put it in my windows directory. Putting NirCmd in your HID macros directory will have the same effect when using NirCmd from within HID macros. since the script is being run be a program in that folder that is the first place windows looks for the exe if no path is specified.
Don't forget this same script can be used to run other programs as well, just replace the path and file with whatever it is you want to run:
Code: Select all
Dim WshShell Set WshShell = CreateObject("WScript.Shell") WshShell.Run ("YourPathAndFileHere")
Now... on to the NirCmd.exe itself I could write all day about the possibilities on key combinations alone, Instead I'll just point you in the direction of their website and let them explain it. But first let me get back to something I left out...
Item three from out list up top. What's up with the a+b in my key combination anyway? I was absolutely shocked when I started flying on myltiplayer servers at the number of people who even after flying for YEARS had no idea that FSX can use ANY regular key as a modifier. Actually it cheats and just allows two regular keys when pressed together, but the effect is the same... Keys to freaking spare if you are willing to let FSX handle them. For example "A" can be assigned "B" can be assigned and "A + B" can be assigned. Up to two normal modifiers and up to two regular keys all at the same time.
All that being said I present to you http://www.nirsoft.net/utils/nircmd.zip and http://www.nirsoft.net/utils/nircmd-x64.zip
The main "help file" page is http://www.nirsoft.net/utils/nircmd2.html#using but I find the reference section http://nircmd.nirsoft.net/sendkeypress.html to be much easier to find things on.