当前位置:   article > 正文

控制window系统应用程序定时关闭和开启_自动控制电脑软件启动和关闭的插件怎么写

自动控制电脑软件启动和关闭的插件怎么写
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. """
  4. @version: v1.0
  5. @author: 梦幻人生人
  6. @license: Apache Licence
  7. @contact: 1229218283@qq.com
  8. @site: none
  9. @software: PyCharm
  10. @file: main.py
  11. @time: 2018/1/8 0:27
  12. """
  13. import win32api
  14. import os
  15. import datetime
  16. import time
  17. """
  18. 例子:
  19. #打开指定应用
  20. win32api.ShellExecute(0, 'open', r'D:\Users\Administrator\AppData'
  21. r'\Roaming\baidu\BaiduNetdisk\BaiduNetdisk.exe', '','',1)
  22. #关闭指定应用
  23. os.system("taskkill /F /IM BaiduNetdisk.exe")
  24. """
  25. def openApplication():
  26. #打开360网页
  27. win32api.ShellExecute(0, 'open', r'C:\Users\Administrator'
  28. r'\AppData\Roaming\360se6\Application\360se.exe', '', '', 1)
  29. def closeApplication():
  30. #关闭360网页
  31. os.system("taskkill /F /IM 360se.exe")
  32. opentime={'hour':17,'minute':50,'second':0}
  33. closetime={'hour':2,'minute':0,'second':0}
  34. while True:
  35. nowtime = datetime.datetime.now()
  36. print unicode("当前的日期和时间是 %s" %nowtime,'utf-8')
  37. if nowtime.hour == opentime['hour'] and nowtime.minute == opentime['minute']\
  38. and nowtime.second == opentime['second']:
  39. openApplication()
  40. elif nowtime.hour == closetime['hour'] and nowtime.minute == closetime['minute'] \
  41. and nowtime.second == closetime['second']:
  42. closeApplication()
  43. time.sleep(1)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/76223
推荐阅读
相关标签
  

闽ICP备14008679号