如何通过脚本启动 Multilogin 桌面应用
使用 Python 脚本,在 Windows、macOS 或 Linux 上启动 Multilogin 桌面应用,再运行其他本地自动化。
➡️ 选择适合操作系统的脚本 → 按需更新应用路径 → 从 IDE 或终端运行脚本。
如果自动化流程需要先运行 Multilogin 桌面应用及其内置 launcher,可以使用此方法。
agent 需要显示环境才能工作。如果系统没有显示环境,请使用虚拟显示器。示例(Linux):
xvfb-run mlx开始前的准备
请确认:
- 已安装 Multilogin 桌面应用
- 已安装 Python
- 知道如何从 IDE 或终端运行 Python 脚本
- Linux 上有可用的图形显示环境,或已配置支持的虚拟显示器
Windows
通过 IDE 或 Command Prompt 运行脚本。不清楚如何操作?请参阅自动化脚本入门。
import os
import subprocess
def connect_agent():
username = os.getlogin()
exe_path = f'C:\\Users\\AntonLa\\AppData\\Local\\Multilogin App\\MLXDesktopApp.exe'
agent_connection = subprocess.run([exe_path])
assert agent_connection.returncode == 0
if agent_connection.returncode == 0:
print("Agent connected")
else:
print(f"Failed to connect agent. Error {agent_connection.returncode}")
if __name__ == "__main__":
connect_agent()macOS
通过 IDE 或 Terminal 运行脚本。不清楚如何操作?请参阅自动化脚本入门。
import subprocess
def connect_agent():
agent_connection = subprocess.Popen(['open', '/Applications/Multilogin App.app/'])
agent_connection.wait()
return_code = agent_connection.returncode
if return_code == 0:
print("Agent connected")
else:
print(f"Failed to connect agent. Error {return_code}")
connect_agent()Linux
通过 IDE 或 Terminal 运行脚本。不清楚如何操作?请参阅自动化脚本入门。
import os
import subprocess
def connect_agent():
username = os.getlogin()
exe_path = f'/opt/mlxapp/desktop.bin'
agent_connection = subprocess.run([exe_path])
assert agent_connection.returncode == 0
if agent_connection.returncode == 0:
print("Agent connected")
else:
print(f"Failed to connect agent. Error {agent_connection.returncode}")
if __name__ == "__main__":
connect_agent()