Jump to content
Sign in to follow this  
Guest HogDriver

Autostart Fsx And Load Flight

Recommended Posts

Guest HogDriver

Hello all,I have a question for you. I am currently developing a small application and I am able to load a flight once a certain key is pressed. Everything is working pretty much OK.However, I would like to have the chance to start my application first and once all setting are done, the user would click a "Load" button. After that FSX would start automatically, loading my flight from the .flt file and skipping the GUI, where you can select your aircraft etc.So basically after clicking the button in my application, the next thing the user would see is fsx starting and then sitting in the cockpit.I would be great if somebody could tell me how to do it and if it is possible at all. I did a search on the forum already, but couldn't find anything similar.Many thanks in advance!

Share this post


Link to post
Share on other sites
Guest DiGaZz

HiFirst you want to start fsx select your aircraft and flightplan if required and then save the flight as default.Then goto settings/general and uncheck load start screen.Then FSX will start in the aircraft you wantCheersDiGaZz

Share this post


Link to post
Share on other sites
However, I would like to have the chance to start my application first and once all setting are done, the user would click a "Load" button. After that FSX would start automatically, loading my flight from the .flt file and skipping the GUI, where you can select your aircraft etc.So basically after clicking the button in my application, the next thing the user would see is fsx starting and then sitting in the cockpit.
I'm pretty sure all you need to do is execute FSX with the full flight name as a command line parameter. That always used to work, at least. Same as double-clicking on a FLT file, when FLT files are "typed" as Flight Simulator files in Explorer.RegardsPete

Win10: 22H2 19045.2728
CPU: 9900KS at 5.5GHz
Memory: 32Gb at 3800 MHz.
GPU:  RTX 24Gb Titan
2 x 2160p projectors at 25Hz onto 200 FOV curved screen

Share this post


Link to post
Share on other sites
Guest HogDriver

Hi,thank you very much for your answers. Pete, it was working like you suggested. I called it via command line from the Windows/Dos shell and it was exactly what I was looking for. FSX started and I ended up in the cockpit cold and dark. Cool!Now I just need to find out, how I can do a command line input from my C++ program after clicking a certain button. If you or somebody else knows how to do it, help would be much appreciated. Otherwise I check it and try to find it out myself.The command line input I used via the shell was

fsx "-flt:Missions\Test\ColdAndDark.flt"

Does anybody know how to do such a thing from inside a C/C++ program?Regards,Peter

Share this post


Link to post
Share on other sites
Now I just need to find out, how I can do a command line input from my C++ program after clicking a certain button. If you or somebody else knows how to do it, help would be much appreciated. Otherwise I check it and try to find it out myself
From C it is simple. Use the system("command string") API, included in the standard library (stdlib.h). I assume this is just as accessible from C++.RegardsPete

Win10: 22H2 19045.2728
CPU: 9900KS at 5.5GHz
Memory: 32Gb at 3800 MHz.
GPU:  RTX 24Gb Titan
2 x 2160p projectors at 25Hz onto 200 FOV curved screen

Share this post


Link to post
Share on other sites
Guest HogDriver

Thanks for the hint Pete. I tried now several hours to get it working, but it looks like that my commands are not executed. My C++ program executable is not located in the FSX directory, so I have to find a way to call the fsx.exe from another directory. I tried a lot of different ways, but it doesnt seem to work.Basically, the most obvious call for me was

system("C:\\Programs\\Microsoft Games\\Microsoft Flightsimulator X\\fsx.exe ");

but it wasn't working either.I have the feeling that it has to do with the blanks in the path. The shell is always saying something like:The command "C:\Programs\Microsoft" is not correct or could not be found. So it looks like that everything after the blank was cut.Do you know what I am doing wrong?Regards,Peter

Share this post


Link to post
Share on other sites
I tried now several hours to get it working, but it looks like that my commands are not executed. My C++ program executable is not located in the FSX directory, so I have to find a way to call the fsx.exe from another directory. I tried a lot of different ways, but it doesnt seem to work.
When FSX loads it needs to have its own folder as the current folder. This is being assumed in the way it sets itself up.
Basically, the most obvious call for me was
system("C:\\Programs\\Microsoft Games\\Microsoft Flightsimulator X\\fsx.exe ");

but it wasn't working either.

Is that really the path to your FSX? Sure it isn't just a typo, "Flight Simulator" not "Flightsimulator"? "Programs" not "Program Files"?I think you'll need to SetCurrentDirectory first.RegardsPete

Win10: 22H2 19045.2728
CPU: 9900KS at 5.5GHz
Memory: 32Gb at 3800 MHz.
GPU:  RTX 24Gb Titan
2 x 2160p projectors at 25Hz onto 200 FOV curved screen

Share this post


Link to post
Share on other sites
Guest HogDriver

Hi Pete,sorry, I had two typos. It should have been:

system("C:\\Program Files\\Microsoft Games\\Microsoft Flight Simulator X\\fsx.exe ");

It really looks like as if the shell can not handle the blanks in path names. If the console opens up, the path is always cut after the first blank.I did some further testing and got finally the executable started by using:

ShellExecute(NULL, "open", "c:\\Program Files\\Microsoft Games\\Microsoft Flight Simulator X\\fsx", NULL, NULL, SW_SHOWNORMAL);

Unfortunately, it is not taking the flight file command line parameter, like:

ShellExecute(NULL, "open", "c:\\Program Files\\Microsoft Games\\Microsoft Flight Simulator X\\fsx \"-flt:Missions\\Test\\ColdAndDark.flt\"", NULL, NULL, SW_SHOWNORMAL);

Also the fsx executable is not starting, if I add the flt command line switch. If I leave it away, everything works fine. This is the final piece I have to solve.Regards,Peter

Share this post


Link to post
Share on other sites
I did some further testing and got finally the executable started by using:
ShellExecute(NULL, "open", "c:\\Program Files\\Microsoft Games\\Microsoft Flight Simulator X\\fsx", NULL, NULL, SW_SHOWNORMAL);

Oh. Right. Never used that.I just checked, and in fact I've not used "system" for some time either! Oops!I use CreateProcess. With that you can provide, separately, the current directory name and the command line strings, separately from the EXE filepath. Not only that, you can get to keep a handle to the process and therefore do things to it/with it, later.I seem to remember trying WinExec (?) at one time. But currently CreateProcess works well.RegardsPete

Win10: 22H2 19045.2728
CPU: 9900KS at 5.5GHz
Memory: 32Gb at 3800 MHz.
GPU:  RTX 24Gb Titan
2 x 2160p projectors at 25Hz onto 200 FOV curved screen

Share this post


Link to post
Share on other sites
Guest HogDriver

Hi Pete,I just solved the problem myself. Finally!!! :-)I got it working by using the following:

SetCurrentDirectory("c:\\Program Files\\Microsoft Games\\Microsoft Flight Simulator X\\");WinExec("fsx \"-flt:Missions\\Test\\ColdAndDark.flt\"", SW_SHOWNORMAL);

Thank you very much for your time and guiding me in the right direction. I will have a look at CreateProcess as well. Best regards,Peter

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...