创建了一个动态渐变背景颜色的 GUI 窗口,颜色在多个颜色通道之间切换,视觉效果类似彩虹渐变。

 

;___[Settings]___;

  rate:=8
  delay:=10
  startwait:=200
  fullscreen:=1
  
;___[Settings]___;

setbatchlines, -1
start:
if fullscreen
  gui +ToolWindow -Caption +AlwaysOnTop
else
  gui, +Resize +MinSize160x25
gui, color, % dec2hex(255*16*16*16*16)
gui, add, text, y4 x4 vtxt gGUI_Move,hello
gui, font, bold s16
gui, add, text, y18 x18 h50 w150 c1a1a1a ,Esc=Quit
gui, font
gui, show, h50 w150, cFlux - Colors FTW!
if fullscreen
{
  PID := DllCall("GetCurrentProcessId")
  WinMove, ahk_pid %PID%,,0,0,A_ScreenWidth,A_ScreenHeight
  WinSet, AlwaysOnTop, On, ahk_pid %PID%
}
tot:=floor(255/rate)
sleep, %startwait%
goto run
return

run:
Loop
{
  loop, %tot%
  {
    k:=dec2hex((A_index*rate*16*16)+(255*16*16*16*16))
    gui, color, %k%
    guicontrol,,txt,%k%
    sleep, %delay%
  }
  loop, %tot%
  {
    k:=dec2hex((255*16*16*16*16)-(A_index*rate*16*16*16*16)+(255*16*16))
    gui, color, %k%
    guicontrol,,txt,%k%
    sleep, %delay%
  }
  loop, %tot%
  {
    k:=dec2hex((A_index*rate)+(255*16*16))
    gui, color, %k%
    guicontrol,,txt,%k%
    sleep, %delay%
  }
  loop, %tot%
  {
    k:=dec2hex((255*16*16)-(A_index*rate*16*16)+(255))
    gui, color, %k%
    guicontrol,,txt,%k%
    sleep, %delay%
  }
  loop, %tot%
  {
    k:=dec2hex((255)+(A_index*rate*16*16*16*16))
    gui, color, %k%
    guicontrol,,txt,%k%
    sleep, %delay%
  }
  loop, %tot%
  {
    k:=dec2hex((255*16*16*16*16)+(255)-(A_index*rate))
    gui, color, %k%
    guicontrol,,txt,%k%
    sleep, %delay%
  }
}
return

GUI_Move:
PostMessage 0xA1,2
return

GuiSize:
GuiControl, Move, txt, w%A_GuiWidth% h%A_GuiHeight%
return

dec2hex(x)
{
  a:=A_FormatInteger
  SetFormat, integer, hex
  x+=0
  setFormat, integer, %a%
  return x
}

q::
Escape::
Guiclose:
exitapp

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。