ezcad.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/python3
  2. import threading
  3. import time
  4. import log
  5. import win32api
  6. import win32con
  7. class ezcad(threading.Thread):
  8. def __init__(self, threadID, name, counter):
  9. threading.Thread.__init__(self)
  10. self.threadID = threadID
  11. self.name = name
  12. self.counter = counter
  13. self.filename = 'D:\Server\模板server.ezd'
  14. self.exename = 'EzCad2.exe'
  15. self.exepath = 'D:\Ezcad2.14.9(20160628新驱动)(1)\Ezcad2.14.9(20160628新驱动)'
  16. self.log_file = log.log_file
  17. self.log_print = log.log_file
  18. def run(self):
  19. try:
  20. win32api.ShellExecute(0, 'open', self.exename, self.filename, self.exepath, 1)
  21. time.sleep(20)
  22. # win32api.keybd_event(0x71, 0, 0, 0) # enter
  23. # time.sleep(0.1)
  24. # win32api.keybd_event(0x71, 0, win32con.KEYEVENTF_KEYUP, 0) # 释放按键
  25. except Exception as e:
  26. self.log_file.logger.error('打标机软件执行异常: {0}'.format(e), exc_info=True, stack_info=True)