You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

run.py 1.1 KiB

2 kuukautta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from datetime import datetime
  2. import psutil
  3. import time
  4. from win10toast import ToastNotifier
  5. toaster = ToastNotifier()
  6. #Dictionnaire pour une prochaine mise à jour
  7. process = ["firefox.exe", "discord.exe"]
  8. def get_time():
  9. now = datetime.now().time()
  10. print("now =", now)
  11. def main():
  12. searching_process = "nothing.exe"
  13. toaster.show_toast("NoSocialLife Counter","Programme recherché : " + searching_process )
  14. i = 0
  15. process_running = False
  16. delay = 1
  17. while process_running == False :
  18. founded_process = catch_process(searching_process)
  19. print("Etat de la recherche : " + founded_process)
  20. get_time()
  21. time.sleep(delay)
  22. i += 1
  23. def catch_process(searching_process):
  24. catched = False
  25. for p in psutil.process_iter(attrs=['pid', 'name']):
  26. if p.info['name'] == searching_process :
  27. founded_process = p.info['name']
  28. catched = True
  29. if catched == False :
  30. print("Programme non trouvé")
  31. founded_process = None
  32. return founded_process
  33. if __name__ == '__main__':
  34. try :
  35. main()
  36. except :
  37. main()