May 31May 31 Hello Lorby,I would like to know if is possible to automatically launch a batch file when I click a switch in the virtual cockpti of a plane.And if yes how to do that.Thank you. Edited May 31May 31 by whityini
May 31May 31 Commercial Member In AAO you use the (EXECBAT: command, see AAO manual around page 83 "AAO specific RPN commands". But "click on a switch in the cockpit" can have many different consequences, and only very few of them can be observed from the outside by AAO. Essentially the sim only "reports" K: events and IEs over SimConnect. For those you can use the (LISTEN_FOR_RPN or (LISTEN_FOR_K script headers to catch whatever is being sent from your switch.If the switch doesn't send anything that you can observe, that would mean that you have to alter the switches' code in the sim to make that happen. Are you the developer of the aircraft? Ideally you would add a bit of Javascript to access the AAO WebAPI and send the EXECBAT command directly. Edited May 31May 31 by Lorby_SI LORBY-SI
Tuesday at 09:14 AM4 days Author I am not a developer, just a user.I already have the batch file that actually I start manually when the iFly 737 is loaded.I would like to intercept the variable L:VC_Battery_SW_VAL (the batteries switch) to laungh the batch automatically
Tuesday at 10:47 AM4 days Commercial Member 1 hour ago, whityini said:I am not a developer, just a user.I already have the batch file that actually I start manually when the iFly 737 is loaded.I would like to intercept the variable L:VC_Battery_SW_VAL (the batteries switch) to laungh the batch automaticallyYou cannot "intercept" an LVar - they are just values, stored in the sim under this name. If this LVar keeps its value, you can write an Autoscript that compares it with your own reference value and then triggers some code of your own design - like calling a batch file. But if the aircraft designer chose to only use the LVar momentarily, this won't work. You will have to try, there is no knowing this in advance.You would create a script like this and save it.(L:VC_Battery_SW_VAL, Number) (L:MyBatRef) != if{ (L:VC_Battery_SW_VAL, Number) 10 == if{ (SPEAK:on) } (L:VC_Battery_SW_VAL, Number) (>L:MyBatRef) }Then use Scripting->Aircraft automated Scripts to run it every 500ms or something. Then, every time you turn on the battery (or rather, flip the switch to "on"), your computer will say "on" - that's what the SPEAK command does. Replace the SPEAK command with whatever you need, probably EXECBAT - see AAO manual.Be mindful that this is just off the top of my head. None of this is tried or tested. Edited Tuesday at 06:39 PM4 days by Lorby_SI LORBY-SI
Tuesday at 03:55 PM4 days Author Thank you Lorby for your help.I have changed the script, but in this case the bat is executed all the time I load the airplane. Could you please check what is wrong?//·Script:·Check_And_Run_Batch//·Initialize·var·to·10·if it doesn't exixt(L:MyVarBat,·Number)·0·==·if{····10·(>L:MyVarBat,·Number)}//·Read the variable in the sim(L:VC_Battery_SW_VAL,·Number)·(L:MyVarBat,·Number)·==·if{····//·Run the·file·batch····(EXECBAT:C:\myfile.bat)····//·Update·var·to·20····20·(>L:MyVarBat,·Number)}THK
Tuesday at 05:31 PM4 days Commercial Member 1 hour ago, whityini said:Thank you Lorby for your help.I have changed the script, but in this case the bat is executed all the time I load the airplane. Could you please check what is wrong?//·Script:·Check_And_Run_Batch//·Initialize·var·to·10·if it doesn't exixt(L:MyVarBat,·Number)·0·==·if{····10·(>L:MyVarBat,·Number)}//·Read the variable in the sim(L:VC_Battery_SW_VAL,·Number)·(L:MyVarBat,·Number)·==·if{····//·Run the·file·batch····(EXECBAT:C:\myfile.bat)····//·Update·var·to·20····20·(>L:MyVarBat,·Number)}THKI'm sorry, but I have no idea what you are doing there. Why aren't you just using my script?Lose the // comments. They are bad form and only slow down processing for no purpose. You know what your own script is doing, you don't need a comment to tell you.(L:MyVarBat) is AAO internal, it doesn't have a unit. Lose the ", Number"(L:MyVarBat) MUST always have the same value as the (L:VC_Battery_SW_VAL,·Number). It serves as a reference, so the script knows when the Battery LVar from the sim has changed. OK? That's the whole "trick" here, it prevents the script from just running every time. You cannot just set it to whatever value you want (why 10? why 20?)LVars don't have to be initialized. Their life begins when they are first used in code. So (L:MyVarBat) is 0 every time AAO is initialized (restarted/connected to the sim/a script is alterted/ etc.) Edited Tuesday at 05:41 PM4 days by Lorby_SI LORBY-SI
Tuesday at 05:51 PM4 days Author Sorry, maybe I was not so clear. I need that the batch should be executed only once on the first click of the battery switch.
Tuesday at 06:15 PM4 days Commercial Member 17 minutes ago, whityini said:Sorry, maybe I was not so clear. I need that the batch should be executed only once on the first click of the battery switch.As I wrote above, you cannot catch the "click", that is not possible with LVars. You can only react to the animation LVar changing its value (=observing the result of the click - that is not the same).Please specify what "the first click" actually means. Do you mean every change of the switch = both ON and OFF direction? Or only "ON" because you always start in cold and dark mode? Edited Tuesday at 06:15 PM4 days by Lorby_SI LORBY-SI
Tuesday at 06:48 PM4 days Commercial Member 6 minutes ago, whityini said:Only on the first ON because i always start c&d.I would still use my autoscript. Since the battery LVar apparently has 10 as the "ON" value, the script would look like this:(L:VC_Battery_SW_VAL, Number) (L:MyBatRef) != if{ (L:VC_Battery_SW_VAL, Number) 10 == if{ (EXECBAT:C:\myfile.bat) } (L:VC_Battery_SW_VAL, Number) (>L:MyBatRef) }This script will always start the batch file every time the Battery switch goes from OFF to ON. It will also start the batch file when you connect AAO after you've already switched to "ON", because that is the state that it is looking for.Initially, both LVars are 0, so the script won't fire. When you click the battery switch ON, the LVar changes to 10 and the if is executed. And since you only want to start the batch when the battery is turned on, the script checks for the value "10".There are probably a dozen other ways to script this, and there are alternatives too. You could create a CONVERSATION type script file and start this when you start your flight. In such a file you can make the logic wait for certain things to happen, then proceed with doing other stuff. AAO users are implementing thier own first officer and/or flight attendant with this technique. In this case, the line that waits for the battery switch would look like this:(...some code...)[(L:VC_Battery_SW_VAL, Number) 10 ==] (EXECBAT:C:\myfile.bat)(...more code...)That CONVERSATION you start at the beginning of your flight (via Autoscript), and it will wait for the battery switch. Edited Tuesday at 06:48 PM4 days by Lorby_SI LORBY-SI
Create an account or sign in to comment