试图执行程序然后最小化所有窗口的问题
我正在尝试执行Windows批处理文件,然后使用Python最大程度地减少打开的每个窗口(以使我的Windows 11屏幕清洁),但我无法实现目标。 我的代码能够执行批处理或最小化所有窗口,但不能将两个功能一起使用,我找不到解决方案的方法。 基本上想执行我的批处理,然后最小化所有窗口,通过这种方式,我可以在Windows 11引导下执行Python脚本,以便打开我的批处理,然后最小化所有内容,以便终端窗口不保持打开状态并使我的屏幕使我的屏幕保持清洁,因为什么都没发生:)
这里的问题是批次正在成功运行,但窗户没有最小化,如果我删除 os.startfile 功能,并且仅保留 pyautogui.hotkey.hotkey. 功能,现在窗口已被最小化,但批处理不运行。 我不能保持两个功能一起工作。 谢谢你的时间
import pyautogui
import time
import os
os.startfile('"C:/Users/villa/Desktop/ETH.lnk"') #Excecutes the batch.
time.sleep(5) #Waits 5 secs to make sure the batch is already running before minimizing everything.
pyautogui.hotkey('win','m') #This is the Windows hotkey that minimizes all windows.
I'm trying to execute a Windows Batch file and then minimize every single window that is open (to make my Windows 11 screen clean) using Python but Im not fulfilling the objective.
My code is able to execute the Batch OR minimize all the windows but not both functions together and I can't find a way to fix it.
Basically want to execute my batch and then minimize all the windows, in this way I can make the Python script execute at Windows 11 boot so it will open my batch and then minimize everything so the terminal window doesn't keep open and makes my screen clean as nothing happened :)
The problem here is that the batch is running successfully but windows are not getting minimized, this changes if I remove the os.startfile function and only keep the pyautogui.hotkey function, now the the windows are getting minimized but clarely the batch is not running.
I can't keep both functions working together.
Thanks for your time
import pyautogui
import time
import os
os.startfile('"C:/Users/villa/Desktop/ETH.lnk"') #Excecutes the batch.
time.sleep(5) #Waits 5 secs to make sure the batch is already running before minimizing everything.
pyautogui.hotkey('win','m') #This is the Windows hotkey that minimizes all windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)