Simple yet effective AI power timesheet
What I Built
Auto Timesheet Desktop is a Windows background agent that silently tracks everything you do on your computer all day - which apps you focus on, which Excel spreadsheets you edit, which web forms you submit, and which emails you send - then, at the end of the day, feeds those raw activity logs to a locally running Gemma LLM (via LM Studio) to generate a clean, structured, professional daily timesheet in seconds.
The person who gets to be lazier: Anyone who has to fill in a daily or weekly timesheet manually. Consultants, freelancers, corporate employees, finance teams - anyone who ends the day trying to remember what they actually worked on for the last 8 hours.
What It Tracks Automatically
What it tracks automatically (zero manual effort):
- 🖥️ Active window focus - app name, document/tab title, and duration (with idle detection > 5 min)
- 📊 Excel & spreadsheet operations - detects when
.xlsx,.xls,.csv, or.xlsmfiles are created, modified, renamed, or deleted in your watched folders - 🌐 Web activity & form submissions - via a lightweight companion browser extension (Chrome/Edge), captures visited URLs and online form submissions (safely masking passwords and tokens)
- 📧 Sent emails - captures outgoing Gmail and Outlook Web emails with recipient and subject via the same browser extension
- ⏱️ Live activity feed - a real-time scrolling dashboard of every tracked event
What the Gemma LLM Does
At end-of-day (manually triggered or scheduled), the app sends the raw .txt activity log to the local Gemma model with a carefully engineered prompt. Gemma reads the log and produces a structured JSON timesheet with:
- Grouped work sessions by project and category (Development, Documentation & Excel, Communication & Email, Research & Web, Admin & Forms)
- Realistic start/end times and duration per task
- Specific artifacts: file names, URLs, email recipients
- An executive summary of the day's work
- Accurate category-level time breakdown
If LM Studio is offline, a smart heuristic fallback analyzer (no LLM required) parses the raw logs using timestamps and classifies every event into the same structured format.
Result: A fully filled-in, exportable timesheet that took zero manual effort.
End-to-End Flow in a Real Session
Here's what the end-to-end flow looks like in a real session:
- The app runs silently in the system tray all day. Raw activity log captured for a real morning session:
[06:34:37] [WINDOW] chrome.exe | Gmail - Google Chrome | 3s
[06:37:01] [WINDOW] chrome.exe | Inbox (78) - Gmail | 144s
[06:39:09] [FILE_EXCEL] RENAMED_OR_MOVED | first book to write.xlsx
[06:40:59] [WINDOW] EXCEL.EXE | first book to write - Excel | 108s
[06:42:20] [WINDOW] chrome.exe | Untitled form - Google Forms | 18s
[06:45:59] [WINDOW] chrome.exe | ChatGPT | 54s
[06:48:53] [WINDOW] LM Studio.exe | LM Studio | 108s
- Click "Generate Timesheet with Gemma" - done in ~15 seconds. The Gemma model reads the log and returns:
{
"date": "2026-10-26",
"summary": "Morning session covered email review, spreadsheet editing (first book to write.xlsx), online form administration, AI research via ChatGPT, and local model setup in LM Studio.",
"total_hours_tracked": 1.4,
"entries": [
{
"project": "Email & Communications",
"category": "Communication & Email",
"start_time": "06:34",
"end_time": "06:38",
"duration_minutes": 5
},
{
"project": "Spreadsheet Management",
"category": "Documentation & Excel",
"start_time": "06:38",
"end_time": "06:41",
"duration_minutes": 12,
"artifacts": ["first book to write.xlsx"]
},
{
"project": "Web Operations & Forms",
"category": "Admin & Forms",
"start_time": "06:41",
"end_time": "06:43",
"duration_minutes": 6
},
{
"project": "Online Research & AI",
"category": "Research & Web",
"start_time": "06:43",
"end_time": "06:47",
"duration_minutes": 5
},
{
"project": "Local AI & Model Setup",
"category": "Development",
"start_time": "06:47",
"end_time": "06:50",
"duration_minutes": 15,
"artifacts": ["LM Studio"]
}
]
}
- Export to Excel
.xlsx, JSON, or copy a Markdown table - one click.
Code
🔗 GitHub: https://github.com/YOUR_USERNAME/Auto_time_sheet (Replace with your actual repository URL before publishing)
Project Structure
Auto_time_sheet/
├── main.py # Entry point (GUI + headless + --analyze modes)
├── config.py # Settings manager
├── requirements.txt
├── tracker/
│ ├── activity_manager.py # Orchestrates all trackers
│ ├── window_monitor.py # Win32 API active window + idle detection
│ ├── file_monitor.py # Watchdog-based Excel file event listener
│ ├── web_receiver.py # HTTP server for browser extension events
│ └── logger.py # Writes activity_YYYY-MM-DD.txt + .jsonl
├── analyzer/
│ ├── prompt_builder.py # Packages raw logs for Gemma prompt
│ ├── gemma_client.py # LM Studio OpenAI-compatible API client
│ └── json_parser.py # JSON repair + smart heuristic fallback
├── ui/
│ ├── app.py # Main window
│ ├── timesheet_view.py # Timesheet cards, category pills, export
│ ├── activity_view.py # Real-time event stream feed
│ ├── settings_view.py # LM Studio config, model auto-detect
│ └── tray_icon.py # Windows system tray support
├── browser_extension/ # Manifest V3 Chrome/Edge extension
│ ├── manifest.json
│ ├── background.js
│ ├── content.js # Captures forms + Gmail/Outlook sent
│ └── popup.html / popup.js
└── data/
├── logs/ # activity_YYYY-MM-DD.txt (gitignored)
├── timesheets/ # timesheet_YYYY-MM-DD.json (gitignored)
└── settings.example.json # Template config for new users
Tech Stack
- Layer Technology Language Python 3.10+ GUI CustomTkinter (dark mode, rounded cards) Window tracking Win32 API via ctypes / pywin32 File monitoring watchdog Browser integration Chrome/Edge Manifest V3 Extension (JS) LLM inference Gemma 2 via LM Studio (local OpenAI-compatible API) Fallback analysis Custom rule-based heuristic log classifier Export openpyxl (Excel), JSON, Markdown clipboard System tray pystray + Pillow
How I Built It
The open-source AI at the core: Google Gemma 2 via LM Studio
The AI backbone is Gemma 2 - Google's open-weight language model family - running 100% locally through LM Studio, which exposes an OpenAI-compatible API endpoint at http://localhost:1234/v1. No OpenAI account. No Anthropic subscription. No API key. Zero dollars spent on inference.
The key engineering challenge was prompt engineering for structured output. Gemma models don't natively support a separate system role in their chat template, so I pack system instructions and user task into one combined user message:
def build_combined_gemma_prompt(date_str, raw_log_text):
"""Single combined prompt - max compatibility with Gemma chat templates."""
sys_prompt, user_prompt = build_gemma_prompt(date_str, raw_log_text)
return f"{sys_prompt}\n\n========================================\nTASK:\n{user_prompt}"
The prompt carefully guards against common Gemma failure modes:
- ✅ Separate different activities - no merging email work with Excel work into one vague block
- ✅ Classify by window title keywords - Gmail/Inbox → Communication & Email, Google Forms → Admin & Forms, ChatGPT → Research & Web, Excel → Documentation & Excel
- ✅ Use real timestamps - the log has exact timestamped events; Gemma derives HH:MM start/end times from them
The Smart Fallback Engine
Because LM Studio can be offline - or Gemma's JSON can be malformed - I built a complete standalone heuristic classifier (generate_fallback_timesheet() in json_parser.py):
- Parses every timestamped log line with regex
- Classifies every event (
FILE_EXCEL,WINDOW,WEBMAIL_SENT,WEB_FORM,WEB_VISIT) viaclassify_event()- matching app names and window titles to work categories - Groups nearby same-category events into sessions (20-minute merge tolerance)
- Calculates real start/end times and durations from actual log timestamps
- Produces the identical JSON schema as Gemma
The parse_timesheet_json() repair layer handles trailing commas, unquoted keys, JS-style comments, and unescaped newlines before falling back to heuristics.
The Browser Extension
Web activity is captured via a Manifest V3 Chrome/Edge extension that:
- Sends
WEB_VISITevents after a 3-second delay on any page (skipping redirect flashes) - Intercepts submit events on
<form>elements - collecting field identifiers only, explicitly excluding passwords and hidden inputs - Hooks into Gmail's Send button via
aria-labelattribute matching and Ctrl+Enter keystroke - Mirrors the same pattern for Outlook Web
Events are POST-ed to a local Python HTTP server (web_receiver.py, port 58432) running in a daemon thread inside the main app.
Why Does Open Innovation Matter?
A closed API would have killed this project before it started - not technically, but ethically. Your daily activity log is deeply personal. It contains:
- The exact URLs you browse
- Subject lines and recipients of your emails
- The filenames of every document you open and edit
- Precisely how long you spent on every task
Sending that to a commercial cloud API means handing your full workday to a third party to store, process, and potentially train on. With GDPR, HIPAA, and NDA obligations in most professional environments, that is a non-starter for lawyers, accountants, healthcare administrators, consultants, and anyone working with confidential client data.
Open-weight local models like Gemma 2 make state-of-the-art structured reasoning available on a modest laptop with zero data leaving the machine. LM Studio democratizes that capability without requiring users to manage Python inference environments.
Open model + open inference runtime = privacy-preserving AI that is genuinely usable by people whose jobs require confidentiality. That's what made this project possible - and that's what a closed API never could have provided.
My Agent Session
(Optional - add your DevRelay session recording here with the agent_session tag, or remove this section)
The Lazy Payoff
I tested this on a real morning session (06:30-07:30) covering email, Excel, Google Forms, ChatGPT, and LM Studio:
Manual Auto Timesheet Time to fill timesheet ~10 minutes 0 minutes Timestamp accuracy Guessed, rounded Exact from log Filenames captured Whatever I remember first book to write.xlsx automatically Tasks missed 2-3 typically 0
Across a 5-day work week that's 50 minutes saved - and the quality is objectively higher because it captures exact timestamps and every task, including the ones you'd normally forget to log.
Prize Categories 🤖 Open-source AI - Built entirely around Google Gemma 2 (open-weight model, local inference via LM Studio) 🐍 Python - Core application built in Python 3.10+ 🔒 Privacy-first AI - Zero cloud dependency; all activity data stays on-device
Installation
# 1. Clone the repo
git clone https://github.com/manik-dev-sudo/Auto_time_sheet.git
cd Auto_time_sheet
# 2. Install dependencies
pip install -r requirements.txt
# 3. Download LM Studio, load any Gemma model, click Start Server
# 4. Run
python main.py
See the full README for browser extension setup, CLI options (--headless, --analyze), and configuration details.
Comments
No comments yet. Start the discussion.