Skip to content

Instantly share code, notes, and snippets.

@vgrivtsov
Created July 21, 2016 06:28
Show Gist options
  • Select an option

  • Save vgrivtsov/fb9245c31c80c2865746f57c3eb0f340 to your computer and use it in GitHub Desktop.

Select an option

Save vgrivtsov/fb9245c31c80c2865746f57c3eb0f340 to your computer and use it in GitHub Desktop.
__author__"Victor Grivtsov"
# -*- coding: utf-8 -*-
# Work pause generator, beep on 45 min of hour and blocking keyboard and mouse
# and unblocking after 15 minutes
import sys
import time
from ctypes import * # windll.user32 , win32con need use for mouse_events
import win32api
def timer():
while True:
minutes = (time.strftime('%M'))
while minutes != '45':
sys.stdout.write(time.strftime('\r%M:%S'))
time.sleep(1)
minutes = time.strftime('%M')
print("\nBlock computer!")
win32api.Beep(2000, 2000)
windll.user32.BlockInput(True) # block mouse&keyboard
time.sleep(900)
windll.user32.BlockInput(False) # unblock mouse&keyboard
print("\nUnBlock computer!")
win32api.Beep(1000, 2000)
if __name__ == '__main__':
timer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment