Jump to content
The simFlight Network Forums

How to send a keystroke to a third program with Lua


Recommended Posts

Hello,

with Shift + F9, you can enable or disable an ENB Mod.I want to send this keystroke with Lua to this ENB mod when the hight of 4000ft is passed by.

I want to ensure that the ENB mod is activated below 4000ft and above disabled.

When the hight reaches 4000ft send Shift+F9 to the ENB Mod

Is that even possible?

If so, how do I program it? have no programming skills.

Cheers

Fritz

Link to comment
Share on other sites

I've moved your support question into the Support forum. You placed it into User Contributions by mistake.

with Shift + F9, you can enable or disable an ENB Mod.I want to send this keystroke with Lua to this ENB mod when the hight of 4000ft is passed by.

I want to ensure that the ENB mod is activated below 4000ft and above disabled.

When the hight reaches 4000ft send Shift+F9 to the ENB Mod

What's an "ENB Mod"? Is it something in FS, or a program outside of FS, or what? It makes a difference because of keyboard focus.

Is that even possible?

If so, how do I program it? have no programming skills.

You need to read the altitude from the correct offset (do you mean altitude on the altimeter, or true altitude AMSL, or AGL?). You could do this in a loop reading the offset once a second or more frequently (using a timer event), reading it via the appropriate ipc.read function, then send the keypress -- via ipc.keypress if this "ENB Mod" is inside FS -- when that checks >= 4000 feet, and ... then, do what? Terminate? Or does it need to do it again if you descend and climb again?

I can help but as you see I woould need more information.

Regards

Pete

Link to comment
Share on other sites

...What's an "ENB Mod"? Is it something in FS, or a program outside of FS, or what? It makes a difference because of keyboard focus...

I already thought that this is an important point, however, difficult for me to answer. The ENB mod changes the display in FSX. There is a dll file must be copied together with an ini file into the FSX root directory. This Mod is frequently used in promotional videos for Scenerys which makes the presentation more realistic.

On the ground this looks well but in the air, this seems too much bright, particularly when using a Beamer.

For this reason I want to disable this mod in the air. Whether altimeter, or true altitude AMSL or AGL is the same. Which is best suited for it.

Would be great if we could manage it.

Regards

Link to comment
Share on other sites

Its looks to me like a hook into direct X, similar to what the screen warping software does.

Fritz can you assign this to a button press (keysend) in fsuipc, cause if you can a lua script should work. I currently have a button press assigned to my warping software, which runs outside of fs btw, through fsuipc using keysend shift +F4. I would think this Mod would work the same way.

here is some info

http://forum.avsim.net/topic/257462-enb-series-mod/

Link to comment
Share on other sites

I already thought that this is an important point, however, difficult for me to answer. The ENB mod changes the display in FSX. There is a dll file must be copied together with an ini file into the FSX root directory. This Mod is frequently used in promotional videos for Scenerys which makes the presentation more realistic.

Ah, yes, I know it. I tried it but didn't like the results -- not so good on my 10 foot wide projected image.

As Alaxus says, see if just assinging a keystroke to a button works. If so we can make a Lua for it. If not it is probably looking for the actual keyboard keypress, which I am not hooking into (needs more provileges, like a driver, to do this), so I'm afraid it then wouldn't be feasible.

Regards

Pete

Link to comment
Share on other sites

I have assigned a joystick button to the keystroke Shift+F9 in FSUIPC.

Now I can enable or disable the ENB Mod with this joystick button.

Okay. So this Lua script should work


done = false

function checkalt()
alt = ipc.readSD[0x0574] * 3.28084 -- gets AMSL in metres, converts to feet
if alt > 4000 then
if not done then
ipc.keypress(120,1) -- send Shift+F9
done = true
end
else
done = false -- makes sure sent when next climb above 4000
end
end


event.timer(1000, "checkalt")[/CODE]

I don't know if you need some other key sent to change it back on descent, but you can see where to put it.

Place it in the Mdules folder, named, say, SetEMB.lua, and add

[Auto]

1=Lua SetEmb

to your FSUIPC INI file.

Regards

Pete

Link to comment
Share on other sites

Had made ​​a mistake. :oops: Have now corrected the entry. It still does not work. Too bad.

Is there an error mentioned in the log? Maybe there's a syntax error I missed? Enable FSUIPC's key and button logging, rerun the test, so we can see what is going on. The logic is okay, so it has to be something simple.

Regards

Pete

Link to comment
Share on other sites

The log-file says:

176359 *** LUA Error: C:\Microsoft Flight Simulator X\Modules\SetEmb.lua:4: attempt to index field 'readSD' (a function value)

177389 *** LUA Error: C:\Microsoft Flight Simulator X\Modules\SetEmb.lua:4: attempt to index field 'readSD' (a function value)

178372 *** LUA Error: C:\Microsoft Flight Simulator X\Modules\SetEmb.lua:4: attempt to index field 'readSD' (a function value)

Regards

Link to comment
Share on other sites

The log-file says:

176359 *** LUA Error: C:\Microsoft Flight Simulator X\Modules\SetEmb.lua:4: attempt to index field 'readSD' (a function value)

OOOPS! I see the error. This

ipc.readSD[0x0574]

should be

ipc.readSD(0x0574)

I think I need new glasses! The square and curved brackets looks too similar to me on my screen!

Sorry.

Pete

Link to comment
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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.