9
9
import subprocess as sp
10
10
11
11
12
- # Adds G14Control.exe to the windows registry to start on boot/login
13
- def registry_add (registry_key_loc , G14dir ):
14
- G14exe = "G14Control.exe"
15
- G14dir = str (G14dir )
16
- G14fileloc = os .path .join (G14dir , G14exe )
17
- G14Key = winreg .OpenKey (
18
- winreg .HKEY_CURRENT_USER , registry_key_loc , 0 , winreg .KEY_SET_VALUE
19
- )
20
- winreg .SetValueEx (G14Key , "G14Control" , 1 , winreg .REG_SZ , G14fileloc )
21
-
22
-
23
- # Removes G14Control.exe from the windows registry
24
- def registry_remove (registry_key_loc , G14dir ):
25
- G14dir = str (G14dir )
26
- G14Key = winreg .OpenKey (
27
- winreg .HKEY_CURRENT_USER , registry_key_loc , 0 , winreg .KEY_ALL_ACCESS
28
- )
29
- winreg .DeleteValue (G14Key , "G14Control" )
12
+ # # Adds G14Control.exe to the windows registry to start on boot/login
13
+ # def registry_add(registry_key_loc, G14dir):
14
+ # G14exe = "G14Control.exe"
15
+ # G14dir = str(G14dir)
16
+ # G14fileloc = os.path.join(G14dir, G14exe)
17
+ # G14Key = winreg.OpenKey(
18
+ # winreg.HKEY_CURRENT_USER, registry_key_loc, 0, winreg.KEY_SET_VALUE
19
+ # )
20
+ # winreg.SetValueEx(G14Key, "G14Control", 1, winreg.REG_SZ, G14fileloc)
21
+ # winreg.CloseKey(G14Key)
22
+
23
+
24
+ # # Removes G14Control.exe from the windows registry
25
+ # def registry_remove(registry_key_loc, G14dir):
26
+ # G14dir = str(G14dir)
27
+ # G14Key = winreg.OpenKey(
28
+ # winreg.HKEY_CURRENT_USER, registry_key_loc, 0, winreg.KEY_ALL_ACCESS
29
+ # )
30
+ # winreg.DeleteValue(G14Key, "G14Control")
31
+ # winreg.CloseKey(G14Key)
30
32
31
33
32
34
# Checks if G14Control registry entry exists already
@@ -70,20 +72,20 @@ def startup_checks(data):
70
72
# Adds registry entry if enabled in config, but not when in debug mode.
71
73
# if not registry entry is already existing,
72
74
# removes registry entry if registry exists but setting is disabled:
73
- reg_run_enabled = registry_check (data .registry_key_loc , G14dir )
74
-
75
- if (
76
- data .config ["start_on_boot" ]
77
- and not data .config ["debug" ]
78
- and not reg_run_enabled
79
- ):
80
- registry_add (data .registry_key_loc , G14dir )
81
- if (
82
- not data .config ["start_on_boot" ]
83
- and not data .config ["debug" ]
84
- and reg_run_enabled
85
- ):
86
- registry_remove (data .registry_key_loc , data .G14dir )
75
+ # reg_run_enabled = registry_check(data.registry_key_loc, G14dir)
76
+
77
+ # if (
78
+ # data.config["start_on_boot"]
79
+ # and not data.config["debug"]
80
+ # and not reg_run_enabled
81
+ # ):
82
+ # registry_add(data.registry_key_loc, G14dir)
83
+ # if (
84
+ # not data.config["start_on_boot"]
85
+ # and not data.config["debug"]
86
+ # and reg_run_enabled
87
+ # ):
88
+ # registry_remove(data.registry_key_loc, data.G14dir)
87
89
return data .auto_power_switch
88
90
89
91
@@ -165,8 +167,10 @@ def get_windows_plan_map(windows_plans):
165
167
def is_admin ():
166
168
try :
167
169
# Returns true if the user launched the app as admin
170
+ val = ctypes .windll .shell32 .IsUserAnAdmin ()
171
+ print ("is admin?:" + val )
168
172
return ctypes .windll .shell32 .IsUserAnAdmin ()
169
- except OSError or WindowsError :
173
+ except Exception :
170
174
return False
171
175
172
176
@@ -179,6 +183,7 @@ def get_windows_theme():
179
183
)
180
184
# Taskbar (where icon is displayed) uses the 'System' light theme key. Index 0 is the value, index 1 is the type of key
181
185
value = winreg .QueryValueEx (sub_key , "SystemUsesLightTheme" )[0 ]
186
+ sub_key .Close ()
182
187
return value # 1 for light theme, 0 for dark theme
183
188
184
189
0 commit comments