Python Forum
Python script that transfer it self - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python script that transfer it self (/thread-6232.html)



Python script that transfer it self - iboman5 - Nov-11-2017

So hello there your are reading my thread thats very nice of you to try to help me. But since its my thread please dont make fun of me if i sound stupid thank you

My name is Jack and i am new to python but can i make a script so when you open a video file or somthing it also opens a python script and the python scripts open every time you open your pc

so i want that you open a video file and a python scipts open too and that python scipt opens every time the pc turn on


RE: Python script that transfer it self - Larz60+ - Nov-11-2017

The quick answer is yes, but more information is needed because there may be a better way to accomplish what you are trying to do,
which is detail is?


RE: Python script that transfer it self - heiner55 - Nov-11-2017

You should also mention which OS you are using: Linux, Windows, Max, ...


RE: Python script that transfer it self - iboman5 - Nov-13-2017

i use 3.6.3 on windows


RE: Python script that transfer it self - AceScottie - Nov-13-2017

first you need to know what media player you want to use, then the video full name and location.
windows has a "start" command embedded in command line, python can use this with the os.system command

import os
os.system("start " + program + var)
if you wanted to open a video using vlc the command would be

import os
os.system("start 'C:\Program Files (x86)\VideoLAN\VLC'\vlc.exe' " + video)



RE: Python script that transfer it self - underoathed - Nov-13-2017

(Nov-11-2017, 05:27 PM)iboman5 Wrote: So hello there your are reading my thread thats very nice of you to try to help me. But since its my thread please dont make fun of me if i sound stupid thank you

My name is Jack and i am new to python but can i make a script so when you open a video file or somthing it also opens a python script and the python scripts open every time you open your pc

so i want that you open a video file and a python scipts open too and that python scipt opens every time the pc turn on

Did you want a Python script to open everytime you open a video? I'm not sure that it's clear what you are trying to do. What media player will be used? What exactly did you want the script to do?


RE: Python script that transfer it self - AceScottie - Nov-13-2017

to run a python script you will need a secon python scrip to check when the program is launched.
taken from stack exchange:

def running():
n=0# number of instances of the program running
prog=[line.split() for line in subprocess.check_output("tasklist").splitlines()]
[prog.pop(e) for e in [0,1,2]] #useless
for task in prog:
if task[0]=="vlc.exe":
n=n+1
  if n>0:
return True
else:
  return False