Click On Progress Bar?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Click On Progress Bar?

27 Jul 2019, 02:45

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
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Click On Progress Bar?

27 Jul 2019, 03:11

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
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Click On Progress Bar?

27 Jul 2019, 03:41

ah-ha

thanks Odlanir :)
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Click On Progress Bar?

27 Jul 2019, 07:15

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
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Click On Progress Bar?

27 Jul 2019, 11:30

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 ...
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Click On Progress Bar?

27 Jul 2019, 12:25

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
Last edited by Odlanir on 27 Jul 2019, 13:00, edited 1 time in total.
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Click On Progress Bar?

27 Jul 2019, 12:49

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.
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Click On Progress Bar?

27 Jul 2019, 12:55

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
   }
}
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Click On Progress Bar?

27 Jul 2019, 13:02

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
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Click On Progress Bar?

27 Jul 2019, 13:02

whoops!! sorry , I just saw your reply - let me check it out
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Click On Progress Bar?

27 Jul 2019, 13:10

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?
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Click On Progress Bar?

27 Jul 2019, 13:24

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)]
   }
}
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Click On Progress Bar?

27 Jul 2019, 13:34

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
scriptor2016
Posts: 844
Joined: 21 Dec 2015, 02:34

Re: Click On Progress Bar?

27 Jul 2019, 13:42

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)]%

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: marypoppins_1 and 132 guests