将图片截成长条gif, 放在屏幕顶部, 根据情况放大图片, 效果好像还可以啊

![]()
![]()
update 2024/07/04 21:49:23:
下面图片显示的是用ahk脚本调整窗口透明度 及python脚本写的无边框动态gui(鼠标中键点击关闭)

ahk脚本调整透明度:
#NoEnv
transparency := 255
^+WheelUp::
transparency -= 5
if (transparency < 100)
transparency := 100
ToolTip %transparency%
SetTimer, ResetToolTip, 1000
WinSet, Transparent, %transparency%, A
return
^+WheelDown::
transparency += 5
if (transparency > 255)
transparency := 255
ToolTip %transparency%
SetTimer, ResetToolTip, 1000
WinSet, Transparent, %transparency%, A
return
ResetToolTip:
ToolTip
return
python脚本显示动态无边框gui
import tkinter as tk
import ctypes
if ctypes.windll.kernel32.GetConsoleWindow() != 0:
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0)
def drag_window(event):
# 记录鼠标按下时的窗口位置
root.x = root.winfo_x()
root.y = root.winfo_y()
# 记录鼠标按下时的光标位置
root.xmouse = event.x_root
root.ymouse = event.y_root
def move_window(event):
# 计算窗口应该移动到的位置
x = root.x + event.x_root - root.xmouse
y = root.y + event.y_root - root.ymouse
# 移动窗口
root.geometry(f"+{x}+{y}")
def close_window(event):
# 当鼠标中键点击时,关闭窗口
root.destroy()
root = tk.Tk()
# root.title("动态GUI")
root.overrideredirect(True)
# canvas = tk.Canvas(root, width=1600, height=200, bg='#E0E7F7')
# canvas.pack()
# 绑定鼠标按下事件以记录初始位置
root.bind("<ButtonPress-1>", drag_window)
# 绑定鼠标移动事件以移动窗口
root.bind("<B1-Motion>", move_window)
# 绑定鼠标中键点击事件以关闭窗口
root.bind("<Button-2>", close_window)
# 禁用窗口的自动调整大小
root.resizable(False, False)
canvas = tk.Canvas(root, width=1600, height=900, bg='#E0E7F7')
canvas.pack(fill='both', expand=True)
green_color = '#FF4F00'
# x 设置为画布宽度的一半
x = 1600 // 2
width = 1600
height = 900
fill_width = 0 # 填充的宽度
direction = 'expand' # 'expand' 或 'contract'
elapsed_time = 0 # 已经过去的时间
# 持续时间变量,用于动态改变
expand_duration = 1.5 # 扩散的总时间(秒)
contract_duration = 2 # 收缩的总时间(秒)
current_duration = expand_duration # 当前阶段的持续时间
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0)
def update_gui():
global fill_width, direction, elapsed_time, current_duration
# 更新已过去的时间
elapsed_time += 0.01 # 每10毫秒调用一次update_gui
# 持续时间变量,用于动态改变
expand_duration = 2 # 扩散的总时间(秒)
contract_duration = 4 # 收缩的总时间(秒)
current_duration = expand_duration # 当前阶段的持续时间
def update_gui():
global fill_width, direction, elapsed_time, current_duration
# 更新已过去的时间
elapsed_time += 0.01 # 每10毫秒调用一次update_gui
# 计算填充宽度
if direction == 'expand':
fill_width = int(elapsed_time / current_duration * (width // 2))
if fill_width >= width // 2:
direction = 'contract'
elapsed_time = 0 # 重置时间计数器
current_duration = contract_duration # 切换到收缩的持续时间
else:
fill_width = int(max(0, (1 - elapsed_time / current_duration) * (width // 2)))
if fill_width <= 0:
direction = 'expand'
elapsed_time = 0 # 重置时间计数器
current_duration = expand_duration # 切换到扩散的持续时间
# 清除画布
canvas.delete('all')
# 在中间开始,向两边绘制矩形
canvas.create_rectangle(x - fill_width, 0, x + fill_width, height, fill=green_color)
# 在10毫秒后再次调用update_gui
root.after(10, update_gui)
update_gui()
root.mainloop()