Page 1 of 1

Help: How to change the ClassNN or control name

Posted: 27 Mar 2020, 17:00
by llTroubleDMinDll
A great day for everyone :D my query is as follows, I want to change the ClassNN of each control that are png images, and replace the StaticNN that has the name of each image by default. There are two commands that I have tried GuiControl and ControlSetText, but when trying to rename the control disappears. What am I doing wrong? I'm just experiencing programming. I have more questions but I do not want to bother my first post :thumbup: .

Code: Select all

SendMode Input
#SingleInstance Force
#UseHook on
#HotkeyInterval 0
#NoEnv
#MaxThreads
Process, priority, , High
SetWorkingDir %A_ScriptDir%
Setbatchlines, -1
SetKeyDelay , -1, -1
SetMouseDelay, -1
SetControlDelay, -1
SetWinDelay, -1
SetDefaultMouseSpeed, 0
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen


Gui ItemsBasico: +AlwaysOnTop +LastFound +ToolWindow -Caption
Win_TransColor:=0x123456
Gui ItemsBasico: Color, %Win_TransColor%
MainHandle:=WinExist()
Gui ItemsBasico: Add, Picture, X5 Y5, imageName1.png
Gui ItemsBasico: Add, Picture, X50 Y5, imageName2.png
Gui ItemsBasico: Show, x0 y0 w500 h800 NoActivate, Items
WinSet, TransColor, %Win_TransColor%, ahk_id %MainHandle%

; first attempt to change the "ClassNN" of the control
GuiControl ItemsBasico: Text, Static1, imageName1
GuiControl ItemsBasico: Text, Static2, imageName2

; second attempt to change the "ClassNN" of the control
ControlSetText ItemsBasico: Static1, imageName1, Items
ControlSetText ItemsBasico: Static2, imageName2, Items

Re: Help: How to change the ClassNN or control name

Posted: 28 Mar 2020, 00:21
by Hellbent
I'm not sure what you are trying to do, my best guess is that you simply don't want to use the ClassNN as the identifier of the control.

If that is the case, you can use the controls hwnd (Handle), or associate a variable with the control and use that as the identifier.

Code: Select all

Gui, 1:Add, Pic, vImage1Variable     

Gui, 1:Add, Pic, hwndImage1Handle 

Re: Help: How to change the ClassNN or control name

Posted: 28 Mar 2020, 08:08
by llTroubleDMinDll
Hellbent wrote:
28 Mar 2020, 00:21
I'm not sure what you are trying to do, my best guess is that you simply don't want to use the ClassNN as the identifier of the control.

If that is the case, you can use the controls hwnd (Handle), or associate a variable with the control and use that as the identifier.

Code: Select all

Gui, 1:Add, Pic, vImage1Variable     

Gui, 1:Add, Pic, hwndImage1Handle 

What I want to do is use an identifier that is text and not numeric, nor in many variables, since there are more than 80 small images that I will use as buttons. In order to do the following.

Code: Select all

Rbutton:: 
Mousegetpos,,,,xcontrol
if(xcontrol)
     msgbox, press Rbutton in %xcontrol%
	 GoSub, %xcontrol%Shop
return

+Lbutton:: 
Mousegetpos,,,,xcontrol
if(xcontrol)
     msgbox, press Rbutton in %xcontrol%
	 GoSub, %xcontrol%Put
return

^+Lbutton:: 
Mousegetpos,,,,xcontrol
if(xcontrol)
     msgbox, press Rbutton in %xcontrol%
	 GoSub, %xcontrol%Add
return
I wait your answer :thumbup: