Skip to content

Commit f5b110e

Browse files
committed
added autostart (not done yet)
1 parent 2a2ed9f commit f5b110e

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Resolution,Left-Top,Right-Bottom,Active,Disconnected,Primary,Colors,Frequency,Orientation,Maximum Resolution,Name,Adapter,Device ID,Device Key,Monitor ID,Short Monitor ID,Monitor Key,Monitor String,Monitor Name,Monitor Serial Number
2-
0 X 0,"0, 0","0, 0",No,No,No,0,0,Default,1920 X 1080,\\.\DISPLAY3,NVIDIA GeForce RTX 2080 Ti,PCI\VEN_10DE&DEV_1E07&SUBSYS_866A1043&REV_A1,\Registry\Machine\System\CurrentControlSet\Control\Video\{3AB1B141-D3F6-11EE-A460-106FD93C4F11}\0002,MONITOR\GSM0001\{4d36e96e-e325-11ce-bfc1-08002be10318}\0010,GSM0001,\Registry\Machine\System\CurrentControlSet\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0010,Generic PnP Monitor,LG TV,
2+
1920 X 1080,"1601, -1080","3521, 0",Yes,No,No,32,60,Default,1920 X 1080,\\.\DISPLAY3,NVIDIA GeForce RTX 2080 Ti,PCI\VEN_10DE&DEV_1E07&SUBSYS_866A1043&REV_A1,\Registry\Machine\System\CurrentControlSet\Control\Video\{3AB1B141-D3F6-11EE-A460-106FD93C4F11}\0002,MONITOR\GSM0001\{4d36e96e-e325-11ce-bfc1-08002be10318}\0010,GSM0001,\Registry\Machine\System\CurrentControlSet\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0010,Generic PnP Monitor,LG TV,
33
2560 X 1440,"2560, 0","5120, 1440",Yes,No,No,32,60,Default,2560 X 1440,\\.\DISPLAY2,NVIDIA GeForce RTX 2080 Ti,PCI\VEN_10DE&DEV_1E07&SUBSYS_866A1043&REV_A1,\Registry\Machine\System\CurrentControlSet\Control\Video\{3AB1B141-D3F6-11EE-A460-106FD93C4F11}\0001,MONITOR\LEN66FB\{4d36e96e-e325-11ce-bfc1-08002be10318}\0008,LEN66FB,\Registry\Machine\System\CurrentControlSet\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0008,Generic PnP Monitor,C27q-35,URHK6FCP
44
2560 X 1440,"0, 0","2560, 1440",Yes,No,Yes,32,144,Default,2560 X 1440,\\.\DISPLAY1,NVIDIA GeForce RTX 2080 Ti,PCI\VEN_10DE&DEV_1E07&SUBSYS_866A1043&REV_A1,\Registry\Machine\System\CurrentControlSet\Control\Video\{3AB1B141-D3F6-11EE-A460-106FD93C4F11}\0000,MONITOR\ACI27EC\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009,ACI27EC,\Registry\Machine\System\CurrentControlSet\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0009,ROG PG279Q,ROG PG279Q,#ASNImfyQBwHd

SimpleMonitorControlTray/configHandler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313

1414
fileNotFound = " file not found. Exiting."
1515

16-
MULTIMONITORTOOL_PATH, CSV_FILE_PATH, MM_CONFIG_FILE_PATH, MONITOR_NAME = (
16+
MULTIMONITORTOOL_PATH, CSV_FILE_PATH, MM_CONFIG_FILE_PATH, MONITOR_NAME, AUTOSTART = (
1717
None,
1818
None,
1919
None,
2020
None,
21+
False,
2122
)
2223

2324

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
import winreg as reg
3+
4+
keyName = "SimpleMonitorControlTray"
5+
6+
exe_path = os.path.join(os.getcwd(), keyName + ".exe")
7+
registry_key = r"Software\Microsoft\Windows\CurrentVersion\Run"
8+
9+
10+
def add_to_autostart():
11+
key = reg.OpenKey(reg.HKEY_CURRENT_USER, registry_key, 0, reg.KEY_WRITE)
12+
reg.SetValueEx(key, keyName, 0, reg.REG_SZ, exe_path)
13+
reg.CloseKey(key)
14+
15+
16+
def remove_from_autostart():
17+
key = reg.OpenKey(reg.HKEY_CURRENT_USER, registry_key, 0, reg.KEY_ALL_ACCESS)
18+
reg.DeleteValue(key, keyName)
19+
reg.CloseKey(key)

SimpleMonitorControlTray/trayHandler.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,29 @@ def openConfigClicked():
3939
os.startfile(os.path.join(script_dir, cH.config_file_path))
4040

4141

42+
checked = False
43+
44+
45+
# TODO implement autostart logic from registryHandler
46+
def toggleAutostart(icon):
47+
# Recreate the menu with the updated title for "Autostart"
48+
new_menu = (
49+
item("New Title", toggleAutostart),
50+
item(
51+
"Save current monitor layout (used when enabling)",
52+
saveMultiMonitorToolConfigClicked,
53+
),
54+
item("Open Config.ini", openConfigClicked),
55+
item("Quit", quitItemClicked),
56+
)
57+
icon.menu = new_menu
58+
59+
4260
def initTray():
4361
global icon
4462
menu = (
4563
item(title, iconTrayClicked, default=True, visible=False),
64+
item("Autostart", toggleAutostart),
4665
item(
4766
"Save current monitor layout (used when enabling)",
4867
saveMultiMonitorToolConfigClicked,

config.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[SETTINGS]
22
monitor_name = \\.\DISPLAY3
33
multimonitorpath = C:\\App_Install\\multimonitortool-x64\\MultiMonitorTool.exe
4+
autostart = False
45
[DEV]
56
mm_csv_export_path = MultiMonitorTool\multiMonitorToolOutput.csv
67
mm_config_file_path = MultiMonitorTool\MultiMonitorToolConfig

0 commit comments

Comments
 (0)