Need a Reset button

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hracer75
Posts: 19
Joined: 19 Dec 2016, 23:52

Need a Reset button

15 Jun 2018, 20:58

Can someone help add a Reset button to clear all fields? This will be in case the user needs to clear the fields without submitting and starting over.

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;HEADER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Name .........: Notmaker-v3.3
; Description ..: A Notmaker that will sent info to a log file and send to clipboard for pasting to notes, ticket etc..
; Language .....: English (en-US)
; Author .......: M R	
; Created .....: 4/1/2018
; Filename .....: NTONMv3.3.ahk
;;;;;;;;;;;;;;;;;;;;;;;Changelog;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 4/13/2018 added stopwatch
; 		    working so far
; 4/14/2018 added name of app to title.
; 4/14/2018 changed font size of stopwatch
; 4/22/2018 Added ",%A_MyDocuments%\TESTLOG.txt" to end of fileappend
; 4/24/2018 Added a date stamp at top of text file, but not clipboard
; 6/3/2018 Added <br> to clipboard code for VxField formatting
; 
;;;;;;;;;;;;;;;;;StopWatch Special Instructions;;;;;;;;;;;;;;;;;

SetBatchLines, -1
; Some variables
ElapsedTime := A_YYYY                                 ; initialize ElapsedTime, it will be treated as YYYY0101000000
BalanceTime := 0                                      ; initialize BalanceTime (time not counted yet)

;;;;;;;;;;;;;;;;;;;;;;;;;;Main GUI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Gui, Color, gray                                      ; Color of GUI background

;---------------------------------------------------------------
Gui, font, s14 bold	cred
Gui, Add, Text,, "Greeting go here...."
Gui, font
;---------------------------------------------------------------
Gui, font, s10 bold
Gui, Add, Text, x6 y74, Tech Name: 
Gui, font, s10 norm
Gui, Add, Edit, x92 y70 w230 h25 vone 
;---------------------------------------------------------------
Gui, font, s10 bold
Gui, Add, Text, x28 y108, Tech ID: 
Gui, font, s10 norm	
Gui, Add, Edit, x92 y104 w230 h25 vtwo
;---------------------------------------------------------------
Gui, font, s10 bold
Gui, Add, Text, x13 y142, Tech CBR: 
Gui, font, s10 norm	
Gui, Add, Edit, x92 y138 w230 h25 vthree
;---------------------------------------------------------------
Gui, font, s10 bold
Gui, Add, Text, x40 y176, TTN #: 
Gui, font, s10 norm	
Gui, Add, Edit, x92 y172 w230 h25 vfour
;---------------------------------------------------------------
Gui, font, s10 bold
Gui, Add, Text, x27 y210, CX BTN: 
Gui, font, s10 norm		
Gui, Add, Edit, x92 y206 w230 h25 vfive
;---------------------------------------------------------------
Gui, font, s10 bold
Gui, Add, Text, x32 y244, CX USI: 
Gui, font, s10 norm		
Gui, Add, Edit, x92 y240 w230 h25 vsix
;---------------------------------------------------------------
Gui, font, s10 bold
Gui, Add, Text, x22 y278, Remarks: 
Gui, font, s10 norm		
Gui, Add, Edit, x92 y274 w340 h200 vseven
;---------------------------------------------------------------
Gui, Add, Button, default, SUBMIT                                      ; Submit button will send to clipboard and log file
Gui, Show, w450 h680                			                       ; Size of GUI window
Gui, Show, , NoteMakr v3.3                                   ; Name showing in Title of GUI

;;;;;;;;;;;;;;;;;;;;;;;;;StopWatch GUI;;;;;;;;;;;;;;;;;;;;;;;;;;

Gui, Add, Text,                                      				   ; added line space
Gui, Font, S24 CDefault Bold, Verdana
Gui, Add, Text, x+50 vDisplayTime, 00:00
Gui, Font, S12, Verdana
Gui, Add, Text, 
Gui, Add, Button, x+0 yp w80 h30 vBtnStartStop gStartStop Default, Start
Gui, Add, Button, x+2 yp w80 h30 vBtnReset gReset, Reset

;;;;;;;;;;;;;;;;;;;;;;;;;;Author INFO;;;;;;;;;;;;;;;;;;;;;;;;;;;

Gui, font, s10 bold
Gui, Add, Text, x300 y660, Created: by Author                   ; author note on GUI
Gui, font

Return

;;;;;;;;;;;;;;;;;;;;;;StopWatch FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;

; BtnStartStop label
StartStop:
   GuiControlGet, BtnStartStop                        ; get the caption of the button
   If (BtnStartStop = "Start") {                      ; if it is "Start"
      StartTickCount := A_TickCount - BalanceTime     ;    initialize StartTickCount
      SetTimer, StopWatch, 10                         ;    start the timer called every 10 ms to be accurate
      GuiControl, , BtnStartStop, Stop                ;    set the caption to Stop
   } Else {                                           ; it should be "Stop"
      BalanceTime := A_TickCount - StartTickCount     ;    memorize the balance time not counted yet
      SetTimer, StopWatch, Off                        ;    stop the timer
      GuiControl, , BtnStartStop, Start               ;    set the caption to "Start"
   }
Return
; BtnReset label
Reset:
   SetTimer, StopWatch, Off                           ; stop the timer
   GuiControl, , BtnStartStop, Start                  ; set the caption of BtnStartStop to "Start"
   GuiControl, , DisplayTime, 00:00                   ; initialize DisplayTime
   ElapsedTime := A_YYYY                              ; initialize ElapsedTime, it will be treated as YYYY0101000000
   BalanceTime := 0                                   ; initialize BalanceTime
   GuiControl, Focus, BtnStartStop                    ; set the focus on BtnStartStop
   GuiControl, -Default, BtnReset                     ; remove the BS_DEFPUSHBUTTON (default) style
   GuiControl, +Default, BtnStartStop                 ; set the BS_DEFPUSHBUTTON (default) style
Return
; Timer routine
StopWatch:
   If ((A_TickCount - StartTickCount) >= 1000) {      ; if current tickcount - StartTickCount >= 1000 (i.e. 1 second)
      StartTickCount += 1000                          ;    add 1000 ms (1 second) to StartTickCount
      ElapsedTime += 1, S                             ;    add 1 second to ElapsedTime
      FormatTime, DisplayTime, %ElapsedTime%, mmm:ss   ;    format ElapsedTime to mmm:ss
      GuiControl, , DisplayTime, %DisplayTime%        ;    update DisplayTime
   }
Return

;;;;;;;;;;;;;;;;;;;;;;;;StopWatch FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ButtonSUBMIT:  ; Submit Button to log file in sam directory of app
Gui, Submit, NoHide

;;;;;;;;;;;;;;;;;;;;;;;;NT Online Notmaker FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

FileCreateDir, %A_MyDocuments%\my-logs			; This will create the folder in my documents folder under the current user login

FileAppend, Date: %A_MM%/%A_DD%/%A_YYYY%`n`nNT @CA ATS:: `n`nTech Name: %one% Tech ID: %two% Tech CBR: %three%`n`n*** Remarks: %seven%`n`n___________________`n`nTTN #: %four%`nCX BTN: %five%`nCX USI: %six%`n`n****************************************`n`n,%A_MyDocuments%\my-logs\onlinelog.txt

clipboard = NT @CA ATS::<br><br>`n`nTech Name: %one% Tech ID: %two% Tech CBR: %three%<br><br>`n`n*** Remarks: %seven%<br><br>`n`n___________________<br><br>`n`nTTN #: %four%<br>`nCX BTN: %five%<br>`nCX USI: %six%<br><br>`n`n****************************************<br><br>`n`n

Loop, 7
  GuiControl,,Edit%A_index%,
Return

^SPACE::  Winset, Alwaysontop, , A

GuiClose: ; Will close app out
ExitApp 
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Need a Reset button

15 Jun 2018, 23:03

is there something im missing here? it appears as though you already have the piece of code that does the clearing for you:

Code: Select all

Loop, 7
  GuiControl,,Edit%A_index%,
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Need a Reset button

15 Jun 2018, 23:46

Hi.
Adding the Reset-Label is easy, while your code is very clear.
Just add this Reset: before starting your loop. Like below:

Code: Select all

...
clipboard = NT @CA ATS::<br><br>`n`nTech Name: %one% Tech ID: %two% Tech CBR: %three%<br><br>`n`n*** Remarks: %seven%<br><br>`n`n___________________<br><br>`n`nTTN #: %four%<br>`nCX BTN: %five%<br>`nCX USI: %six%<br><br>`n`n****************************************<br><br>`n`n
Reset:
Loop, 7
  GuiControl,,Edit%A_index%,
...
EDIT: Now I see double g-label. No problem. Forget my suggestion above and just copy the loop (with the line beneath) into existing Reset-label.
Thats it? I think so. [untested] [no warranty] [no payback]
Einfach nur ein toller Typ. :mrgreen:
hracer75
Posts: 19
Joined: 19 Dec 2016, 23:52

Re: Need a Reset button

16 Jun 2018, 14:23

Thank you. Sorry I was not clear. I want to have 2 reset buttons. 1 to just clear the fields and the other that is there now is for the timer. Reason I need another reset button is in case I have already typed info in each field, but just need to start over. The submit button will clear it now, but it does other functions that I need. I am basically looking for a clear button.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Need a Reset button

17 Jun 2018, 08:22

Hi.
I don`t have run your script, so I don't know how it looks and where another button could or should be placed.
Try to insert your desired second reset-button with g-label and use the loop, shown above.

It should be not too difficult :crazy: :crazy:
Einfach nur ein toller Typ. :mrgreen:
hracer75
Posts: 19
Joined: 19 Dec 2016, 23:52

Re: Need a Reset button

22 Jun 2018, 14:08

Thank you all for your input. I did resolve the issue. @divanebaba your code did help me figure a "Clear" button with it to clear the fields without sending the data anywhere. Thanks

Code: Select all

Reset:
Loop, 7
  GuiControl,,Edit%A_index%,

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, doanmvu, uchihito, zvit and 279 guests