gpt4 book ai didi

python - 如何在不丧失键盘/鼠标控制的情况下实现自动化(类似于 selenium 的受控窗口)

转载 作者:行者123 更新时间:2023-12-03 09:39:44 27 4
gpt4 key购买 nike

我在表述这个标题时遇到了一些麻烦,但请允许我解释一下。 PyAutoGUI我允许您通过控制鼠标和键盘来自动化任何事情。但是,如果 pyAutoGUI脚本正在运行,这意味着 无法触摸您的键盘/鼠标,因为它由脚本控制。

我的问题是如何使程序自动化(这不是窗口程序,例如 Photoshop、Steam 或其他非 Windows 程序 [澄清一下,当我说非 Windows 程序时,我的意思是默认程序,如记事本、绘画等])无需放弃您的键盘和鼠标。我知道有PyWinAuto ,但这仅适用于 Windows 程序,如 notepad )。这意味着您可以让脚本在后台运行,而您可以在计算机上执行其他操作。

一个可能的解决方案是在虚拟机中运行脚本,但我正在寻找一个我不必这样做的解决方案。是否有一个 python 模块可以让我这样做?我想与 Photoshop 的界面进行交互,而不必坐下来观看脚本接管我的计算机并执行其操作。

pyAutoGui 的示例场景:

// I run the python script.
// I can no longer touch the keyboard and mouse because
// if I do, it will mess up the script. Meaning the active window on my
// computer is photoshop and I am forced to look at the endless
// while loop
Open photoshop
i = 0
while(1) {
mouse click x=i y=i
type "hello world"
i++
}

我正在寻求的解决方案示例:
// I run the python script.
// A controlled window (similar to a selenium browser) opens up.
// In Selenium you can minimise a selenium browser while its doing its
// automated tasks and do whatever you wish.
//
// I minimise the controlled window and start doing my own thing while
// in the controlled window, its opens photoshop and does the while loop
Open photoshop
i = 0
while(1) {
mouse click x=i y=i
type "hello world"
i++
}

最佳答案

一个 photoshop API现在在 2020 年可用,我还发现了这个 post有一个视频演练,详细介绍了如何使用 python 控制 Photoshop。从简短的视频来看,代码似乎在 Windows 后端执行,因此您可以在代码运行时自由使用鼠标和键盘,而不会受到任何干扰。

关于python - 如何在不丧失键盘/鼠标控制的情况下实现自动化(类似于 selenium 的受控窗口),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57984115/

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