-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
60 lines (45 loc) · 1.34 KB
/
main.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
54
55
56
57
58
59
60
import datetime
import getpass
import os
import shutil
import sys
import time
from threading import Thread
import schedule
import idleTime
import ss
#import Startup
import winshell
from win32com.client import Dispatch
TodayDate = datetime.datetime.now()
def start():
Thread(target = ss.TakeSS).start()
Thread(target = idleTime.IdleCalculator).start()
def CleanUp():
a = os.getcwd()
fp = a+"\\"+TodayDate.strftime('%Y%m%d')
shutil.rmtree(fp, ignore_errors=True)
if (TodayDate.hour>9 and TodayDate.hour<23):
start()
else:
print("will start next day..................")
#Current = os.getcwd()
#FilePath = Current + '\\' + 'main.exe'
#Startup.add_to_startup(FilePath)
USER_NAME = getpass.getuser()
st_path = r'C:\\Users\\%s\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup' % USER_NAME
path = os.path.join(st_path, "Activity Monitor.lnk")
target = os.getcwd()+"\\"+"main.exe"
wDir = os.getcwd()
icon = os.getcwd()+"\\"+"main.exe"
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
schedule.every().day.at("09:00").do(start)
schedule.every().day.at("23:02").do(CleanUp)
while 1:
schedule.run_pending()
time.sleep(1)