Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Launch an OpenSesame program (osexp) via Python subprocess

Hi all!

I'm glad to post for the first time on this supportive OS community (hopefully I can contribute in turn later)!

I have written an experiment in OpenSesame, and I am trying to integrate it within a Python script that would serve as a 'batch-script' for my whole setup. What I mean is that this 'outer' python script is first launching my webcam software (to record my participant throughout the experiment), then it is playing the instruction video on VLC, then the first part of my OS experiment (let's call it part1.osexp), then another video on VLC, then part2.osexp

(I know that I could read the video from OpenSesame with openCV for example, but for several reasons I'd rather not.)

I have figured out how to run the subprocesses for the webcam recording, and for playing videos with VLC. I also figured out how to start OpenSesame with the snippet of code below:

import subprocess

path = 'C:\\Programs\\OpenSesame\\opensesame.exe'

p = subprocess.Popen([path], shell=True)

It works fine to start OpenSesame.

My question is: would it be possible to extend this bit of code to run a particular code (e.g., part1.osexp) without further clic?

Many thanks in advance, this would be immensely helpful! And please let me know if you need more details / if anything is unclear.

I'm also happy to describe the (successful and unsuccessful) attempts at doing any of that, if somebody is interested.


(NB: I did think of doing all in the OpenSesame script, but I've already spent a lot of time on it, to eventualy get stuck on the impossibility to have my webcam software and/or VLC going in front of the screen. Basically I found another post on this forum suggesting it is not possible to get win32gui installed, which would have been a nice workaround)


  • Well, I think I managed eventually! I'll leave the answer here in case sb may find it useful someday!

    import subprocess
    soft_path = 'C:\\Programs\\OpenSesame\\opensesamerun.exe'
    file_path = 'C:\\Users\\admin\\Documents\\OSrun\\test.osexp'[soft_path, file_path, '--fullscreen'], shell=False)

    Which can be expanded thanks to the arguments presented here:

Sign In or Register to comment.