Any Breaks scheduler in AHK? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
usser
Posts: 145
Joined: 22 Oct 2014, 13:03

Any Breaks scheduler in AHK?

Post by usser » 28 Mar 2024, 10:16

Hi

Has anyone built a Break Scheduler in AHK?

There are tons of such programs but I think none combines all preferred features or is lightweight enough.

They will either:
1) not detect inactivity to reset screen time counting
2) not have independent notification sound level from the mail device sound level so that you get notified even when your device is on mute
3) not be lightweight of few kilo or mega bytes

Are you aware of any such AHK based breaks scheduler? I think everyone should have on their device as it can be really unhealthy to have extended screen time.

Thanks
RussF
Posts: 1269
Joined: 05 Aug 2021, 06:36

Re: Any Breaks scheduler in AHK?

Post by RussF » 28 Mar 2024, 10:30

Climbing on to soapbox...

A "break timer" and "auto-clicker" (as mentioned in another of your posts) to reduce RSI and other maladies resulting from computer use are not needed at all if one uses some "common sense" (which may not be all that common anymore) as well as good posture, frequent stretching and exercise. Must we continue to diminish the need for human intelligence by constantly "protecting us from ourselves" with these gimmicks?

Just get up, walk around and stretch a couple of muscles every half hour and when you're sitting, sit up straight, use wrist supports and set your monitor at eye level. Common sense - if not, there are plenty of web sites to instruct you.

Stepping down from soapbox...

Russ
User avatar
kunkel321
Posts: 1061
Joined: 30 Nov 2015, 21:19

Re: Any Breaks scheduler in AHK?

Post by kunkel321 » 28 Mar 2024, 10:46

Here's a fun clicker that @Hellbent made a long time ago.
https://pastebin.com/yCTyiXYx
It's AHK v1 code though.

Skrommel on the DC site makes some fun things with AHK. I think I recall him making a break timer(?) Again, it will be v1. Also, the page is not loading right now... Not sure why. Link to the page is here:
https://www.donationcoder.com/software/friends-of-dc
ste(phen|ve) kunkel
User avatar
mikeyww
Posts: 26973
Joined: 09 Sep 2014, 18:38

Re: Any Breaks scheduler in AHK?  Topic is solved

Post by mikeyww » 28 Mar 2024, 14:08

Ideas are below.

A break timer

Code: Select all

; This script provides a "break timer": alerts after a defined period of continuous user activity
#Requires AutoHotkey v2.0
InstallKeybdHook
lastMouseButton := 0   ; Time when a mouse button or wheel was last activated
ProcessSetPriority 'B'
SetTimer rest, 1000    ; Start monitoring for idle time

~LButton::
~MButton::
~RButton::
~XButton1::
~XButton2::
~WheelUp::
~WheelDown:: {
 Global lastMouseButton := A_TickCount
}

rest() {
 Static restAfterMin    := 60                   ; Rest after this many minutes of active time
      , idleSec         := 3                    ; Seconds of inactivity defining idle time
      , minDist         := 5                    ; Mouse move less than this distance is ignored
      , restAfterMS     := 60000 * restAfterMin
      , idleMS          := 1000  * idleSec
      , startActive     := 0                    ; Time when active period started
      , last            := False                ; User was previously active
      , lastMouseCursor := A_TickCount          ; Time when mouse cursor last moved
 tick := A_TickCount, idleKB := A_TimeIdleKeyboard
 (mouseMoved(minDist)) && lastMouseCursor := tick
 timeIdleMouse := tick - Max(lastMouseCursor, lastMouseButton)
 Switch last active := timeIdleMouse < idleMS || idleKB < idleMS {
  Case '10': SoundBeep 1000
  Case '01': startActive := tick, SoundBeep(1500)
 }
 If (timeIdleMouse < 1000 || idleKB < 1000) && tick - startActive > restAfterMS
  MsgBox('Take a break!', 'Instructions', 'Iconi'), last := 0
 Else last := active
}

mouseMoved(minDist) {
 Static last ; Previous mouse cursor position
 CoordMode('Mouse'), MouseGetPos(&x, &y)
 moved := IsSet(last) ? Abs(x - last.x) >= minDist || Abs(y - last.y) >= minDist : False
 last  := {x: x, y: y}
 Return moved
}
Post Reply

Return to “Ask for Help (v2)”