forked from Avnsx/EFT_Flea_Market_Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetToken.py
39 lines (35 loc) · 1.26 KB
/
getToken.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
import psutil
import os
import subprocess
import time
# for silent message stdout, stderr
DEVNULL = open(os.devnull, 'wb')
# Get Process pID
def getProcessPID(processName):
# check process
for process in psutil.process_iter():
try:
processInfo = process.as_dict(attrs=['pid', 'name', 'create_time'])
if processInfo['name'] is None:
continue
# Check if process name contains the given name string.
if processName.lower() in processInfo['name'].lower():
listOfProcessObjects = processInfo
break
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return listOfProcessObjects['pid']
def getToken():
token = None
# waiting for the process endlessly
while True:
try:
token = psutil.Process(getProcessPID('EscapeFromTarkov_BE.exe')).cmdline()[3][7:]
pID = getProcessPID('EscapeFromTarkov_BE.exe')
command = 'taskkill /PID ' + str(pID) + ' /f'
time.sleep(0.33)
except:
pass
if token is not None:
subprocess.Popen(command, stdout=DEVNULL, stderr=DEVNULL)
return token