Skip to content

Commit 286c112

Browse files
committed
fixed autostart and removed [DEV] from config.ini
1 parent b40baf8 commit 286c112

File tree

6 files changed

+28
-49
lines changed

6 files changed

+28
-49
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,4 @@ cython_debug/
153153

154154
output/
155155
.vscode/
156+
MultiMonitorTool/

SimpleMonitorControlTrayModule/autoStartHandler.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

SimpleMonitorControlTrayModule/configHandler.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,39 @@
66
import SimpleMonitorControlTrayModule.notificationHandler as nH
77
import SimpleMonitorControlTrayModule.trayHandler as tH
88

9-
config_file_path = "config.ini"
10-
assets_folder = "assets"
11-
asset_iconEnabled = "assets\iconEnabled.png"
12-
asset_iconDisabled = "assets\iconDisabled.png"
9+
config_file_path = dH.getDirectory() + r"\config.ini"
10+
asset_iconEnabled_path = dH.getDirectory() + r"\assets\iconEnabled.png"
11+
asset_iconDisabled_path = dH.getDirectory() + r"\assets\iconDisabled.png"
1312

1413
fileNotFound = " file not found. Exiting."
1514

16-
MULTIMONITORTOOL_PATH, CSV_FILE_PATH, MM_CONFIG_FILE_PATH, MONITOR_NAME, AUTOSTART = (
17-
None,
18-
None,
19-
None,
20-
None,
15+
MULTIMONITORTOOL_PATH, MONITOR_NAME, AUTOSTART = (
16+
"",
17+
"",
2118
False,
2219
)
2320

21+
CSV_FILE_PATH = dH.getDirectory() + r"\MultiMonitorTool\multiMonitorToolOutput.csv"
22+
MM_CONFIG_FILE_PATH = dH.getDirectory() + r"\MultiMonitorTool\MultiMonitorToolConfig"
23+
24+
"""[DEV]
25+
mm_csv_export_path = MultiMonitorTool\multiMonitorToolOutput.csv
26+
mm_config_file_path = MultiMonitorTool\MultiMonitorToolConfig"""
27+
2428

2529
def check_for_missing_files():
2630

2731
if not os.path.exists(MULTIMONITORTOOL_PATH):
2832
nH.sendError(MULTIMONITORTOOL_PATH + fileNotFound)
2933
tH.exitItemClicked()
30-
if not os.path.exists(os.path.join(dH.getDirectory(), asset_iconEnabled)):
31-
nH.sendError(asset_iconDisabled + fileNotFound)
34+
if not os.path.exists(os.path.join(dH.getDirectory(), asset_iconEnabled_path)):
35+
nH.sendError(asset_iconDisabled_path + fileNotFound)
3236
tH.exitItemClicked()
3337

3438
if not os.path.exists(CSV_FILE_PATH):
3539
mH.saveMultiMonitorToolConfig()
3640

37-
multiMonitorToolOutputPath = os.path.join(dH.getDirectory(), "MultiMonitorTool")
41+
multiMonitorToolOutputPath = dH.getDirectory() + r"\MultiMonitorTool"
3842

3943
if not os.path.exists(multiMonitorToolOutputPath):
4044
os.makedirs(multiMonitorToolOutputPath)
@@ -51,8 +55,8 @@ def read_config():
5155

5256
global AUTOSTART, MULTIMONITORTOOL_PATH, CSV_FILE_PATH, MM_CONFIG_FILE_PATH, MONITOR_NAME
5357

54-
if not os.path.exists(os.path.join(dH.getDirectory(), asset_iconEnabled)):
55-
nH.sendError(config_file_path + fileNotFound)
58+
if not os.path.exists(os.path.join(dH.getDirectory(), asset_iconEnabled_path)):
59+
nH.sendError(asset_iconEnabled_path + fileNotFound)
5660
tH.exitItemClicked()
5761

5862
config = configparser.ConfigParser()
@@ -62,9 +66,6 @@ def read_config():
6266
MULTIMONITORTOOL_PATH = config.get("SETTINGS", "multimonitorpath")
6367
MONITOR_NAME = config.get("SETTINGS", "monitor_name")
6468
AUTOSTART = config.get("SETTINGS", "autostart")
65-
CSV_FILE_PATH = config.get("DEV", "mm_csv_export_path")
66-
MM_CONFIG_FILE_PATH = config.get("DEV", "mm_config_file_path")
67-
6869
check_for_missing_files()
6970

7071

SimpleMonitorControlTrayModule/registryHandler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def isAutostartKeyinRegistry():
2121

2222
def add_to_autostart():
2323
key = reg.OpenKey(reg.HKEY_CURRENT_USER, registry_key, 0, reg.KEY_WRITE)
24-
reg.SetValueEx(key, keyName, 0, reg.REG_SZ, exe_path)
24+
reg.SetValueEx(
25+
key, keyName, 0, reg.REG_SZ, f'"{exe_path[0].upper() + exe_path[1:]}"'
26+
)
2527
reg.CloseKey(key)
2628

2729

SimpleMonitorControlTrayModule/trayHandler.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
from PIL import Image
55
from pystray import MenuItem as item
66

7-
import SimpleMonitorControlTrayModule.autoStartHandler as aH
87
import SimpleMonitorControlTrayModule.configHandler as cH
98
import SimpleMonitorControlTrayModule.directoryHandler as dH
109
import SimpleMonitorControlTrayModule.monitorHandler as mH
10+
import SimpleMonitorControlTrayModule.registryHandler as rH
1111

1212
icon = None
1313
itemTitle = ""
1414

1515
script_dir = dH.getDirectory()
16-
assets_dir = script_dir + "\\assets"
16+
assets_dir = script_dir + r"\assets"
1717

1818
imageIconEnabled = Image.open(os.path.join(assets_dir, "iconEnabled.png"))
1919
imageIconDisabled = Image.open(os.path.join(assets_dir, "iconDisabled.png"))
@@ -45,12 +45,14 @@ def toggleAutostart(icon):
4545
global itemTitle
4646
if cH.AUTOSTART == "False":
4747
itemTitle = "Disable Autostart"
48-
aH.addShortcutToStartupFolder()
48+
# aH.addShortcutToStartupFolder()
49+
rH.add_to_autostart()
4950
cH.set_config_value("SETTINGS", "autostart", "True")
5051
cH.AUTOSTART = "True"
5152
else:
5253
itemTitle = "Enable Autostart"
53-
aH.removeShortcutFromStartupFolder()
54+
# aH.removeShortcutFromStartupFolder()
55+
rH.remove_from_autostart()
5456
cH.set_config_value("SETTINGS", "autostart", "False")
5557
cH.AUTOSTART = "False"
5658

config.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@ monitor_name = \\.\DISPLAY3
33
multimonitorpath = C:\\App_Install\\multimonitortool-x64\\MultiMonitorTool.exe
44
autostart = False
55

6-
[DEV]
7-
mm_csv_export_path = MultiMonitorTool\multiMonitorToolOutput.csv
8-
mm_config_file_path = MultiMonitorTool\MultiMonitorToolConfig
9-

0 commit comments

Comments
 (0)