Alright, sorry about that, I was trying to simplify. Here is the entire code..........
Code:
#SingleInstance force
CoordMode, Mouse, Screen
;Shutdown Detection
OnMessage(0x16,"ExitFunc")
ExitFunc(wParam,lParam)
{
Msgbox we are shutting down
}
;Save everything here and clear crash state for clean down.
;Startup Recovery Function
IniRead,CloseState,settings.ini,General,CloseState
IfNotInString, CloseState, Normal
CrashRecovery := "1"
IniWrite,0,settings.ini,General,CloseState
;Startup Recovery Function
;Last Log Clear Check
IniRead,LastLogReset,settings.ini,General,LastLogReset
IniRead,FirstRun,settings.ini,General,FirstRun
If FirstRun = 1
{
IniWrite,%A_YDay%,settings.ini,General,LastLogReset
IniWrite,0,settings.ini,General,FirstRun
MsgBox, 4, , This is your first time running Timer.`nIt is highly recommended that you watch the tutorial presentation.`n`nWould you like to learn how to use Timer now?
IfMsgBox Yes
{
Run, Help.html
}
}
Else
{
IniRead,LastLogReset,settings.ini,General,LastLogReset
LastCheck := LastLogReset+30
If (LastCheck < A_YDay)
{
MsgBox, 4, , Your Work Log hasn't been cleared in 30 days or more!`nThis file may take up extra space on your computer.`nIt is not necessary to clear it if you do not want to.`nIf you do not need prior work history anymore it is recommended you clear it.`nWould you like to clear the work history now?
IfMsgBox Yes
{
FileDelete,log.html
FileAppend,`n<html>,log.html
FileAppend,`n<head>,log.html
FileAppend,`n<Title> Timer Work History</title>,log.html
FileAppend,`n</head>,log.html
FileAppend,`n<body>,log.html
FileAppend,`n<center><h2> Timer History</h2></center>,log.html
FileAppend,`n<br><br>,log.html
IniWrite,%A_YDay%,settings.ini,General,LastLogReset
Msgbox Work history has been cleared!
}
Ifmsgbox No
Msgbox History will not be deleted.`nYou will not be prompted again in the next 30 days.
}
}
;Last Log Clear Check
;Last Clear Check
IniRead,LastReset,settings.ini,General,LastReset
LastTime := LastReset-A_WDay
If LastTime > 0
{
IniWrite,0,settings.ini,StatsKW,1
IniWrite,0,settings.ini,StatsKW,2
IniWrite,0,settings.ini,StatsKW,3
IniWrite,0,settings.ini,StatsKW,4
IniWrite,0,settings.ini,StatsKW,5
IniWrite,0,settings.ini,StatsKW,6
IniWrite,0,settings.ini,StatsKW,7
IniWrite,0,settings.ini,StatsAS,1
IniWrite,0,settings.ini,StatsAS,2
IniWrite,0,settings.ini,StatsAS,3
IniWrite,0,settings.ini,StatsAS,4
IniWrite,0,settings.ini,StatsAS,5
IniWrite,0,settings.ini,StatsAS,6
IniWrite,0,settings.ini,StatsAS,7
IniWrite,0,settings.ini,StatsTime,1
IniWrite,0,settings.ini,StatsTime,2
IniWrite,0,settings.ini,StatsTime,3
IniWrite,0,settings.ini,StatsTime,4
IniWrite,0,settings.ini,StatsTime,5
IniWrite,0,settings.ini,StatsTime,6
IniWrite,0,settings.ini,StatsTime,7
IniWrite,%A_WDay%,settings.ini,General,LastReset
}
;Last Clear Check
;BEGIN FUNCTION DEFINE
/*
WinGet_Click_Through - Checks if a window is unclickable.
I - ID of the window to set as unclickable.
If the window ID doesn't exist, it returns -1.
*/
WinGet_Click_Through(I="") {
If(I == "" || I == "A")
I := WinExist("A")
IfWinNotExist, % "ahk_id " I
Return -1
WinGet, S, ExStyle, % "ahk_id " I
If (S & 0x80000 && S & 0x8 && S & 0x00000020)
Return True
Else
Return False
}
/*
WinSet_Click_Through - Makes a window unclickable.
I - ID of the window to set as unclickable.
T - The transparency to set the window. Leaving it blank will set it to 254. It can also be set On or Off. Any numbers lower then 0 or greater then 254 will simply be changed to 254.
If the window ID doesn't exist, it returns -1.
*/
WinSet_Click_Through(I="", T="255") {
If(I == "" || I == "A")
I := WinExist("A")
IfWinExist, % "ahk_id " I
{
If (T == "Off")
{
WinSet, AlwaysOnTop, Off, % "ahk_id " I
WinSet, Transparent, Off, % "ahk_id " I
WinSet, ExStyle, -0x20, % "ahk_id " I
}
Else
{
WinSet, AlwaysOnTop, On, % "ahk_id " I
If(T < 0 || T > 255 || T == "On")
T := 255
WinSet, Transparent, % T, % "ahk_id " I
WinSet, ExStyle, +0x20, % "ahk_id " I
}
}
Else
Return 0
}
;END FUNCTION DEFINE
;STARTUP ROUTINE
IniRead,DisplayColor,settings.ini,General,Displaycolor
IniRead,SetColor,settings.ini,General,Setcolor
IniWrite,v2.1,settings.ini,General,Version ;write version number
Menu, tray, add, Settings, MSettings
Menu, tray, add, History, MHistory
Menu, tray, add, About, MAbout
Menu, tray, add, Stats, MStats
Menu, tray, add, Help, MHelp
Menu, tray, add, Exit, ExitSub
Menu, Tray, NoStandard
Menu, Tray, Tip, Timer
SysGet, ScreenWidth, 61
SysGet, ScreenHeight, 62
posx := ScreenWidth/2-78
WasActive=0
hrfix=1
;END STARTUP ROUTINE
GroupAdd, GroupName , Editorial Verification Desktop - [Entity review - Keyword]
GroupAdd, GroupName , Editorial Verification Desktop - [Entity review - Text asset]
;GroupAdd, GroupName, Untitled - Notepad
CustomColor = %Setcolor%
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, %CustomColor%
Gui, Font, s18
Gui, Add, Text, vMyText %DisplayColor%,0:00:00
Gui, Show, x%posx% y-17 NoActivate, Timer
ID := WinExist()
WinSet_Click_Through(ID, "On")
WinSet, TransColor, %CustomColor% 150
;Recovery Mode
If (CrashRecovery = "1")
{
IniRead,RecoveryTime,settings.ini,General,AutoSave
IniRead,RecoveryKW,settings.ini,General,AutoSaveKW
IniRead,RecoveryAS,settings.ini,General,AutoSaveAS
timers := RecoveryTime
Msgbox Timer was not shutdown properly on last usage.`nThis could be caused by a computer crash or forced shutdown`nTo avoid this in the future shutdown timer by closing it properly.`nTimer automatically saves data every 3 minutes.`nTimer will now automatically restore.
}
;Revodery Mode
Settimer, Stopwatch, 250
time1 := A_TickCount
Settimer, AutoSave, 180000
Settimer, HourFix, 30000
Return
;Correct Stats so this saves to previous day and doesn't merge at midnight
HourFix:
If (hrfix = 1)
{
If (A_Hour = 05)
{
If (A_Min = 42)
{
IniRead,kwcountfinal,settings.ini,StatsKW,%A_WDay%
IniRead,ascountfinal,settings.ini,StatsAS,%A_WDay%
IniRead,timersfinal,settings.ini,StatsTime,%A_WDay%
kwcountfinal +=kwcount
ascountfinal +=ascount
timersfinal +=timers
IniWrite,%kwcountfinal%,settings.ini,StatsKW,%A_WDay%
IniWrite,%ascountfinal%,settings.ini,StatsAS,%A_WDay%
IniWrite,%timersfinal%,settings.ini,StatsTime,%A_WDay%
timers := 0
hrfix := 0
}
}
WinSet, Top,, Timer
Return
}
AutoSave:
IniWrite,%timers%,settings.ini,General,AutoSave
IniWrite,%kwcount%,settings.ini,General,AutoSaveKW
IniWrite,%ascount%,settings.ini,General,AutoSaveAS
return
Stopwatch:
IfWinExist, ahk_Group GroupName
{
forgiveCount = 0
timers := A_TickCount - time1
GuiControl,, MyText,% FormatSeconds(timers)
If (WasActive=0)
{
WasActive=1
VarSetCapacity(Text, 100) ;Expand buffer to allow for full Wintext
WinGetText, Text ; The window found above will be used.
RegExMatch( Text, "All\((.*)\)", Res )
Goto JobType
}
}
Else
{
forgiveCount++
if (forgiveCount <10000 )
{
If (WasActive=1)
{
WasActive=0
If (kworas = "kw")
Goto KeywordWrite
else if (kworas = "as")
Goto AssetWrite
else if (kworas = "error")
return
}
timers := A_TickCount - time1
GuiControl,, MyText,% FormatSeconds(timers)
return
}
If (WasActive=1)
{
Msgbox Why here?
WasActive=0
If (kworas = "kw")
Goto KeywordWrite
else if (kworas = "as")
Goto AssetWrite
else if (kworas = "error")
return
}
}
return
FormatSeconds(NumberOfSeconds) ; Convert the specified number of seconds to hh:mm:ss format.
{
time = 19990101 ; *Midnight* of an arbitrary date.
time += %NumberOfSeconds%, seconds
FormatTime, mmss, %time%, mm:ss
return NumberOfSeconds//3600 ":" mmss ; This method is used to support more than 24 hours worth of sections.
}
KeywordWrite:
currcount= % Res1
kwcount +=currcount
totalkwjobs++
;Msgbox Added %Res1% KW JOBS`nTotal KW:%kwcount%`nTotal KW JOBS %totalkwjobs%
Return
AssetWrite:
currcount= % Res1
ascount +=currcount
totalasjobs++
;Msgbox Added %Res1% AS JOBS`nTotal Assets:%ascount%`nTotal AS JOBS %totalasjobs%
Return
JobType:
IfWinExist, ahk_Group GroupName
WinActivate
WinGetTitle, Title, A
IfInString,Title,Keyword
kworas := "kw"
Else IfinString,Title,Asset
kworas := "as"
Else
kworas := "error"
Text := 0
Return
MHelp:
Run,Help.html
Return
MHistory:
Run,Log.html
Return
MAbout:
Run,About.exe
Return
MStats:
IniWrite,%kwcount%,settings.ini,StatsKW,T
IniWrite,%ascount%,settings.ini,StatsAS,T
IniWrite,%timers%,settings.ini,StatsTime,T
IniWrite,1,settings.ini,General,TempStats ;So that stats knows to use Temps
Run,Stats.exe
Return
MSettings:
Run,Settings.exe
Return
`::
While GetKeyState("``","p")
{
MouseGetPos, XPos, YPos
WinMove, Timer,, XPos-30, YPos-25
}
Return
ExitSub:
If timers < 599
{
Msgbox Time worked was less than one minute.`n Timer will not save this to the work history.
IniWrite,Normal,settings.ini,General,CloseState ;crash prevention
IniWrite,0,settings.ini,General,AutoSave ;crash prevention
IniWrite,0,settings.ini,General,AutoSaveKW ;crash prevention
IniWrite,0,settings.ini,General,AutoSaveAS ;crash prevention
ExitApp
}
IniRead,RatePerHour,settings.ini,General,RatePerHour
TotalTime = % FormatSeconds(Floor(Timers/10))
Hours:=Floor(timers/600)/60 ;divide by 600 to get min floor that to disregard seconds then divide by 60 to get hours
Money:=RatePerHour*Hours
SetFormat, FloatFast, 0.2 ;Limit to two decimal places
FileAppend,`n<br><br><b>Date:</b> %A_MMM% %A_DD% %A_YYYY% (%A_hour%:%A_Min%),log.html
FileAppend,`n<br><b>Keywords Worked:</b> %kwcount%,log.html
FileAppend,`n<br><b>Assets Worked:</b> %ascount%,log.html
FileAppend,`n<br><FONT COLOR="33CC00">Money Earned: $ %money%</font>,log.html
FileAppend,`n<br><FONT COLOR="#FF0000">Invoice Time:</font> <FONT COLOR="#FF0000">%TotalTime%</font>,log.html
IniWrite,Normal,settings.ini,General,CloseState ;crash prevention
IniWrite,0,settings.ini,General,AutoSave ;crash prevention
IniWrite,0,settings.ini,General,AutoSaveKW ;crash prevention
IniWrite,0,settings.ini,General,AutoSaveAS ;crash prevention
IniRead,kwcountfinal,settings.ini,StatsKW,%A_WDay%
IniRead,ascountfinal,settings.ini,StatsAS,%A_WDay%
IniRead,timersfinal,settings.ini,StatsTime,%A_WDay%
kwcountfinal +=kwcount
ascountfinal +=ascount
timersfinal +=timers
IniWrite,%kwcountfinal%,settings.ini,StatsKW,%A_WDay%
IniWrite,%ascountfinal%,settings.ini,StatsAS,%A_WDay%
IniWrite,%timersfinal%,settings.ini,StatsTime,%A_WDay%
ExitApp