|
-
- from datetime import datetime
- import psutil
- import time
- from win10toast import ToastNotifier
- toaster = ToastNotifier()
-
- #Dictionnaire pour une prochaine mise à jour
- process = ["firefox.exe", "discord.exe"]
-
-
-
- def get_time():
- now = datetime.now().time()
- print("now =", now)
-
- def main():
- searching_process = "nothing.exe"
- toaster.show_toast("NoSocialLife Counter","Programme recherché : " + searching_process )
- i = 0
- process_running = False
- delay = 1
-
- while process_running == False :
- founded_process = catch_process(searching_process)
- print("Etat de la recherche : " + founded_process)
- get_time()
- time.sleep(delay)
- i += 1
-
-
- def catch_process(searching_process):
- catched = False
- for p in psutil.process_iter(attrs=['pid', 'name']):
- if p.info['name'] == searching_process :
- founded_process = p.info['name']
- catched = True
-
- if catched == False :
- print("Programme non trouvé")
- founded_process = None
- return founded_process
-
-
- if __name__ == '__main__':
- try :
- main()
- except :
- main()
|