Cách khởi chạy ứng dụng Multilogin X trên máy tính để bàn thông qua tệp lệnh
Bạn có thể sử dụng các đoạn mã bên dưới để khởi chạy ứng dụng. Chúng rất hữu ích cho việc tự động hóa và có thể được kết hợp với các đoạn mã khác mà chúng tôi chia sẻ trong kho kiến thức của mình .
Agent cần có màn hình để hoạt động. Nếu hệ thống của bạn không có, hãy sử dụng màn hình ảo. Ví dụ (cho Linux):
xvfb-run mlx
Windows
Chạy tập lệnh thông qua IDE hoặc Command Prompt. Bạn chưa biết cách? Hãy đọc bài viết sau: Bắt đầu với tập lệnh tự động hóa.
import os
import subprocess
def connect_agent():
username = os.getlogin()
exe_path = f'C:\\Users\\AntonLa\\AppData\\Local\\MultiloginX 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
Chạy tập lệnh qua IDE hoặc Terminal. Bạn chưa biết cách? Đọc bài viết sau: Bắt đầu với tập lệnh tự động hóa.
import subprocess
def connect_agent():
agent_connection = subprocess.Popen(['open', '/Applications/MultiloginX 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
Chạy tập lệnh qua IDE hoặc Terminal. Bạn chưa biết cách? Đọc bài viết sau: Bắt đầu với tập lệnh tự động hóa.
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()