Skip to content

Instantly share code, notes, and snippets.

@hplc
Last active September 17, 2023 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hplc/c74f7b912d240e259c23cb0474a9fd12 to your computer and use it in GitHub Desktop.
Save hplc/c74f7b912d240e259c23cb0474a9fd12 to your computer and use it in GitHub Desktop.
Monitor Kid using computer, just let kid using some limited programs, close other browsers. If the kid switch window, then make sound to alerm. Works for Windows system.
# To run this program in backgorund, run it on command line: pythonw Kid_Monitor.py
# SoundVolumeView.exe is a simple tool for Windows that adjust system volume level.
# Can be downloaded from https://www.nirsoft.net/utils/sound_volume_view.html.
import win32gui
import time
import winsound
import os
i = 0
while i<=1:
# Loop every 3 seconds.
time.sleep(3)
# Prevent kid mute or adjust sound volume.
os.popen('SoundVolumeView.exe /SetVolume {0.0.0.00000000}.{e8953996-74fd-430d-ba38-6a272650d013} 20')
os.popen('SoundVolumeView.exe /Unmute {0.0.0.00000000}.{e8953996-74fd-430d-ba38-6a272650d013}')
# Kill other browser windows.
os.popen("taskkill /f /im opera.exe")
# os.popen("taskkill /f /im chrome.exe")
os.popen("taskkill /f /im firefox.exe")
# Check the current window title, if not correct, make sound alerm.
w=win32gui
title=w.GetWindowText(w.GetForegroundWindow())
tile = str(title)
print(title)
if not (title.find('ClassIn')>=0 or title.find('思维')>=0 or title.find('数学')>=0 or title.find('哔哩哔哩')>=0 or title.find('红星')>=0):
winsound.Beep(400, 700)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment