How to tile a background image for an AutoHotkey GUI Version 1.1.36.02 ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rx65m
Posts: 19
Joined: 16 Mar 2018, 17:29

How to tile a background image for an AutoHotkey GUI Version 1.1.36.02 ?

Post by rx65m » 13 Mar 2023, 13:12

I have tried several ways to tile my background image for my AutoHotkey GUI Version 1.1.36.02 , but always getting error messages.

This is my code:

Code: Select all

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
And this is the image I want to use as the tiled background. It is already saved at the same folder of my AHK script, which is 1px x 52px :
Image

How can I do this in the correct way?

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How to tile a background image for an AutoHotkey GUI Version 1.1.36.02 ?

Post by mikeyww » 13 Mar 2023, 14:22

Hello,

You can add multiple picture controls, and position them as you wish.

User avatar
RDC
Posts: 112
Joined: 29 Jan 2023, 10:22

Re: How to tile a background image for an AutoHotkey GUI Version 1.1.36.02 ?

Post by RDC » 13 Mar 2023, 19:43

@rx65m ... this got me curious so I started my own search. Check out the last post at https://www.autohotkey.com/board/topic/80576-how-to-set-a-tiled-background-for-gui/ by maestrith and I think you'll find what you are looking for.
I've been playing and updating it to my preferences for fun for the past couple hours. Good reference for future Gui projects.

Code: Select all

Menu, Tray, Icon, moricons.dll, 36 
#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.
;  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶ ̶  ̶  ̶  ̶  
;
^T::
;  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶   These will download original image samples from maestrith's post...
;  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶   Or use the included testing samples included. Must remain in same location as script.
; IfNotExist,tile.bmp,UrlDownloadToFile,http://www.maestrith.com/files/tile.bmp,tile.bmp
; IfNotExist,lens.png,UrlDownloadToFile,http://i.imgur.com/pGL6k.png,lens.png
;  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶ ̶  ̶  ̶  ̶  

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, xm ym+11 BackgroundTrans, BAT.png 		 ; Image inside Gui.
Gui, Add, Text, y+5 cBlue , Tiled Background 			 ; Text inside Gui.
Gui, Show,, GUI with 'Tiled background' 				 ; Titlebar Text.
Sleep 10
Return

;  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶   Must use bmp image. Change with personal choice below. "TILED2.bmp" is example.
WM_CTLCOLORDLG(){
	Static wBrush
	If !wBrush
	hBM:=DllCall("LoadImage",Int,0,Str,"TILED2.bmp",Int,0,Int,0,Int,0,UInt,0x2010),wBrush:=DllCall("CreatePatternBrush",UInt,hBM)
	Return wBrush
}
GuiClose:
GuiEscape:
ExitApp

;
;  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶ ̶  ̶  ̶  ̶  
RETURN
;  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶ ̶  ̶  ̶  ̶  

^!R::Reload 	 ; (Ctrl+Alt+R)

^Esc::ExitApp 	 ; (Ctrl+Esc)

;  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  ̶  
BAT.png
BAT.png (18.34 KiB) Viewed 256 times
TILED2.png
TILED2.png will need to be converted to TILED.bmp as appears can't upload .bmp files?
TILED2.png (1.07 KiB) Viewed 256 times

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How to tile a background image for an AutoHotkey GUI Version 1.1.36.02 ?

Post by mikeyww » 13 Mar 2023, 20:06

I did not try it, but it looks cool! Thanks for the details.

Post Reply

Return to “Ask for Help (v1)”