-
Notifications
You must be signed in to change notification settings - Fork 0
/
handle_system.py
47 lines (40 loc) · 1.44 KB
/
handle_system.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
import ctypes, time, os
def hide_console():
if os.name == "nt":
hWnd = ctypes.windll.kernel32.GetConsoleWindow()
if hWnd:
ctypes.windll.user32.ShowWindow(hWnd, 0)
else:
print("> fix hide_console()")
def show_console():
wipe()
if os.name == "nt":
hWnd = ctypes.windll.kernel32.GetConsoleWindow()
if hWnd:
set_console_size(400, 300)
ctypes.windll.user32.ShowWindow(hWnd, 1)
time.sleep(0.100)
ctypes.windll.user32.SetForegroundWindow(hWnd)
else:
print("> fix show_console()")
def set_console_size(width, height):
hWnd = ctypes.windll.kernel32.GetConsoleWindow()
if hWnd:
rect = ctypes.wintypes.RECT()
ctypes.windll.user32.GetWindowRect(hWnd, ctypes.byref(rect))
ctypes.windll.user32.MoveWindow(hWnd, rect.left, rect.top, width, height, True)
def time_since_input():
if os.name == "nt":
class LASTINPUTINFO(ctypes.Structure):
_fields_ = [('cbSize', ctypes.c_uint), ('dwTime', ctypes.c_uint)]
lastInputInfo = LASTINPUTINFO()
lastInputInfo.cbSize = ctypes.sizeof(LASTINPUTINFO)
ctypes.windll.user32.GetLastInputInfo(ctypes.byref(lastInputInfo))
return ctypes.windll.kernel32.GetTickCount() - lastInputInfo.dwTime
else:
print("> fix idle_checking()")
def wipe():
if os.name == "nt":
os.system("cls")
else:
os.system("clear")