-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreen_locker.py
57 lines (44 loc) · 1.56 KB
/
screen_locker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import tkinter as tk
import keyboard
import mouse
import threading
class ScreenLocker:
def __init__(self, root):
self.root = root
self.root.attributes("-fullscreen", True)
self.root.attributes("-topmost", True)
self.root.config(cursor="none")
self.password = "1234" # Defina a senha aqui
self.create_widgets()
self.block_input()
def create_widgets(self):
self.label = tk.Label(self.root, text="Digite a senha para desbloquear", font=("Helvetica", 24), bg="black", fg="white")
self.label.pack(pady=20)
self.entry = tk.Entry(self.root, font=("Helvetica", 24), show="*")
self.entry.pack(pady=20)
self.entry.bind("<Return>", self.check_password)
self.button = tk.Button(self.root, text="Desbloquear", font=("Helvetica", 24), command=self.check_password)
self.button.pack(pady=20)
def check_password(self, event=None):
if self.entry.get() == self.password:
self.root.destroy()
self.unblock_input()
def block_input(self):
self.blocking = True
threading.Thread(target=self._block_input).start()
def _block_input(self):
while self.blocking:
keyboard.block_key('all')
mouse.move(0, 0)
mouse.click('left')
mouse.click('right')
def unblock_input(self):
self.blocking = False
keyboard.unhook_all()
mouse.unhook_all()
def main():
root = tk.Tk()
app = ScreenLocker(root)
root.mainloop()
if __name__ == "__main__":
main()