Files
autoMate/tests/test_path.py
yuruo a865e340b6 添加(chat_page.py): 引入ActionItems类和ActionList类,重构鼠标点击和双击事件处理逻辑
🚀 部署(test_path.py): 添加test_window函数,测试并获取当前活动窗口的标题
🔧 添加(window_util.py): 引入WindowUtil类,获取当前活动窗口的标题。
2024-05-27 14:19:43 +08:00

31 lines
752 B
Python

import os
import time
def test_path():
desktop_path = r"C:\Users\yuruo\Desktop"
file_list = []
for dirpath, dirnames, filenames in os.walk(desktop_path):
for filename in filenames:
file_list.append(os.path.join(dirpath, filename))
print(file_list)
def test_window():
import ctypes
# 获取当前活动窗口的句柄
hWnd = ctypes.windll.user32.GetForegroundWindow()
# 获取窗口标题
length = ctypes.c_int(256)
buffer = ctypes.create_unicode_buffer(length.value)
ctypes.windll.user32.GetWindowTextW(hWnd, buffer, length)
title = buffer.value.split("-")[-1]
print(title)
if __name__ == "__main__":
while True:
test_window()
time.sleep(2)