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)