Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

gLabel auto executes when I start my script



  • Please log in to reply
2 replies to this topic
mikeres0
  • Members
  • 3 posts
  • Last active: May 01 2015 02:09 PM
  • Joined: 24 Apr 2015

Hey guys, 

 

I'm writing a script so that I can keep track of the time I stay away from my desk during the working day. 

 

I have a few gLabels on a few Gui input elements which auto execute whenever the script is ran. 

 

Can anyone explain why this is? See my code below. 

 

Ps. I'm aware there are flaws in it, it's in it's very early days. 

SetWorkingDir C:\Timelog  ; Ensures a consistent starting directory.

SetTimer, GetTime, 1
GoSub, GetDate
Sleep, 100

Gui, New
Gui, Font, s10 q5, Verdana
Gui, Add, Text, x20 y10 w8, Out: 
Gui, Add, Edit, x60 y10 w80 vTimeOut, %CurrentTime%
Gui, Add, Text, x20 y40, In: 
Gui, Add, Edit, x60 y40 w80 vTimeIn
Gui, Add, Button, w80 Center gPopulateTime, Time in?
Gui, Add, Button, x40 y120 w120, &Save
Gui, show, W200 H160 Center, Time log

GetTime:
FormatTime, CurrentTime, , HH:mm:ss

PopulateTime:
GuiControl, Text, TimeIn, %CurrentTime%

GetDate:
FormatTime, CurrentDate, , ddMMyy

Save:
Filename = Log - %CurrentDate%
MsgBox, %Filename%
Loop, %A_WorkingDir%\*.txt {
	if (A_LoopFileName <> Filename) {
		FileAppend, -----`nTime out: %TimeOut% Time in: %TimeIn%`n-----, %FileName%.txt
		break
	}
	else {
		FileAppend, -----`nTime out: %TimeOut% Time in: %TimeIn%`n-----, %FileName%.txt
	}
}
return



kon
  • Members
  • 1652 posts
  • Last active:
  • Joined: 04 Mar 2013
✓  Best Answer

You should place a return at the end of the auto-execute section. (The point you want the script to stop at when it first loads.)

Also, your subroutines should all have a return.



mikeres0
  • Members
  • 3 posts
  • Last active: May 01 2015 02:09 PM
  • Joined: 24 Apr 2015

You should place a return at the end of the auto-execute section (the point you want the script to stop at when it first loads.

Also, your subroutines should all have a return.

 

Thanks for your quick reply, it all works great.  :D