-
Notifications
You must be signed in to change notification settings - Fork 0
/
res.py
53 lines (39 loc) · 1.46 KB
/
res.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
53
import argparse
import time
import pywinauto
import pyautogui
def switch_resolution(resolution):
# Open NVIDIA Control Panel
pyautogui.hotkey('win', 's')
pyautogui.typewrite('NVIDIA Control Panel')
time.sleep(0.5)
pyautogui.press('enter')
time.sleep(3)
# Find the NVIDIA Control Panel window
app = pywinauto.Desktop(backend='uia').window(title='NVIDIA Systemsteuerung')
app.set_focus()
# Select "Change resolution"
app.child_window(title='Auflösung ändern', found_index=0).click_input()
# Find and click the matching resolution
resolution_item = app.child_window(title_re=f'.*{resolution}.*', found_index=0)
resolution_item.click_input()
# Click "Apply"
app.child_window(title='Übernehmen').click_input()
# Confirm the resolution change
time.sleep(0.75)
pyautogui.press('alt')
pyautogui.press('j')
pyautogui.press('j')
time.sleep(0.75)
pyautogui.hotkey('alt', 'f4')
# Close the NVIDIA Control Panel
app.close()
if __name__ == "__main__":
# Create the argument parser
parser = argparse.ArgumentParser(description='Switch resolution using NVIDIA Control Panel.')
# Add the resolution argument
parser.add_argument('resolution', choices=['1920', '1440'], help='Resolution to switch to (1920 or 1440)')
# Parse the command-line arguments
args = parser.parse_args()
# Call the function to switch the resolution
switch_resolution(args.resolution)