From 75e8fe7ed8f318e830af1bde702d7c806bf93715 Mon Sep 17 00:00:00 2001 From: Cinabre Date: Thu, 22 Oct 2020 21:22:10 +0200 Subject: [PATCH] initial commit --- README.md | 1 + run.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 README.md create mode 100644 run.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..2d1c0fa --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +NoSocialLife diff --git a/run.py b/run.py new file mode 100644 index 0000000..e9d6944 --- /dev/null +++ b/run.py @@ -0,0 +1,49 @@ + +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()