我尝试了几种方法来平铺我的 AutoHotkey (AHK) 版本 1.1.36.02 GUI 的背景图像,但总是收到错误消息。
这是我的代码:
Gui, -Caption +LastFound +AlwaysOnTop
Gui, +Border
Gui, Margin, 0, 0
Gui, Color, white
Gui, Add, Picture, x0 y0 w1 h52, 1x52.png
Gui, Show, x100 y600 w200 h398
这是我想要用作平铺背景的图像。它已经保存在我的 AHK 脚本的同一文件夹中,尺寸为 1px x 52px : https://i.stack.imgur.com/mxxNg.png
我怎样才能以正确的方式做到这一点?
答案1
如果您仍在寻找获取平铺背景的方法,请尝试一下...
; Tiled Background.ahk has included files...
; BAT.png, BATblack.png, and Weathered.bmp
; Background image must be .bmp file.
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#NoEnv ; Recommended for performance and future compatibility.
#Persistent ; Keeps a script permanently running until user closes it or ExitApp is encountered.
#SingleInstance, Force ; Determines whether a script is allowed to run again when it is already running.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Menu, Tray, Icon, wmploc.dll, 99
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
^T::
; = = = = = Use the included testing samples. Must remain in same location as script.
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Gui,
+Resize ; Makes the window resizable and enables its maximize button in the title bar.
+AlwaysOnTop ; Makes a window stay on top of all other windows.
OnMessage(0x136,"WM_CTLCOLORDLG")
; = = = = = WM_CTLCOLORDLG message: Sent to a dialog box before the system draws the dialog box. By responding to this message, the dialog box can set its text and background colors using the specified display device context handle.
Gui, Margin, 15, 15
Gui, Font, S12 Bold, Arial Black
Gui, Add, Picture,x14 y16 Center vImage1 BackgroundTrans , %A_ScriptDir%/BATblack.png ; Offset shadowed image.
Gui, Add, Picture,x10 y10 Center vImage2 BackgroundTrans , %A_ScriptDir%/BAT.png ; Image inside Gui.
Gui, Show,, GUI with 'Tiled background'
Sleep 10
Return
; = = = = = Must use bmp image. Change with personal choice below. "Weathered.bmp" is example.
WM_CTLCOLORDLG(){
Static wBrush
If !wBrush
hBM:=DllCall("LoadImage",Int,0,Str,"Weathered.bmp",Int,0,Int,0,Int,0,UInt,0x2010),wBrush:=DllCall("CreatePatternBrush",UInt,hBM)
Return wBrush
}
GuiClose:
GuiEscape:
Reload
; ExitApp
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
RETURN
^Home::
Reload ; Ctrl + [Home]
^Esc::
ExitApp ; Ctrl + [Esc]
; = = = = =
图片仅供参考。您可以根据需要随意更改。