python控制窗口移动(轨迹为圆)

需先打开一个无标题记事本,

import win32con
import win32gui
import time
import math
notepad = win32gui.FindWindow("Notepad","无标题 - 记事本")
while True:
    SE = 0.0  # 弧度
    while SE - 3.1415926535 *2 < 0.0000001: #浮点数运算存在误差
        time.sleep(0.1)
        SE += 0.1
        newx = int(400+400*math.cos(SE)) # 圆心加半径
        newy = int(400+400*math.sin(SE))  # 圆心加半径
        win32gui.SetWindowPos(notepad,  # 操作记事本
                              win32con.HWND_TOPMOST,
                              newx,  # x位置
                              newy,  # y位置
                              300,  # 宽
                              300,  # 高
                              win32con.SWP_SHOWWINDOW)
原文地址:https://www.cnblogs.com/sea-stream/p/10804820.html