Lable buttons via Ini File

Get help with using AutoHotkey and its commands and hotkeys
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Lable buttons via Ini File

25 Jun 2019, 18:39

hi guys im trying to lable buttons via an ini file, struggling, I have the basic code to write the ini files for the name and the value of it but done quite know how to finish it off, if anyone can help would be much appreciated here is what I have so far:

Code: Select all

Gui, 6:Show , w1540 h805, Programming

Gui, 6:add, Button, x1460 y10 w70 h70 Home

Gui, 6:add, button, gSet1 x10 y30 w70 h70, 1
Gui, 6:add, button, x10 y100 w70 h70, 2
Gui, 6:add, button, x10 y170 w70 h70, 3
Gui, 6:add, button, x10 y240 w70 h70, 4
Gui, 6:add, button, x10 y310 w70 h70, 5
Gui, 6:add, button, x10 y380 w70 h70, 6
Gui, 6:add, button, x10 y450 w70 h70, 7
Gui, 6:add, button, x10 y520 w70 h70, 8
Gui, 6:add, button, x10 y590 w70 h70, 9
Gui, 6:add, button, x10 y660 w70 h70, 10

Set1:
gui, 7:show, w500 h150, Please Name Button.
gui, 7:add, Edit, vNewName 
gui, 7:add, button, gProgOk1, Ok
return

ProgOk1:
Gui, Submit, NoHide
Iniwrite, %NewName%, Menu.ini, Menu:, 1
Gui, 7:Destroy
gui, 8:show, w500 h150, Please set Price.
gui, 8:add, Edit, vNewPrice 
gui, 8:add, button, gProgOk2, Ok
return

ProgOk2:
Gui, Submit, NoHide
Iniwrite, %NewPrice%, Menu.ini, Price:, 1
Gui, 8:Destroy
return
Basically it writes the ini for a name and a price, what I want it to do is, rename the button from "1" to "Chips" for example then it will ask to set the price, so for example I set it to 2.00

so when I press the button (on my main script) it come up with:

Chips 2.00
(then new line)

Any ideas? Thanks in advance been racking my brains all day
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

26 Jun 2019, 08:29

I mean if its even possible?
just me
Posts: 6425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

26 Jun 2019, 08:48

Something like this?

Code: Select all

#NoEnv
IniFile := "Menu.ini"
BtnCount := 10
; ------------------------------------------------------------------------------
Gui, MenuBtns:New, , Programming
Gui, Add, Button, x1460 y10 w70 h70, Home
Y := 30
Loop, %BtnCount% {
   IniRead, Menu, %IniFile%, Menu:, %A_Index%, %A_Index%
   IniRead, Price, %IniFile%, Price:, %A_Index%, %A_Space%
   Gui, Add, Button, x10 y%Y% w140 h70 vBtn%A_Index% gSet, %Menu%`n%Price%
   Y += 70
}
; ------------------------------------------------------------------------------
Gui, SetBtns:New, , New Values
Gui, Add, Text, h20 0x0200 Section, Enter new name:
Gui, Add, Text, xs hp 0x0200, Enter new price:
Gui, Add, Edit, ys w100 h20 vNewName
Gui, Add, Edit, xp y+m w100 h20 vNewPrice
GuiControlGet, P, Pos, NewPrice
Gui, Add, Button, xm w80 gWriteIni, Apply
X := PX + PW - 80
Gui, Add, Button, x%X% yp wp gSetBtnsGuiClose, Cancel
; ------------------------------------------------------------------------------
Gui, MenuBtns:Show, w1540 h805
Return
; ------------------------------------------------------------------------------
MenuBtnsGuiClose:
ExitApp
; ------------------------------------------------------------------------------
WriteIni:
   Gui, Submit, NoHide
   ; MsgBox, 0, New Values, Name:`t%NewName%`n`nPrice:`t%NewPrice
   GuiControl, MenuBtns:, Btn%BtnNumber%, %NewName%`n%NewPrice%
   Iniwrite, %NewName%, %IniFile%, Menu:, %BtnNumber%
   Iniwrite, %NewPrice%, %IniFile%, Price:, %BtnNumber%
; ------------------------------------------------------------------------------
SetBtnsGuiClose:
   Gui, MenuBtns:-Disabled
   Gui, Hide
Return
; ------------------------------------------------------------------------------
Set:
BtnNumber := SubStr(A_GuiControl, 4)
GuiControlGet, BtnCaption, , %A_GuiControl%
Split := StrSplit(BtnCaption, "`n", " ")
GuiControl, SetBtns:, NewName, % Split[1]
GuiControl, SetBtns:, NewPrice, % Split[2]
Gui, +Disabled
Gui, SetBtns:Show
Return
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

26 Jun 2019, 09:09

yes amazing! Thank you!!
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

26 Jun 2019, 14:11

How would I change it to add more buttons? So the next 10 go to the side as they just go underneath but it’s off the screen
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

26 Jun 2019, 18:32

layout.jpg
layout.jpg (86.85 KiB) Viewed 835 times
so the buttons look like this

This is my original script, so at the moment the buttons are just dead buttons,

Code: Select all

Gui, 6:Show , w1540 h805, Programming

Gui, 6:add, button, gSet1 x10 y30 w70 h70, 1
Gui, 6:add, button, x10 y100 w70 h70, 2
Gui, 6:add, button, x10 y170 w70 h70, 3
Gui, 6:add, button, x10 y240 w70 h70, 4
Gui, 6:add, button, x10 y310 w70 h70, 5
Gui, 6:add, button, x10 y380 w70 h70, 6
Gui, 6:add, button, x10 y450 w70 h70, 7
Gui, 6:add, button, x10 y520 w70 h70, 8
Gui, 6:add, button, x10 y590 w70 h70, 9
Gui, 6:add, button, x10 y660 w70 h70, 10

Gui, 6:add, button, x80 y30 w70 h70 ,11
Gui, 6:add, button, x80 y100 w70 h70, 12
Gui, 6:add, button, x80 y170 w70 h70, 13
Gui, 6:add, button, x80 y240 w70 h70, 14
Gui, 6:add, button, x80 y310 w70 h70, 15
Gui, 6:add, button, x80 y380 w70 h70, 16
Gui, 6:add, button, x80 y450 w70 h70, 17
Gui, 6:add, button, x80 y520 w70 h70, 18
Gui, 6:add, button, x80 y590 w70 h70, 19
Gui, 6:add, button, x80 y660 w70 h70, 20

Gui, 6:add, button, x150 y30 w70 h70 ,21
Gui, 6:add, button, x150 y100 w70 h70, 22
Gui, 6:add, button, x150 y170 w70 h70, 23
Gui, 6:add, button, x150 y240 w70 h70, 24
Gui, 6:add, button, x150 y310 w70 h70, 25
Gui, 6:add, button, x150 y380 w70 h70, 26
Gui, 6:add, button, x150 y450 w70 h70, 27
Gui, 6:add, button, x150 y520 w70 h70, 28
Gui, 6:add, button, x150 y590 w70 h70, 29
Gui, 6:add, button, x150 y660 w70 h70, 30

Gui, 6:add, button, x220 y30 w70 h70 ,31
Gui, 6:add, button, x220 y100 w70 h70, 32
Gui, 6:add, button, x220 y170 w70 h70, 33
Gui, 6:add, button, x220 y240 w70 h70, 34
Gui, 6:add, button, x220 y310 w70 h70, 35
Gui, 6:add, button, x220 y380 w70 h70, 36
Gui, 6:add, button, x220 y450 w70 h70, 37
Gui, 6:add, button, x220 y520 w70 h70, 38
Gui, 6:add, button, x220 y590 w70 h70, 39
Gui, 6:add, button, x220 y660 w70 h70, 40

Gui, 6:add, button, x290 y30 w70 h70 ,41
Gui, 6:add, button, x290 y100 w70 h70, 42
Gui, 6:add, button, x290 y170 w70 h70, 43
Gui, 6:add, button, x290 y240 w70 h70, 44
Gui, 6:add, button, x290 y310 w70 h70, 45
Gui, 6:add, button, x290 y380 w70 h70, 46
Gui, 6:add, button, x290 y450 w70 h70, 47
Gui, 6:add, button, x290 y520 w70 h70, 48
Gui, 6:add, button, x290 y590 w70 h70, 49
Gui, 6:add, button, x290 y660 w70 h70, 50

Gui, 6:add, button, x360 y30 w70 h70 ,51
Gui, 6:add, button, x360 y100 w70 h70, 52
Gui, 6:add, button, x360 y170 w70 h70, 53
Gui, 6:add, button, x360 y240 w70 h70, 54
Gui, 6:add, button, x360 y310 w70 h70, 55
Gui, 6:add, button, x360 y380 w70 h70, 56
Gui, 6:add, button, x360 y450 w70 h70, 57
Gui, 6:add, button, x360 y520 w70 h70, 58
Gui, 6:add, button, x360 y590 w70 h70, 59
Gui, 6:add, button, x360 y660 w70 h70, 60
return

Set1:
gui, 7:show, w500 h150, Please Name Button.
gui, 7:add, Edit, vNewName 
gui, 7:add, button, gProgOk1, Ok
return

ProgOk1:
Gui, Submit, NoHide
Iniwrite, %NewName%, Menu.ini, Menu:, 1
Gui, 7:Destroy
gui, 8:show, w500 h150, Please set Price.
gui, 8:add, Edit, vNewPrice 
gui, 8:add, button, gProgOk2, Ok
return

ProgOk2:
Gui, Submit, NoHide
Iniwrite, %NewPrice%, Menu.ini, Price:, 1
Gui, 8:Destroy
return

 
Odlanir
Posts: 425
Joined: 20 Oct 2016, 08:20

Re: Lable buttons via Ini File

27 Jun 2019, 03:10

Dyson wrote:
26 Jun 2019, 14:11
How would I change it to add more buttons? So the next 10 go to the side as they just go underneath but it’s off the screen
try this:

Code: Select all

Gui, 6:Show , w1240 h805, Programming
Loop, 6 {		
	x := a_index = 1 ? (10, z := 0) : (x +70, z +=10)
	Loop, 10 {		
		i := A_index
		Gui, 6:add, button, % " vBut" z+i " gSet x" x " y" 30+(i-1)*70 " w70 h70", % z+i
	}
}
return

Set:
	gui,Submit,NoHide
	MsgBox % A_GuiControl
return
GuiEscape:
GuiClose:
Esc::
  ExitApp
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
just me
Posts: 6425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

27 Jun 2019, 05:53

Code: Select all

#NoEnv
; ------------------------------------------------------------------------------
; Settings
IniFile := "Menu.ini"
BtnCount := 60       ; total number of buttons
BtnsPerColumn := 10  ; buttons per column
BtnW := 140          ; button width
BtnH := 70           ; button height
; ------------------------------------------------------------------------------
Gui, MenuBtns:New, , Programming
Gui, Margin, 10, 10
Gui, Add, Button, x1460 y10 w70 h70, Home
Y := "ym"
X := "xm"
Loop, %BtnCount% {
   IniRead, Menu, %IniFile%, Menu:, %A_Index%, %A_Index%
   IniRead, Price, %IniFile%, Price:, %A_Index%, %A_Space%
   Gui, Add, Button, %X% %Y% w%BtnW% h%BtnH% vBtn%A_Index% gSet, %Menu%`n%Price%
   If (Mod(A_Index, BtnsPerColumn) = 0) {
      Y := "ym"
      X := "x+0"
   }
   Else {
      Y := "y+0"
      X := "xp"
   }
}
; ------------------------------------------------------------------------------
Gui, SetBtns:New
Gui, Margin, 10, 10
Gui, Add, Text, h20 0x0200 Section, Enter new name:
Gui, Add, Text, xs hp 0x0200, Enter new price:
W := BtnW - 10
Gui, Add, Edit, ys w%W% h20 Limit vNewName
Gui, Add, Edit, xp y+m wp h20 Limit vNewPrice
GuiControlGet, P, Pos, NewPrice
Gui, Add, Button, xm w80 gWriteIni, Apply
X := PX + PW - 80
Gui, Add, Button, x%X% yp wp gSetBtnsGuiClose, Cancel
; ------------------------------------------------------------------------------
Gui, MenuBtns:Show
Return
; ------------------------------------------------------------------------------
MenuBtnsGuiClose:
ExitApp
; ------------------------------------------------------------------------------
WriteIni:
   Gui, Submit, NoHide
   ; MsgBox, 0, New Values, Name:`t%NewName%`n`nPrice:`t%NewPrice
   GuiControl, MenuBtns:, Btn%BtnNumber%, %NewName%`n%NewPrice%
   Iniwrite, %NewName%, %IniFile%, Menu:, %BtnNumber%
   Iniwrite, %NewPrice%, %IniFile%, Price:, %BtnNumber%
; ------------------------------------------------------------------------------
SetBtnsGuiClose:
   Gui, MenuBtns:-Disabled
   Gui, Hide
Return
; ------------------------------------------------------------------------------
Set:
BtnNumber := SubStr(A_GuiControl, 4)
GuiControlGet, BtnCaption, , %A_GuiControl%
Split := StrSplit(BtnCaption, "`n", " ")
GuiControl, SetBtns:, NewName, % Split[1]
GuiControl, SetBtns:, NewPrice, % Split[2]
Gui, +Disabled
Gui, SetBtns:Show, , Button %BtnNumber%
Return
?
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

27 Jun 2019, 06:39

just me wrote:
27 Jun 2019, 05:53

Code: Select all

#NoEnv
; ------------------------------------------------------------------------------
; Settings
IniFile := "Menu.ini"
BtnCount := 60       ; total number of buttons
BtnsPerColumn := 10  ; buttons per column
BtnW := 140          ; button width
BtnH := 70           ; button height
; ------------------------------------------------------------------------------
Gui, MenuBtns:New, , Programming
Gui, Margin, 10, 10
Gui, Add, Button, x1460 y10 w70 h70, Home
Y := "ym"
X := "xm"
Loop, %BtnCount% {
   IniRead, Menu, %IniFile%, Menu:, %A_Index%, %A_Index%
   IniRead, Price, %IniFile%, Price:, %A_Index%, %A_Space%
   Gui, Add, Button, %X% %Y% w%BtnW% h%BtnH% vBtn%A_Index% gSet, %Menu%`n%Price%
   If (Mod(A_Index, BtnsPerColumn) = 0) {
      Y := "ym"
      X := "x+0"
   }
   Else {
      Y := "y+0"
      X := "xp"
   }
}
; ------------------------------------------------------------------------------
Gui, SetBtns:New
Gui, Margin, 10, 10
Gui, Add, Text, h20 0x0200 Section, Enter new name:
Gui, Add, Text, xs hp 0x0200, Enter new price:
W := BtnW - 10
Gui, Add, Edit, ys w%W% h20 Limit vNewName
Gui, Add, Edit, xp y+m wp h20 Limit vNewPrice
GuiControlGet, P, Pos, NewPrice
Gui, Add, Button, xm w80 gWriteIni, Apply
X := PX + PW - 80
Gui, Add, Button, x%X% yp wp gSetBtnsGuiClose, Cancel
; ------------------------------------------------------------------------------
Gui, MenuBtns:Show
Return
; ------------------------------------------------------------------------------
MenuBtnsGuiClose:
ExitApp
; ------------------------------------------------------------------------------
WriteIni:
   Gui, Submit, NoHide
   ; MsgBox, 0, New Values, Name:`t%NewName%`n`nPrice:`t%NewPrice
   GuiControl, MenuBtns:, Btn%BtnNumber%, %NewName%`n%NewPrice%
   Iniwrite, %NewName%, %IniFile%, Menu:, %BtnNumber%
   Iniwrite, %NewPrice%, %IniFile%, Price:, %BtnNumber%
; ------------------------------------------------------------------------------
SetBtnsGuiClose:
   Gui, MenuBtns:-Disabled
   Gui, Hide
Return
; ------------------------------------------------------------------------------
Set:
BtnNumber := SubStr(A_GuiControl, 4)
GuiControlGet, BtnCaption, , %A_GuiControl%
Split := StrSplit(BtnCaption, "`n", " ")
GuiControl, SetBtns:, NewName, % Split[1]
GuiControl, SetBtns:, NewPrice, % Split[2]
Gui, +Disabled
Gui, SetBtns:Show, , Button %BtnNumber%
Return
?
yes this is perfect! just need to make it 6th gui now and should be good to add to my main script :D Thanks again
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

27 Jun 2019, 08:50

ok so I added it to my main script:

once I have clicked on a button to set the name and price, the whole script goes dead, I cant even close it (have to right click the task bar and close that way) here is the whole script if you wanted to have a little play with it,

to get to programming:

Home>Manager Functions >programming

Code: Select all

Gui, 2:Show , w1540 h805, Home
; ############################################################
Gui, 1:Add, Button, x50 y50 w300 h300 gSales ,Sales Mode
Gui, 1:Add, Button, x350 y50 w300 h300 gManager ,Manager Functions
; ############################################################


Gui, 2: Font, s16

Gui, 2:add, Edit, x1100 y10 w400 h100 vClerkNumIn Password* ;or Password#

;~ Gui, 2:Add, Picture, gHome x10 y10 w100 h-1, Home.BMP
Gui, 2:Add, Button, gHome x10 y10 w100 h100, Home

Gui, 2:add, button, gClear x10 y113 w85 h85, C
Gui, 2:Add, Button, gSignOn x95 y113 w170 h85, Sign on
Gui, 2:Add, Button, gAddText x10 y197 w85 h85, 1
Gui, 2:Add, Button, gAddText x95 y197 w85 h85, 2
Gui, 2:Add, Button, gAddText x180 y197 w85 h85, 3
gui, 2:add, button, gAddText x10 y281 w85 h85, 4
Gui, 2:Add, Button, gAddText x95 y281 w85 h85, 5
Gui, 2:Add, Button, gAddText x180 y281 w85 h85, 6
gui, 2:add, button, gAddText x10 y365 w85 h85, 7
Gui, 2:Add, Button, gAddText x95 y365 w85 h85, 8
Gui, 2:Add, Button, gAddText x180 y365 w85 h85, 9
gui, 2:add, button, gAddText x10 y449 w85 h85, 0
Gui, 2:Add, Button, gAddText x95 y449 w85 h85, 00
Gui, 2:Add, Button, gAddText x180 y449 w85 h85, .
Gui, 2:Add, Button, gClockIn x280 y381 w200 h150 ,Clock in
Gui, 2:Add, Button, gClockOut x480 y381 w200 h150 ,Clock out
Gui, 2: Font, s28 
Gui, 2:add, text, x660 y10, Please sign on
Gui, 2: Font, s16

; ############################################################
Gui, 3:Add, Button, gHome x10 y10 w100 h100, Home
Gui, 3:Add, Button, x150 y50 w250 h250 gSales ,Sales Mode
Gui, 3:Add, Button, gProgramming x400 y50 w250 h250 ,Programming
Gui, 3:Add, Button, x650 y50 w250 h250 gAddClerk ,Add Clerk
Gui, 3:Add, Button, x900 y50 w250 h250  ,Staff Attend
Gui, 3:Add, Button, x1150 y50 w250 h250  ,Weekly Stock Report
; ############################################################
Gui, 4:Add, Button, gHome x10 y10 w100 h100, Home

gui, 4:add, edit, x150 y10 w400 h50 vClerkName
gui, 4:add, edit, x650 y10 w400 h50 vClerkNum

Gui, 4:Add, Button, gAddTextName x160 y175 w25 h25, A
Gui, 4:Add, Button, gAddTextName x240 y200 w25 h25, B
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, C
Gui, 4:Add, Button, gAddTextName x210 y175 w25 h25, D
Gui, 4:Add, Button, gAddTextName x200 y150 w25 h25, E
Gui, 4:Add, Button, gAddTextName x235 y175 w25 h25, F
Gui, 4:Add, Button, gAddTextName x260 y175 w25 h25, G
Gui, 4:Add, Button, gAddTextName x285 y175 w25 h25, H
Gui, 4:Add, Button, gAddTextName x325 y150 w25 h25, I
Gui, 4:Add, Button, gAddTextName x310 y175 w25 h25, J
Gui, 4:Add, Button, gAddTextName x335 y175 w25 h25, K
Gui, 4:Add, Button, gAddTextName x360 y175 w25 h25, L
Gui, 4:Add, Button, gAddTextName x290 y200 w25 h25, M
Gui, 4:Add, Button, gAddTextName x265 y200 w25 h25, N
Gui, 4:Add, Button, gAddTextName x350 y150 w25 h25, O
Gui, 4:Add, Button, gAddTextName x375 y150 w25 h25, P
Gui, 4:Add, Button, gAddTextName x150 y150 w25 h25, Q
Gui, 4:Add, Button, gAddTextName x225 y150 w25 h25, R
Gui, 4:Add, Button, gAddTextName x185 y175 w25 h25, S
Gui, 4:Add, Button, gAddTextName x250 y150 w25 h25, T
Gui, 4:Add, Button, gAddTextName x300 y150 w25 h25, U
Gui, 4:Add, Button, gAddTextName x220 y200 w25 h25, V
Gui, 4:Add, Button, gAddTextName x175 y150 w25 h25, W
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, X
Gui, 4:Add, Button, gAddTextName x275 y150 w25 h25, Y
Gui, 4:Add, Button, gAddTextName x170 y200 w25 h25, Z
Gui, 4:Add, Button, gAddTextspace x315 y200 w75 h25, Space

gui, 4:add, button, gClear x10 y113 w85 h85, C

Gui, 4:Add, Button, gAddTextNum x650 y197 w85 h85, 1
Gui, 4:Add, Button, gAddTextNum x734 y197 w85 h85, 2
Gui, 4:Add, Button, gAddTextNum x818 y197 w85 h85, 3
gui, 4:add, button, gAddTextNum x650 y281 w85 h85, 4
Gui, 4:Add, Button, gAddTextNum x734 y281 w85 h85, 5
Gui, 4:Add, Button, gAddTextNum x818 y281 w85 h85, 6
gui, 4:add, button, gAddTextNum x650 y365 w85 h85, 7
Gui, 4:Add, Button, gAddTextNum x734 y365 w85 h85, 8
Gui, 4:Add, Button, gAddTextNum x818 y365 w85 h85, 9
gui, 4:add, button, gAddTextNum x734 y449 w85 h85, 0

gui, 4:add, Button, gAddclerk2 x150 y300 w150 h85, Add Clerk

; ################################################################################

gui, 5:Font, s12

Gui, 5:add, Edit, x1200 y10 w300 h370 vMenu
Gui, 5:add, Edit, x1200 y380 w300 h30 vTotal

Gui, 5:add, text, x660 y10, %ClerkName%
Gui, 5:add, button, gClear x1100 y410 w70 h70, C
Gui, 5:add, button, gAddTextMenu x1100 y480 w70 h70, 7
Gui, 5:add, button, gAddTextMenu x1100 y550 w70 h70, 4
Gui, 5:add, button, gAddTextMenu x1100 y620 w70 h70, 1
Gui, 5:add, button, gAddTextMenu x1100 y690 w70 h70, 0

Gui, 5:add, button, x1170 y410 w70 h70, X
Gui, 5:add, button, gAddTextMenu x1170 y480 w70 h70, 8
Gui, 5:add, button, gAddTextMenu x1170 y550 w70 h70, 5
Gui, 5:add, button, gAddTextMenu x1170 y620 w70 h70, 2
Gui, 5:add, button, gAddTextMenu x1170 y690 w70 h70, 00

Gui, 5:add, button, gSignOff x1240 y410 w70 h70, Sign Off
Gui, 5:add, button, gAddTextMenu x1240 y480 w70 h70, 9
Gui, 5:add, button, gAddTextMenu x1240 y550 w70 h70, 6
Gui, 5:add, button, gAddTextMenu x1240 y620 w70 h70, 3
Gui, 5:add, button, gAddTextMenu x1240 y690 w70 h70, .

Gui, 5:add, button, x1310 y410 w140 h70, Void
Gui, 5:add, button, x1310 y480 w140 h70, Refund
Gui, 5:add, button, x1310 y550 w140 h140, Payment

Gui, 5:add, button, x10 y30 w70 h70, 1
Gui, 5:add, button, x10 y100 w70 h70, 2
Gui, 5:add, button, x10 y170 w70 h70, 3
Gui, 5:add, button, x10 y240 w70 h70, 4
Gui, 5:add, button, x10 y310 w70 h70, 5
Gui, 5:add, button, x10 y380 w70 h70, 6
Gui, 5:add, button, x10 y450 w70 h70, 7
Gui, 5:add, button, x10 y520 w70 h70, 8
Gui, 5:add, button, x10 y590 w70 h70, 9
Gui, 5:add, button, x10 y660 w70 h70, 10

Gui, 5:add, button, x80 y30 w70 h70 ,11
Gui, 5:add, button, x80 y100 w70 h70, 12
Gui, 5:add, button, x80 y170 w70 h70, 13
Gui, 5:add, button, x80 y240 w70 h70, 14
Gui, 5:add, button, x80 y310 w70 h70, 15
Gui, 5:add, button, x80 y380 w70 h70, 16
Gui, 5:add, button, x80 y450 w70 h70, 17
Gui, 5:add, button, x80 y520 w70 h70, 18
Gui, 5:add, button, x80 y590 w70 h70, 19
Gui, 5:add, button, x80 y660 w70 h70, 20

Gui, 5:add, button, x150 y30 w70 h70 ,21
Gui, 5:add, button, x150 y100 w70 h70, 22
Gui, 5:add, button, x150 y170 w70 h70, 23
Gui, 5:add, button, x150 y240 w70 h70, 24
Gui, 5:add, button, x150 y310 w70 h70, 25
Gui, 5:add, button, x150 y380 w70 h70, 26
Gui, 5:add, button, x150 y450 w70 h70, 27
Gui, 5:add, button, x150 y520 w70 h70, 28
Gui, 5:add, button, x150 y590 w70 h70, 29
Gui, 5:add, button, x150 y660 w70 h70, 30

Gui, 5:add, button, x220 y30 w70 h70 ,31
Gui, 5:add, button, x220 y100 w70 h70, 32
Gui, 5:add, button, x220 y170 w70 h70, 33
Gui, 5:add, button, x220 y240 w70 h70, 34
Gui, 5:add, button, x220 y310 w70 h70, 35
Gui, 5:add, button, x220 y380 w70 h70, 36
Gui, 5:add, button, x220 y450 w70 h70, 37
Gui, 5:add, button, x220 y520 w70 h70, 38
Gui, 5:add, button, x220 y590 w70 h70, 39
Gui, 5:add, button, x220 y660 w70 h70, 40

Gui, 5:add, button, x290 y30 w70 h70 ,41
Gui, 5:add, button, x290 y100 w70 h70, 42
Gui, 5:add, button, x290 y170 w70 h70, 43
Gui, 5:add, button, x290 y240 w70 h70, 44
Gui, 5:add, button, x290 y310 w70 h70, 45
Gui, 5:add, button, x290 y380 w70 h70, 46
Gui, 5:add, button, x290 y450 w70 h70, 47
Gui, 5:add, button, x290 y520 w70 h70, 48
Gui, 5:add, button, x290 y590 w70 h70, 49
Gui, 5:add, button, x290 y660 w70 h70, 50

Gui, 5:add, button, x360 y30 w70 h70 ,51
Gui, 5:add, button, x360 y100 w70 h70, 52
Gui, 5:add, button, x360 y170 w70 h70, 53
Gui, 5:add, button, x360 y240 w70 h70, 54
Gui, 5:add, button, x360 y310 w70 h70, 55
Gui, 5:add, button, x360 y380 w70 h70, 56
Gui, 5:add, button, x360 y450 w70 h70, 57
Gui, 5:add, button, x360 y520 w70 h70, 58
Gui, 5:add, button, x360 y590 w70 h70, 59
Gui, 5:add, button, x360 y660 w70 h70, 60

;#######################################################################
#NoEnv
; ------------------------------------------------------------------------------
; Settings
IniFile := "Menu.ini"
BtnCount := 60       ; total number of buttons
BtnsPerColumn := 10  ; buttons per column
BtnW := 100          ; button width
BtnH := 70           ; button height
; ------------------------------------------------------------------------------
Gui, 6:Add, Button, gHome x1460 y10 w70 h70, Home
Y := "ym"
X := "xm"
Loop, %BtnCount% {
   IniRead, Menu, %IniFile%, Menu:, %A_Index%, %A_Index%
   IniRead, Price, %IniFile%, Price:, %A_Index%, %A_Space%
   Gui, 6:Add, Button, %X% %Y% w%BtnW% h%BtnH% vBtn%A_Index% gSet, %Menu%`n%Price%
   If (Mod(A_Index, BtnsPerColumn) = 0) {
      Y := "ym"
      X := "x+0"
   }
   Else {
      Y := "y+0"
      X := "xp"
   }
}
; ------------------------------------------------------------------------------
Gui, SetBtns:New
Gui, Margin, 10, 10
Gui, Add, Text, h20 0x0200 Section, Enter new name:
Gui, Add, Text, xs hp 0x0200, Enter new price:
W := BtnW - 10
Gui, Add, Edit, ys w%W% h20 Limit vNewName
Gui, Add, Edit, xp y+m wp h20 Limit vNewPrice
GuiControlGet, P, Pos, NewPrice
Gui, Add, Button, xm w80 gWriteIni, Apply
X := PX + PW - 80
Gui, Add, Button, x%X% yp wp gSetBtnsGuiClose, Cancel
; ------------------------------------------------------------------------------
Gui, MenuBtns:Show
Return
; ------------------------------------------------------------------------------
MenuBtnsGuiClose:
ExitApp
; ------------------------------------------------------------------------------
WriteIni:
   Gui, Submit, NoHide
   ; MsgBox, 0, New Values, Name:`t%NewName%`n`nPrice:`t%NewPrice
   GuiControl, MenuBtns:, Btn%BtnNumber%, %NewName%`n%NewPrice%
   Iniwrite, %NewName%, %IniFile%, Menu:, %BtnNumber%
   Iniwrite, %NewPrice%, %IniFile%, Price:, %BtnNumber%
; ------------------------------------------------------------------------------
SetBtnsGuiClose:
   Gui, MenuBtns:-Disabled
   Gui, Hide
Return
; ------------------------------------------------------------------------------
Set:
BtnNumber := SubStr(A_GuiControl, 4)
GuiControlGet, BtnCaption, , %A_GuiControl%
Split := StrSplit(BtnCaption, "`n", " ")
GuiControl, SetBtns:, NewName, % Split[1]
GuiControl, SetBtns:, NewPrice, % Split[2]
Gui, +Disabled
Gui, SetBtns:Show, , Button %BtnNumber%
Return
;#######################################################################
Gui, 2:Show , w1540 h805, Home
return

Home:
Gui, 2:Hide
Gui, 3:Hide
Gui, 4:Hide
Gui, 6:Hide
Gui, 1:Show , w1540 h805, Home
return

Sales:
Gui, 1:Hide
Gui, 2:Show , w1540 h805, Home
return

Manager:
Gui, 1:Hide
Gui, 3:Show , w1540 h805, Manager Functions
return

SignOn:
gui, 2:Hide
gui, 5:Show , w1540 h805, Order
return


Addclerk:
Gui, 3:Hide
Gui, 4:Show , w1540 h805, Add Clerk
return

SignOff:
Gui, 5:Hide
Gui, 2:Show , w1540 h805, Home
return

Programming:
gui, 3:Hide
Gui, 6:Show , w1540 h805, Programming
Return

;-------------------------------------------------------------
1GuiClose:
Gui, 1:Hide
Gui, 2:Show , w1540 h805, Home
return

2GuiClose:
ExitApp
return

3GuiClose:
Gui, 3:Hide
Gui, 2:Show , w1540 h805, Home
return

4GuiClose:
Gui, 4:Hide
Gui, 3:Show , w1540 h805, Manager Functions
return

Addclerk2:
Gui, Submit, NoHide
IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNum%
if (IsClerkNumExist == "ERROR")
{
    IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
    if (ClerkList == "ERROR")
    {
        IniWrite, |, Clerk.ini, ClerkList, ClerkList
        IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
    }
    IfNotInString, ClerkList, %ClerkName%
    {
        IniWrite, %ClerkName%, Clerk.ini, Clerk, %ClerkNum%
        IniWrite, %ClerkList%%ClerkName%|, Clerk.ini, ClerkList, ClerkList
        IniWrite, No, Online.ini, Clocked In:, %ClerkName%
        MsgBox, 262208,Attention ,%ClerkName% Created.,2
        return
    }
    else
    {
        MsgBox, 16,Attention ,%ClerkName% In Use.,2
    }
}
else
    MsgBox, 16,Attention ,%ClerkNum% In Use.,2
return

ClockIn:
Gui, Submit, NoHide
IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNumIn%
if (IsClerkNumExist == "ERROR")
{
 GuiControl,, ClerkNumIn
    MsgBox, 262192,Attention ,No Such Clerk.,2
    return
}
if (ClerkNumIn == "")
{
    GuiControl,, ClerkNumIn
    MsgBox, 262192,Attention ,No Such Clerk.,2
    return
}
IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
if (Value == "No")
{
    FormatTime, TimeIn,, HH:mm:ss
    FormatTime, DateIn,, ShortDate
    IniWrite, Yes, Online.ini, Clocked In:, %ClerkInName%
    IniWrite, %A_Now%, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
    IniWrite, In, Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
    GuiControl,, ClerkNumIn
    MsgBox, 262208,Attention ,%ClerkInName% Clocked In.,2
return
}
else
    GuiControl,, ClerkNumIn
    MsgBox, 262192,Attention , Already Clocked In,2
return

ClockOut:
Gui, Submit, NoHide
IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNumIn%
if (IsClerkNumExist == "ERROR")
{
 GuiControl,, ClerkNumIn
    MsgBox, 262192,Attention ,No Such Clerk.,2
    return
}
if (ClerkNumIn == "")
{
    MsgBox, 262192,Attention ,No such Clerk.,2
    return
}
IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
if (Value == "Yes")
{
    FormatTime, TimeIn,, HH:mm:ss
    FormatTime, DateIn,, ShortDate
    IniRead, LastTimeClockedin, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
    RegExMatch(LastTimeClockedin, "(....)(..)(..)(..)(..)(..)",D)
    TimeClockedin := ((A_YYYY - D1) ? A_YYYY - D1 " Years, " : "") ((A_MM - D2) ? A_MM - D2 " Months, " : "") ((A_DD - D3) ? A_DD - D3 " Days, " : "") ((A_Hour - D4) ? A_Hour - D4 " Hours, " : "") ((A_Min - D5) ? A_Min - D5 " Minutes, " : "") ((A_Sec - D6) ? A_Sec - D6 " Seconds" : "")
    IniWrite, Out (%TimeClockedin%), Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
    IniWrite, No, Online.ini, Clocked In:, %ClerkInName%
    GuiControl,, ClerkNumIn
    MsgBox, 262208,Attention ,%ClerkInName% Clocked Out.,2
}
else
    MsgBox, 262192,Attention ,Not Clocked In.,2
    GuiControl,, ClerkNumIn
return

AddText:
Gui, Submit, NoHide
  GuiControl, , ClerkNumIn, % ClerkNumIn A_GuiControl
Return

AddTextMenu:
Gui, Submit, NoHide
  GuiControl, , Menu, % Menu A_GuiControl
Return

Clear:
ClerkNumIn := ClerkNum := ClerkName := Menu := ""
GuiControl,, ClerkNumIn
GuiControl,, ClerkNum
GuiControl,, ClerkName
GuiControl,, Menu
return

AddTextName:
Gui, Submit, NoHide
  GuiControl,, ClerkName, % ClerkName A_GuiControl
return

AddTextNum:
Gui, Submit, NoHide
  GuiControl,, ClerkNum, % ClerkNum A_GuiControl
return

AddTextspace:
  GuiControl,, ClerkName, % ClerkName " "
Return




idealy after setting the name and price in the programming section, I would like the names of the buttons to coincide with the buttons on the sign on option, (without showing the price)
once pressed in the sign on option it should add the name and the price to the editbox ( vMenu ) and drop to next line ready for next item to be added also calculating the total of each item as its added in the vTotal edit box

if that makes sence
eg.png
eg.png (117.03 KiB) Viewed 757 times
just me
Posts: 6425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

27 Jun 2019, 11:53

Hi Dyson,

I tried to adjust the script.

Most important changes:
  • Moved settings to the top of the script.
  • Added missing adjustments for GUI 6.
  • Changed SetBtns GUI to number 7 and adjusted the code.

Code: Select all

#NoEnv
; ------------------------------------------------------------------------------
; Settings
IniFile := "Menu.ini"
BtnCount := 60       ; total number of buttons
BtnsPerColumn := 10  ; buttons per column
BtnW := 100          ; button width
BtnH := 70           ; button height
; ------------------------------------------------------------------------------
; ##############################################################################
Gui, 1:Add, Button, x50 y50 w300 h300 gSales ,Sales Mode
Gui, 1:Add, Button, x350 y50 w300 h300 gManager ,Manager Functions
; ##############################################################################
Gui, 2: Font, s16

Gui, 2:add, Edit, x1100 y10 w400 h100 vClerkNumIn Password* ;or Password#

;~ Gui, 2:Add, Picture, gHome x10 y10 w100 h-1, Home.BMP
Gui, 2:Add, Button, gHome x10 y10 w100 h100, Home

Gui, 2:add, button, gClear x10 y113 w85 h85, C
Gui, 2:Add, Button, gSignOn x95 y113 w170 h85, Sign on
Gui, 2:Add, Button, gAddText x10 y197 w85 h85, 1
Gui, 2:Add, Button, gAddText x95 y197 w85 h85, 2
Gui, 2:Add, Button, gAddText x180 y197 w85 h85, 3
gui, 2:add, button, gAddText x10 y281 w85 h85, 4
Gui, 2:Add, Button, gAddText x95 y281 w85 h85, 5
Gui, 2:Add, Button, gAddText x180 y281 w85 h85, 6
gui, 2:add, button, gAddText x10 y365 w85 h85, 7
Gui, 2:Add, Button, gAddText x95 y365 w85 h85, 8
Gui, 2:Add, Button, gAddText x180 y365 w85 h85, 9
gui, 2:add, button, gAddText x10 y449 w85 h85, 0
Gui, 2:Add, Button, gAddText x95 y449 w85 h85, 00
Gui, 2:Add, Button, gAddText x180 y449 w85 h85, .
Gui, 2:Add, Button, gClockIn x280 y381 w200 h150 ,Clock in
Gui, 2:Add, Button, gClockOut x480 y381 w200 h150 ,Clock out
Gui, 2: Font, s28
Gui, 2:add, text, x660 y10, Please sign on
Gui, 2: Font, s16
; ##############################################################################
Gui, 3:Add, Button, gHome x10 y10 w100 h100, Home
Gui, 3:Add, Button, x150 y50 w250 h250 gSales ,Sales Mode
Gui, 3:Add, Button, gProgramming x400 y50 w250 h250 ,Programming
Gui, 3:Add, Button, x650 y50 w250 h250 gAddClerk ,Add Clerk
Gui, 3:Add, Button, x900 y50 w250 h250  ,Staff Attend
Gui, 3:Add, Button, x1150 y50 w250 h250  ,Weekly Stock Report
; ############################################################
Gui, 4:Add, Button, gHome x10 y10 w100 h100, Home

gui, 4:add, edit, x150 y10 w400 h50 vClerkName
gui, 4:add, edit, x650 y10 w400 h50 vClerkNum

Gui, 4:Add, Button, gAddTextName x160 y175 w25 h25, A
Gui, 4:Add, Button, gAddTextName x240 y200 w25 h25, B
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, C
Gui, 4:Add, Button, gAddTextName x210 y175 w25 h25, D
Gui, 4:Add, Button, gAddTextName x200 y150 w25 h25, E
Gui, 4:Add, Button, gAddTextName x235 y175 w25 h25, F
Gui, 4:Add, Button, gAddTextName x260 y175 w25 h25, G
Gui, 4:Add, Button, gAddTextName x285 y175 w25 h25, H
Gui, 4:Add, Button, gAddTextName x325 y150 w25 h25, I
Gui, 4:Add, Button, gAddTextName x310 y175 w25 h25, J
Gui, 4:Add, Button, gAddTextName x335 y175 w25 h25, K
Gui, 4:Add, Button, gAddTextName x360 y175 w25 h25, L
Gui, 4:Add, Button, gAddTextName x290 y200 w25 h25, M
Gui, 4:Add, Button, gAddTextName x265 y200 w25 h25, N
Gui, 4:Add, Button, gAddTextName x350 y150 w25 h25, O
Gui, 4:Add, Button, gAddTextName x375 y150 w25 h25, P
Gui, 4:Add, Button, gAddTextName x150 y150 w25 h25, Q
Gui, 4:Add, Button, gAddTextName x225 y150 w25 h25, R
Gui, 4:Add, Button, gAddTextName x185 y175 w25 h25, S
Gui, 4:Add, Button, gAddTextName x250 y150 w25 h25, T
Gui, 4:Add, Button, gAddTextName x300 y150 w25 h25, U
Gui, 4:Add, Button, gAddTextName x220 y200 w25 h25, V
Gui, 4:Add, Button, gAddTextName x175 y150 w25 h25, W
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, X
Gui, 4:Add, Button, gAddTextName x275 y150 w25 h25, Y
Gui, 4:Add, Button, gAddTextName x170 y200 w25 h25, Z
Gui, 4:Add, Button, gAddTextspace x315 y200 w75 h25, Space

gui, 4:add, button, gClear x10 y113 w85 h85, C

Gui, 4:Add, Button, gAddTextNum x650 y197 w85 h85, 1
Gui, 4:Add, Button, gAddTextNum x734 y197 w85 h85, 2
Gui, 4:Add, Button, gAddTextNum x818 y197 w85 h85, 3
gui, 4:add, button, gAddTextNum x650 y281 w85 h85, 4
Gui, 4:Add, Button, gAddTextNum x734 y281 w85 h85, 5
Gui, 4:Add, Button, gAddTextNum x818 y281 w85 h85, 6
gui, 4:add, button, gAddTextNum x650 y365 w85 h85, 7
Gui, 4:Add, Button, gAddTextNum x734 y365 w85 h85, 8
Gui, 4:Add, Button, gAddTextNum x818 y365 w85 h85, 9
gui, 4:add, button, gAddTextNum x734 y449 w85 h85, 0

gui, 4:add, Button, gAddclerk2 x150 y300 w150 h85, Add Clerk
; ##############################################################################
gui, 5:Font, s12

Gui, 5:add, Edit, x1200 y10 w300 h370 vMenu
Gui, 5:add, Edit, x1200 y380 w300 h30 vTotal

Gui, 5:add, text, x660 y10, %ClerkName%
Gui, 5:add, button, gClear x1100 y410 w70 h70, C
Gui, 5:add, button, gAddTextMenu x1100 y480 w70 h70, 7
Gui, 5:add, button, gAddTextMenu x1100 y550 w70 h70, 4
Gui, 5:add, button, gAddTextMenu x1100 y620 w70 h70, 1
Gui, 5:add, button, gAddTextMenu x1100 y690 w70 h70, 0

Gui, 5:add, button, x1170 y410 w70 h70, X
Gui, 5:add, button, gAddTextMenu x1170 y480 w70 h70, 8
Gui, 5:add, button, gAddTextMenu x1170 y550 w70 h70, 5
Gui, 5:add, button, gAddTextMenu x1170 y620 w70 h70, 2
Gui, 5:add, button, gAddTextMenu x1170 y690 w70 h70, 00

Gui, 5:add, button, gSignOff x1240 y410 w70 h70, Sign Off
Gui, 5:add, button, gAddTextMenu x1240 y480 w70 h70, 9
Gui, 5:add, button, gAddTextMenu x1240 y550 w70 h70, 6
Gui, 5:add, button, gAddTextMenu x1240 y620 w70 h70, 3
Gui, 5:add, button, gAddTextMenu x1240 y690 w70 h70, .

Gui, 5:add, button, x1310 y410 w140 h70, Void
Gui, 5:add, button, x1310 y480 w140 h70, Refund
Gui, 5:add, button, x1310 y550 w140 h140, Payment

Gui, 5:add, button, x10 y30 w70 h70, 1
Gui, 5:add, button, x10 y100 w70 h70, 2
Gui, 5:add, button, x10 y170 w70 h70, 3
Gui, 5:add, button, x10 y240 w70 h70, 4
Gui, 5:add, button, x10 y310 w70 h70, 5
Gui, 5:add, button, x10 y380 w70 h70, 6
Gui, 5:add, button, x10 y450 w70 h70, 7
Gui, 5:add, button, x10 y520 w70 h70, 8
Gui, 5:add, button, x10 y590 w70 h70, 9
Gui, 5:add, button, x10 y660 w70 h70, 10

Gui, 5:add, button, x80 y30 w70 h70 ,11
Gui, 5:add, button, x80 y100 w70 h70, 12
Gui, 5:add, button, x80 y170 w70 h70, 13
Gui, 5:add, button, x80 y240 w70 h70, 14
Gui, 5:add, button, x80 y310 w70 h70, 15
Gui, 5:add, button, x80 y380 w70 h70, 16
Gui, 5:add, button, x80 y450 w70 h70, 17
Gui, 5:add, button, x80 y520 w70 h70, 18
Gui, 5:add, button, x80 y590 w70 h70, 19
Gui, 5:add, button, x80 y660 w70 h70, 20

Gui, 5:add, button, x150 y30 w70 h70 ,21
Gui, 5:add, button, x150 y100 w70 h70, 22
Gui, 5:add, button, x150 y170 w70 h70, 23
Gui, 5:add, button, x150 y240 w70 h70, 24
Gui, 5:add, button, x150 y310 w70 h70, 25
Gui, 5:add, button, x150 y380 w70 h70, 26
Gui, 5:add, button, x150 y450 w70 h70, 27
Gui, 5:add, button, x150 y520 w70 h70, 28
Gui, 5:add, button, x150 y590 w70 h70, 29
Gui, 5:add, button, x150 y660 w70 h70, 30

Gui, 5:add, button, x220 y30 w70 h70 ,31
Gui, 5:add, button, x220 y100 w70 h70, 32
Gui, 5:add, button, x220 y170 w70 h70, 33
Gui, 5:add, button, x220 y240 w70 h70, 34
Gui, 5:add, button, x220 y310 w70 h70, 35
Gui, 5:add, button, x220 y380 w70 h70, 36
Gui, 5:add, button, x220 y450 w70 h70, 37
Gui, 5:add, button, x220 y520 w70 h70, 38
Gui, 5:add, button, x220 y590 w70 h70, 39
Gui, 5:add, button, x220 y660 w70 h70, 40

Gui, 5:add, button, x290 y30 w70 h70 ,41
Gui, 5:add, button, x290 y100 w70 h70, 42
Gui, 5:add, button, x290 y170 w70 h70, 43
Gui, 5:add, button, x290 y240 w70 h70, 44
Gui, 5:add, button, x290 y310 w70 h70, 45
Gui, 5:add, button, x290 y380 w70 h70, 46
Gui, 5:add, button, x290 y450 w70 h70, 47
Gui, 5:add, button, x290 y520 w70 h70, 48
Gui, 5:add, button, x290 y590 w70 h70, 49
Gui, 5:add, button, x290 y660 w70 h70, 50

Gui, 5:add, button, x360 y30 w70 h70 ,51
Gui, 5:add, button, x360 y100 w70 h70, 52
Gui, 5:add, button, x360 y170 w70 h70, 53
Gui, 5:add, button, x360 y240 w70 h70, 54
Gui, 5:add, button, x360 y310 w70 h70, 55
Gui, 5:add, button, x360 y380 w70 h70, 56
Gui, 5:add, button, x360 y450 w70 h70, 57
Gui, 5:add, button, x360 y520 w70 h70, 58
Gui, 5:add, button, x360 y590 w70 h70, 59
Gui, 5:add, button, x360 y660 w70 h70, 60
; ##############################################################################
Gui, 6:Add, Button, gHome x1460 y10 w70 h70, Home
Y := "ym"
X := "xm"
Loop, %BtnCount% {
   IniRead, Menu, %IniFile%, Menu:, %A_Index%, %A_Index%
   IniRead, Price, %IniFile%, Price:, %A_Index%, %A_Space%
   Gui, 6:Add, Button, %X% %Y% w%BtnW% h%BtnH% vBtn%A_Index% gSet, %Menu%`n%Price%
   If (Mod(A_Index, BtnsPerColumn) = 0) {
      Y := "ym"
      X := "x+0"
   }
   Else {
      Y := "y+0"
      X := "xp"
   }
}
; ##############################################################################
Gui, 7:Margin, 10, 10
Gui, 7:Add, Text, h20 0x0200 Section, Enter new name:
Gui, 7:Add, Text, xs hp 0x0200, Enter new price:
W := BtnW - 10
Gui, 7:Add, Edit, ys w%W% h20 Limit vNewName
Gui, 7:Add, Edit, xp y+m wp h20 Limit vNewPrice
GuiControlGet, P, 7:Pos, NewPrice
Gui, 7:Add, Button, xm w80 gWriteIni, Apply
X := PX + PW - 80
Gui, 7:Add, Button, x%X% yp wp g7GuiClose, Cancel
; ##############################################################################
Gui, 2:Show , w1540 h805, Home
Return
; ##############################################################################
WriteIni:
   Gui, Submit, NoHide
   ; MsgBox, 0, New Values, Name:`t%NewName%`n`nPrice:`t%NewPrice
   GuiControl, 6:, Btn%BtnNumber%, %NewName%`n%NewPrice%
   Iniwrite, %NewName%, %IniFile%, Menu:, %BtnNumber%
   Iniwrite, %NewPrice%, %IniFile%, Price:, %BtnNumber%
   Gosub, 7GuiClose
Return
; ##############################################################################
Set:
   BtnNumber := SubStr(A_GuiControl, 4)
   GuiControlGet, BtnCaption, , %A_GuiControl%
   Split := StrSplit(BtnCaption, "`n", " ")
   GuiControl, 7:, NewName, % Split[1]
   GuiControl, 7:, NewPrice, % Split[2]
   Gui, +Disabled
   Gui, 7:Show, , Button %BtnNumber%
Return
; ##############################################################################
Home:
   Gui, 2:Hide
   Gui, 3:Hide
   Gui, 4:Hide
   Gui, 6:Hide
   Gui, 1:Show , w1540 h805, Home
return
; ##############################################################################
Sales:
   Gui, 1:Hide
   Gui, 2:Show , w1540 h805, Home
return
; ##############################################################################
Manager:
   Gui, 1:Hide
   Gui, 3:Show , w1540 h805, Manager Functions
return
; ##############################################################################
SignOn:
   gui, 2:Hide
   gui, 5:Show , w1540 h805, Order
return
; ##############################################################################
Addclerk:
   Gui, 3:Hide
   Gui, 4:Show , w1540 h805, Add Clerk
return
; ##############################################################################
SignOff:
   Gui, 5:Hide
   Gui, 2:Show , w1540 h805, Home
return
; ##############################################################################
Programming:
   gui, 3:Hide
   Gui, 6:Show , w1540 h805, Programming
Return
; ##############################################################################
1GuiClose:

   return
; ##############################################################################
2GuiClose:
ExitApp
; ##############################################################################
3GuiClose:
   Gui, 3:Hide
   Gui, 2:Show , w1540 h805, Home
return
; ##############################################################################
4GuiClose:
   Gui, 4:Hide
   Gui, 3:Show , w1540 h805, Manager Functions
return
; ##############################################################################
6GuiClose:
   Gui, 6:Hide
   Gui, 3:Show , w1540 h805, Manager Functions
return
; ##############################################################################
7GuiClose:
   Gui, 6:-Disabled
   Gui, Hide
Return
; ##############################################################################
Addclerk2:
   Gui, Submit, NoHide
   IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNum%
   if (IsClerkNumExist == "ERROR")
   {
      IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
      if (ClerkList == "ERROR")
      {
         IniWrite, |, Clerk.ini, ClerkList, ClerkList
         IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
      }
      IfNotInString, ClerkList, %ClerkName%
      {
         IniWrite, %ClerkName%, Clerk.ini, Clerk, %ClerkNum%
         IniWrite, %ClerkList%%ClerkName%|, Clerk.ini, ClerkList, ClerkList
         IniWrite, No, Online.ini, Clocked In:, %ClerkName%
         MsgBox, 262208,Attention ,%ClerkName% Created.,2
         return
      }
      else
      {
         MsgBox, 16,Attention ,%ClerkName% In Use.,2
      }
   }
   else
   MsgBox, 16,Attention ,%ClerkNum% In Use.,2
return
; ##############################################################################
ClockIn:
   Gui, Submit, NoHide
   IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNumIn%
   if (IsClerkNumExist == "ERROR")
   {
      GuiControl,, ClerkNumIn
      MsgBox, 262192,Attention ,No Such Clerk.,2
      return
   }
   if (ClerkNumIn == "")
   {
      GuiControl,, ClerkNumIn
      MsgBox, 262192,Attention ,No Such Clerk.,2
      return
   }
   IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
   if (Value == "No")
   {
      FormatTime, TimeIn,, HH:mm:ss
      FormatTime, DateIn,, ShortDate
      IniWrite, Yes, Online.ini, Clocked In:, %ClerkInName%
      IniWrite, %A_Now%, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
      IniWrite, In, Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
      GuiControl,, ClerkNumIn
      MsgBox, 262208,Attention ,%ClerkInName% Clocked In.,2
      return
   }
   else
      GuiControl,, ClerkNumIn
   MsgBox, 262192,Attention , Already Clocked In,2
return
; ##############################################################################
ClockOut:
   Gui, Submit, NoHide
   IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNumIn%
   if (IsClerkNumExist == "ERROR")
   {
      GuiControl,, ClerkNumIn
      MsgBox, 262192,Attention ,No Such Clerk.,2
      return
   }
   if (ClerkNumIn == "")
   {
      MsgBox, 262192,Attention ,No such Clerk.,2
      return
   }
   IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
   if (Value == "Yes")
   {
      FormatTime, TimeIn,, HH:mm:ss
      FormatTime, DateIn,, ShortDate
      IniRead, LastTimeClockedin, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
      RegExMatch(LastTimeClockedin, "(....)(..)(..)(..)(..)(..)",D)
      TimeClockedin := ((A_YYYY - D1) ? A_YYYY - D1 " Years, " : "") ((A_MM - D2) ? A_MM - D2 " Months, " : "") ((A_DD - D3) ? A_DD - D3 " Days, " : "") ((A_Hour - D4) ? A_Hour - D4 " Hours, " : "") ((A_Min - D5) ? A_Min - D5 " Minutes, " : "") ((A_Sec - D6) ? A_Sec - D6 " Seconds" : "")
      IniWrite, Out (%TimeClockedin%), Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
      IniWrite, No, Online.ini, Clocked In:, %ClerkInName%
      GuiControl,, ClerkNumIn
      MsgBox, 262208,Attention ,%ClerkInName% Clocked Out.,2
   }
   else
      MsgBox, 262192,Attention ,Not Clocked In.,2
   GuiControl,, ClerkNumIn
return
; ##############################################################################
AddText:
Gui, Submit, NoHide
   GuiControl, , ClerkNumIn, % ClerkNumIn A_GuiControl
Return
; ##############################################################################
AddTextMenu:
Gui, Submit, NoHide
   GuiControl, , Menu, % Menu A_GuiControl
Return
; ##############################################################################
Clear:
   ClerkNumIn := ClerkNum := ClerkName := Menu := ""
   GuiControl,, ClerkNumIn
   GuiControl,, ClerkNum
   GuiControl,, ClerkName
   GuiControl,, Menu
return
; ##############################################################################
AddTextName:
   Gui, Submit, NoHide
   GuiControl,, ClerkName, % ClerkName A_GuiControl
return
; ##############################################################################
AddTextNum:
   Gui, Submit, NoHide
   GuiControl,, ClerkNum, % ClerkNum A_GuiControl
return
; ##############################################################################
AddTextspace:
   GuiControl,, ClerkName, % ClerkName " "
Return
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

27 Jun 2019, 12:08

just me wrote:
27 Jun 2019, 11:53
Hi Dyson,

I tried to adjust the script.

Most important changes:
  • Moved settings to the top of the script.
  • Added missing adjustments for GUI 6.
  • Changed SetBtns GUI to number 7 and adjusted the code.

Code: Select all

#NoEnv
; ------------------------------------------------------------------------------
; Settings
IniFile := "Menu.ini"
BtnCount := 60       ; total number of buttons
BtnsPerColumn := 10  ; buttons per column
BtnW := 100          ; button width
BtnH := 70           ; button height
; ------------------------------------------------------------------------------
; ##############################################################################
Gui, 1:Add, Button, x50 y50 w300 h300 gSales ,Sales Mode
Gui, 1:Add, Button, x350 y50 w300 h300 gManager ,Manager Functions
; ##############################################################################
Gui, 2: Font, s16

Gui, 2:add, Edit, x1100 y10 w400 h100 vClerkNumIn Password* ;or Password#

;~ Gui, 2:Add, Picture, gHome x10 y10 w100 h-1, Home.BMP
Gui, 2:Add, Button, gHome x10 y10 w100 h100, Home

Gui, 2:add, button, gClear x10 y113 w85 h85, C
Gui, 2:Add, Button, gSignOn x95 y113 w170 h85, Sign on
Gui, 2:Add, Button, gAddText x10 y197 w85 h85, 1
Gui, 2:Add, Button, gAddText x95 y197 w85 h85, 2
Gui, 2:Add, Button, gAddText x180 y197 w85 h85, 3
gui, 2:add, button, gAddText x10 y281 w85 h85, 4
Gui, 2:Add, Button, gAddText x95 y281 w85 h85, 5
Gui, 2:Add, Button, gAddText x180 y281 w85 h85, 6
gui, 2:add, button, gAddText x10 y365 w85 h85, 7
Gui, 2:Add, Button, gAddText x95 y365 w85 h85, 8
Gui, 2:Add, Button, gAddText x180 y365 w85 h85, 9
gui, 2:add, button, gAddText x10 y449 w85 h85, 0
Gui, 2:Add, Button, gAddText x95 y449 w85 h85, 00
Gui, 2:Add, Button, gAddText x180 y449 w85 h85, .
Gui, 2:Add, Button, gClockIn x280 y381 w200 h150 ,Clock in
Gui, 2:Add, Button, gClockOut x480 y381 w200 h150 ,Clock out
Gui, 2: Font, s28
Gui, 2:add, text, x660 y10, Please sign on
Gui, 2: Font, s16
; ##############################################################################
Gui, 3:Add, Button, gHome x10 y10 w100 h100, Home
Gui, 3:Add, Button, x150 y50 w250 h250 gSales ,Sales Mode
Gui, 3:Add, Button, gProgramming x400 y50 w250 h250 ,Programming
Gui, 3:Add, Button, x650 y50 w250 h250 gAddClerk ,Add Clerk
Gui, 3:Add, Button, x900 y50 w250 h250  ,Staff Attend
Gui, 3:Add, Button, x1150 y50 w250 h250  ,Weekly Stock Report
; ############################################################
Gui, 4:Add, Button, gHome x10 y10 w100 h100, Home

gui, 4:add, edit, x150 y10 w400 h50 vClerkName
gui, 4:add, edit, x650 y10 w400 h50 vClerkNum

Gui, 4:Add, Button, gAddTextName x160 y175 w25 h25, A
Gui, 4:Add, Button, gAddTextName x240 y200 w25 h25, B
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, C
Gui, 4:Add, Button, gAddTextName x210 y175 w25 h25, D
Gui, 4:Add, Button, gAddTextName x200 y150 w25 h25, E
Gui, 4:Add, Button, gAddTextName x235 y175 w25 h25, F
Gui, 4:Add, Button, gAddTextName x260 y175 w25 h25, G
Gui, 4:Add, Button, gAddTextName x285 y175 w25 h25, H
Gui, 4:Add, Button, gAddTextName x325 y150 w25 h25, I
Gui, 4:Add, Button, gAddTextName x310 y175 w25 h25, J
Gui, 4:Add, Button, gAddTextName x335 y175 w25 h25, K
Gui, 4:Add, Button, gAddTextName x360 y175 w25 h25, L
Gui, 4:Add, Button, gAddTextName x290 y200 w25 h25, M
Gui, 4:Add, Button, gAddTextName x265 y200 w25 h25, N
Gui, 4:Add, Button, gAddTextName x350 y150 w25 h25, O
Gui, 4:Add, Button, gAddTextName x375 y150 w25 h25, P
Gui, 4:Add, Button, gAddTextName x150 y150 w25 h25, Q
Gui, 4:Add, Button, gAddTextName x225 y150 w25 h25, R
Gui, 4:Add, Button, gAddTextName x185 y175 w25 h25, S
Gui, 4:Add, Button, gAddTextName x250 y150 w25 h25, T
Gui, 4:Add, Button, gAddTextName x300 y150 w25 h25, U
Gui, 4:Add, Button, gAddTextName x220 y200 w25 h25, V
Gui, 4:Add, Button, gAddTextName x175 y150 w25 h25, W
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, X
Gui, 4:Add, Button, gAddTextName x275 y150 w25 h25, Y
Gui, 4:Add, Button, gAddTextName x170 y200 w25 h25, Z
Gui, 4:Add, Button, gAddTextspace x315 y200 w75 h25, Space

gui, 4:add, button, gClear x10 y113 w85 h85, C

Gui, 4:Add, Button, gAddTextNum x650 y197 w85 h85, 1
Gui, 4:Add, Button, gAddTextNum x734 y197 w85 h85, 2
Gui, 4:Add, Button, gAddTextNum x818 y197 w85 h85, 3
gui, 4:add, button, gAddTextNum x650 y281 w85 h85, 4
Gui, 4:Add, Button, gAddTextNum x734 y281 w85 h85, 5
Gui, 4:Add, Button, gAddTextNum x818 y281 w85 h85, 6
gui, 4:add, button, gAddTextNum x650 y365 w85 h85, 7
Gui, 4:Add, Button, gAddTextNum x734 y365 w85 h85, 8
Gui, 4:Add, Button, gAddTextNum x818 y365 w85 h85, 9
gui, 4:add, button, gAddTextNum x734 y449 w85 h85, 0

gui, 4:add, Button, gAddclerk2 x150 y300 w150 h85, Add Clerk
; ##############################################################################
gui, 5:Font, s12

Gui, 5:add, Edit, x1200 y10 w300 h370 vMenu
Gui, 5:add, Edit, x1200 y380 w300 h30 vTotal

Gui, 5:add, text, x660 y10, %ClerkName%
Gui, 5:add, button, gClear x1100 y410 w70 h70, C
Gui, 5:add, button, gAddTextMenu x1100 y480 w70 h70, 7
Gui, 5:add, button, gAddTextMenu x1100 y550 w70 h70, 4
Gui, 5:add, button, gAddTextMenu x1100 y620 w70 h70, 1
Gui, 5:add, button, gAddTextMenu x1100 y690 w70 h70, 0

Gui, 5:add, button, x1170 y410 w70 h70, X
Gui, 5:add, button, gAddTextMenu x1170 y480 w70 h70, 8
Gui, 5:add, button, gAddTextMenu x1170 y550 w70 h70, 5
Gui, 5:add, button, gAddTextMenu x1170 y620 w70 h70, 2
Gui, 5:add, button, gAddTextMenu x1170 y690 w70 h70, 00

Gui, 5:add, button, gSignOff x1240 y410 w70 h70, Sign Off
Gui, 5:add, button, gAddTextMenu x1240 y480 w70 h70, 9
Gui, 5:add, button, gAddTextMenu x1240 y550 w70 h70, 6
Gui, 5:add, button, gAddTextMenu x1240 y620 w70 h70, 3
Gui, 5:add, button, gAddTextMenu x1240 y690 w70 h70, .

Gui, 5:add, button, x1310 y410 w140 h70, Void
Gui, 5:add, button, x1310 y480 w140 h70, Refund
Gui, 5:add, button, x1310 y550 w140 h140, Payment

Gui, 5:add, button, x10 y30 w70 h70, 1
Gui, 5:add, button, x10 y100 w70 h70, 2
Gui, 5:add, button, x10 y170 w70 h70, 3
Gui, 5:add, button, x10 y240 w70 h70, 4
Gui, 5:add, button, x10 y310 w70 h70, 5
Gui, 5:add, button, x10 y380 w70 h70, 6
Gui, 5:add, button, x10 y450 w70 h70, 7
Gui, 5:add, button, x10 y520 w70 h70, 8
Gui, 5:add, button, x10 y590 w70 h70, 9
Gui, 5:add, button, x10 y660 w70 h70, 10

Gui, 5:add, button, x80 y30 w70 h70 ,11
Gui, 5:add, button, x80 y100 w70 h70, 12
Gui, 5:add, button, x80 y170 w70 h70, 13
Gui, 5:add, button, x80 y240 w70 h70, 14
Gui, 5:add, button, x80 y310 w70 h70, 15
Gui, 5:add, button, x80 y380 w70 h70, 16
Gui, 5:add, button, x80 y450 w70 h70, 17
Gui, 5:add, button, x80 y520 w70 h70, 18
Gui, 5:add, button, x80 y590 w70 h70, 19
Gui, 5:add, button, x80 y660 w70 h70, 20

Gui, 5:add, button, x150 y30 w70 h70 ,21
Gui, 5:add, button, x150 y100 w70 h70, 22
Gui, 5:add, button, x150 y170 w70 h70, 23
Gui, 5:add, button, x150 y240 w70 h70, 24
Gui, 5:add, button, x150 y310 w70 h70, 25
Gui, 5:add, button, x150 y380 w70 h70, 26
Gui, 5:add, button, x150 y450 w70 h70, 27
Gui, 5:add, button, x150 y520 w70 h70, 28
Gui, 5:add, button, x150 y590 w70 h70, 29
Gui, 5:add, button, x150 y660 w70 h70, 30

Gui, 5:add, button, x220 y30 w70 h70 ,31
Gui, 5:add, button, x220 y100 w70 h70, 32
Gui, 5:add, button, x220 y170 w70 h70, 33
Gui, 5:add, button, x220 y240 w70 h70, 34
Gui, 5:add, button, x220 y310 w70 h70, 35
Gui, 5:add, button, x220 y380 w70 h70, 36
Gui, 5:add, button, x220 y450 w70 h70, 37
Gui, 5:add, button, x220 y520 w70 h70, 38
Gui, 5:add, button, x220 y590 w70 h70, 39
Gui, 5:add, button, x220 y660 w70 h70, 40

Gui, 5:add, button, x290 y30 w70 h70 ,41
Gui, 5:add, button, x290 y100 w70 h70, 42
Gui, 5:add, button, x290 y170 w70 h70, 43
Gui, 5:add, button, x290 y240 w70 h70, 44
Gui, 5:add, button, x290 y310 w70 h70, 45
Gui, 5:add, button, x290 y380 w70 h70, 46
Gui, 5:add, button, x290 y450 w70 h70, 47
Gui, 5:add, button, x290 y520 w70 h70, 48
Gui, 5:add, button, x290 y590 w70 h70, 49
Gui, 5:add, button, x290 y660 w70 h70, 50

Gui, 5:add, button, x360 y30 w70 h70 ,51
Gui, 5:add, button, x360 y100 w70 h70, 52
Gui, 5:add, button, x360 y170 w70 h70, 53
Gui, 5:add, button, x360 y240 w70 h70, 54
Gui, 5:add, button, x360 y310 w70 h70, 55
Gui, 5:add, button, x360 y380 w70 h70, 56
Gui, 5:add, button, x360 y450 w70 h70, 57
Gui, 5:add, button, x360 y520 w70 h70, 58
Gui, 5:add, button, x360 y590 w70 h70, 59
Gui, 5:add, button, x360 y660 w70 h70, 60
; ##############################################################################
Gui, 6:Add, Button, gHome x1460 y10 w70 h70, Home
Y := "ym"
X := "xm"
Loop, %BtnCount% {
   IniRead, Menu, %IniFile%, Menu:, %A_Index%, %A_Index%
   IniRead, Price, %IniFile%, Price:, %A_Index%, %A_Space%
   Gui, 6:Add, Button, %X% %Y% w%BtnW% h%BtnH% vBtn%A_Index% gSet, %Menu%`n%Price%
   If (Mod(A_Index, BtnsPerColumn) = 0) {
      Y := "ym"
      X := "x+0"
   }
   Else {
      Y := "y+0"
      X := "xp"
   }
}
; ##############################################################################
Gui, 7:Margin, 10, 10
Gui, 7:Add, Text, h20 0x0200 Section, Enter new name:
Gui, 7:Add, Text, xs hp 0x0200, Enter new price:
W := BtnW - 10
Gui, 7:Add, Edit, ys w%W% h20 Limit vNewName
Gui, 7:Add, Edit, xp y+m wp h20 Limit vNewPrice
GuiControlGet, P, 7:Pos, NewPrice
Gui, 7:Add, Button, xm w80 gWriteIni, Apply
X := PX + PW - 80
Gui, 7:Add, Button, x%X% yp wp g7GuiClose, Cancel
; ##############################################################################
Gui, 2:Show , w1540 h805, Home
Return
; ##############################################################################
WriteIni:
   Gui, Submit, NoHide
   ; MsgBox, 0, New Values, Name:`t%NewName%`n`nPrice:`t%NewPrice
   GuiControl, 6:, Btn%BtnNumber%, %NewName%`n%NewPrice%
   Iniwrite, %NewName%, %IniFile%, Menu:, %BtnNumber%
   Iniwrite, %NewPrice%, %IniFile%, Price:, %BtnNumber%
   Gosub, 7GuiClose
Return
; ##############################################################################
Set:
   BtnNumber := SubStr(A_GuiControl, 4)
   GuiControlGet, BtnCaption, , %A_GuiControl%
   Split := StrSplit(BtnCaption, "`n", " ")
   GuiControl, 7:, NewName, % Split[1]
   GuiControl, 7:, NewPrice, % Split[2]
   Gui, +Disabled
   Gui, 7:Show, , Button %BtnNumber%
Return
; ##############################################################################
Home:
   Gui, 2:Hide
   Gui, 3:Hide
   Gui, 4:Hide
   Gui, 6:Hide
   Gui, 1:Show , w1540 h805, Home
return
; ##############################################################################
Sales:
   Gui, 1:Hide
   Gui, 2:Show , w1540 h805, Home
return
; ##############################################################################
Manager:
   Gui, 1:Hide
   Gui, 3:Show , w1540 h805, Manager Functions
return
; ##############################################################################
SignOn:
   gui, 2:Hide
   gui, 5:Show , w1540 h805, Order
return
; ##############################################################################
Addclerk:
   Gui, 3:Hide
   Gui, 4:Show , w1540 h805, Add Clerk
return
; ##############################################################################
SignOff:
   Gui, 5:Hide
   Gui, 2:Show , w1540 h805, Home
return
; ##############################################################################
Programming:
   gui, 3:Hide
   Gui, 6:Show , w1540 h805, Programming
Return
; ##############################################################################
1GuiClose:

   return
; ##############################################################################
2GuiClose:
ExitApp
; ##############################################################################
3GuiClose:
   Gui, 3:Hide
   Gui, 2:Show , w1540 h805, Home
return
; ##############################################################################
4GuiClose:
   Gui, 4:Hide
   Gui, 3:Show , w1540 h805, Manager Functions
return
; ##############################################################################
6GuiClose:
   Gui, 6:Hide
   Gui, 3:Show , w1540 h805, Manager Functions
return
; ##############################################################################
7GuiClose:
   Gui, 6:-Disabled
   Gui, Hide
Return
; ##############################################################################
Addclerk2:
   Gui, Submit, NoHide
   IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNum%
   if (IsClerkNumExist == "ERROR")
   {
      IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
      if (ClerkList == "ERROR")
      {
         IniWrite, |, Clerk.ini, ClerkList, ClerkList
         IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
      }
      IfNotInString, ClerkList, %ClerkName%
      {
         IniWrite, %ClerkName%, Clerk.ini, Clerk, %ClerkNum%
         IniWrite, %ClerkList%%ClerkName%|, Clerk.ini, ClerkList, ClerkList
         IniWrite, No, Online.ini, Clocked In:, %ClerkName%
         MsgBox, 262208,Attention ,%ClerkName% Created.,2
         return
      }
      else
      {
         MsgBox, 16,Attention ,%ClerkName% In Use.,2
      }
   }
   else
   MsgBox, 16,Attention ,%ClerkNum% In Use.,2
return
; ##############################################################################
ClockIn:
   Gui, Submit, NoHide
   IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNumIn%
   if (IsClerkNumExist == "ERROR")
   {
      GuiControl,, ClerkNumIn
      MsgBox, 262192,Attention ,No Such Clerk.,2
      return
   }
   if (ClerkNumIn == "")
   {
      GuiControl,, ClerkNumIn
      MsgBox, 262192,Attention ,No Such Clerk.,2
      return
   }
   IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
   if (Value == "No")
   {
      FormatTime, TimeIn,, HH:mm:ss
      FormatTime, DateIn,, ShortDate
      IniWrite, Yes, Online.ini, Clocked In:, %ClerkInName%
      IniWrite, %A_Now%, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
      IniWrite, In, Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
      GuiControl,, ClerkNumIn
      MsgBox, 262208,Attention ,%ClerkInName% Clocked In.,2
      return
   }
   else
      GuiControl,, ClerkNumIn
   MsgBox, 262192,Attention , Already Clocked In,2
return
; ##############################################################################
ClockOut:
   Gui, Submit, NoHide
   IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNumIn%
   if (IsClerkNumExist == "ERROR")
   {
      GuiControl,, ClerkNumIn
      MsgBox, 262192,Attention ,No Such Clerk.,2
      return
   }
   if (ClerkNumIn == "")
   {
      MsgBox, 262192,Attention ,No such Clerk.,2
      return
   }
   IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
   if (Value == "Yes")
   {
      FormatTime, TimeIn,, HH:mm:ss
      FormatTime, DateIn,, ShortDate
      IniRead, LastTimeClockedin, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
      RegExMatch(LastTimeClockedin, "(....)(..)(..)(..)(..)(..)",D)
      TimeClockedin := ((A_YYYY - D1) ? A_YYYY - D1 " Years, " : "") ((A_MM - D2) ? A_MM - D2 " Months, " : "") ((A_DD - D3) ? A_DD - D3 " Days, " : "") ((A_Hour - D4) ? A_Hour - D4 " Hours, " : "") ((A_Min - D5) ? A_Min - D5 " Minutes, " : "") ((A_Sec - D6) ? A_Sec - D6 " Seconds" : "")
      IniWrite, Out (%TimeClockedin%), Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
      IniWrite, No, Online.ini, Clocked In:, %ClerkInName%
      GuiControl,, ClerkNumIn
      MsgBox, 262208,Attention ,%ClerkInName% Clocked Out.,2
   }
   else
      MsgBox, 262192,Attention ,Not Clocked In.,2
   GuiControl,, ClerkNumIn
return
; ##############################################################################
AddText:
Gui, Submit, NoHide
   GuiControl, , ClerkNumIn, % ClerkNumIn A_GuiControl
Return
; ##############################################################################
AddTextMenu:
Gui, Submit, NoHide
   GuiControl, , Menu, % Menu A_GuiControl
Return
; ##############################################################################
Clear:
   ClerkNumIn := ClerkNum := ClerkName := Menu := ""
   GuiControl,, ClerkNumIn
   GuiControl,, ClerkNum
   GuiControl,, ClerkName
   GuiControl,, Menu
return
; ##############################################################################
AddTextName:
   Gui, Submit, NoHide
   GuiControl,, ClerkName, % ClerkName A_GuiControl
return
; ##############################################################################
AddTextNum:
   Gui, Submit, NoHide
   GuiControl,, ClerkNum, % ClerkNum A_GuiControl
return
; ##############################################################################
AddTextspace:
   GuiControl,, ClerkName, % ClerkName " "
Return
This works and stops the script crashing, which is brilliant, I will now play around with the code for the gui 5 page to hopefully be able to reflect the item and price into the order :D
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

28 Jun 2019, 08:18

ok so ive played around a little bit, and this is the code I have got:

Code: Select all

gui, 5:Font, s12

Gui, 5:add, Edit, x1200 y10 w300 h370 vMenu
Gui, 5:add, Edit, x1400 y380 w100 h30 vTotal
Gui, 5:add, text, x1350 y385, Total:

gui, 5:Font, s26
Gui, 5:add, text, x750 y10, Clerk
gui, 5:Font, s12

Gui, 5:add, button, gClear x1100 y410 w70 h70, C
Gui, 5:add, button, gAddTextMenu x1100 y480 w70 h70, 7
Gui, 5:add, button, gAddTextMenu x1100 y550 w70 h70, 4
Gui, 5:add, button, gAddTextMenu x1100 y620 w70 h70, 1
Gui, 5:add, button, gAddTextMenu x1100 y690 w70 h70, 0

Gui, 5:add, button, x1170 y410 w70 h70, X
Gui, 5:add, button, gAddTextMenu x1170 y480 w70 h70, 8
Gui, 5:add, button, gAddTextMenu x1170 y550 w70 h70, 5
Gui, 5:add, button, gAddTextMenu x1170 y620 w70 h70, 2
Gui, 5:add, button, gAddTextMenu x1170 y690 w70 h70, 00

Gui, 5:add, button, gSignOff x1240 y410 w70 h70, Sign Off
Gui, 5:add, button, gAddTextMenu x1240 y480 w70 h70, 9
Gui, 5:add, button, gAddTextMenu x1240 y550 w70 h70, 6
Gui, 5:add, button, gAddTextMenu x1240 y620 w70 h70, 3
Gui, 5:add, button, gAddTextMenu x1240 y690 w70 h70, .

Gui, 5:add, button, x1310 y410 w140 h70, Void
Gui, 5:add, button, x1310 y480 w140 h70, Refund
Gui, 5:add, button, x1310 y620 w140 h140, Payment

Y := "ym"
X := "xm"
Loop, %BtnCount% {
   IniRead, Menu, %IniFile%, Menu:, %A_Index%, %A_Index%
   IniRead, Price, %IniFile%, Price:, %A_Index%, %A_Space%
   Gui, 5:Add, Button, %X% %Y% w%BtnW% h%BtnH% vBtn%A_Index% gAddToOrder, %Menu%
   If (Mod(A_Index, BtnsPerColumn) = 0) {
      Y := "ym"
      X := "x+0"
   }
   Else {
      Y := "y+0"
      X := "xp"
   }
}
which brings this up:
Untitled.png
Untitled.png (123.99 KiB) Viewed 695 times
this is how it should look, but when i press the buttons it doesnt quite trigger correctly, like if i press chips it should move chips and the price into the top editbox, and just the price into the editbox underneath, i also need it to be able to add another button value to the top edit box instead it just replaces it, and the bottom editbox i will need it to calculate to add the 2 prices together, ive played around with it a fair bit but this is the closest i can get it (stilll missing a bit i know) anyone able to correct me here or guide me in the right direction? this is only the code from gui 5 page the rest of the script is still as above

Thanks in advance
just me
Posts: 6425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

28 Jun 2019, 09:07

Hi Dyson,

the AddToOrder subroutine is missing in your code.

In the meantime, I played with the INI file. I tried a new design using on section for each button (number) holding two entries Menu and Price.

Code: Select all

[1]
Menu=Chips
Price=1.50
[2]
Menu=Cod
Price=7.50
...
[60]
Menu=60
Price=
I read this INI into an array at the start of the script. Are you interested?
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

28 Jun 2019, 09:36

just me wrote:
28 Jun 2019, 09:07
Hi Dyson,

the AddToOrder subroutine is missing in your code.

In the meantime, I played with the INI file. I tried a new design using on section for each button (number) holding two entries Menu and Price.

Code: Select all

[1]
Menu=Chips
Price=1.50
[2]
Menu=Cod
Price=7.50
...
[60]
Menu=60
Price=
I read this INI into an array at the start of the script. Are you interested?
yes please :D sorry i forgot to post the AddToOrder routine here is what i have:

Code: Select all

AddToOrder:
Y := "ym"
X := "xm"
   IniRead, Menu, %IniFile%, Menu:, %A_Index%, %A_Index%
   IniRead, Price, %IniFile%, Price:, %A_Index%, %A_Space%
   GuiControl, , Menu, % "%Menu% 		%Price%"
Return
just me
Posts: 6425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

29 Jun 2019, 08:13

Hi Dyson,

I'm in a hurry, so I post some code without further comments:

Code: Select all

#NoEnv
; ------------------------------------------------------------------------------
; Settings
IniFile := "Menu.ini"
BtnCount := 60       ; total number of buttons
BtnsPerColumn := 10  ; buttons per column
BtnW := 100          ; button width
BtnH := 70           ; button height
; ------------------------------------------------------------------------------
; Read  the INI file into an array
Menus := []
Loop, %BtnCount%
{
   IniRead, Menu, %IniFile%, %A_Index%, Menu, %A_Index%
   IniRead, Price, %IniFile%, %A_Index%, Price, %A_Space%
   Menus[A_Index] := {Name: Menu, Price: Price}
}
; ##############################################################################
Gui, 1:Add, Button, x50 y50 w300 h300 gSales ,Sales Mode
Gui, 1:Add, Button, x350 y50 w300 h300 gManager ,Manager Functions
; ##############################################################################
Gui, 2:Font, s16

Gui, 2:Add, Edit, x1100 y10 w400 h100 vClerkNumIn Password* ;or Password#

;~ Gui, 2:Add, Picture, gHome x10 y10 w100 h-1, Home.BMP
Gui, 2:Add, Button, gHome x10 y10 w100 h100, Home

Gui, 2:Add, button, gClear x10 y113 w85 h85, C
Gui, 2:Add, Button, gSignOn x95 y113 w170 h85, Sign on
Gui, 2:Add, Button, gAddText x10 y197 w85 h85, 1
Gui, 2:Add, Button, gAddText x95 y197 w85 h85, 2
Gui, 2:Add, Button, gAddText x180 y197 w85 h85, 3
Gui, 2:Add, button, gAddText x10 y281 w85 h85, 4
Gui, 2:Add, Button, gAddText x95 y281 w85 h85, 5
Gui, 2:Add, Button, gAddText x180 y281 w85 h85, 6
Gui, 2:Add, button, gAddText x10 y365 w85 h85, 7
Gui, 2:Add, Button, gAddText x95 y365 w85 h85, 8
Gui, 2:Add, Button, gAddText x180 y365 w85 h85, 9
Gui, 2:Add, button, gAddText x10 y449 w85 h85, 0
Gui, 2:Add, Button, gAddText x95 y449 w85 h85, 00
Gui, 2:Add, Button, gAddText x180 y449 w85 h85, .
Gui, 2:Add, Button, gClockIn x280 y381 w200 h150 ,Clock in
Gui, 2:Add, Button, gClockOut x480 y381 w200 h150 ,Clock out
Gui, 2:Font, s28
Gui, 2:Add, text, x660 y10, Please sign on
Gui, 2:Font, s16
; ##############################################################################
Gui, 3:Add, Button, gHome x10 y10 w100 h100, Home
Gui, 3:Add, Button, x150 y50 w250 h250 gSales ,Sales Mode
Gui, 3:Add, Button, gProgramming x400 y50 w250 h250 ,Programming
Gui, 3:Add, Button, x650 y50 w250 h250 gAddClerk ,Add Clerk
Gui, 3:Add, Button, x900 y50 w250 h250  ,Staff Attend
Gui, 3:Add, Button, x1150 y50 w250 h250  ,Weekly Stock Report
; ############################################################
Gui, 4:Add, Button, gHome x10 y10 w100 h100, Home

Gui, 4:Add, edit, x150 y10 w400 h50 vClerkName
Gui, 4:Add, edit, x650 y10 w400 h50 vClerkNum

Gui, 4:Add, Button, gAddTextName x160 y175 w25 h25, A
Gui, 4:Add, Button, gAddTextName x240 y200 w25 h25, B
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, C
Gui, 4:Add, Button, gAddTextName x210 y175 w25 h25, D
Gui, 4:Add, Button, gAddTextName x200 y150 w25 h25, E
Gui, 4:Add, Button, gAddTextName x235 y175 w25 h25, F
Gui, 4:Add, Button, gAddTextName x260 y175 w25 h25, G
Gui, 4:Add, Button, gAddTextName x285 y175 w25 h25, H
Gui, 4:Add, Button, gAddTextName x325 y150 w25 h25, I
Gui, 4:Add, Button, gAddTextName x310 y175 w25 h25, J
Gui, 4:Add, Button, gAddTextName x335 y175 w25 h25, K
Gui, 4:Add, Button, gAddTextName x360 y175 w25 h25, L
Gui, 4:Add, Button, gAddTextName x290 y200 w25 h25, M
Gui, 4:Add, Button, gAddTextName x265 y200 w25 h25, N
Gui, 4:Add, Button, gAddTextName x350 y150 w25 h25, O
Gui, 4:Add, Button, gAddTextName x375 y150 w25 h25, P
Gui, 4:Add, Button, gAddTextName x150 y150 w25 h25, Q
Gui, 4:Add, Button, gAddTextName x225 y150 w25 h25, R
Gui, 4:Add, Button, gAddTextName x185 y175 w25 h25, S
Gui, 4:Add, Button, gAddTextName x250 y150 w25 h25, T
Gui, 4:Add, Button, gAddTextName x300 y150 w25 h25, U
Gui, 4:Add, Button, gAddTextName x220 y200 w25 h25, V
Gui, 4:Add, Button, gAddTextName x175 y150 w25 h25, W
Gui, 4:Add, Button, gAddTextName x195 y200 w25 h25, X
Gui, 4:Add, Button, gAddTextName x275 y150 w25 h25, Y
Gui, 4:Add, Button, gAddTextName x170 y200 w25 h25, Z
Gui, 4:Add, Button, gAddTextspace x315 y200 w75 h25, Space

Gui, 4:Add, button, gClear x10 y113 w85 h85, C

Gui, 4:Add, Button, gAddTextNum x650 y197 w85 h85, 1
Gui, 4:Add, Button, gAddTextNum x734 y197 w85 h85, 2
Gui, 4:Add, Button, gAddTextNum x818 y197 w85 h85, 3
Gui, 4:Add, button, gAddTextNum x650 y281 w85 h85, 4
Gui, 4:Add, Button, gAddTextNum x734 y281 w85 h85, 5
Gui, 4:Add, Button, gAddTextNum x818 y281 w85 h85, 6
Gui, 4:Add, button, gAddTextNum x650 y365 w85 h85, 7
Gui, 4:Add, Button, gAddTextNum x734 y365 w85 h85, 8
Gui, 4:Add, Button, gAddTextNum x818 y365 w85 h85, 9
Gui, 4:Add, button, gAddTextNum x734 y449 w85 h85, 0

Gui, 4:Add, Button, gAddclerk2 x150 y300 w150 h85, Add Clerk
; ##############################################################################
Gui,5:Font, s12

Gui, 5:Add, Edit, x1200 y10 w300 h370 vMenu hwndHMENU
Gui, 5:Add, Edit, x1400 y380 w100 h30 vTotal Right, 0.00
Gui, 5:Add, text, x1350 y385, Total:

Gui, 5:Font, s26
Gui, 5:Add, text, x750 y10, Clerk
Gui, 5:Font, s12

Gui, 5:Add, button, gClear x1100 y410 w70 h70, C
Gui, 5:Add, button, gAddTextMenu x1100 y480 w70 h70, 7
Gui, 5:Add, button, gAddTextMenu x1100 y550 w70 h70, 4
Gui, 5:Add, button, gAddTextMenu x1100 y620 w70 h70, 1
Gui, 5:Add, button, gAddTextMenu x1100 y690 w70 h70, 0

Gui, 5:Add, button, x1170 y410 w70 h70, X
Gui, 5:Add, button, gAddTextMenu x1170 y480 w70 h70, 8
Gui, 5:Add, button, gAddTextMenu x1170 y550 w70 h70, 5
Gui, 5:Add, button, gAddTextMenu x1170 y620 w70 h70, 2
Gui, 5:Add, button, gAddTextMenu x1170 y690 w70 h70, 00

Gui, 5:Add, button, gSignOff x1240 y410 w70 h70, Sign Off
Gui, 5:Add, button, gAddTextMenu x1240 y480 w70 h70, 9
Gui, 5:Add, button, gAddTextMenu x1240 y550 w70 h70, 6
Gui, 5:Add, button, gAddTextMenu x1240 y620 w70 h70, 3
Gui, 5:Add, button, gAddTextMenu x1240 y690 w70 h70, .

Gui, 5:Add, button, x1310 y410 w140 h70, Void
Gui, 5:Add, button, x1310 y480 w140 h70, Refund
Gui, 5:Add, button, x1310 y620 w140 h140, Payment

Y := "ym"
X := "xm"
Loop, %BtnCount% {
   Gui, 5:Add, Button, %X% %Y% w%BtnW% h%BtnH% vBtn%A_Index% gAddToOrder, % Menus[A_Index, "Name"]
   If (Mod(A_Index, BtnsPerColumn) = 0) {
      Y := "ym"
      X := "x+0"
   }
   Else {
      Y := "y+0"
      X := "xp"
   }
}
; ##############################################################################
Gui, 6:Add, Button, gHome x1460 y10 w70 h70, Home
Y := "ym"
X := "xm"
Loop, %BtnCount% {
   Gui, 6:Add, Button, %X% %Y% w%BtnW% h%BtnH% vBtn%A_Index% gSet, % Menus[A_Index, "Name"]
   If (Mod(A_Index, BtnsPerColumn) = 0) {
      Y := "ym"
      X := "x+0"
   }
   Else {
      Y := "y+0"
      X := "xp"
   }
}
; ##############################################################################
Gui, 7:Margin, 10, 10
Gui, 7:Add, Text, h20 0x0200 Section, Enter new name:
Gui, 7:Add, Text, xs hp 0x0200, Enter new price:
W := BtnW - 10
Gui, 7:Add, Edit, ys w%W% h20 Limit vNewName
Gui, 7:Add, Edit, xp y+m wp h20 Limit vNewPrice
GuiControlGet, P, 7:Pos, NewPrice
Gui, 7:Add, Button, xm w80 gWriteIni, Apply
X := PX + PW - 80
Gui, 7:Add, Button, x%X% yp wp g7GuiClose, Cancel
; ##############################################################################
Gui, 2:Show, w1540 h805, Home
Return
; ##############################################################################
AddToOrder:
   BtnNumber := SubStr(A_GuiControl, 4)
   Menu := Menus[BtnNumber, "Name"]
   If (Menu = BtnNumber) {
      MsgBox, 16, Error!, No menu stored for button %BtnNumber%!
      Return
   }
   Price := Menus[BtnNumber, "Price"]
   GuiControlGet, Total
   Total += Price
   GuiControl, , Total, % Format("{:0.2f}", Total)
   DllCall("SendMessage", "Ptr", HMENU, "UInt", 0x00B1, "Ptr", -1, "Ptr", -2) ; EM_SETSEL
   DllCall("SendMessage", "Ptr", HMENU, "UInt", 0x00C2, "Ptr", True, "Str", Menu . " - " . Price) ; EM_REPLACESEL
Return
; ##############################################################################
WriteIni:
   Gui, Submit, NoHide
   ; MsgBox, 0, New Values, Name:`t%NewName%`n`nPrice:`t%NewPrice
   GuiControl, 6:, Btn%BtnNumber%, %NewName%
   Iniwrite, %NewName%, %IniFile%, %BtnNumber%, Menu
   Iniwrite, %NewPrice%, %IniFile%, %BtnNumber%, Price
   Menus[BtnNumber, "Name"] := NewName
   Menus[BtnNumber, "Price"] := NewPrice
   Gosub, 7GuiClose
Return
; ##############################################################################
Set:
   BtnNumber := SubStr(A_GuiControl, 4)
   GuiControl, 7:, NewName, % Menus[BtnNumber, "Name"]
   GuiControl, 7:, NewPrice, % Menus[BtnNumber, "Price"]
   Gui, +Disabled
   Gui, 7:Show, , Button %BtnNumber%
Return
; ##############################################################################
Home:
   Gui, 2:Hide
   Gui, 3:Hide
   Gui, 4:Hide
   Gui, 6:Hide
   Gui, 1:Show, w1540 h805, Home
return
; ##############################################################################
Sales:
   Gui, 1:Hide
   Gui, 2:Show, w1540 h805, Home
return
; ##############################################################################
Manager:
   Gui, 1:Hide
   Gui, 3:Show, w1540 h805, Manager Functions
return
; ##############################################################################
SignOn:
   Gui, 2:Hide
   Gui, 5:Show, w1540 h805, Order
return
; ##############################################################################
Addclerk:
   Gui, 3:Hide
   Gui, 4:Show, w1540 h805, Add Clerk
return
; ##############################################################################
SignOff:
   Gui, 5:Hide
   Gui, 2:Show, w1540 h805, Home
return
; ##############################################################################
Programming:
   Gui, 3:Hide
   Gui, 6:Show, w1540 h805, Programming
Return
; ##############################################################################
1GuiClose:
   Gui, 1:Hide
   Gui, 2:Show, w1540 h805, Home
Return
; ##############################################################################
2GuiClose:
ExitApp
; ##############################################################################
3GuiClose:
   Gui, 3:Hide
   Gui, 2:Show, w1540 h805, Home
return
; ##############################################################################
4GuiClose:
   Gui, 4:Hide
   Gui, 3:Show, w1540 h805, Manager Functions
return
; ##############################################################################
6GuiClose:
   Gui, 6:Hide
   Gui, 3:Show, w1540 h805, Manager Functions
return
; ##############################################################################
7GuiClose:
   Gui, 6:-Disabled
   Gui, Hide
Return
; ##############################################################################
Addclerk2:
   Gui, Submit, NoHide
   IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNum%
   if (IsClerkNumExist == "ERROR")
   {
      IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
      if (ClerkList == "ERROR")
      {
         IniWrite, |, Clerk.ini, ClerkList, ClerkList
         IniRead, ClerkList, Clerk.ini, ClerkList, ClerkList
      }
      IfNotInString, ClerkList, %ClerkName%
      {
         IniWrite, %ClerkName%, Clerk.ini, Clerk, %ClerkNum%
         IniWrite, %ClerkList%%ClerkName%|, Clerk.ini, ClerkList, ClerkList
         IniWrite, No, Online.ini, Clocked In:, %ClerkName%
         MsgBox, 262208,Attention ,%ClerkName% Created.,2
         return
      }
      else
      {
         MsgBox, 16,Attention ,%ClerkName% In Use.,2
      }
   }
   else
   MsgBox, 16,Attention ,%ClerkNum% In Use.,2
return
; ##############################################################################
ClockIn:
   Gui, Submit, NoHide
   IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNumIn%
   if (IsClerkNumExist == "ERROR")
   {
      GuiControl,, ClerkNumIn
      MsgBox, 262192,Attention ,No Such Clerk.,2
      return
   }
   if (ClerkNumIn == "")
   {
      GuiControl,, ClerkNumIn
      MsgBox, 262192,Attention ,No Such Clerk.,2
      return
   }
   IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
   if (Value == "No")
   {
      FormatTime, TimeIn,, HH:mm:ss
      FormatTime, DateIn,, ShortDate
      IniWrite, Yes, Online.ini, Clocked In:, %ClerkInName%
      IniWrite, %A_Now%, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
      IniWrite, In, Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
      GuiControl,, ClerkNumIn
      MsgBox, 262208,Attention ,%ClerkInName% Clocked In.,2
      return
   }
   else
      GuiControl,, ClerkNumIn
   MsgBox, 262192,Attention , Already Clocked In,2
return
; ##############################################################################
ClockOut:
   Gui, Submit, NoHide
   IniRead, IsClerkNumExist, Clerk.ini, Clerk, %ClerkNumIn%
   if (IsClerkNumExist == "ERROR")
   {
      GuiControl,, ClerkNumIn
      MsgBox, 262192,Attention ,No Such Clerk.,2
      return
   }
   if (ClerkNumIn == "")
   {
      MsgBox, 262192,Attention ,No such Clerk.,2
      return
   }
   IniRead, ClerkInName, Clerk.ini, Clerk, %ClerkNumIn%
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%
   if (Value == "Yes")
   {
      FormatTime, TimeIn,, HH:mm:ss
      FormatTime, DateIn,, ShortDate
      IniRead, LastTimeClockedin, Online.ini, Clocked In:, %ClerkInName% Last Time Clocked in
      RegExMatch(LastTimeClockedin, "(....)(..)(..)(..)(..)(..)",D)
      TimeClockedin := ((A_YYYY - D1) ? A_YYYY - D1 " Years, " : "") ((A_MM - D2) ? A_MM - D2 " Months, " : "") ((A_DD - D3) ? A_DD - D3 " Days, " : "") ((A_Hour - D4) ? A_Hour - D4 " Hours, " : "") ((A_Min - D5) ? A_Min - D5 " Minutes, " : "") ((A_Sec - D6) ? A_Sec - D6 " Seconds" : "")
      IniWrite, Out (%TimeClockedin%), Hours.ini, %ClerkInName% - %DateIn%, %TimeIn% Clocked
      IniWrite, No, Online.ini, Clocked In:, %ClerkInName%
      GuiControl,, ClerkNumIn
      MsgBox, 262208,Attention ,%ClerkInName% Clocked Out.,2
   }
   else
      MsgBox, 262192,Attention ,Not Clocked In.,2
   GuiControl,, ClerkNumIn
return
; ##############################################################################
AddText:
Gui, Submit, NoHide
   GuiControl, , ClerkNumIn, % ClerkNumIn A_GuiControl
Return
; ##############################################################################
AddTextMenu:
Gui, Submit, NoHide
   GuiControl, , Menu, % Menu A_GuiControl
Return
; ##############################################################################
Clear:
   ClerkNumIn := ClerkNum := ClerkName := Menu := ""
   GuiControl,, ClerkNumIn
   GuiControl,, ClerkNum
   GuiControl,, ClerkName
   GuiControl,, Menu
return
; ##############################################################################
AddTextName:
   Gui, Submit, NoHide
   GuiControl,, ClerkName, % ClerkName A_GuiControl
return
; ##############################################################################
AddTextNum:
   Gui, Submit, NoHide
   GuiControl,, ClerkNum, % ClerkNum A_GuiControl
return
; ##############################################################################
AddTextspace:
   GuiControl,, ClerkName, % ClerkName " "
Return
If you have questions, I'll answer them later.
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

29 Jun 2019, 09:38

this is almost perfect to what I need it to be, ive been playing around trying to add a new line each time the buttons are pressed, for example with this code:

Code: Select all

AddToOrder:
   BtnNumber := SubStr(A_GuiControl, 4)
   Menu := Menus[BtnNumber, "Name"]
   If (Menu = BtnNumber) {
      MsgBox, 16, Error!, No menu stored for button %BtnNumber%!
      Return
   }
   Price := Menus[BtnNumber, "Price"]
   GuiControlGet, Total
   Total += Price
   GuiControl, , Total, % Format("{:0.2f}", Total)
   DllCall("SendMessage", "Ptr", HMENU, "UInt", 0x00B1, "Ptr", -1, "Ptr", -2) ; EM_SETSEL
   DllCall("SendMessage", "Ptr", HMENU, "UInt", 0x00C2, "Ptr", True, "Str", Menu . "-" . Price) ; EM_REPLACESEL 
Return
The layout in the editbox is: Chips-2.10Chips2.10 When i need to to be :
Chips 2.10
chips 2.10
Etc etc

ive tried Added {Enter} and `r but no luck maybe im adding it in the wrong place?

Also is it possible for example if i had a button labled "Pies" and it was pressed it would still come up in the edit box but a msgbox comes up with 3 buttons with diffrent lables so the lay out could be changed,eg:

Chips-2.10
Pie-3.05
(Steak and Kidney)
sauce sachet 0.20
(Ketchup)


Total: 5.35
(this is so i can save duplicate buttons on the programming, i understand i would need to change the programming layout to maybe have an add list check box when checked a value window highlights where u can input a number of menues to add to the list how ever many you press another box pops up where u can write the list)
once pressed in the order screen the list will pop up and you can click which variable name needed

if im asking too much please tell me i dont want to feel like im getting everyone else to do my work as i realise it may come across that way, im still learning myself and the more and more i read your guys code in the format of a script im basically describing the better i can understand it etc.

Yet again, Thanks in advance
just me
Posts: 6425
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

30 Jun 2019, 05:06

Hi Dyson,

we're expecting about 38°C in Berlin today and are straight on the way. That's rather hot for Germany, so here's jst a short first answer:

Adding line feeds:

Code: Select all

   DllCall("SendMessage", "Ptr", HMENU, "UInt", 0x00C2, "Ptr", True, "Str", Menu . " - " . Price . "`n") ; EM_REPLACESEL
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

30 Jun 2019, 05:10

I missed the quotes around the ‘n ( am using phone does t have the right quotes lol)
Dyson
Posts: 45
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

01 Jul 2019, 02:17

ok so, today im thinking about adding thos extra options I was talking about,

Code: Select all

WriteIni:
   Gui, Submit, NoHide
   ; MsgBox, 0, New Values, Name:`t%NewName%`n`nPrice:`t%NewPrice
   GuiControl, 6:, Btn%BtnNumber%, %NewName%
   Iniwrite, %NewName%, %IniFile%, %BtnNumber%, Menu
   Iniwrite, %NewPrice%, %IniFile%, %BtnNumber%, Price
   Menus[BtnNumber, "Name"] := NewName
   Menus[BtnNumber, "Price"] := NewPrice
   Gosub, 7GuiClose
Return

basically when this brings up the option to change the new values, I need to add an option for extras, for example if I was to add a button for pies, and im in the order menu I can press the pies button and another msgbox can appear asking what flavour,


Eg: when setting the new name and price a check box can be available to add extras? when checked it highlights another section where u can set a numerical value (eg; 3) when you press apply ANOTHER msgbox appears with 3 lines to set options

line1: Steak and kidney
Line2: Chicken and Mushroom
Line3: Beef and Onion

When pressed in order screen (gui5) the AddToOrder command with send the option "Pie - Price" then under it "Chicken and Mushroom" (if selected)

If when setting the buttons the box isn't checked it stays how it is Hope im explaining this right?

so if the button is checked and the numercal value is set:

Code: Select all

   Iniwrite, Yes, %IniFile%, %BtnNumber%, Extras
   Iniwrite, %ExtraCount%, %IniFile%, %BtnNumber%, Extracount

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], reluct, swagfag and 169 guests