r/howdidtheycodeit • u/fiddlemouth • Sep 16 '22
Productivity software that blocks Windows apps for certain periods of time
For example the 'Freedom' app: it lets you select certain processes, and for the duration of the work session you define yourself, it closes the selected processes if they're running or as soon as you turn them on.
How would I go about making my own app like this? What libraries should I look for?
15
Upvotes
4
u/LordNuggetzor Sep 17 '22 edited Sep 17 '22
For windows, SystemManagement.dll when icluded can close processes. I used it to make an anti-cheat software for our examination platform.
There are also some windows events that fire when you are doing mechanical things, like plugging in a usb. I also automatically eject them using said events.
I'm using Windows Forms btw, so a bit dated but it works.
3
u/NickHoyer Sep 17 '22
You’d need different libraries depending on your OS. If you’re on Windows, Microsoft has a Windows API, that lets you interact with other processes. The API is in C, but most languages has bindings to it.
9
u/Axikita Sep 16 '22
I've been able to make something for myself like this in AutoHotKey, that closes games if I go past the time budget I've set for the week. I think it would be reasonably straightforward to adjust it to close things during scheduled work periods, rather than based on a time budget.
The core of it is the Process function: https://www.autohotkey.com/docs/commands/Process.htm
which allows you to check if a process exists, or close a process.
Here's the script I made for myself, in case it helps to see it in context:
https://github.com/axikita/GameLimit
-1
u/denierCZ Sep 16 '22
On PC try RescueTime. They have a function like that afaik.