-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 536be45
Showing
20 changed files
with
1,661 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# excel-pomodoro-timer | ||
Excel Pomodoro Timer for Windows | ||
|
||
This Project offers a simple Excel Timer for the Pomodoro Technique. | ||
More details: https://en.wikipedia.org/wiki/Pomodoro_Technique | ||
|
||
|
||
# Installation | ||
|
||
For end users, no installation is required, you simply need to download the file Pomodoro_Timer.xlsb and open it with Excel to start using the tool. | ||
You will need to enable macros in order for the timer to work. | ||
|
||
For developpers, the source code for modules and forms is located in the src directory. | ||
Note: the VbaDeveloper tool was used to export the source code (Availabe at: https://github.com/hilkoc/vbaDeveloper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
Attribute VB_Name = "API_AlwaysOnTop" | ||
'PURPOSE: This module includes the functions used to make sure that the Timer stays on top of all windows. | ||
'REFERENCE: https://www.mrexcel.com/forum/excel-questions/386643-userform-always-top-2.html | ||
|
||
Option Explicit | ||
|
||
Public Const SWP_NOMOVE = &H2 | ||
Public Const SWP_NOSIZE = &H1 | ||
|
||
' For hWndInsertAfter in SetWindowPos | ||
Public Enum HWND_TYPE | ||
HWND_TOP = 0 | ||
HWND_NOTOPMOST = -2 | ||
HWND_TOPMOST = -1 | ||
HWND_BOTTOM = 1 | ||
End Enum | ||
|
||
' For nIndex in SetWindowLongPtr | ||
Public Enum GWL_TYPE | ||
GWL_EXSTYLE = -20 | ||
GWL_STYLE = -16 | ||
GWLP_HINSTANCE = -6 | ||
GWLP_ID = -12 | ||
GWLP_USERDATA = -21 | ||
GWLP_WNDPROC = -4 | ||
End Enum | ||
|
||
' For dwNewLong in SetWindowLongPtr | ||
Public Const WS_MAXIMIZEBOX = &H10000 | ||
Public Const WS_MINIMIZEBOX = &H20000 | ||
Public Const WS_SYSMENU = &H80000 | ||
|
||
'https://msdn.microsoft.com/en-us/library/office/gg264421.aspx | ||
'64-Bit Visual Basic for Applications Overview | ||
|
||
#If VBA7 Then | ||
|
||
'VBA version 7 compiler, therefore >= Office 2010 | ||
'PtrSafe means function works in 32-bit and 64-bit Office | ||
'LongPtr type alias resolves to Long (32 bits) in 32-bit Office, or LongLong (64 bits) in 64-bit Office | ||
|
||
Public Declare PtrSafe Function SetWindowPos Lib "user32" _ | ||
(ByVal hWnd As LongPtr, _ | ||
ByVal hWndInsertAfter As LongPtr, _ | ||
ByVal x As Long, _ | ||
ByVal Y As Long, _ | ||
ByVal cx As Long, _ | ||
ByVal cy As Long, _ | ||
ByVal uFlags As Long) As Long | ||
|
||
Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _ | ||
(ByVal lpClassName As String, _ | ||
ByVal lpWindowName As String) As LongPtr | ||
|
||
'GetWindowLongPtr (Uses different alias (true name) between 32-bit and 64-bit) | ||
#If Win64 Then | ||
'64-bit Office | ||
Public Declare PtrSafe Function GetWindowLongPtr Lib "user32" Alias "GetWindowLongPtrA" _ | ||
(ByVal hWnd As LongPtr, _ | ||
ByVal nIndex As Long) As LongPtr | ||
#Else | ||
'32-bit Office | ||
Public Declare PtrSafe Function GetWindowLongPtr Lib "user32" Alias "GetWindowLongA" _ | ||
(ByVal hWnd As LongPtr, _ | ||
ByVal nIndex As Long) As LongPtr | ||
#End If | ||
|
||
'Set WindowsLongPtr (Uses different alias (true name) between 32-bit and 64-bit) | ||
#If Win64 Then | ||
Public Declare PtrSafe Function SetWindowLongPtr Lib "user32" Alias "SetWindowLongPtrA" _ | ||
(ByVal hWnd As LongPtr, _ | ||
ByVal nIndex As Long, _ | ||
ByVal dwNewLong As LongPtr) As LongPtr | ||
#Else | ||
Public Declare PtrSafe Function SetWindowLongPtr Lib "user32" Alias "SetWindowLongA" _ | ||
(ByVal hWnd As LongPtr, _ | ||
ByVal nIndex As Long, _ | ||
ByVal dwNewLong As LongPtr) As LongPtr | ||
#End If | ||
|
||
Public Declare PtrSafe Function DrawMenuBar Lib "user32" _ | ||
(ByVal hWnd As LongPtr) As Long | ||
|
||
#Else | ||
|
||
'VBA version 6 or earlier compiler, therefore <= Office 2007 | ||
|
||
Public Declare Function SetWindowPos Lib "user32" _ | ||
(ByVal hWnd As Long, _ | ||
ByVal hWndInsertAfter As Long, _ | ||
ByVal X As Long, _ | ||
ByVal Y As Long, _ | ||
ByVal cx As Long, _ | ||
ByVal cy As Long, _ | ||
ByVal uFlags As Long) As Long | ||
|
||
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ | ||
(ByVal lpClassName As String, _ | ||
ByVal lpWindowName As String) As Long | ||
|
||
Public Declare Function GetWindowLongPtr Lib "user32" Alias "GetWindowLongA" _ | ||
(ByVal hWnd As Long, _ | ||
ByVal nIndex As Long) As Long | ||
|
||
Public Declare Function SetWindowLongPtr Lib "user32" Alias "SetWindowLongA" _ | ||
(ByVal hWnd As Long, _ | ||
ByVal nIndex As Long, _ | ||
ByVal dwNewLong As Long) As Long | ||
|
||
Public Declare Function DrawMenuBar Lib "user32" _ | ||
(ByVal hWnd As Long) As Long | ||
|
||
#End If |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Attribute VB_Name = "API_Maximize" | ||
'PURPOSE: Contain function that allows to maximize or minimize a window. | ||
'REFERENCE: http://www.vbaexpress.com/forum/archive/index.php/t-36677.html | ||
|
||
Option Explicit | ||
|
||
#If VBA7 Then | ||
|
||
Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hWnd As LongPtr, ByVal nCmdShow As Long) As Long | ||
Declare PtrSafe Function GetForegroundWindow Lib "user32" () As LongPtr | ||
#Else | ||
Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long | ||
Declare Function GetForegroundWindow Lib "user32" () As Long | ||
#End If | ||
|
||
' ShowWindow() Commands | ||
Public Const SW_HIDE = 0 | ||
Public Const SW_SHOWNORMAL = 1 | ||
Public Const SW_NORMAL = 1 | ||
Public Const SW_SHOWMINIMIZED = 2 | ||
Public Const SW_SHOWMAXIMIZED = 3 | ||
Public Const SW_MAXIMIZE = 3 | ||
Public Const SW_SHOWNOACTIVATE = 4 | ||
Public Const SW_SHOW = 5 | ||
Public Const SW_MINIMIZE = 6 | ||
Public Const SW_SHOWMINNOACTIVE = 7 | ||
Public Const SW_SHOWNA = 8 | ||
Public Const SW_RESTORE = 9 | ||
Public Const SW_SHOWDEFAULT = 10 | ||
Public Const SW_MAX = 10 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Attribute VB_Name = "API_Pixel" | ||
'PURPOSE: This module have functions to help convert pixels to points in Excel, allowing to scale things. | ||
'REFERENCE: http://www.vbaexpress.com/forum/showthread.php?21896-Pixel-to-Point-ratio | ||
|
||
Option Explicit | ||
|
||
#If VBA7 Then | ||
Private Declare PtrSafe Function GetDC Lib "user32" (ByVal hWnd As LongPtr) As LongPtr | ||
Private Declare PtrSafe Function ReleaseDC Lib "user32" (ByVal hWnd As LongPtr, ByVal hdc As LongPtr) As Long | ||
Private Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hdc As LongPtr, ByVal nIndex As Long) As Long | ||
#Else | ||
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long | ||
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long) As Long | ||
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long | ||
#End If | ||
|
||
Private Const LOGPIXELSX As Long = 88 | ||
Private Const LOGPIXELSY As Long = 90 | ||
|
||
Function PointPerPixelX() As Double | ||
#If VBA7 Then | ||
Dim hdc As LongPtr | ||
#Else | ||
Dim hdc As Long | ||
#End If | ||
hdc = GetDC(0) | ||
PointPerPixelX = 1 / (GetDeviceCaps(hdc, LOGPIXELSX) / 72) | ||
End Function | ||
|
||
Function PointPerPixelY() As Double | ||
#If VBA7 Then | ||
Dim hdc As LongPtr | ||
#Else | ||
Dim hdc As Long | ||
#End If | ||
hdc = GetDC(0) | ||
PointPerPixelY = 1 / (GetDeviceCaps(hdc, LOGPIXELSY) / 72) | ||
End Function | ||
|
||
Sub Example() | ||
#If VBA7 Then | ||
Dim hdc As LongPtr | ||
#Else | ||
Dim hdc As Long | ||
#End If | ||
Dim PixPerInchX As Long | ||
Dim PixPerInchY As Long | ||
Dim PixPerPtX As Double | ||
Dim PixPerPtY As Double | ||
Dim PtPerPixX As Double | ||
Dim PtPerPixY As Double | ||
|
||
hdc = GetDC(0) | ||
|
||
PixPerInchX = GetDeviceCaps(hdc, LOGPIXELSX) | ||
PixPerInchY = GetDeviceCaps(hdc, LOGPIXELSY) | ||
|
||
'there are 72 points per inch | ||
PixPerPtX = PixPerInchX / 72 | ||
PixPerPtY = PixPerInchY / 72 | ||
|
||
Debug.Print "PixPerPtX: " & PixPerPtX, "PixPerPtY: " & PixPerPtY | ||
|
||
PtPerPixX = 1 / PixPerPtX | ||
PtPerPixY = 1 / PixPerPtY | ||
|
||
Debug.Print "PtPerPixX: " & PtPerPixX, "PtPerPixY: " & PtPerPixX | ||
ReleaseDC 0, hdc | ||
End Sub | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Attribute VB_Name = "API_Sleep" | ||
'PURPOSE: Define the sleep function to stop the code from running and releasing CPU usage. | ||
|
||
Option Explicit | ||
|
||
#If VBA7 Then | ||
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 64 Bit Systems | ||
#Else | ||
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 32 Bit Systems | ||
#End If | ||
|
||
Sub SleepTest() | ||
'MsgBox "Execution is started" | ||
Sleep 10000 'delay in milliseconds | ||
MsgBox "Waiting completed" | ||
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Attribute VB_Name = "API_WorkArea" | ||
'PURPOSE: Get screen size in pixels | ||
'REFERENCE: https://www.excelforum.com/excel-programming-vba-macros/565556-why-does-spi_getworkarea-come-in-too-large.html | ||
|
||
Option Explicit | ||
|
||
Private Const SPI_GETWORKAREA = 48 | ||
|
||
#If VBA7 Then | ||
Private Declare PtrSafe Function SystemParametersInfo Lib "user32" _ | ||
Alias "SystemParametersInfoA" (ByVal uAction As Long, _ | ||
ByVal uParam As Long, ByRef lpvParam As Any, _ | ||
ByVal fuWinIni As Long) As Long | ||
#Else | ||
Private Declare Function SystemParametersInfo Lib "user32" _ | ||
Alias "SystemParametersInfoA" (ByVal uAction As Long, _ | ||
ByVal uParam As Long, ByRef lpvParam As Any, _ | ||
ByVal fuWinIni As Long) As Long | ||
#End If | ||
|
||
Private Type RECT | ||
Left As Long | ||
Top As Long | ||
Right As Long | ||
Bottom As Long | ||
End Type | ||
|
||
Function GETWORKAREA_HEIGHT() As Double | ||
'PURPOSE: Get the screen size exluding the taskbar | ||
Dim nRect As RECT | ||
SystemParametersInfo SPI_GETWORKAREA, 0, nRect, 0 | ||
GETWORKAREA_HEIGHT = (nRect.Bottom - nRect.Top) | ||
End Function | ||
|
||
|
||
Function GETWORKAREA_WIDTH() As Double | ||
'PURPOSE: Get the screen size exluding the taskbar | ||
Dim nRect As RECT | ||
SystemParametersInfo SPI_GETWORKAREA, 0, nRect, 0 | ||
GETWORKAREA_WIDTH = (nRect.Right - nRect.Left) | ||
End Function | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Attribute VB_Name = "Main" | ||
'Infos: different modes for userform: | ||
'https://www.mrexcel.com/forum/excel-questions/465425-minimize-excel-leave-userform-showing.html | ||
|
||
|
||
Public AllowedTime As Integer 'Number of minutes to count down | ||
Public AllowedTimeSec As Integer 'Number of seconds to count down | ||
Public BreakTime As Double | ||
Public BreakTimeSec As Integer | ||
Public AutoLaunch As Boolean | ||
Public TaskName As String | ||
Public StopTimer As Boolean 'User stopped timer | ||
Public CloseTimer As Boolean 'User clicked the X | ||
Public OngoingTimer As Boolean 'Take the value true after the timer has started (was initialized) | ||
Public StartTime As Variant | ||
Public TodaysDate As Variant | ||
|
||
Sub PomodoroSession() | ||
AllowedTime = Range("Pomodoro") | ||
AllowedTimeSec = Range("Pomodoro_sec") | ||
BreakTime = Range("Break") | ||
BreakTimeSec = Range("Break_sec") | ||
AutoLaunch = True | ||
ThisWorkbook.Application.WindowState = xlMinimized | ||
If Reopen_decision = True Then | ||
MsgBox "To let you work with Excel while the timer is running, this file will now be reopen in a second instance of Excel." & vbNewLine & _ | ||
"Once, the was has been reopen, you will need to relaunch the timer." | ||
Call OpenItSelfInAnotherInstance | ||
End If | ||
PomodoroTimer.Show vbModeless | ||
'Note:vbModeless as opposed to vbModal will allow the Excel application to be unlocked while the timer is running | ||
End Sub | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Break,=Settings!$B$4, | ||
Break_sec,=Settings!$B$5, | ||
Custom_position,=Settings!$B$12, | ||
Flashing_color,=Settings!$B$16, | ||
Left_pos,=Settings!$B$13, | ||
No_Recording_limit,=Settings!$B$9, | ||
Pomodoro,=Settings!$B$2, | ||
Pomodoro_sec,=Settings!$B$3, | ||
Recent_Tasks,=OFFSET(Recent!$A$2,0,0,COUNTA(Recent!$A$2:$A$1000002)), | ||
Record_unfinished,=Settings!$B$8, | ||
Reopen_Excel_after_x,=Settings!$B$7, | ||
Run_in_seperate_instance,=Settings!$B$6, | ||
Shortcut,=Settings!$B$15, | ||
Sound_end_Break,=Settings!$B$11, | ||
Sound_end_Pomodoro,=Settings!$B$10, | ||
TaskNameRng,=Pomodoro!$E$2, | ||
Top_pos,=Settings!$B$14, | ||
TopLeftCorner,=Table24[[#Headers],[Date]], |
Oops, something went wrong.