Tema je v originalu tukaj:
http://www.flightdecksolutions.com/forum/viewtopic.php?t=1099
========================================
Although this is a hardware forum, the software interface side of things is
integrally related, so I believe this is a helpful place to put this. I received a question regarding autostarting of flight-sim realted apps, so here's my response for the benefit of all:
Just about every flight simmer requires the ability to have multiple applications open automatically on startup and in a particular order - either on a MSFS server or client PC. You can do this two ways - the first way everybody knows:
- Place shortcuts into "C:\Documents and Settings\<userName>\Start
Menu\Programs\Startup" and have them open automatically in alphabetical order.
but there's a second way that is just as easy and gives you far more control: - Create a batch file (.bat)!
A .bat file is just a text file that tells windows what to do line by line. Don't be put off thinking this is too technical or for programmers only - it really isn't - for builders with full decks and multiple client PCs, I imagine this will be a necessity. For flightsim purposes, we just need one to launch programs in a particular order, and in some cases pause for a bit inbetween. Here's how do exactly this:
First, create a new text file - lets put it in C:\temp\ and name it something like "simLaunch.bat" - ignore window's warning about changing the file extension - no danger at all.
There are just three 'commands' that we need for our purposes - they are:
'
echo' - outputs a message
'
start' - launches a program and keeps going
'
call' - launches a program and waits until it's closed before continuing
Although there are a dozen or so different commands, we only need these for our purposes.
Right-click on your new bat file and click 'Edit' - this will open the file using 'notepad'. Now simply enter a line for each thing you want the batch file to do by entering the 'command' followed by a space followed by the 'parameter'. In the case of 'echo', the parameter will be the message you want to output, and in the case of 'start' the parameter will be the path to the program. Easy! Here's an example:
Koda:
echo starting wideClient
start C:\wideFS\wideClient.exe
echo starting PMSystems
start C:\pmSystems\pmsystems.exe
echo starting MCP
start C:\MCP\mcp.exe
Make your own to open some programs you have and give it a test now by just double-clicking the bat file. The bat will execute in a command prompt, and then close automatically once finish.
All fine and good - everything executes immediately with no delay, but what if we want to pause and wait for a bit before opening the next program? An example of the need for this might be if we wanted to make sure that PMSystems was the last application to open, thus making it the application with 'focus' and the recipient of subsiquent keystrokes (from an encoder or keyboard). There is a simple program called 'sleep.exe' which you can get here:
http://www.computerhope.com/download/utility/sleep.exe Download it (5kb) and put in your C:\windows directory. The sleep.exe program takes a parameter that specifies how many seconds to 'sleep' for before closing itself - perfect for our needs. Now you recall that the 'call' command waits until the program has finished before continuing to the next line in the batch file, so with that in mind, we can 'call' the sleep program followed by the number of seconds to wait, effectively 'pausing' the batch file while the other programs load. So:
Koda:
call C:\windows\sleep.exe 45
will put a 45 second pause into the batch file. Now here's an expansion on the first example using sleep:
Koda:
echo starting wideClient
start C:\wideFS\wideClient.exe
echo sleeping for 5 seconds
call C:\windows\sleep.exe 5
echo starting PMSystems
start C:\pmSystems\pmsystems.exe
echo sleeping for 10 seconds
call C:|windows\sleep.exe 10
echo starting MCP
start C:\MCP\mcp.exe
Finally, once you have your batch file operating as you require, just drop a shortcut to it (or even the .bat file itself if you want) into your
C:\Documents and Settings\<userName>\Start Menu\Programs\Startup and there you have it!
They can be even better - I have been able to create a bat file that open seven flight sim realted apps on my flight-sim server, in a particular order, over a period of three minutes (waiting for MSFS to open etc.) and call a truVoice.exe to have an artificial voice speak what it is about to do and wish me a good flight when it is finished - all with a single double-click - you get the picture. If you'd like to find out more just google batch files - there's a lot of imfo out there.
I hope this helps some of you. If you have any further questions I'm more than happy
to help.
-Timh