-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (27 loc) · 806 Bytes
/
main.py
File metadata and controls
38 lines (27 loc) · 806 Bytes
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
# 注意: 所有用到的模块都要在此处导入
import os # noqa 841
import webbrowser # noqa 841
import ctypes # noqa 841
import sys # noqa 841
import PySimpleGUI as sg # noqa 841
import scripts.MainGUI as MainGUI
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except Exception as e: # noqa841
return False
def run():
MainGUI.gui_start()
def admin_run():
if is_admin():
run()
else:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 0)
if __name__ == "__main__":
if len(sys.argv) > 1: # 第一个是文件名,如果多于1个,说明其他模式启动
if sys.argv[1] == "-d":
run()
else:
admin_run()
else:
admin_run()