-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
52 lines (49 loc) · 1.64 KB
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pyautogui
import pyperclip
import time
import pygetwindow as gw
import psutil
import subprocess
def copy_paste(username, password):
window = gw.getWindowsWithTitle("Riot Client")[0]
window.activate()
time.sleep(1)
pyautogui.PAUSE=0.01
pyperclip.copy(username)
time.sleep(0.1)
pyautogui.hotkey('ctrl','v')
pyautogui.hotkey('tab')
pyperclip.copy(password)
time.sleep(0.1)
pyautogui.hotkey('ctrl','v')
pyautogui.hotkey('enter')
def is_process_running(process_name):
for proc in psutil.process_iter(['name']):
if proc.info['name'] == process_name:
return True
return False
def launch(username, password, app):
if not is_process_running("LeagueClient.exe"):
window = gw.getWindowsWithTitle("Riot Client")
if not window:
try:
subprocess.Popen(app)
while not window:
window = gw.getWindowsWithTitle("Riot Client")
time.sleep(1)
copy_paste(username, password)
except FileNotFoundError:
print(f"Error: The file {app} was not found.")
except Exception as e:
print(f"An error has occurred: {e}")
else:
subprocess.run(["taskkill", "/F", "/IM", "RiotClientServices.exe"])
time.sleep(1)
subprocess.Popen(app)
window = gw.getWindowsWithTitle("Riot Client")
while not window:
window = gw.getWindowsWithTitle("Riot Client")
time.sleep(1)
copy_paste(username, password)
else:
print("League of Legends is already running.")