-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenshinDSR.py
executable file
·50 lines (44 loc) · 1.44 KB
/
GenshinDSR.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
# -*- coding: utf-8 -*-
import sys
import time
import psutil
import ctypes
import win32api
import win32con
import pyautogui
import subprocess
import pywintypes
game_width = 3840 # DSR resolution width
game_height = 2160 # DSR resolution height
origin_width = 2560 # Monitor resolution width
origin_height = 1440 # Monitor resolution height
launcher_name = "launcher.exe"
game_name = "GenshinImpact.exe"
process_path = r"C:\Program Files\Genshin Impact\launcher.exe"
if not ctypes.windll.shell32.IsUserAnAdmin():
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
sys.exit(0)
def check_process(process_name):
for proc in psutil.process_iter(["name"]):
if proc.info["name"] == process_name:
return True
return False
def change_resolution(width, height):
while True:
screen_width, screen_height = pyautogui.size()
if screen_width != width and screen_height != height:
devmode = pywintypes.DEVMODEType()
devmode.PelsWidth = width
devmode.PelsHeight = height
devmode.Fields = win32con.DM_PELSWIDTH | win32con.DM_PELSHEIGHT
win32api.ChangeDisplaySettings(devmode, 0)
else:
break
subprocess.Popen(process_path)
while True:
if not check_process(launcher_name):
sys.exit(0)
if check_process(game_name):
change_resolution(game_width, game_height)
sys.exit(0)
time.sleep(0.1)