Page 1 of 1

Click On Progress Bar?

Posted: 27 Jul 2019, 02:45
by scriptor2016
Hi

Is there any way to left click on a progress bar and have it send a command? It won't accept a Glabel so I'm not sure if it can be done...

Code: Select all

Gui Add, Progress, w300 h20 Backgroundccccff vPrBar1 
Gui Show, w700 h140, My Progress Bar  
return

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 03:11
by Odlanir

Code: Select all

OnMessage(0x201,"WM_LBUTTONDOWN")
WM_LBUTTONDOWN() {
	If (A_GuiControl = "PrBar1") {
      Msgbox % "You've clicked on the progress bar"
   }
}

Gui Add, Progress, w300 h20 Backgroundccccff vPrBar1
Gui Show, w700 h140, My Progress Bar  
return

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 03:41
by scriptor2016
ah-ha

thanks Odlanir :)

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 07:15
by tmplinshi
How about making the Progress control disabled, then adding a transparent Text control over it?

Code: Select all

Gui Add, Progress, w300 h20 Backgroundccccff vPrBar1 Disabled
Gui, Add, Text, xp wp hp gPrBar1_OnClick BackgroundTrans, 
Gui Show, w700 h140, My Progress Bar  
return

PrBar1_OnClick:
	MsgBox, Clicked
Return

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 11:30
by scriptor2016
that works too!!

What I'm trying to do:

Create only one gui and inside that gui have many rows and columns of controls, arranged in a grid-like fashion. Maybe 10rows x 10columns. Each control will be a colored square and its variable would be 1 thru 100. When clicking on any of the squares in the grid, for example, it would say "you have clicked on control 47"

I was trying to find ways to create these colored squares, and it seems that using a progressbar might be a good idea. Or even using child guis might work too but I have a feeling that way could get too complicated...


thanks for the suggestions! I'm going to play around with both of these ...

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 12:25
by Odlanir
Some like this?

Code: Select all

OnMessage(0x201,"WM_LBUTTONDOWN")
cnt := 0
Gui, add, text, y-35 Hidden
loop, 10 {
	Gui, add, Progress,% "x010 yp+41 w40 h40 Background" rndCol() " vControl" ++cnt
	loop, 9		
		Gui, add, Progress,% "x" a_index * 40 +10 " yp w40 h40 Background" rndCol() " vControl" ++cnt
}
Gui, Show
return
rndCol() {
   Random, rnd, 0, 0xFFFFFF
   return format("{:06x}",rnd)
}

WM_LBUTTONDOWN() {
	If (A_GuiControl) {
         Msgbox % "You've clicked on " a_guicontrol
   }
}

*esc::
   ExitApp

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 12:49
by scriptor2016
wow!!! yes that's exactly the look I'm going for!!!! I'll have to study how you did it though.


I need to get the script to read a text file which will have a list of 100 different colors, the file will look like:

Code: Select all

B25950
B250A5
1300F8
0027F9
0063F9
009FFA
009FFA
00DBF9
00F9DB
00F99F
00F863
01F927
13F900
4FF900
C7F900
F9EF01
FAB301
F97600
F93B00
F70100
F90076
F900B2
F901EE
C700F9
8B00F9
4F00F9
506CB2
A8CADA
428A29
506CB2
B25950
B250A5
1300F8
0027F9
0063F9
009FFA
009FFA
00DBF9
00F9DB
00F99F
00F863
01F927
13F900
4FF900
C7F900
F9EF01
FAB301
F97600
F93B00
F70100
F90076
F900B2
F901EE
C700F9
8B00F9
4F00F9
506CB2
A8CADA
428A29
506CB2
B25950
B250A5
1300F8
0027F9
0063F9
009FFA
009FFA
00DBF9
00F9DB
00F99F
00F863
01F927
13F900
4FF900
C7F900
F9EF01
FAB301
F97600
F93B00
F70100
F90076
F900B2
F901EE
C700F9
8B00F9
4F00F9
506CB2
1300F8
0027F9
0063F9
009FFA
009FFA
00DBF9
00F9DB
00F99F
00F863
01F927
1300F8
0027F9
0063F9
There are 100 lines, each containing a HEX value. (I've repeated many of these codes here just by cut/paste so it's faster to type in all 100 values lol)


it will read all 100 colors, then display them in the grid.

This part I think can handle. I'll try to adapt it to your code :)

From there, I'll take care of the left-clicking on each square and have it carry out the commands.

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 12:55
by Odlanir
I've saved your list in color.txt.

Code: Select all

FileRead, colors, colors.txt
arr := StrSplit(colors,"`n","`r")

OnMessage(0x201,"WM_LBUTTONDOWN")
cnt := 0
Gui, add, text, y-35 Hidden
loop, 10 {
	Gui, add, Progress,% "x010 yp+41 w40 h40 Background" arr[++cnt] " vControl" cnt
	loop, 9		
		Gui, add, Progress,% "x" a_index * 40 +10 " yp w40 h40 Background" arr[++cnt] " vControl" cnt
}
Gui, Show
return

WM_LBUTTONDOWN() {
	If (A_GuiControl) {
         Msgbox % "You've clicked on " a_guicontrol
   }
}

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 13:02
by scriptor2016
ok so I've tried to read the text file and have it load the colors into the grid, but as you can see it has gone a little sideways on me lol ;)

Code: Select all

OnMessage(0x201,"WM_LBUTTONDOWN")
cnt := 0
Gui, add, text, y-35 Hidden

Loop, Read, C:\hex_list.txt

{
Gui, add, Progress,% "x010 yp+41 w40 h40 Background%A_LoopReadLine%   vControl" ++cnt
loop, 9	
Gui, add, Progress,% "x" a_index * 40 +10 " yp w40 h40 Background%A_LoopReadLine% vControl" ++cnt
}
Gui, Show
return


 
WM_LBUTTONDOWN() {
	If (A_GuiControl) {
         Msgbox % "You've clicked on " a_guicontrol
   }
}

*esc::
ExitApp

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 13:02
by scriptor2016
whoops!! sorry , I just saw your reply - let me check it out

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 13:10
by scriptor2016
this is amazing :)

when clicking on a square, how do I get the hex code associated with it. Is there a way to store the A_LoopReadLine information along with the Control, so in other words if we click on square 65, it would say

"you have clicked on Control65 and the HEX code is 0063F9" ...(just as an example)

or should I do it using pixelgetcolor?

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 13:24
by Odlanir
The array already contains all the colors code so you can access it in the function using the global declaration.

Code: Select all

WM_LBUTTONDOWN() {
   global arr
   If (A_GuiControl) {
      Msgbox % "You've clicked on " a_guicontrol " and the HEX code is " arr[substr(a_guicontrol,8)]
   }
}

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 13:34
by scriptor2016
hey - I can't thank you enough for this :) :)

I'm going to keep adapting to this and I'll post what I have a little later on - hopefully I can figure out something

Re: Click On Progress Bar?

Posted: 27 Jul 2019, 13:42
by scriptor2016
sorry, one last thing - how do I get the HEX code as a variable, something like:

Msgbox, the HEX code is %arr[substr(a_guicontrol,8)]%