Lable buttons via Ini File

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Dyson
Posts: 46
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

10 Jul 2019, 04:38

with my clocking in system, the ini file layout it:

Code: Select all

[Dyson]
10/07/2019 - 09:51:34 Clocked=In
10/07/2019 - 09:51:55 Clocked=Out (21 Seconds)
How would I make it so the 21 seconds can accumulate each time I clock out, so like adding a total clocked in time to the section?

Code: Select all

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
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

10 Jul 2019, 05:39

... so like adding a total clocked in time to the section?
Why don't you want to add a Total key to the section? (IMO, it would be the easiest way.)

Code: Select all

[Dyson]
Total=21
10/07/2019 - 09:51:34 Clocked=In
10/07/2019 - 09:51:55 Clocked=Out (21 Seconds)
Dyson
Posts: 46
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

10 Jul 2019, 09:16

just me wrote:
10 Jul 2019, 05:39
... so like adding a total clocked in time to the section?
Why don't you want to add a Total key to the section? (IMO, it would be the easiest way.)

Code: Select all

[Dyson]
Total=21
10/07/2019 - 09:51:34 Clocked=In
10/07/2019 - 09:51:55 Clocked=Out (21 Seconds)
Yea that’s how i mean but more like
Total=00:00:21
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

13 Jul 2019, 04:24

Hi, it took some time but you might want to try:

Code: Select all

#NoEnv
SetWorkingDir, %A_ScriptDir%
ClerkInName := "Dyson"
; Testing ------------------------------------------------
IniRead, Ini, Hours.ini, Dyson
GuiControl, , IniContent, %Ini%
; Testing ------------------------------------------------
Gui, Add, Edit, w300 r10 vIniContent, %Ini%
Gui, Add, Button, wp gClockIn, Clock in
Gui, Add, Button, wp gClockOut, Clock Out
Gui, Show, , Clerk: %ClerkInName%
Return

GuiClose:
ExitApp

ClockIn:
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%, No
   If (Value == "No") {
      IniRead, Test, Hours.ini, %ClerkInName%, Total
      If (Test = "ERROR")
         IniWrite, 00:00:00, Hours.ini, %ClerkInName%, Total
      Now := A_Now
      FormatTime, TimeIn, %Now%, HH:mm:ss
      FormatTime, DateIn, %Now%, ShortDate
      IniWrite, %Now%, 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
      MsgBox, 262208,Attention ,%ClerkInName% Clocked In.,2
   }
   Else
      MsgBox, 262192,Attention , Already Clocked In,2
   ; GuiControl,, ClerkNumIn
   ; Testing ------------------------------------------------
   IniRead, Ini, Hours.ini, Dyson
   GuiControl, , IniContent, %Ini%
   ; Testing ------------------------------------------------
Return
; ##############################################################################
ClockOut:
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%, No
   if (Value != "No") {
      Now := A_Now
      FormatTime, TimeOut, %Now%, HH:mm:ss
      FormatTime, DateOut, %Now%, ShortDate
      Secs := Now
      Secs -= Value, Seconds
      IniRead, Total, Hours.Ini, %ClerkInName%, Total
      PrevSecs := Time2Seconds(Total)
      If (PrevSecs = "")
         PrevSecs := 0
      Time := Seconds2Time(Secs)
      Total := Seconds2Time(PrevSecs + Secs)
      IniWrite, %Total%, Hours.ini, %ClerkInName%, Total
      IniWrite, Out (%Time%), Hours.ini, %ClerkInName%, %DateOut% - %TimeOut% Clocked
      IniWrite, No, Online.ini, Clocked In:, %ClerkInName%
      MsgBox, 262208,Attention ,%ClerkInName% Clocked Out.,2
      ; GuiControl,, ClerkNumIn
   }
   Else
      MsgBox, 262192,Attention ,Not Clocked In.,2
   ; GuiControl,, ClerkNumIn
   ; Testing ------------------------------------------------
   IniRead, Ini, Hours.ini, Dyson
   GuiControl, , IniContent, %Ini%
   ; Testing ------------------------------------------------
Return
; ##############################################################################
Seconds2Time(Secs) {
   Return Format("{:02}:{:02}:{:02}", Secs // 3600, Mod(Secs, 3600) // 60, Mod(Secs, 60))
}
; ##############################################################################
Time2Seconds(Time) {
   Return RegExMatch(Time, "^(\d+):(\d\d):(\d\d)$", M) ? ((M1 * 3600) + (M2 * 60) + M3) : ""
}
; ##############################################################################
Dyson
Posts: 46
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

13 Jul 2019, 05:41

just me wrote:
13 Jul 2019, 04:24
Hi, it took some time but you might want to try:

Code: Select all

#NoEnv
SetWorkingDir, %A_ScriptDir%
ClerkInName := "Dyson"
; Testing ------------------------------------------------
IniRead, Ini, Hours.ini, Dyson
GuiControl, , IniContent, %Ini%
; Testing ------------------------------------------------
Gui, Add, Edit, w300 r10 vIniContent, %Ini%
Gui, Add, Button, wp gClockIn, Clock in
Gui, Add, Button, wp gClockOut, Clock Out
Gui, Show, , Clerk: %ClerkInName%
Return

GuiClose:
ExitApp

ClockIn:
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%, No
   If (Value == "No") {
      IniRead, Test, Hours.ini, %ClerkInName%, Total
      If (Test = "ERROR")
         IniWrite, 00:00:00, Hours.ini, %ClerkInName%, Total
      Now := A_Now
      FormatTime, TimeIn, %Now%, HH:mm:ss
      FormatTime, DateIn, %Now%, ShortDate
      IniWrite, %Now%, 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
      MsgBox, 262208,Attention ,%ClerkInName% Clocked In.,2
   }
   Else
      MsgBox, 262192,Attention , Already Clocked In,2
   ; GuiControl,, ClerkNumIn
   ; Testing ------------------------------------------------
   IniRead, Ini, Hours.ini, Dyson
   GuiControl, , IniContent, %Ini%
   ; Testing ------------------------------------------------
Return
; ##############################################################################
ClockOut:
   IniRead, Value, Online.ini, Clocked In:, %ClerkInName%, No
   if (Value != "No") {
      Now := A_Now
      FormatTime, TimeOut, %Now%, HH:mm:ss
      FormatTime, DateOut, %Now%, ShortDate
      Secs := Now
      Secs -= Value, Seconds
      IniRead, Total, Hours.Ini, %ClerkInName%, Total
      PrevSecs := Time2Seconds(Total)
      If (PrevSecs = "")
         PrevSecs := 0
      Time := Seconds2Time(Secs)
      Total := Seconds2Time(PrevSecs + Secs)
      IniWrite, %Total%, Hours.ini, %ClerkInName%, Total
      IniWrite, Out (%Time%), Hours.ini, %ClerkInName%, %DateOut% - %TimeOut% Clocked
      IniWrite, No, Online.ini, Clocked In:, %ClerkInName%
      MsgBox, 262208,Attention ,%ClerkInName% Clocked Out.,2
      ; GuiControl,, ClerkNumIn
   }
   Else
      MsgBox, 262192,Attention ,Not Clocked In.,2
   ; GuiControl,, ClerkNumIn
   ; Testing ------------------------------------------------
   IniRead, Ini, Hours.ini, Dyson
   GuiControl, , IniContent, %Ini%
   ; Testing ------------------------------------------------
Return
; ##############################################################################
Seconds2Time(Secs) {
   Return Format("{:02}:{:02}:{:02}", Secs // 3600, Mod(Secs, 3600) // 60, Mod(Secs, 60))
}
; ##############################################################################
Time2Seconds(Time) {
   Return RegExMatch(Time, "^(\d+):(\d\d):(\d\d)$", M) ? ((M1 * 3600) + (M2 * 60) + M3) : ""
}
; ##############################################################################

Sadly it isnt working correctly, im pressing my number (1) and pressing clock in and its just popping up a msgbpx saying already clocked in, then writing to the inifile like this:

Code: Select all

[]
Total=00:00:00
13/07/2019 - 11:36:56 Clocked=In
13/07/2019 - 11:37:03 Clocked=Out (00:00:07)
13/07/2019 - 11:37:32 Clocked=Out (00:00:00)
13/07/2019 - 11:37:37 Clocked=Out (00:00:00)
13/07/2019 - 11:38:56 Clocked=Out (00:00:00)
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

13 Jul 2019, 06:25

My sample script only considers Online.ini and Hours.ini. Does it happen if you run my original script with two empty INI files?
Dyson
Posts: 46
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

13 Jul 2019, 12:38

Yes it requires clerk.ini to determine if the person is already clocked in or not, to stop multiple clockin times, so if you are already clocked in it will tell you already clocked in, if not already clocked in then it will clock you in etc
Dyson
Posts: 46
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

13 Jul 2019, 12:39

I will play around with it some more after work and see if I can resolve it
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

14 Jul 2019, 05:30

Show your test code for ClockIn: and ClockOut:, please.
Dyson
Posts: 46
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

14 Jul 2019, 07:39

I have played around with it now and it works perfectly :D

Code: Select all

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")
   {
      IniRead, Test, Hours.ini, %ClerkInName%, Total
      If (Test = "ERROR")
         IniWrite, 00:00:00, Hours.ini, %ClerkInName%, Total
      Now := A_Now
      FormatTime, TimeIn, %Now%, HH:mm:ss
      FormatTime, DateIn, %Now%, ShortDate
      IniWrite, %Now%, 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
      MsgBox, 262208,Attention ,%ClerkInName% Clocked In.,2
      GuiControl,, ClerkNumIn
      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 != "No") {
      Now := A_Now
      FormatTime, TimeOut, %Now%, HH:mm:ss
      FormatTime, DateOut, %Now%, ShortDate
      Secs := Now
      Secs -= Value, Seconds
      IniRead, Total, Hours.Ini, %ClerkInName%, Total
      PrevSecs := Time2Seconds(Total)
      If (PrevSecs = "")
         PrevSecs := 0
      Time := Seconds2Time(Secs)
      Total := Seconds2Time(PrevSecs + Secs)
      IniWrite, %Total%, Hours.ini, %ClerkInName%, Total
      IniWrite, Out (%Time%), Hours.ini, %ClerkInName%, %DateOut% - %TimeOut% Clocked
      IniWrite, No, Online.ini, Clocked In:, %ClerkInName%
      MsgBox, 262208,Attention ,%ClerkInName% Clocked Out.,2
      GuiControl,, ClerkNumIn
   }
   else
      MsgBox, 262192,Attention ,Not Clocked In.,2
   GuiControl,, ClerkNumIn
return
This is the layout in Hours.ini after a few clock in and outs to test it

Code: Select all

[Dyson]
Total=00:00:34
14/07/2019 - 13:31:03 Clocked=In
14/07/2019 - 13:31:10 Clocked=Out (00:00:07)
14/07/2019 - 13:31:31 Clocked=In
14/07/2019 - 13:31:38 Clocked=Out (00:00:07)
14/07/2019 - 13:32:30 Clocked=In
14/07/2019 - 13:32:39 Clocked=Out (00:00:09)
14/07/2019 - 13:32:59 Clocked=In
14/07/2019 - 13:33:03 Clocked=Out (00:00:04)
14/07/2019 - 13:34:07 Clocked=In
14/07/2019 - 13:34:14 Clocked=Out (00:00:07)
it has even rectified the problem of

Code: Select all

14/07/2019 - 13:32:59 Clocked=In
14/07/2019 - 13:33:03 Clocked=Out (00:00:04)
where it used to put (1 min -56 seconds) when only being clocked in for 4 seconds which is also a bonus.
Dyson
Posts: 46
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

14 Jul 2019, 08:01

Next phase of my script, after using gui5 to place your order and you press the payment option, it flicks to this screen:
Untitled.png
Untitled.png (102.79 KiB) Viewed 2243 times
if the customer hands me a £5 note i press the £5 button (same if they hand me a 10 or a 20 note)
What i need to happen is for it to deduct 5.00 from the total section, and a msgbox appear in the center of the screen saying: Change: £2.81 (if £5 button is pressed) same ammount relating to the 10 or 20 button being pressed,

failing that if the customer hands me the correct amount of cash, I can manually type it in using the numpad on screen and press cash,

you will notice a small editbox next to the order box, if that value is equal to (or more than) the total amount when pressing cash it will enter the next phase of the script

Next phase of script yet to be written:
Msgbox will apear stating how much change to give (if customer gives more than total)
Cash drawer will open (im currently waiting on a wire to be able to connect the cash draw to laptop)
the order screen will open in a new gui on a 2nd moniter (still testing the dimentions out)
The order will be written into an Ini file labled [Date]Order.ini (the layout willl look like this:)

Code: Select all

[1]
Chips=2.19
[2]
Jumbo sausage=1.79
(providing the second order is a jumbo sausage)
etc etc

the order screen will be printed on to a ticket via a thermal printer (yet to arrive in post)
each item in order screen will be written to another ini file to determine stock used (Eg chips will be written in Stock.ini the layout will be like this:)

Code: Select all

[Chips]
Sold=1
[Jumbo sausage]
Sold=1
Etc Etc

the total amount of these items will increase each time the sale goes through with one of these items on the order

if the order box is empty and the "No Sale" button is pressed it will open the cash drawer

Code: Select all

Gui, 8:Font, s12

gui, 8:Add, Edit, x1100 y10 w100 h30 vInput1
Gui, 8:Add, Edit, x1200 y10 w300 h370 vMenu2 hwndHMENU2
Gui, 8:Add, Edit, x1400 y380 w100 h30 vTotal2 Right2, 0.00
Gui, 8:Add, text, x1350 y385, Total:

Gui, 8:Font, s26
Gui, 8:Add, text, x750 y10, %ClerkName%
Gui, 8:Font, s12
gui, 8:Add, button, gTakeAway w100 h100, Take Away
Gui, 8:Add, button, gClear2 x1100 y410 w70 h70, C
Gui, 8:Add, button, gAddTextInput1 x1100 y480 w70 h70, 7
Gui, 8:Add, button, gAddTextInput1 x1100 y550 w70 h70, 4
Gui, 8:Add, button, gAddTextInput1 x1100 y620 w70 h70, 1
Gui, 8:Add, button, gAddTextInput1 x1100 y690 w70 h70, 0

Gui, 8:Add, button, x1170 y410 w70 h70, No Sale
Gui, 8:Add, button, gAddTextInput1 x1170 y480 w70 h70, 8
Gui, 8:Add, button, gAddTextInput1 x1170 y550 w70 h70, 5
Gui, 8:Add, button, gAddTextInput1 x1170 y620 w70 h70, 2
Gui, 8:Add, button, gAddTextInput1 x1170 y690 w70 h70, 00

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

Gui, 8:Add, button, x1310 y410 w140 h70, Cheque
Gui, 8:Add, button, x1310 y480 w140 h140, Card
Gui, 8:Add, button, x1310 y620 w140 h140, Cash

gui, 8:Add, Button, g20pound x960 y480 w140 h70, £20
gui, 8:Add, Button, g10pound x960 y550 w140 h70, £10
gui, 8:Add, Button, g5pound x960 y620 w140 h70, £5
return
; ##############################################################################
TakeAway:
gui, 8:Hide
Gui, 5:Show, w1540 h805, Order
return
; ##############################################################################
5pound:
Gui, Submit, NoHide
   GuiControl, , Input1, % 5.00 
Return
; ##############################################################################
10pound:
Gui, Submit, NoHide
   GuiControl, , Input1, % 10.00
Return
; ##############################################################################
20pound:
Gui, Submit, NoHide
   GuiControl, , Input1, % 20.00
Return
This is the code i have for Gui8
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Lable buttons via Ini File

15 Jul 2019, 06:13

Hmmm! Many much INI files and many much GUIs! :shock:

Here's something to start the next step:

Code: Select all

#NoEnv
Menu := "Chips`t2.19`nCod`t4.79"   ; taken fom Gui5
Total := "6.68"         ; taken from Gui5

Gui, 8:Font, s12

Gui, 8:Add, Text, x1000 y10 w95 h30 +0x200 Right, Paid:
Gui, 8:Add, Edit, x1100 y10 w100 h30 vPaid, 0.00
Gui, 8:Add, Text, x1000 y50 w95 h30 +0x200 Right, Change:
Gui, 8:Add, Edit, x1100 y50 w100 h30 vChange, 0.00
Gui, 8:Add, Edit, x1200 y10 w300 h370 vMenu2 hwndHMENU2, %Menu%
Gui, 8:Add, Edit, x1400 y380 w100 h30 vTotal2 Right2, %Total%
Gui, 8:Add, text, x1350 y385, Total:

Gui, 8:Font, s26
Gui, 8:Add, text, x750 y10, %ClerkName%
Gui, 8:Font, s12
gui, 8:Add, button, gTakeAway w100 h100, Take Away
Gui, 8:Add, button, gClear2 x1100 y410 w70 h70, C
Gui, 8:Add, button, gAddTextInput1 x1100 y480 w70 h70, 7
Gui, 8:Add, button, gAddTextInput1 x1100 y550 w70 h70, 4
Gui, 8:Add, button, gAddTextInput1 x1100 y620 w70 h70, 1
Gui, 8:Add, button, gAddTextInput1 x1100 y690 w70 h70, 0

Gui, 8:Add, button, x1170 y410 w70 h70, No Sale
Gui, 8:Add, button, gAddTextInput1 x1170 y480 w70 h70, 8
Gui, 8:Add, button, gAddTextInput1 x1170 y550 w70 h70, 5
Gui, 8:Add, button, gAddTextInput1 x1170 y620 w70 h70, 2
Gui, 8:Add, button, gAddTextInput1 x1170 y690 w70 h70, 00

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

Gui, 8:Add, button, x1310 y410 w140 h70, Cheque
Gui, 8:Add, button, x1310 y480 w140 h140, Card
Gui, 8:Add, button, x1310 y620 w140 h140, Cash

Gui, 8:Add, Button, gPound vPound20 x960 y480 w140 h70, £20
Gui, 8:Add, Button, gPound vPound10 x960 y550 w140 h70, £10
Gui, 8:Add, Button, gPound vPound5  x960 y620 w140 h70, £5
Gui, 8:Show, , Payment
Return
; ##############################################################################
8GuiClose:
ExitApp
; ##############################################################################
TakeAway:
; gui, 8:Hide
; Gui, 5:Show, w1540 h805, Order
Return
; ##############################################################################
Clear2:
   GuiControl, , Paid, 0.00
   GuiControl, , Change, 0.00
Return
; ##############################################################################
AddTextInput1:
Return
; ##############################################################################
SignOff:
Return
; ##############################################################################
Pound:
   Gui, +OwnDialogs
   Given := SubStr(A_GuiControl, 6)
   If (Total > Given) {
      MsgBox, 16, Payment, !!!%Given% £ is not enough!!!
      Return
   }
   Change := Format("{:0.2f}", Given - Total)
   GuiControl, , Paid, % Format("{:0.2f}", Given)
   GuiControl, , Change, %Change%
   MsgBox, 0, Payment, Change: %Change%
Return
Dyson
Posts: 46
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

15 Jul 2019, 08:43

I like it!
But instead of:

Code: Select all

      MsgBox, 16, Payment, !!!%Given% £ is not enough!!!
Can we just deduct ot from the total, some people may wish to pay part card and part cash etc, Other than that it looks good, here is the code I have for the Cash button if we can incorporate it into the script?

Code: Select all

Cash:
if (input1 == 0) { 
msgbox, Enforce Ammount Tendered
Return 
}
Tendered := Total2 -= Input1
Gui, Submit, NoHide
if (Tendered >= 0) {
   GuiControl, , Total2, % Tendered
   GuiControl, , Input1 
   return
}
If Input1 <= Total2 {
msgbox, Change due: £%Tendered%
   GuiControl, , Input1
Return
However its not quite completed as the mathematical part is wrong (was done in a rush)
Dyson
Posts: 46
Joined: 03 Jun 2019, 14:09

Re: Lable buttons via Ini File

16 Jul 2019, 09:53

Code: Select all

#NoEnv
; ------------------------------------------------------------------------------
; Settings
IniFile := "Menu.ini"
BtnCount := 71       ; 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%
   IniRead, Options, %IniFile%, %A_Index%, Options, %A_Space%
   Menus[A_Index] := {Name: Menu, Price: Price, Options: Options}
}
; ##############################################################################
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 gStaff ,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, %ClerkName%
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, gPayment 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, Text, xm, Options:
W := PW + PX - 10
Gui, 7:Add, Edit, xm y+2 w%W% r5 vNewOptions
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
; ##############################################################################
Gui, 8:Font, s12

Gui, 8:Add, Text, x1000 y10 w95 h30 +0x200 Right, Paid:
Gui, 8:Add, Edit, x1100 y10 w100 h30 vPaid, 
Gui, 8:Add, Text, x1000 y50 w95 h30 +0x200 Right, Change:
Gui, 8:Add, Edit, x1100 y50 w100 h30 vChange, 0.00
Gui, 8:Add, Edit, x1200 y10 w300 h370 vMenu2 hwndHMENU2, %Menu%
Gui, 8:Add, Edit, x1400 y380 w100 h30 vTotal2 Right2, %Total%
Gui, 8:Add, text, x1350 y385, Total:

Gui, 8:Font, s26
Gui, 8:Add, text, x750 y10, %ClerkName%
Gui, 8:Font, s12
gui, 8:Add, button, gTakeAway w100 h100, Take Away
Gui, 8:Add, button, gClear2 x1100 y410 w70 h70, C
Gui, 8:Add, button, gAddTextInput1 x1100 y480 w70 h70, 7
Gui, 8:Add, button, gAddTextInput1 x1100 y550 w70 h70, 4
Gui, 8:Add, button, gAddTextInput1 x1100 y620 w70 h70, 1
Gui, 8:Add, button, gAddTextInput1 x1100 y690 w70 h70, 0

Gui, 8:Add, button, x1170 y410 w70 h70, No Sale
Gui, 8:Add, button, gAddTextInput1 x1170 y480 w70 h70, 8
Gui, 8:Add, button, gAddTextInput1 x1170 y550 w70 h70, 5
Gui, 8:Add, button, gAddTextInput1 x1170 y620 w70 h70, 2
Gui, 8:Add, button, gAddTextInput1 x1170 y690 w70 h70, 00

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

Gui, 8:Add, button, x1310 y410 w140 h70, Cheque
Gui, 8:Add, button, x1310 y480 w140 h140, Card
Gui, 8:Add, button, gCash x1310 y620 w140 h140, Cash

Gui, 8:Add, Button, gPound vPound20 x960 y480 w140 h70, £20
Gui, 8:Add, Button, gPound vPound10 x960 y550 w140 h70, £10
Gui, 8:Add, Button, gPound vPound5  x960 y620 w140 h70, £5
Return
; ##############################################################################
AddTextInput1:
Gui, Submit, NoHide
   GuiControl, , Paid, % Paid A_GuiControl
Return
; ##############################################################################
Pound:
   Gui, +OwnDialogs
   Given := SubStr(A_GuiControl, 6)
   If (Total > Given) {
   Remainder := Format("{:0.2f}",  Total - Given)
   GuiControl, , Total2, %Remainder%
   Total := Remainder
   Return
   }
   Remainder := Format("{:0.2f}",  Total - Given)
   GuiControl, , Total2, %Remainder%
   Change := Format("{:0.2f}", Given - Total)
   GuiControl, , Paid, % Format("{:0.2f}", Given)
   GuiControl, , Change, %Change%
   MsgBox, 0, Payment, Change: £%Change%, 5
return

; ###############################################################################
Cash:
Given := SubStr(A_GuiControl, 6)
   If (Total > Given) {
   Remainder := Format("{:0.2f}",  Total - Given)
   GuiControl, , Total2, %Remainder%
   Total := Remainder
   Return
   }
   Change := Format("{:0.2f}", Given - Total)
   GuiControl, , Paid, % Format("{:0.2f}", Given)
   GuiControl, , Change, %Change%
   MsgBox, 0, Payment, Change: £%Change%, 5
Return
; ##############################################################################
TakeAway:
gui, 8:Hide
Gui, 5:Show, w1540 h805, Order
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"]
   Options := Menus[BtnNumber, "Options"]
   OptNumber := 0
   If (Options <> "") {
      Gui, Opts:New, +hwndHOPTS
      Options := StrSplit(Options, "|")
      For Index, Option in Options
         Gui, Add, Radio, % (Index = 1 ? "vOptNumber" : ""), %Option%
      Gui, 5:+Disabled
      Gui, Show, , Options
      While WinExist("ahk_id " . HOPTS)
         Sleep 100
   }
   Gui, 5:Default
   GuiControlGet, Total
   Total += Price
   GuiControl, , Total, % Format("{:0.2f}", Total)
   DllCall("SendMessage", "Ptr", HMENU, "UInt", 0x00B1, "Ptr", -1, "Ptr", -2) ; EM_SETSEL
   Order := Menu . "		" . Price . "`r`n" . (OptNumber ? "(" . Options[OptNumber] . ")`r`n" : "")
   DllCall("SendMessage", "Ptr", HMENU, "UInt", 0x00C2, "Ptr", True, "Str", Order) ; EM_REPLACESEL
Gui, 8:Default
   GuiControl, , Total2, % Format("{:0.2f}", Total)
   DllCall("SendMessage", "Ptr", HMENU2, "UInt", 0x00B1, "Ptr", -1, "Ptr", -2) ; EM_SETSEL
   Order := Menu . "		" . Price . "`r`n" . (OptNumber ? "(" . Options[OptNumber] . ")`r`n" : "")
   DllCall("SendMessage", "Ptr", HMENU2, "UInt", 0x00C2, "Ptr", True, "Str", Order) ; EM_REPLACESEL
Return

OptsGuiClose:
Gui, 5:-Disabled
Gui, Submit
Gui, Destroy
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
   Options := StrReplace(Trim(RTrim(NewOptions, "`n")), "`n", "|")
   Iniwrite, %Options%, %IniFile%, %BtnNumber%, Options
   Menus[BtnNumber, "Name"] := NewName
   Menus[BtnNumber, "Price"] := NewPrice
   Menus[BtnNumber, "Options"] := Options
   Gosub, 7GuiClose
Return
; ##############################################################################
Set:
   BtnNumber := SubStr(A_GuiControl, 4)
   GuiControl, 7:, NewName, % Menus[BtnNumber, "Name"]
   GuiControl, 7:, NewPrice, % Menus[BtnNumber, "Price"]
   GuiControl, 7:, NewOptions, % StrReplace(Menus[BtnNumber, "Options"], "|", "`n")
   Gui, +Disabled
   Gui, 7:Show, , Button %BtnNumber%
Return
; ##############################################################################
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, Text, xm, Options:
W := PW + PX - 10
Gui, 7:Add, Edit, xm y+2 w%W% r5 vNewOptions
Gui, 7:Add, Button, xm w80 gWriteIni, Apply
X := PX + PW - 80
Gui, 7:Add, Button, x%X% yp wp g7GuiClose, Cancel
; ##############################################################################
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
; ##############################################################################
Payment:
   Gui, 5:Hide
   Gui, 8:Show, w1540 h805, Payment
return
; ##############################################################################
SignOn:
   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
   }
   else
      GuiControl,, ClerkNumIn
   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")
   {
      IniRead, Test, Hours.ini, %ClerkInName%, Total
      If (Test = "ERROR")
         IniWrite, 00:00:00, Hours.ini, %ClerkInName%, Total
      Now := A_Now
      FormatTime, TimeIn, %Now%, HH:mm:ss
      FormatTime, DateIn, %Now%, ShortDate
      IniWrite, %Now%, 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
      MsgBox, 262208,Attention ,%ClerkInName% Clocked In.,2
      GuiControl,, ClerkNumIn
      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 != "No") {
      Now := A_Now
      FormatTime, TimeOut, %Now%, HH:mm:ss
      FormatTime, DateOut, %Now%, ShortDate
      Secs := Now
      Secs -= Value, Seconds
      IniRead, Total, Hours.Ini, %ClerkInName%, Total
      PrevSecs := Time2Seconds(Total)
      If (PrevSecs = "")
         PrevSecs := 0
      Time := Seconds2Time(Secs)
      Total := Seconds2Time(PrevSecs + Secs)
      IniWrite, %Total%, Hours.ini, %ClerkInName%, Total
      IniWrite, Out (%Time%), Hours.ini, %ClerkInName%, %DateOut% - %TimeOut% Clocked
      IniWrite, No, Online.ini, Clocked In:, %ClerkInName%
      MsgBox, 262208,Attention ,%ClerkInName% Clocked Out.,2
      GuiControl,, ClerkNumIn
   }
   else
      MsgBox, 262192,Attention ,Not Clocked In.,2
   GuiControl,, ClerkNumIn
return
; ##############################################################################
Seconds2Time(Secs) {
   Return Format("{:02}:{:02}:{:02}", Secs // 3600, Mod(Secs, 3600) // 60, Mod(Secs, 60))
}
; ##############################################################################
Time2Seconds(Time) {
   Return RegExMatch(Time, "^(\d+):(\d\d):(\d\d)$", M) ? ((M1 * 3600) + (M2 * 60) + M3) : ""
}
; ##############################################################################
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
   GuiControl,, Total
   GuiControl,, Menu2
   GuiControl,, Total2
   GuiControl,, Input1
return
; ##############################################################################
Clear2:
   GuiControl,, Input1
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
; ##############################################################################
GetCursorPos(ByRef X, ByRef Y) {
   VarSetCapacity(XY, 8, 0)
   RetVal := DllCall("GetCursorPos", "Ptr", &XY, "UInt")
   X := NumGet(XY, 0, "Int")
   Y := NumGet(XY, 4, "Int")
   Return RetVal
}
; ##############################################################################
Staff:
run Hours.ini
return
; ##############################################################################

This is the whole script I have so far, The Cash: part doesn't work as it should as of yet, and also in the Pound: section when the total is less than 0 it still triggers, I would like to make it so it cant, and if the Total is less than 0 and you press sign off Or Takeaway Button it resets it all so you can take another order? but if the total is more than 0 and you press takeaway you can add to it, any ideas how I can do this?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 130 guests