Run code after subprocess calls a program? - python

I am trying to add code after I successfully open a program with a subprocess, but it's not working.
Can anyone tell me why?
import win32api, win32con
import subprocess
subprocess.call(['C:\ProgramData\Microsoft\Windows\Start
Menu\Programs\Adobe Premiere Pro 2022.lnk'],shell=True)
#This code doesn't run after subprocess
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
click(50,40)

Related

I made a script in python, in debug mode it works, then I run it normally it says syntax error

import os
import subprocess
import pyautogui
pyautogui.moveTo(-1329, 507)
pyautogui.click()
pyautogui.moveTo(-1189, 695)
pyautogui.click()
pyautogui.moveTo(-679, 1136)
pyautogui.click()
for i in range(5):
pyautogui.typewrite("test")
pyautogui.press("enter")
In my python script I'm trying to make a spam script for discord and in debug mode it works, when i run it normally it says syntax error.

Why does my tkinter app will show a node.js window?

I use pyinstaller to pack a .py file.
Then when I use something about web crawler (I use requests module).
This window will show and disappear fastly.
I want to say that it is maybe incredible.It wouldn't pop this window when I run this .py file,but after using pyinstaller to pack it,it will pop this window.
(In another computer,it doesn't install node.js.And it doesn't pop this window)
Here is the module I use:
from pynput import keyboard
from PIL import Image, ImageTk
import ctypes
from io import BytesIO
import threading
from win10toast import ToastNotifier
import base64
from win32com.shell import shell
import requests
import execjs
import sys
import pythoncom
import getpass
import tkinter
from random import randint
from tkinter import ttk
from tkinter import messagebox
import os
import json
import traceback
from webbrowser import open_new_tab
from tkinter import scrolledtext
import win32con, win32clipboard, win32gui
from PIL.ImageGrab import grabclipboard, grab
from aip import AipOcr
import time
And the window is this:
What should I do except uninstall node.js? How to avoid this node.js window shows?
Thanks in advance.
Thanks bro,acw1668's suggestion enlighten me a lot.
I want to say,execjs module will run js code.
And if your computer install node.js and you set PATH for node.js,Then your default js environment is node.js(If you don't install node.js,then your default js environment is Jscript in windows system).
So if you doesn't want to use node.js,you should set the default js environment in python.
# change the js environment.
os.environ["EXECJS_RUNTIME"] = "JScript"
# all of environment which execjs support
PyV8 = "PyV8"
Node = "Node"
JavaScriptCore = "JavaScriptCore"
SpiderMonkey = "SpiderMonkey"
JScript = "JScript"
PhantomJS = "PhantomJS"
SlimerJS = "SlimerJS"
Nashorn = "Nashorn"

Launching external program Python with parameter

I need to launch a program within a python script that has an argument.
Code is:
from datetime import date, timedelta
import os
yesterday = (date.today() - timedelta(days=1)).strftime('%m%d%y')
os.system('"E:/Bootdrv/AlohaTs/Bin/grind.exe /yesterday"')
Any help?
for calling a program with python i use subprocess lib
https://docs.python.org/3/library/subprocess.html
from subprocess import call
call("service camera restart")
this restart a linux service

webbrowser modul windows service?

my example code:
import pyautogui
import webbrowser
import time
webbrowser.open_new_tab("http://127.0.0.1:8080/scripts/a.php")
time.sleep(5)
pyautogui.hotkey('tab')
pyautogui.typewrite(' lololo',interval=0.25)
pyautogui.hotkey('enter')
How can I start the module of webbrowser modul as aservice of windows ?

Python using Tkinter (Raspberry Pi running Debian).

To use Tkinter to open a dialog box I have the following Python 2.7 code:
from Tkinkter import Tk
from tkFileDialog import asksavesfinename
root = Tk().withdraw()
f = asksaveaskfilename()
This works just fine if I run the program under Idle.
However, if I run it, as root, from the LXTerminal, it fails with the exception “Client is not authorized to connect to Server…..”
Any help will be appreciated, Thanks.

Categories