Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Version:
- 0.46 Update the Desktop Widget without making it show on top of anything else.
- 0.45 Added more user editable values at the top of the file
- 0.44 Show "it's a new day" for either the start of a new week, or someones first day.
- 0.43 added dynamic width calculation. I think that can be done via the gui itself, but it's less fun that way.
- 0.42 removed the taskbar button, now it has to be closed from the notification tray.
- 0.41 made the window transparent, dynamically resizes a bit, tracks weeks, removed borders/title bar.
- */
- start_date = 20180505 ; Date in a YYYYYMMDD format.
- menu_X := 435 ;x cordinate for where the menu loads
- menu_Y := 20 ; y coord
- gosub load_gui ; end user editable variables
- gosub update_gui
- SetTimer, update_gui, 900000 ; update every 10 minutes
- return
- load_gui:
- Gui, Color, Black
- Gui +Owner ; hide taskbar button, it must be closed from the notification tray.
- Gui, Font, s10, Trebuchet MS
- Gui, Add, Text, x2 y2 h200 w200 vDays cwhite ;cf4f3f5,
- Gui, Show, x%menu_X% y%menu_Y% h80 w125,
- Gui +LastFound ; Make the GUI window the last found window for use by the line below.
- WinSet, Transparent, 150, A
- ;Gui, Color, EEAA99 ;this and the line below allows full transparency
- ;WinSet, TransColor, EEAA99
- WinSet, Style, ^0xC00000, A ; Hide the title bar and borders
- OnMessage(0x201, "WM_LBUTTONDOWN") ; allow the menu to be dragged by the font. Ouch.
- return
- WM_LBUTTONDOWN()
- {
- PostMessage, 0xA1, 2
- }
- uiMove:
- PostMessage, 0xA1, 2,,, A
- Return
- GuiClose:
- ExitApp
- return
- update_gui:
- FormatTime, m_days, YYYYMMDD, yyyyMMdd
- EnvSub, m_days, %start_date%, days
- ;m_days := 725 ; testing purposes
- m_totaldays := m_days
- m_includetotal := ( m_days >= 7 )
- m_string := ""
- if ( m_days >= 365 )
- m_string := m_string . "Years sober: " Floor( m_days / 365 ) . "`n"
- while m_days >= 365
- m_days -= 365
- if ( m_days >= 30 ) ; average days in a month is a smidge over 30
- m_string := m_string . "Months Sober: " Floor( m_days / 30 ) . "`n"
- while m_days >= 30
- m_days -= 30
- if ( m_days >= 7 )
- m_string := m_string . "Weeks Sober: " Floor( m_days / 7 ) . "`n"
- while m_days >= 7
- m_days -= 7
- if ( m_Days > 0 )
- m_string := m_string . "Days Sober: " m_days . "`n"
- else
- m_string := m_string . "It's a new day!`n"
- if ( m_includetotal )
- m_string := m_string . "`nTotal days sober: " m_totaldays
- GuiControl, Text, Days, %m_string%
- StringReplace, m_string, m_string, `n, `n, UseErrorLevel
- height := ( ErrorLevel *= 24 ) ; 25 pixels for every 2 lines
- ;width := ( m_totaldays >= 1000 ? 137 : 127 ) ; just add 10 pixels for the thousandths collumn, I don't care all that much about tens of thousands.
- width := ( StrLen( m_totaldays ) >= 4 ? 127 + ( ( StrLen( m_totaldays ) - 3 ) * 8 ) : 127 ) ; I lied.
- Gui, Show, x%menu_X% y%menu_Y% h%height% w%width% NA,
- return
- IsWhole(Number)
- {
- return !Mod(Number, Floor(number))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement