test_name.py 533 B

12345678910111213141516171819202122232425
  1. # This Python file uses the following encoding: utf-8
  2. # @author runhey
  3. # github https://github.com/runhey
  4. import ctypes
  5. import time
  6. import psutil
  7. # 定义Windows API函数
  8. kernel32 = ctypes.WinDLL('kernel32')
  9. SetConsoleTitleW = kernel32.SetConsoleTitleW
  10. # 设置进程名称
  11. new_title = "Netle"
  12. SetConsoleTitleW(new_title)
  13. processes = psutil.process_iter()
  14. for process in processes:
  15. if not process.name().startswith('python'):
  16. continue
  17. print(f"进程ID: {process.pid}, 名字: {process.name()}")
  18. time.sleep(3)