刹那的菜鸟

博客园 首页 新随笔 联系 管理

import win32gui
import win32con
from pywinauto import mouse
from time import sleep

def foreground(window_title):
hwnd = win32gui.FindWindow(None, window_title)
win32gui.ShowWindow(hwnd, win32con.SW_SHOW)
win32gui.SetForegroundWindow(hwnd)

if name == "main":
foreground("Document - Wordpad")
sleep(1)
#if you comment the next line you will get a 'Access is denied.' error
mouse.move(coords=(-10000, 500))
foreground("Task Manager")

posted on 2024-11-13 16:54  刹那的菜鸟  阅读(0)  评论(0编辑  收藏  举报