如何通过脚本启动Multilogin X agent
您可以使用以下脚本启动应用程序。它可用于自动化操作,并且可以与我们知识库中分享的其他脚本结合使用。
Agent需要显示器才能工作。如果您的系统没有显示器,请使用虚拟显示器。示例(适用于Linux ):
xvfb-run mlx
Windows
通过IDE 或命令提示符运行脚本。不知道怎么做?请阅读以下文章: 自动化脚本入门。
import os
import subprocess
def connect_agent():
username = os.getlogin()
exe_path = f'C:\\Users\\AntonLa\\AppData\\Local\\Multilogin X\\agent.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 或终端运行脚本。不知道怎么操作?请阅读这篇文章: 自动化脚本入门。
import subprocess
def connect_agent():
agent_connection = subprocess.Popen(['open', '/Applications/MultiloginX.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 或终端运行脚本。不知道怎么操作?请阅读这篇文章: 自动化脚本入门。
import os
import subprocess
def connect_agent():
username = os.getlogin()
exe_path = f'/opt/mlx/agent.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()