Python Forum
Python script that transfer it self
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python script that transfer it self
#1
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
Reply
#2
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?
Reply
#3
You should also mention which OS you are using: Linux, Windows, Max, ...
Reply
#4
i use 3.6.3 on windows
Reply
#5
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)
Reply
#6
(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?
Reply
#7
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,010 Jun-29-2023, 11:57 AM
Last Post: gologica
  python transfer Sql table to csv using BCP mg24 2 1,314 Oct-04-2022, 06:54 AM
Last Post: mg24
  file transfer via python SFTP SCP mg24 3 2,875 Sep-15-2022, 04:20 AM
Last Post: mg24
  DNP3 file transfer with python Aussie 0 1,417 Sep-01-2020, 10:45 PM
Last Post: Aussie
  How to kill a bash script running as root from a python script? jc_lafleur 4 5,794 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,254 May-28-2020, 05:27 PM
Last Post: micseydel
  Package python script which has different libraries as a single executable or script tej7gandhi 1 2,583 May-11-2019, 08:12 PM
Last Post: keames
  How to run python script which has dependent python script in another folder? PrateekG 1 3,106 May-23-2018, 04:50 PM
Last Post: snippsat
  How to call one python script and use its output in another python script lravikumarvsp 3 32,289 May-16-2018, 02:08 AM
Last Post: lravikumarvsp
  Python script that transfer it self iboman5 2 2,999 Nov-10-2017, 06:56 PM
Last Post: iboman5

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020