Add another column

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jrachr
Posts: 518
Joined: 01 Mar 2021, 17:33

Add another column

Post by jrachr » 13 Sep 2021, 08:29

My name is Jr. A while back this script was posted showing 2 columns of buttons and the ability to show url's and/or programs depending on choice. My question is if I wanted to add a 3 column or even 4'th is there a way to do that. I am kind of a newbie at this but looking through the script I don't see anything that appears to be able to be changed to add a 3 column. Tk's

Code: Select all

;-- Example GUI with Buttons to Start URL/Program -----------
#warn
#NoEnv
name1=TEST
setworkingdir,%a_scriptdir%
Gui,2:default
Gui,2: -DPIScale
SS_REALSIZECONTROL := 0x40
transform,s,chr,127
WA:=A_screenwidth,HA:=A_screenheight,xx:=100
;Gui,2:Color,C8D0D4,Black                  ;-gray
Gui,2:Color,Black,Black
;- maybe change fontsize don't know which is the best font-size depending screen-size
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
 Gui,2:Font,s12 cBlack,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa=1920)
 Gui,2:Font,s10 cBlack,Lucida Console
else
 Gui,2:Font,s7 cBlack,Lucida Console
;=============================================================
;--------------------
cx:=""
ck:=""
sectx=   
(Ltrim comments Join`r`n % 
Autohotkey;https://www.autohotkey.com/
YT_Rotterdam2Amsterdam;https://www.youtube.com/watch?v=HfPCdJapIXA
YT_Offenbach_Barcarole;https://www.youtube.com/watch?v=R-MbbebSQjQ&t=91
NL_Rijkswaterstaat;https://www.youtube.com/channel/UCOESCgenMD6CMDiiHe-iG-g
NL_Archive_1;https://www.youtube.com/channel/UC3Xw6AMOJIiUJ0cNHB7CdIg
NL_Archive_2;https://basromeijnfilms.blogspot.com/
British_pathe;https://www.youtube.com/channel/UCGp4u0WHLsK8OAxnvwiTyhA
BBC_Archive;https://www.bbc.co.uk/archive/
LA_CAMERA_STYLO;https://www.youtube.com/channel/UCxT4JLBXafKV7dCafIceCUg/videos  ;- Film collection
News_Portugal;https://news.google.com/topstories?hl=pt-PT&gl=PT&ceid=PT:pt-150
Weather_Portugal;https://www.timeanddate.com/weather/portugal/lisbon
Hurrican;https://www.accuweather.com/en/hurricane/tracker
Typhoon;https://www.metoc.navy.mil/jtwc/jtwc.html
Wind_Asia;https://earth.nullschool.net/#current/wind/surface/level/orthographic=123.04,23.45,1821/loc=124.879,13.692
Euronews;https://de.euronews.com/bulletin
Charmap;charmap
Modern_Times_1936;https://www.youtube.com/watch?v=2gLa4wAia9g     ;- Full movie Charles Chaplin
)
;---------------------
loop,parse,sectx,`n,`r
  {
  x:=a_loopfield
  if x=
     break
  stringsplit,k,x,`;
  cx .= k1 . s
  ck .= k2 . s
  }
stringsplit,m,ck,%s%
stringsplit,q,cx,%s%
totx:=(q0-1)
x:=(wa*1)/xx,y:=(ha*2)/xx,w :=(wa*13 )/xx,h:=(ha*2.5)/xx,v:=(ha*.5)/xx
Gui,2:add,text,section x%x% y%y% w0 h0,  ;- button position
i=0
Loop,%totx%
  {
  i++
  if (i=10)
    {
    x:=(wa*15)/xx
    Gui,2:add,text,section x%x% y%y% w0 h0,     ;- new button position
    }
  BTName:= q%i%
  Gui,2: Add, Button, xs   y+%v% w%w%  h%h% gStart1 v%btname%_%i% ,%btname%
  }
x:=(wa*1)/xx,y:=(ha*1)/xx,w:=(wa*30)/xx,h:=(ha*30)/xx
Gui,2:Show, x%x% y%y% h%h% w%w%,%name1%
return
;-------------------------------------------------------------------------
2Guiclose:
exitapp
;-------------------------------------------------------------------------
;--------------- start --------------------------
start1:
gui,2:submit,nohide
Mousegetpos,,,,Ctrl       ;- Button1
r:= a_guicontrol          ;- vVar ( Buttonname )
stringtrimleft,ct,ctrl,6  ;- Button-(1)
url:= m%ct%
;msgbox, 262208, ,R=%r%`nCT=%ct%`nCTRL=%ctrl%`nURL=%url%
try
 run,%url%
return
;=================== END SCRIPT =============================================
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 13 Sep 2021, 08:55, edited 1 time in total.
Reason: Please use code tags. Thank you!
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Add another column

Post by mikeyww » 13 Sep 2021, 08:36

You would want to focus on the loop that is computing the x-value of the text's position. You can use any x and y values that are needed, to have as many columns as you like. Other methods of positioning GUI controls are explained in the documentation; you don't even need to specify the x values. A demo is below.

Code: Select all

Gui, Font, s10
Gui, Add, Button,    w100, 1
Gui, Add, Button,    wp  , 2
Gui, Add, Button, ym wp  , 3
Gui, Add, Button,    wp  , 4
Gui, Add, Button, ym wp  , 5
Gui, Add, Button,    wp  , 6
Gui, Show
Last edited by mikeyww on 13 Sep 2021, 08:37, edited 1 time in total.
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: Add another column

Post by Hellbent » 13 Sep 2021, 08:36

Hi @jrachr

Please put your code inside code tags.
20210913093418.png
20210913093418.png (15.83 KiB) Viewed 2033 times
ahk7
Posts: 572
Joined: 06 Nov 2013, 16:35

Re: Add another column

Post by ahk7 » 13 Sep 2021, 08:54

I don't know who made that code, but that is far too complicated for my taste, and also very unreadable. Indent the code and use some CAPS to make some things stand out, all lowercase makes it very hard to read.
Below a stripped down version (removed all color, dpi etc as well but you can put that back in) - here a simple associative array (SectX) which we simply parse and move to the next column defined by the "PerColumn" value. (this is far as I'll go btw)

Code: Select all

;-- Example GUI with Buttons to Start URL/Program -----------
#warn
#NoEnv
Gui,2:default

SectX:={ "Autohotkey": "https://www.autohotkey.com/"
	, "YT_Rotterdam2Amsterdam": "https://www.youtube.com/watch?v=HfPCdJapIXA"
	, "YT_Offenbach_Barcarole": "https://www.youtube.com/watch?v=R-MbbebSQjQ&t=91"
	, "NL_Rijkswaterstaat": "https://www.youtube.com/channel/UCOESCgenMD6CMDiiHe-iG-g"
	, "NL_Archive_1": "https://www.youtube.com/channel/UC3Xw6AMOJIiUJ0cNHB7CdIg"
	, "NL_Archive_2": "https://basromeijnfilms.blogspot.com/"
	, "British_pathe": "https://www.youtube.com/channel/UCGp4u0WHLsK8OAxnvwiTyhA"
	, "BBC_Archive": "https://www.bbc.co.uk/archive/"
	, "LA_CAMERA_STYLO": "https://www.youtube.com/channel/UCxT4JLBXafKV7dCafIceCUg/videos"
	, "News_Portugal": "https://news.google.com/topstories?hl=pt-PT&gl=PT&ceid=PT:pt-150"
	, "Weather_Portugal": "https://www.timeanddate.com/weather/portugal/lisbon"
	, "Hurrican": "https://www.accuweather.com/en/hurricane/tracker"
	, "Typhoon": "https://www.metoc.navy.mil/jtwc/jtwc.html"
	, "Wind_Asia": "https://earth.nullschool.net/#current/wind/surface/level/orthographic=123.04,23.45,1821/loc=124.879,13.692"
	, "Euronews": "https://de.euronews.com/bulletin"
	, "Charmap": "charmap"
	, "Modern_Times_1936": "https://www.youtube.com/watch?v=2gLa4wAia9g" }

;---------------------

PerColumn=5
x=10
y=10
ButtonWidth:=200
ButtonHeight:=20

for k, v in SectX
	{
	 Gui,2: Add, Button, x%x% y%y% w%ButtonWidth% h%ButtonHeight% gStart1, %k%
	 y+=25
	 if (Mod(A_Index, PerColumn) = 0)
		{
		 x+=210
		 y:=10
		}
	}
	
Gui,2:Show
Return

;-------------------------------------------------------------------------
ESC::
2Guiclose:
ExitApp

;--------------- start --------------------------
start1:
Try 
	Run % sectx[A_GuiControl]
Return
;=================== END SCRIPT =============================================
jrachr
Posts: 518
Joined: 01 Mar 2021, 17:33

Re: Add another column

Post by jrachr » 13 Sep 2021, 08:55

Thank you Mikey. I am still new at this. But learning. So in my script just to get me started where would I put this example to get a button in a 3'rd column? Tk's Sorry Hellbent. Will try to remember next time.
jrachr
Posts: 518
Joined: 01 Mar 2021, 17:33

Re: Add another column

Post by jrachr » 13 Sep 2021, 08:56

Tk's ahk7. Will try it out. Cheer's
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Add another column

Post by garry » 14 Sep 2021, 08:57

@ahk7 thank you for the easy code
here again the old script , example for the first 2-buttons : one button starts 2 URL's / or programs

Code: Select all

;-- Date-modified =20210914   
;-- Example GUI with Buttons to Start URL/Program -----------
#warn
#NoEnv
name1=TEST
setworkingdir,%a_scriptdir%
Gui,2:default
Gui,2: -DPIScale
transform,s,chr,127    ;- delimiter for stringsplit
WA:=A_screenwidth,HA:=A_screenheight,xx:=100
;Gui,2:Color,C8D0D4,Black                  ;-gray
Gui,2:Color,Black,Black
;- maybe change fontsize don't know which is the best font-size depending screen-size
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
 Gui,2:Font,s12 cBlack,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa=1920)
 Gui,2:Font,s10 cBlack,Lucida Console
else
 Gui,2:Font,s7 cBlack,Lucida Console
;=============================================================
;--------------------
col1:=""
col2:=""
col3:=""
;---------------------  NAME - URL1 - URL2 --------------------
sectx=   
(Ltrim comments Join`r`n % 
Charmap_CALC;charmap;calc
Hurrican_TAIFUN;https://www.accuweather.com/en/hurricane/tracker;https://www.metoc.navy.mil/jtwc/jtwc.html
Autohotkey;https://www.autohotkey.com/;
YT_Rotterdam2Amsterdam;https://www.youtube.com/watch?v=HfPCdJapIXA;
YT_Offenbach_Barcarole;https://www.youtube.com/watch?v=R-MbbebSQjQ&t=91;
NL_Rijkswaterstaat;https://www.youtube.com/channel/UCOESCgenMD6CMDiiHe-iG-g;
NL_Archive_1;https://www.youtube.com/channel/UC3Xw6AMOJIiUJ0cNHB7CdIg;
NL_Archive_2;https://basromeijnfilms.blogspot.com/;
British_pathe;https://www.youtube.com/channel/UCGp4u0WHLsK8OAxnvwiTyhA;
BBC_Archive;https://www.bbc.co.uk/archive/;
LA_CAMERA_STYLO;https://www.youtube.com/channel/UCxT4JLBXafKV7dCafIceCUg/videos;  ;- Film collection
News_Portugal;https://news.google.com/topstories?hl=pt-PT&gl=PT&ceid=PT:pt-150;
Weather_Portugal;https://www.timeanddate.com/weather/portugal/lisbon;
Wind_Asia;https://earth.nullschool.net/#current/wind/surface/level/orthographic=123.04,23.45,1821/loc=124.879,13.692;
Euronews;https://de.euronews.com/bulletin;
Modern_Times_1936;https://www.youtube.com/watch?v=2gLa4wAia9g;             ;- Full movie Charles Chaplin
)
;---------------------
loop,parse,sectx,`n,`r
  {
  x:=a_loopfield
  if x=
     break
  stringsplit,k,x,`;
  col1 .= k1 . s
  col2 .= k2 . s
  col3 .= k3 . s
  }
stringsplit,q,col1,%s%
stringsplit,m,col2,%s%
stringsplit,n,col3,%s%
;-----------------------
totx:=(q0-1)
x:=(wa*1)/xx,y:=(ha*1)/xx,w :=(wa*13 )/xx,h:=(ha*2.5)/xx,v:=(ha*3)/xx        ;- button x y w h v=distance vertical
i=0
vert:=4                    ;-- change here how many vertikal buttons want have
Loop,%totx%
  {
  i++
  BTName:= q%i%
  Gui,2: Add, Button, x%x%   y%y% w%w%  h%h% gStart1 v%btname%_%i% ,%btname%
  y+=%v%
  Md:=mod(i,vert)
  if md=0
     x+=(wa*14)/xx,y:=(ha*1)/xx   ;- if modulo = 0 them move to new x (right)  y (top)
  }
;---------
x:=(wa*1)/xx,y:=(ha*1)/xx,w:=(wa*96)/xx,h:=(ha*30)/xx                        ;- GUI x y w h
Gui,2:Show, x%x% y%y% h%h% w%w%,%name1%
return
;-------------------------------------------------------------------------
2Guiclose:
exitapp
;-------------------------------------------------------------------------
;--------------- start --------------------------
start1:
gui,2:submit,nohide
Mousegetpos,,,,Ctrl       ;- Button1
r:= a_guicontrol          ;- vVar ( Buttonname )
stringtrimleft,ct,ctrl,6  ;- Button-(1)
clm2:= m%ct%
clm3:= n%ct%
;msgbox, 262208, ,R=%r%`nCT=%ct%`nCTRL=%ctrl%`nURL1=%clm2%`nURL2=%clm3%
try
 run,%clm2%
try
 run,%clm3%
return
;=================== END SCRIPT =============================================
jrachr
Posts: 518
Joined: 01 Mar 2021, 17:33

Re: Add another column

Post by jrachr » 14 Sep 2021, 17:52

Just wanted to thank everyone for their help. Do have one last question if I may as I can not find any information in the documentation. Is it possible to change the color of the text in the button? If so how? And for ahk7 who has made my life much easier. Besides url's is it possible to add program's to the list as well. Tk's again
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Add another column

Post by garry » 15 Sep 2021, 03:18

same as above with color buttons ( background-color and text-color from button )

Code: Select all

;-- Date-modified =20210915   color buttons
;-- Date-modified =20210914   one button starts 2 URL's or programs 

;-- Example GUI with Buttons to Start URL/Program -----------
#warn
#NoEnv
name1=TEST
setworkingdir,%a_scriptdir%
Gui,2:default
Gui,2: -DPIScale
transform,s,chr,127    ;- delimiter for stringsplit
WA:=A_screenwidth,HA:=A_screenheight,xx:=100
;Gui,2:Color,C8D0D4,Black                  ;-gray
Gui,2:Color,Black,Black
;- maybe change fontsize don't know which is the best font-size depending screen-size
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
 Gui,2:Font,s12 cBlack bold,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa=1920)
 Gui,2:Font,s10 cBlack bold,Lucida Console
else
 Gui,2:Font,s7 cBlack bold,Lucida Console
;=============================================================
;--------------------
col1:=""
col2:=""
col3:=""
;---------------------  NAME - URL1 - URL2 --------------------
sectx=   
(Ltrim comments Join`r`n % 
Charmap_CALC;charmap;calc
Hurrican_TAIFUN;https://www.accuweather.com/en/hurricane/tracker;https://www.metoc.navy.mil/jtwc/jtwc.html
Autohotkey;https://www.autohotkey.com/;
YT_Rotterdam2Amsterdam;https://www.youtube.com/watch?v=HfPCdJapIXA;
YT_Offenbach_Barcarole;https://www.youtube.com/watch?v=R-MbbebSQjQ&t=91;
NL_Rijkswaterstaat;https://www.youtube.com/channel/UCOESCgenMD6CMDiiHe-iG-g;
NL_Archive_1;https://www.youtube.com/channel/UC3Xw6AMOJIiUJ0cNHB7CdIg;
NL_Archive_2;https://basromeijnfilms.blogspot.com/;
British_pathe;https://www.youtube.com/channel/UCGp4u0WHLsK8OAxnvwiTyhA;
BBC_Archive;https://www.bbc.co.uk/archive/;
LA_CAMERA_STYLO;https://www.youtube.com/channel/UCxT4JLBXafKV7dCafIceCUg/videos;  ;- Film collection
News_Portugal;https://news.google.com/topstories?hl=pt-PT&gl=PT&ceid=PT:pt-150;
Weather_Portugal;https://www.timeanddate.com/weather/portugal/lisbon;
Wind_Asia;https://earth.nullschool.net/#current/wind/surface/level/orthographic=123.04,23.45,1821/loc=124.879,13.692;
Euronews;https://de.euronews.com/bulletin;
Modern_Times_1936;https://www.youtube.com/watch?v=2gLa4wAia9g;             ;- Full movie Charles Chaplin
)
;---------------------
loop,parse,sectx,`n,`r
  {
  x:=a_loopfield
  if x=
     break
  stringsplit,k,x,`;
  col1 .= k1 . s
  col2 .= k2 . s
  col3 .= k3 . s
  }
stringsplit,q,col1,%s%
stringsplit,m,col2,%s%
stringsplit,n,col3,%s%
;-----------------------
totx:=(q0-1)
x:=(wa*1)/xx,y:=(ha*1)/xx,w :=(wa*13 )/xx,h:=(ha*2.5)/xx,v:=(ha*3)/xx        ;- button x y w h v=distance vertical
i=0
vert:=4                    ;-- change here how many vertikal buttons want have
Loop,%totx%
  {
  i++
  BTName:= q%i%

   ;- color background and text
  ;color=C8D0D4
  color=teal
  ;text=Black
  text=yellow
  Gui,2:Add,Progress,            x%x%   y%y% w%w%  h%h%  Disabled Background%color%
  Gui,2:Add,Text,                xp    yp     wp    hp   c%text%  BackgroundTrans Center 0x200 gStart1 v%btname%_%i% ,%btname%


  ;- normal button :
  ;Gui,2: Add, Button, x%x%   y%y% w%w%  h%h% gStart1 v%btname%_%i% ,%btname%
  y+=%v%
  Md:=mod(i,vert)
  if md=0
     x+=(wa*14)/xx,y:=(ha*1)/xx   ;- if modulo = 0 them move to new x (right)  y (top)
  }
;---------
x:=(wa*1)/xx,y:=(ha*1)/xx,w:=(wa*96)/xx,h:=(ha*30)/xx                        ;- GUI x y w h
Gui,2:Show, x%x% y%y% h%h% w%w%,%name1%
return
;-------------------------------------------------------------------------
2Guiclose:
exitapp
;-------------------------------------------------------------------------
;--------------- start --------------------------
start1:
gui,2:submit,nohide
Mousegetpos,,,,Ctrl       ;- Button1
r:= a_guicontrol          ;- vVar ( Buttonname )
stringtrimleft,ct,ctrl,6  ;- Button-(1)
clm2:= m%ct%
clm3:= n%ct%
;msgbox, 262208, ,R=%r%`nCT=%ct%`nCTRL=%ctrl%`nURL1=%clm2%`nURL2=%clm3%
try
 run,%clm2%
try
 run,%clm3%
return
;=================== END SCRIPT =============================================
jrachr
Posts: 518
Joined: 01 Mar 2021, 17:33

Re: Add another column

Post by jrachr » 15 Sep 2021, 03:54

Understood. Thank you.
jrachr
Posts: 518
Joined: 01 Mar 2021, 17:33

Re: Add another column

Post by jrachr » 17 Sep 2021, 07:26

@garry. Just wanted to thank you again for all your help. Lol. Took a little bit to find the width and height adjustment for the gui window but I got it. However after mass searching I have one last question. Is it possible to put a space between the buttons. Ie have say 5 buttons then a blank and then another say 6 buttons. Almost like sections of blocks. News,Sports ,etc. Just to make it easier to read. If not no big deal,I will continue to use lines. Tk's. Cheer's
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Add another column

Post by garry » 17 Sep 2021, 08:42

EDIT : added +Resize ( thank you Hellbent )
modified to add TITLE or SPACE between buttons

example for GUI position and size x y w h , example for height > h:=(ha*50)/xx , means height is 50% from screen
I have just a problem with fontsize / dpi , maybe change s12 to s14 etc ... and then also button size and position if needed

Code: Select all

x:=(wa*.1)/xx,y:=(ha*.1)/xx,w:=(wa*99)/xx,h:=(ha*90)/xx   ;- GUI x y w h
Gui,2:Show, x%x% y%y% h%h% w%w%,%name1%
modified script ( add SPACE or TITLE between BUTTONs )

Code: Select all

;-- Date-modified =20210917/3   add TITLE or SPACE between buttons / made GUI smaller and added +Resize 
;-- Date-modified =20210915     color buttons
;-- Date-modified =20210914     one button starts 2 URL's or programs 
;--
;-- Example GUI with Buttons to Start URL/Program -----------
#warn
#NoEnv
name1=TEST
setworkingdir,%a_scriptdir%
Gui,2:default
Gui,2: -DPIScale +Resize
transform,s,chr,127    ;- delimiter for stringsplit
WA:=A_screenwidth,HA:=A_screenheight,xx:=100
;Gui,2:Color,C8D0D4,Black                  ;-gray
Gui,2:Color,Black,Black
;- maybe change fontsize don't know which is the best font-size depending screen-size
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
 Gui,2:Font,s12 cYellow,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa=1920)
 Gui,2:Font,s10 cYellow,Lucida Console
else
 Gui,2:Font,s7 cYellow bold,Lucida Console
;=============================================================
;--------------------
col1:=""
col2:=""
col3:=""
;---------------------  NAME - URL1 - URL2 --------------------
sectx=   
(Ltrim comments Join`r`n % 
$;PPROGRAMS:;
Charmap_CALC;charmap;calc
$;Youtube:;
YT_Rotterdam2Amsterdam;https://www.youtube.com/watch?v=HfPCdJapIXA;
YT_Offenbach_Barcarole;https://www.youtube.com/watch?v=R-MbbebSQjQ&t=91;
NL_Rijkswaterstaat;https://www.youtube.com/channel/UCOESCgenMD6CMDiiHe-iG-g;
NL_Archive_1;https://www.youtube.com/channel/UC3Xw6AMOJIiUJ0cNHB7CdIg;
British_pathe;https://www.youtube.com/channel/UCGp4u0WHLsK8OAxnvwiTyhA;
LA_CAMERA_STYLO;https://www.youtube.com/channel/UCxT4JLBXafKV7dCafIceCUg/videos;  ;- Film collection
Modern_Times_1936;https://www.youtube.com/watch?v=2gLa4wAia9g;                    ;- Full movie Charles Chaplin
$;URL divers:;
Autohotkey;https://www.autohotkey.com/;
NL_Archive_2;https://basromeijnfilms.blogspot.com/;
BBC_Archive;https://www.bbc.co.uk/archive/;
S;;                                                                               ;- S = add SPACE  ( instead of button )
S;;
$;NEWS:;                                                                          ;- $ = add TITLE  ( instead of button )
Euronews;https://de.euronews.com/bulletin;
News_Portugal;https://news.google.com/topstories?hl=pt-PT&gl=PT&ceid=PT:pt-150;
S;;
$;WEATHER:;
Hurrican_TAIFUN;https://www.accuweather.com/en/hurricane/tracker;https://www.metoc.navy.mil/jtwc/jtwc.html
Weather_Portugal;https://www.timeanddate.com/weather/portugal/lisbon;
Wind_Asia;https://earth.nullschool.net/#current/wind/surface/level/orthographic=123.04,23.45,1821/loc=124.879,13.692;
)
;---------------------
loop,parse,sectx,`n,`r
  {
  x:=a_loopfield
  if x=
     break
  stringsplit,k,x,`;
  col1 .= k1 . s
  col2 .= k2 . s
  col3 .= k3 . s
  }
stringsplit,q,col1,%s%
stringsplit,m,col2,%s%
stringsplit,n,col3,%s%
;-----------------------
totx:=(q0-1)
x:=(wa*1)/xx,y:=(ha*1)/xx,w :=(wa*13 )/xx,h:=(ha*2.5)/xx,v:=(ha*3)/xx        ;- button x y w h v=distance vertical
i=0
vert:=10                    ;-- change here how many vertikal buttons want have ( inclusive SPACE or TITLE )
;-------
Loop,%totx%
  {
  i++
  BTName := q%i%
  column2:= m%i%
  if (btname="$")
    Gui,2:Add,Text,            x%x%   y%y% w%w%  h%h% center,%column2% 
  else if (btname="S")
    Gui,2:Add,Text,            x%x%   y%y% w%w%  h%h% center, 
  else
    {
    ;---------------------------
    ;- button color background and text
    ;---
    ;color=C8D0D4
    color=teal
    ;text=Black
    text=yellow
    ;---
    Gui,2:Add,Progress,            x%x%   y%y% w%w%  h%h%  Disabled Background%color%
    Gui,2:Add,Text,                xp    yp     wp    hp   c%text%  BackgroundTrans Center 0x200 gStart1 v%btname%_%i% ,%btname%
    ;---
    ;- normal button :
    ;Gui,2: Add, Button, x%x%   y%y% w%w%  h%h% gStart1 v%btname%_%i% ,%btname%
  ;---------------------------
  }
  y+=%v%
  Md:=mod(i,vert)
  if md=0
     x+=(wa*14)/xx,y:=(ha*1)/xx   ;- if modulo = 0 them move to new x (right)  y (top)
  }
;---------
x:=(wa*.1)/xx,y:=(ha*.1)/xx,w:=(wa*43)/xx,h:=(ha*35)/xx   ;- GUI x y w h
Gui,2:Show, x%x% y%y% h%h% w%w%,%name1%
return
;-------------------------------------------------------------------------
2Guiclose:
exitapp
;-------------------------------------------------------------------------
;--------------- start --------------------------
start1:
gui,2:submit,nohide
Mousegetpos,,,,Ctrl       ;- Button1
r:= a_guicontrol          ;- vVar ( Buttonname )
stringtrimleft,ct,ctrl,6  ;- Button-(1)
clm2:= m%ct%
clm3:= n%ct%
;msgbox, 262208, ,R=%r%`nCT=%ct%`nCTRL=%ctrl%`nURL1=%clm2%`nURL2=%clm3%
try
 run,%clm2%
try
 run,%clm3%
return
;=================== END SCRIPT =============================================
Last edited by garry on 17 Sep 2021, 13:57, edited 2 times in total.
jrachr
Posts: 518
Joined: 01 Mar 2021, 17:33

Re: Add another column

Post by jrachr » 17 Sep 2021, 09:01

@garry. Thank's again garry. I will play with this. Last question for sure(maybe). I understand the Title parts. IE news ,weather,etc. But if I wanted to say leave weather teal with yellow text and create a space between news_portugal and weather is that possible?
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Add another column

Post by garry » 17 Sep 2021, 12:49

I modified last script above
not sure , can add SPACE or TITLE between buttons
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: Add another column

Post by Hellbent » 17 Sep 2021, 13:14

@garry Nice. :thumbup:

There is one small issue. Your guis size exceeds the size of the min monitor size you are likely to encounter. In this case there is a easy solution that shouldn't cause any issues with how your script functions. Simply add +Resize to the gui options and it can fill the screen.

The only issue you would run into is when your controls go outside the usable space. In that case other methods would be required.

One method would be to put all your controls on one gui and have it sit inside another gui as a child. Then it is a matter of coding in scroll bars to move around the inner window so every area of the gui can be seen on any monitor.

Not the easiest thing to do but it is the price of making guis that are bigger than the screen real estate available. (this all assumes that the gui isn't just for your own use)
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Add another column

Post by garry » 17 Sep 2021, 13:48

@Hellbent thank you for suggestions and help . I'm not good in programming .
I use a cheap computer with 4K
I calculated x y w h with procent depending screensize , should work for 4K , FullHD , etc ...
Have only problem with fontsize / dpi ( windows screen setting possible 100%--350% ) , I used 175%
Here example for GUI-size ( example above was nearly 100% ) , I change here width and height to make it smaller depending how many buttons want be created in script ( this can also been calculated )
( only changed width and height in procent > 43,35 )

Code: Select all

x:=(wa*.1)/xx,y:=(ha*.1)/xx,w:=(wa*43)/xx,h:=(ha*35)/xx   ;- GUI x y w h
Gui,2:Show, x%x% y%y% h%h% w%w%,%name1%
jrachr
Posts: 518
Joined: 01 Mar 2021, 17:33

Re: Add another column

Post by jrachr » 17 Sep 2021, 13:53

@garry. Perfect. Thank you very much. Now just some fine tuning and all will be good.

Code: Select all

;-- Date-modified =20210917/2   add TITLE or SPACE between buttons
;-- Date-modified =20210915     color buttons
;-- Date-modified =20210914     one button starts 2 URL's or programs 
;--
;-- Example GUI with Buttons to Start URL/Program -----------
#warn
#NoEnv
name1=TEST
setworkingdir,%a_scriptdir%
Gui,2:default
Gui,2: -DPIScale
transform,s,chr,127    ;- delimiter for stringsplit
WA:=A_screenwidth,HA:=A_screenheight,xx:=100
;Gui,2:Color,C8D0D4,Black                  ;-gray
Gui,2:Color,Black,Black
;- maybe change fontsize don't know which is the best font-size depending screen-size
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
 Gui,2:Font,s12 cYellow,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa=1920)
 Gui,2:Font,s10 cYellow,Lucida Console
else
 Gui,2:Font,s7 cYellow bold,Lucida Console
;=============================================================
;--------------------
col1:=""
col2:=""
col3:=""
;---------------------  NAME - URL1 - URL2 --------------------
sectx=   
(Ltrim comments Join`r`n % 
Halifax_Retales
Halifax_Retales_Facebook;https://www.facebook.com/HalifaxReTales
Halifax_Retales_Chat;https://www.facebook.com/groups/HalifaxReTalesChat/?fref=mentions
Halifax_Retales_Twitter;https://twitter.com/HalifaxReTales
S;;
Weather
Weather_Network;https://www.theweathernetwork.com/ca/weather/nova-scotia/halifax
National_Hurricane_Center;https://www.nhc.noaa.gov/?atl
Canada_Hurricane_Center;https://weather.gc.ca/hurricane/track_e.html
S;;
Utilities
Bell_Aliant;https://mybell.bell.ca/Login?TYPE=33554433&REALMOID=06-000db269-81bc-1874-88d4-791a8e75d0dd&GUID=&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=-SM-QKP7nnHXh2qXJfMWInHziJlTBdI9C7eOEOJRmIO63Oa%2fimktrTgbipB8hCBdh8Ey&TARGET=-SM-HTTPS%3a%2f%2fmybell%2ebell%2eca%2fMobility%3fAcctNo%3d8D711C5DA4B3704F0A5FE8ED0DB141225B124765045364C13F3345E0CA9697EBA72FAFBE86087BF101511830FD449071%26SubNo%3d13180274
NS_Power;https://myaccount.nspower.ca/
News
Chronicle_Herald;https://www.thechronicleherald.ca/
Global_News;https://globalnews.ca/halifax/
Halifax_Today;https://www.halifaxtoday.ca/
NY_Post;https://nypost.com/
Las_Vegas_Sun;https://lasvegassun.com/
CNN_News;https://www.cnn.com/
S;;
TV_Guide;https://www.tvtv.ca/ns/halifax/lu4663D
TD_Bank;https://authentication.td.com/uap-ui/index.html?consumer=easyweb&locale=en_CA#/login/easyweb-getting-started
S;;
Amazon_Canada;https://www.amazon.ca/
Amazon_Canada_Phone;https://gethuman.com/phone-number/Amazon-Canada
Sports
Sportsnet;https://www.sportsnet.ca/
ESPN;https://www.espn.com/
Halifax_Airport;https://halifaxstanfield.ca/
S;;
Halifax_Airport_Twitter;https://twitter.com/HfxStanfield
)
;---------------------
loop,parse,sectx,`n,`r
  {
  x:=a_loopfield
  if x=
     break
  stringsplit,k,x,`;
  col1 .= k1 . s
  col2 .= k2 . s
  col3 .= k3 . s
  }
stringsplit,q,col1,%s%
stringsplit,m,col2,%s%
stringsplit,n,col3,%s%
;-----------------------
totx:=(q0-1)
x:=(wa*1)/xx,y:=(ha*1)/xx,w :=(wa*13 )/xx,h:=(ha*2.5)/xx,v:=(ha*3)/xx        ;- button x y w h v=distance vertical
i=0
vert:=13                    ;-- change here how many vertikal buttons want have ( inclusive SPACE or TITLE )
;-------
Loop,%totx%
  {
  i++
  BTName := q%i%
  column2:= m%i%
  if (btname="$")
    Gui,2:Add,Text,            x%x%   y%y% w%w%  h%h% center,%column2% 
  else if (btname="S")
    Gui,2:Add,Text,            x%x%   y%y% w%w%  h%h% center, 
  else
    {
    ;---------------------------
    ;- button color background and text
    ;---
    ;color=C8D0D4
    color=teal
    ;text=Black
    text=yellow
    ;---
    Gui,2:Add,Progress,            x%x%   y%y% w%w%  h%h%  Disabled Background%color%
    Gui,2:Add,Text,                xp    yp     wp    hp   c%text%  BackgroundTrans Center 0x200 gStart1 v%btname%_%i% ,%btname%
    ;---
    ;- normal button :
    ;Gui,2: Add, Button, x%x%   y%y% w%w%  h%h% gStart1 v%btname%_%i% ,%btname%
  ;---------------------------
  }
  y+=%v%
  Md:=mod(i,vert)
  if md=0
     x+=(wa*14)/xx,y:=(ha*1)/xx   ;- if modulo = 0 them move to new x (right)  y (top)
  }
;---------
x:=(wa*.25)/xx,y:=(ha*.30)/xx,w:=(wa*43)/xx,h:=(ha*40)/xx   ;- GUI x y w h
Gui,2:Show, x%x% y%y% h%h% w%w%,%name1%
return
;-------------------------------------------------------------------------
2Guiclose:
exitapp
;-------------------------------------------------------------------------
;--------------- start --------------------------
start1:
gui,2:submit,nohide
Mousegetpos,,,,Ctrl       ;- Button1
r:= a_guicontrol          ;- vVar ( Buttonname )
stringtrimleft,ct,ctrl,6  ;- Button-(1)
clm2:= m%ct%
clm3:= n%ct%
;msgbox, 262208, ,R=%r%`nCT=%ct%`nCTRL=%ctrl%`nURL1=%clm2%`nURL2=%clm3%
try
 run,%clm2%
try
 run,%clm3%
return
;=================== END SCRIPT =============================================
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Add another column

Post by garry » 17 Sep 2021, 14:12

@jrachr I get a small error (k2,k3) ( possible remove #Warn )
we have 3 columns and the csv-file need 2 delimiters ( ; )
I've modified
... and added +Resize , see suggestion from user Hellbent
and maybe the button-TITLE can have another color (?)

Code: Select all

;---------------------  NAME - URL1 - URL2 --------------------
sectx=   
(Ltrim comments Join`r`n % 
Halifax_Retales;;
Halifax_Retales_Facebook;https://www.facebook.com/HalifaxReTales;
Halifax_Retales_Chat;https://www.facebook.com/groups/HalifaxReTalesChat/?fref=mentions;
Halifax_Retales_Twitter;https://twitter.com/HalifaxReTales;
S;;
Weather;;
Weather_Network;https://www.theweathernetwork.com/ca/weather/nova-scotia/halifax;
National_Hurricane_Center;https://www.nhc.noaa.gov/?atl;
Canada_Hurricane_Center;https://weather.gc.ca/hurricane/track_e.html;
S;;
Utilities;;
Bell_Aliant;https://mybell.bell.ca/Login?TYPE=33554433&REALMOID=06-000db269-81bc-1874-88d4-791a8e75d0dd&GUID=&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=-SM-QKP7nnHXh2qXJfMWInHziJlTBdI9C7eOEOJRmIO63Oa%2fimktrTgbipB8hCBdh8Ey&TARGET=-SM-HTTPS%3a%2f%2fmybell%2ebell%2eca%2fMobility%3fAcctNo%3d8D711C5DA4B3704F0A5FE8ED0DB141225B124765045364C13F3345E0CA9697EBA72FAFBE86087BF101511830FD449071%26SubNo%3d13180274;
NS_Power;https://myaccount.nspower.ca/;
News;;
Chronicle_Herald;https://www.thechronicleherald.ca/;
Global_News;https://globalnews.ca/halifax/;
Halifax_Today;https://www.halifaxtoday.ca/;
NY_Post;https://nypost.com/;
Las_Vegas_Sun;https://lasvegassun.com/;
CNN_News;https://www.cnn.com/;
S;;
TV_Guide;https://www.tvtv.ca/ns/halifax/lu4663D;
TD_Bank;https://authentication.td.com/uap-ui/index.html?consumer=easyweb&locale=en_CA#/login/easyweb-getting-started;
S;;
Amazon_Canada;https://www.amazon.ca/;
Amazon_Canada_Phone;https://gethuman.com/phone-number/Amazon-Canada;
Sports;;
Sportsnet;https://www.sportsnet.ca/;
ESPN;https://www.espn.com/;
Halifax_Airport;https://halifaxstanfield.ca/;
S;;
Halifax_Airport_Twitter;https://twitter.com/HfxStanfield;
)
;---------------------
jrachr
Posts: 518
Joined: 01 Mar 2021, 17:33

Re: Add another column

Post by jrachr » 17 Sep 2021, 14:24

@garry. Yes I saw the warnings and was thinking about removing the #warn. And yes would definitely be interested in being able to have a different color for the title's. That would be ideal if it's not to hard.
garry
Posts: 3720
Joined: 22 Dec 2013, 12:50

Re: Add another column

Post by garry » 17 Sep 2021, 14:26

... button-TITLE has another color

Code: Select all

;-- Date-modified =20210917/3   csv Halifax / TITLE-button has another color / +Resize 
;-- Date-modified =20210917/2   add TITLE or SPACE between buttons
;-- Date-modified =20210915     color buttons
;-- Date-modified =20210914     one button starts 2 URL's or programs 
;--
;-- Example GUI with Buttons to Start URL/Program -----------
#warn
#NoEnv
name1=TEST
setworkingdir,%a_scriptdir%
Gui,2:default
Gui,2: -DPIScale +Resize
transform,s,chr,127    ;- delimiter for stringsplit
WA:=A_screenwidth,HA:=A_screenheight,xx:=100
;Gui,2:Color,C8D0D4,Black                  ;-gray
Gui,2:Color,Black,Black
;- maybe change fontsize don't know which is the best font-size depending screen-size
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
 Gui,2:Font,s12 cYellow,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa=1920)
 Gui,2:Font,s10 cYellow,Lucida Console
else
 Gui,2:Font,s7 cYellow bold,Lucida Console
;=============================================================
;--------------------
col1:=""
col2:=""
col3:=""
;---------------------  NAME - URL1 - URL2 --------------------
sectx=   
(Ltrim comments Join`r`n % 
Halifax_Retales;;
Halifax_Retales_Facebook;https://www.facebook.com/HalifaxReTales;
Halifax_Retales_Chat;https://www.facebook.com/groups/HalifaxReTalesChat/?fref=mentions;
Halifax_Retales_Twitter;https://twitter.com/HalifaxReTales;
S;;
Weather;;
Weather_Network;https://www.theweathernetwork.com/ca/weather/nova-scotia/halifax;
National_Hurricane_Center;https://www.nhc.noaa.gov/?atl;
Canada_Hurricane_Center;https://weather.gc.ca/hurricane/track_e.html;
S;;
Utilities;;
Bell_Aliant;https://mybell.bell.ca/Login?TYPE=33554433&REALMOID=06-000db269-81bc-1874-88d4-791a8e75d0dd&GUID=&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=-SM-QKP7nnHXh2qXJfMWInHziJlTBdI9C7eOEOJRmIO63Oa%2fimktrTgbipB8hCBdh8Ey&TARGET=-SM-HTTPS%3a%2f%2fmybell%2ebell%2eca%2fMobility%3fAcctNo%3d8D711C5DA4B3704F0A5FE8ED0DB141225B124765045364C13F3345E0CA9697EBA72FAFBE86087BF101511830FD449071%26SubNo%3d13180274;
NS_Power;https://myaccount.nspower.ca/;
News;;
Chronicle_Herald;https://www.thechronicleherald.ca/;
Global_News;https://globalnews.ca/halifax/;
Halifax_Today;https://www.halifaxtoday.ca/;
NY_Post;https://nypost.com/;
Las_Vegas_Sun;https://lasvegassun.com/;
CNN_News;https://www.cnn.com/;
S;;
TV_Guide;https://www.tvtv.ca/ns/halifax/lu4663D;
TD_Bank;https://authentication.td.com/uap-ui/index.html?consumer=easyweb&locale=en_CA#/login/easyweb-getting-started;
S;;
Amazon_Canada;https://www.amazon.ca/;
Amazon_Canada_Phone;https://gethuman.com/phone-number/Amazon-Canada;
Sports;;
Sportsnet;https://www.sportsnet.ca/;
ESPN;https://www.espn.com/;
Halifax_Airport;https://halifaxstanfield.ca/;
S;;
Halifax_Airport_Twitter;https://twitter.com/HfxStanfield;
)
;---------------------
loop,parse,sectx,`n,`r
  {
  x:=a_loopfield
  if x=
     break
  stringsplit,k,x,`;
  col1 .= k1 . s
  col2 .= k2 . s
  col3 .= k3 . s
  }
stringsplit,q,col1,%s%
stringsplit,m,col2,%s%
stringsplit,n,col3,%s%
;-----------------------
totx:=(q0-1)
x:=(wa*1)/xx,y:=(ha*1)/xx,w :=(wa*13 )/xx,h:=(ha*2.5)/xx,v:=(ha*3)/xx        ;- button x y w h v=distance vertical
i=0
vert:=13                    ;-- change here how many vertikal buttons want have ( inclusive SPACE or TITLE )
;-------
Loop,%totx%
  {
  i++
  BTName := q%i%
  column2:= m%i%
  if (btname="S")
    Gui,2:Add,Text,            x%x%   y%y% w%w%  h%h% center, 
  else if column2=
    {
    Gui,2:Add,Progress,            x%x%   y%y% w%w%  h%h%  Disabled BackgroundRed
    Gui,2:Add,Text,                xp    yp     wp    hp   cWhite  BackgroundTrans Center 0x200 gStart1 v%btname%_%i% ,%btname%
    }
  else if (btname="S")
    Gui,2:Add,Text,            x%x%   y%y% w%w%  h%h% center, 
  else
    {
    ;---------------------------
    ;- button color background and text
    ;---
    ;color=C8D0D4
    color=teal
    ;text=Black
    text=yellow
    ;---
    Gui,2:Add,Progress,            x%x%   y%y% w%w%  h%h%  Disabled Background%color%
    Gui,2:Add,Text,                xp    yp     wp    hp   c%text%  BackgroundTrans Center 0x200 gStart1 v%btname%_%i% ,%btname%
    ;---
    ;- normal button :
    ;Gui,2: Add, Button, x%x%   y%y% w%w%  h%h% gStart1 v%btname%_%i% ,%btname%
  ;---------------------------
  }
  y+=%v%
  Md:=mod(i,vert)
  if md=0
     x+=(wa*14)/xx,y:=(ha*1)/xx   ;- if modulo = 0 them move to new x (right)  y (top)
  }
;---------
x:=(wa*.25)/xx,y:=(ha*.30)/xx,w:=(wa*43)/xx,h:=(ha*40)/xx   ;- GUI x y w h
Gui,2:Show, x%x% y%y% h%h% w%w%,%name1%
return
;-------------------------------------------------------------------------
2Guiclose:
exitapp
;-------------------------------------------------------------------------
;--------------- start --------------------------
start1:
gui,2:submit,nohide
Mousegetpos,,,,Ctrl       ;- Button1
r:= a_guicontrol          ;- vVar ( Buttonname )
stringtrimleft,ct,ctrl,6  ;- Button-(1)
clm2:= m%ct%
clm3:= n%ct%
;msgbox, 262208, ,R=%r%`nCT=%ct%`nCTRL=%ctrl%`nURL1=%clm2%`nURL2=%clm3%
try
 run,%clm2%
try
 run,%clm3%
return
;=================== END SCRIPT =============================================
Post Reply

Return to “Ask for Help (v1)”