From 3acc8b08080226d9a8e939b03ba5674bf042d1ad Mon Sep 17 00:00:00 2001 From: Usermode Date: Fri, 24 May 2024 21:41:29 +0900 Subject: [PATCH 1/3] Fix table display issue --- main.py | 44 +++++++++++++++++++++++++++++--------------- src/get_title.py | 21 +++++++++++++++++++++ 2 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 src/get_title.py diff --git a/main.py b/main.py index bc28f27..4136ece 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ +#*-* coding: utf-8 *-* import win32gui -import pywintypes +import pywintypes # fix win32gui dll error import asyncio import os import socket @@ -36,6 +37,7 @@ from src.table import Table from src.websocket import Ws from src.os import get_os +from src.get_title import get_title from src.account_manager.account_manager import AccountManager from src.account_manager.account_config import AccountConfig @@ -49,12 +51,16 @@ server = "" -# os.system("mode con cols=200 lines=50") - -# import pygetwindow -# win = pygetwindow.getWindowsWithTitle(title_with_version)[0] -# win.size = (1536, 864) +try: + Logging = Logging() + log = Logging.log +except Exception as e: + print("Failed to initialize logger!") + print(e) + input("press enter to exit...\n") + os._exit(1) +# solve table display issue os_string = get_os() if "Windows 10" in os_string: os.system("mode con cols=200 lines=50") @@ -62,18 +68,29 @@ try: hwnd = win32gui.FindWindow(None, title_with_version) x0, y0, x1, y1 = win32gui.GetWindowRect(hwnd) - win32gui.MoveWindow(hwnd, x0, y0, x0+1536, y0+864, True) - except: - print("Do not run with administrator privileges.") - input("press enter to exit...\n") - os._exit(1) + win32gui.MoveWindow(hwnd, x0, y0, x0+1286, y0+654, True) + except Exception as check_admin: + try: + hwnd = win32gui.FindWindow(None, "관리자: " + title_with_version) + x0, y0, x1, y1 = win32gui.GetWindowRect(hwnd) + win32gui.MoveWindow(hwnd, x0, y0, x0+1286, y0+654, True) + except Exception as check_korean: + try: + hwnd = win32gui.FindWindow(None, "Administrator: " + title_with_version) + x0, y0, x1, y1 = win32gui.GetWindowRect(hwnd) + win32gui.MoveWindow(hwnd, x0, y0, x0+1286, y0+654, True) + except Exception as check_english: + log(f"Failed to resize window: {check_admin}\n{check_korean}\n{check_english}\n\nAll title name: {get_title()}") + print("Do not run with administrative privilege.\nUnless please contact to scottjsh@whitesky.kr with log files.") + input("press enter to exit...\n") + os._exit(1) else: print("This tool only supports Windows 10, Windows 11.") input("press enter to exit...\n") os._exit(1) -def program_exit(status: int): # so we don't need to import the entire sys module +def program_exit(status: int): log(f"exited program with error code {status}") raise sys.exit(status) @@ -93,9 +110,6 @@ def get_ip(): try: - Logging = Logging() - log = Logging.log - # OS Logging log(f"Operating system: {get_os()}\n") diff --git a/src/get_title.py b/src/get_title.py new file mode 100644 index 0000000..a5d6f21 --- /dev/null +++ b/src/get_title.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +import win32gui + +output = [] + +def callback(hwnd, strings): + if win32gui.IsWindowVisible(hwnd): + window_title = win32gui.GetWindowText(hwnd) + left, top, right, bottom = win32gui.GetWindowRect(hwnd) + if window_title and right-left and bottom-top: + strings.append('0x{:08x}: "{}"'.format(hwnd, window_title)) + return True + +def get_title(): + win_list = [] # list of strings containing win handles and window titles + win32gui.EnumWindows(callback, win_list) # populate list + + for window in win_list: # print results + output.append(window) + + return output \ No newline at end of file From 57267087e06d7a4cd407b171d807a14206c2f31d Mon Sep 17 00:00:00 2001 From: Usermode Date: Fri, 24 May 2024 21:41:57 +0900 Subject: [PATCH 2/3] coding: utf-8 --- setup.py | 1 + src/Loadouts.py | 1 + src/account_manager/account_auth.py | 1 + src/account_manager/account_config.py | 1 + src/account_manager/account_manager.py | 1 + src/chatlogs.py | 5 +++-- src/colors.py | 1 + src/config.py | 1 + src/configurator.py | 1 + src/content.py | 1 + src/errors.py | 1 + src/experimental.py | 1 + src/logs.py | 3 ++- src/names.py | 1 + src/os.py | 4 +--- src/player_stats.py | 2 +- src/presences.py | 4 +--- src/questions.py | 1 + src/rank.py | 2 +- src/requestsV.py | 11 +---------- src/rpc.py | 1 + src/server.py | 1 + src/states/coregame.py | 1 + src/states/menu.py | 2 +- src/states/pregame.py | 2 +- src/stats.py | 1 + src/table.py | 1 + src/websocket.py | 1 + 28 files changed, 31 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index 0b76b17..24d6132 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import sys from cx_Freeze import setup, Executable from src.constants import version diff --git a/src/Loadouts.py b/src/Loadouts.py index df5b84e..c59f079 100644 --- a/src/Loadouts.py +++ b/src/Loadouts.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import time import requests from colr import color diff --git a/src/account_manager/account_auth.py b/src/account_manager/account_auth.py index 393f8b7..a2d07c3 100644 --- a/src/account_manager/account_auth.py +++ b/src/account_manager/account_auth.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import requests import time import re diff --git a/src/account_manager/account_config.py b/src/account_manager/account_config.py index 9f03944..c5118b3 100644 --- a/src/account_manager/account_config.py +++ b/src/account_manager/account_config.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import yaml import json import os diff --git a/src/account_manager/account_manager.py b/src/account_manager/account_manager.py index 8f52bcb..27f877a 100644 --- a/src/account_manager/account_manager.py +++ b/src/account_manager/account_manager.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import InquirerPy import subprocess import re diff --git a/src/chatlogs.py b/src/chatlogs.py index e7d8e14..3ad3d2d 100644 --- a/src/chatlogs.py +++ b/src/chatlogs.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import glob import os import time @@ -22,12 +23,12 @@ def chatLog(self, stringToLog: str): if self.chatFileOpened: with open(f"chat_logs/chat_log-{max(filenames)}.txt", "a") as logFile: logFile.write( - f"{self.escape_ansi(stringToLog.encode('ascii', 'replace').decode())}\n") + f"{self.escape_ansi(stringToLog.encode('utf-8', 'replace').decode())}\n") else: with open(f"chat_logs/chat_log-{max(filenames) + 1}.txt", "w") as logFile: self.chatFileOpened = True logFile.write( - f"{self.escape_ansi(stringToLog.encode('ascii', 'replace').decode())}\n") + f"{self.escape_ansi(stringToLog.encode('utf-8', 'replace').decode())}\n") def escape_ansi(self, line): ansi_escape = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]') diff --git a/src/colors.py b/src/colors.py index 58928a1..f24f943 100644 --- a/src/colors.py +++ b/src/colors.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from colr import color from src.constants import tierDict import re diff --git a/src/config.py b/src/config.py index ce19b00..bb6b3b2 100644 --- a/src/config.py +++ b/src/config.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import json from io import TextIOWrapper from json import JSONDecodeError diff --git a/src/configurator.py b/src/configurator.py index fb1a97c..7770176 100644 --- a/src/configurator.py +++ b/src/configurator.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import json import os diff --git a/src/content.py b/src/content.py index 7f9a74d..4a2b8da 100644 --- a/src/content.py +++ b/src/content.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import requests diff --git a/src/errors.py b/src/errors.py index 7c03108..891e3eb 100644 --- a/src/errors.py +++ b/src/errors.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import socket import os.path import time diff --git a/src/experimental.py b/src/experimental.py index b37a497..834107b 100644 --- a/src/experimental.py +++ b/src/experimental.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import requests diff --git a/src/logs.py b/src/logs.py index e56acd6..6717975 100644 --- a/src/logs.py +++ b/src/logs.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import glob import os import time @@ -34,4 +35,4 @@ def log(self, log_string: str): current_time = time.strftime( "%Y.%m.%d-%H.%M.%S", time.localtime(time.time())) log_file.write( - f"[{current_time}] {log_string.encode('ascii', 'replace').decode()}\n") + f"[{current_time}] {log_string.encode('utf-8', 'replace').decode()}\n") diff --git a/src/names.py b/src/names.py index eb09e1a..5722679 100644 --- a/src/names.py +++ b/src/names.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import requests diff --git a/src/os.py b/src/os.py index 9fa0a99..4b72f7b 100644 --- a/src/os.py +++ b/src/os.py @@ -1,9 +1,7 @@ +# -*- coding: utf-8 -*- import platform import sys -# This function detects the OS the user is running and if Valorant is officially supported in said platform -# returns ["operating system" (string), "Runs Valorant" (bool)] - def get_os(): # Handles Windows operating systems diff --git a/src/player_stats.py b/src/player_stats.py index 7b9a82f..91b8108 100644 --- a/src/player_stats.py +++ b/src/player_stats.py @@ -1,4 +1,4 @@ - +# -*- coding: utf-8 -*- class PlayerStats: def __init__(self, Requests, log, config): self.Requests = Requests diff --git a/src/presences.py b/src/presences.py index dc2dc09..ed96df8 100644 --- a/src/presences.py +++ b/src/presences.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import base64 import json import time @@ -19,9 +20,6 @@ def get_game_state(self, presences): def get_private_presence(self, presences): for presence in presences: if presence['puuid'] == self.Requests.puuid: - # preventing VAS from crashing when lol is open - # print(presence) - # print(presence.get("championId")) if presence.get("championId") is not None or presence.get("product") == "league_of_legends": return None else: diff --git a/src/questions.py b/src/questions.py index dae22b7..13e1bd5 100644 --- a/src/questions.py +++ b/src/questions.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from InquirerPy.base.control import Choice from src.constants import DEFAULT_CONFIG, WEAPONS diff --git a/src/rank.py b/src/rank.py index d1a7893..37f2584 100644 --- a/src/rank.py +++ b/src/rank.py @@ -1,4 +1,4 @@ - +# -*- coding: utf-8 -*- class Rank: def __init__(self, Requests, log, content, ranks_before): self.Requests = Requests diff --git a/src/requestsV.py b/src/requestsV.py index 72f0451..c58d5be 100644 --- a/src/requestsV.py +++ b/src/requestsV.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import base64 import json import time @@ -50,16 +51,6 @@ def check_version(version, copy_run_update_script): print(f"New version available! {link}") input("press enter to exit...\n") os._exit(1) - # if sys.argv[0][-3:] == "exe": - # while True: - # update_now = input("Do you want to update now? (Y/n): ") - # if update_now.lower() == "n" or update_now.lower() == "no": - # return - # elif update_now.lower() == "y" or update_now.lower() == "yes" or update_now == "": - # copy_run_update_script(link) - # os._exit(1) - # else: - # print('Invalid input please response with "yes" or "no" ("y", "n") or press enter to update') @staticmethod def copy_run_update_script(link): diff --git a/src/rpc.py b/src/rpc.py index 61af4ee..6787e96 100644 --- a/src/rpc.py +++ b/src/rpc.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pypresence import Presence from pypresence.exceptions import DiscordNotFound, InvalidID import nest_asyncio diff --git a/src/server.py b/src/server.py index cc8cc00..194e72a 100644 --- a/src/server.py +++ b/src/server.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import json import logging from websocket_server import WebsocketServer diff --git a/src/states/coregame.py b/src/states/coregame.py index 1fa8e2f..bda9d85 100644 --- a/src/states/coregame.py +++ b/src/states/coregame.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import time diff --git a/src/states/menu.py b/src/states/menu.py index 5a017f4..a27214e 100644 --- a/src/states/menu.py +++ b/src/states/menu.py @@ -1,4 +1,4 @@ - +# -*- coding: utf-8 -*- class Menu: def __init__(self, Requests, log, presences): diff --git a/src/states/pregame.py b/src/states/pregame.py index b8ec0ba..fbd07de 100644 --- a/src/states/pregame.py +++ b/src/states/pregame.py @@ -1,4 +1,4 @@ - +# -*- coding: utf-8 -*- class Pregame: def __init__(self, Requests, log): diff --git a/src/stats.py b/src/stats.py index 11697b2..a54f410 100644 --- a/src/stats.py +++ b/src/stats.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import os import time import json diff --git a/src/table.py b/src/table.py index 177cd39..ff89870 100644 --- a/src/table.py +++ b/src/table.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from typing import Literal, get_args # from prettytable import PrettyTable diff --git a/src/websocket.py b/src/websocket.py index e86fc4a..7ee91c0 100644 --- a/src/websocket.py +++ b/src/websocket.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import re import websockets import websockets.client From 4fc303fccf8897ca9248ef4b6f42771f1895e707 Mon Sep 17 00:00:00 2001 From: Usermode Date: Fri, 24 May 2024 21:42:10 +0900 Subject: [PATCH 3/3] Bump version --- src/constants.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/constants.py b/src/constants.py index fa43419..5730aa6 100644 --- a/src/constants.py +++ b/src/constants.py @@ -1,7 +1,8 @@ +# -*- coding: utf-8 -*- import requests from colr import color -version = "4.61" +version = "4.65" enablePrivateLogging = True hide_names = True hide_levels = True