GuiControl not changing image when 'Gui, New' used ??

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
niczoom
Posts: 78
Joined: 09 Mar 2016, 22:17

GuiControl not changing image when 'Gui, New' used ??

25 Jun 2016, 03:31

I pulled some code from a larger project. I am testing changing images using the GuiControl command, in the following code when I press the right arrow key my image changes (from Icon_Settings_0 to Icon_Settings_1):

Code: Select all

#SingleInstance force

global IconResourcesPath := A_ScriptDir "\Resources\126466-multimedia-collection\png\!final\images\"
global Icon_Settings_0	:= IconResourcesPath "settings_normal.png"
global Icon_Settings_1	:= IconResourcesPath "settings_focus.png"	

;~ Gui, Meee: New
Gui, Add, Picture, w250 h-1 +BackgroundTrans, % Icon_Settings_0
Gui, Show
return


Right::
	test()
	return


test() {
	GuiControl,,Static1,%Icon_Settings_1%
}
But when I un-comment the line Gui, Meee: New (which I use to set a number of options) the image does not change when pressing the right arrow key?

Any ideas why this would be?
[AHK] 1.1.23.05 x32 Unicode
[WIN] 10 Pro x64 Version 5111 (Build 10586.218)
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: GuiControl not changing image when 'Gui, New' used ??

25 Jun 2016, 04:27

Code: Select all

test() {
	GuiControl, Meee:, Static1, %Icon_Settings_1% ; added Gui name
}
The default window name for a GUI thread is that of the window that launched the thread. Non-GUI threads use 1 as their default.
User avatar
niczoom
Posts: 78
Joined: 09 Mar 2016, 22:17

Re: GuiControl not changing image when 'Gui, New' used ??

25 Jun 2016, 09:08

Thanks for pointing me in the right direction, I was going round in circles reading the docs, obviously too tired to take much in! I've been using AHK for a while but never for GUI's, so its been a learning experience ...
[AHK] 1.1.23.05 x32 Unicode
[WIN] 10 Pro x64 Version 5111 (Build 10586.218)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 287 guests