0%

Alarm on Windows for Eye Relaxing

Recently I felt uncomfortable on my eyes due to long-time use of the computer and phone. Therefore, I write simple scripts on Windows and execute periodically to force me to relax every hour.

My idea is to write a batch file to minimize all working windows and pop out a message box saying something like “Leave fuck off the screen!”.

Here is the batch file running PowerShell commands.

1
2
3
:: eye-protection.bat
powershell -command "(new-object -com shell.application).minimizeall()"
powerShell -command "add-type -assemblyname presentationframework;[system.windows.messagebox]::show('Leave fuck off the screen!')"

Now we can force the user to temporarily stop the ongoing work. However, it is not graceful enough to show the execution windows. Here I use another VBScript to run the batch file invisibly as follow.

1
2
' invisible.vbs
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

Run eye-protection.bat invisibly.

1
invisible.vbs eye-protection.bat

The last step is to run the above command periodically, said every hour. I exploit “Task Scheduler” on Windows to reach the goal.

Reference