In-game Interaction with other programs

Hi,
I am curently trying to create a condition when during the game the actions of the player influence other programs running on the computer at the same time. i am currently writing to a file, and have the other programs sampling said file and getting their instructions from it. Ideally, i would like to be able to send commands directly.
any ideas how to acomplish this?
(can i activate exec’s from within blender-python? can it be done without a time lag or focus change? are there any global params i can access?)

would appreciate any idea…

thanks in advance,
Sh

I don’t know much about stuff like that but maybe use some global database, a MySQL database for example, and use Python (or other languages in your other programs) to store/get data from it… Or something like that. I hope it helped your thinking process or something in some way.

you could make a connection via TCP or UDP. Check the Python docs for socket.

Haven’t opened other programs in python for a while now, the current focus will depend on how the other .exe is accessed, I think, you might have to include some lines to ensure focus stays on blender player. However, I believe setting/getting focus is platform specific. Also you can pass parameters to the program your opening (like running a program through a command line with flags/prams) and get return values from that program. Lag will depend on the system specs and the process and memory consumption of the program you’re trying to open. Note that some methods of opening an another program will wait for the newly opened program to return something before executing the rest of the code.

Sorry I can’t give you anything more specific but I’d start with looking at the subprocess module docs at the top of the page there’s a list of some other modules that do similar sorts of things that might be worth looking at too.

Hope this helps!

to open a program from blender (on windows), use

from os import system
system("start /min C:\\yourFolder\\yourProgram.exe")

the parameter “/min” will let the program start minimized so that blender keeps focus

for communication, listen to monster.
here is a good overview of python sockets:
http://www.tutorialspoint.com/python/python_networking.htm

Thanks! - i ended up using both options…
i start by opening the other program in minimized mode as a server, and interact with it via sockets during the game itself.
works great!

thanks again,
Sh