1
1
import win32api
2
- import win32con
3
2
import time
4
3
import numpy as np
5
- from colorama import Fore , Style , init
4
+ from colorama import Fore , Style
6
5
import win32gui
7
- import os
6
+ import printer
8
7
9
8
def get_mouse_position ():
10
9
return win32api .GetCursorPos ()
11
10
11
+
12
12
def get_mouse_speed (prev_pos , prev_time , cur_pos , cur_time ):
13
13
if prev_pos is None or prev_time is None :
14
14
return 0
15
15
distance = np .linalg .norm (np .array (cur_pos ) - np .array (prev_pos ))
16
16
time_diff = cur_time - prev_time
17
17
return distance / time_diff
18
18
19
+
19
20
def get_pixel_color (x , y ):
20
21
hdc = win32gui .GetDC (0 )
21
22
color = win32gui .GetPixel (hdc , x , y )
22
23
win32gui .ReleaseDC (0 , hdc )
23
24
return color & 0xFF , (color >> 8 ) & 0xFF , (color >> 16 ) & 0xFF
24
25
26
+
25
27
def color_to_ansi (rgb ):
26
28
if rgb [0 ] > rgb [1 ] and rgb [0 ] > rgb [2 ]:
27
29
return Fore .RED
@@ -32,49 +34,40 @@ def color_to_ansi(rgb):
32
34
else :
33
35
return Fore .WHITE
34
36
35
- def print_debug_info (prev_mouse_pos , prev_time , prev_speed , prev_window_title ):
37
+
38
+ def print_debug_info (prev_mouse_pos , prev_time , prev_speed , prev_window_title , printTool : printer .printer ):
36
39
cur_mouse_pos = get_mouse_position ()
37
40
cur_time = time .time ()
38
41
39
42
mouse_speed = get_mouse_speed (prev_mouse_pos , prev_time , cur_mouse_pos , cur_time )
40
43
mouse_color = get_pixel_color (cur_mouse_pos [0 ], cur_mouse_pos [1 ])
41
44
window_title = win32gui .GetWindowText (win32gui .GetForegroundWindow ())
42
45
43
- os .system ('cls' )
44
- print (Style .BRIGHT + Fore .CYAN + f'WA Modern Console Debug Information' + Style .RESET_ALL )
45
- print (f'Mouse Position:' )
46
- print (f' X: { Fore .YELLOW } ------> { cur_mouse_pos [0 ]} { Style .RESET_ALL } ' )
47
- print (f' Y: { Fore .YELLOW } ------> { cur_mouse_pos [1 ]} { Style .RESET_ALL } ' )
48
- print (f'Mouse Color: { color_to_ansi (mouse_color )} RGB({ mouse_color [0 ]} , { mouse_color [1 ]} , { mouse_color [2 ]} ){ Style .RESET_ALL } ' )
49
- print (f'Mouse Speed: { mouse_speed :.2f} pixels per second' )
46
+ printTool .join (Style .BRIGHT + Fore .CYAN + f'WA Modern Console Debug Information' + Style .RESET_ALL )
47
+ printTool .join (f'Mouse Position:' )
48
+ printTool .join (f' X: { Fore .YELLOW } ------> { cur_mouse_pos [0 ]} { Style .RESET_ALL } ' )
49
+ printTool .join (f' Y: { Fore .YELLOW } ------> { cur_mouse_pos [1 ]} { Style .RESET_ALL } ' )
50
+ printTool .join (f'Mouse Color: { color_to_ansi (mouse_color )} RGB({ mouse_color [0 ]} , { mouse_color [1 ]} , { mouse_color [2 ]} ){ Style .RESET_ALL } ' )
51
+ printTool .join (f'Mouse Speed: { mouse_speed :.2f} pixels per second ' )
50
52
51
53
if mouse_speed == 0 and prev_speed == 0 :
52
- print (f'Is Mouse Stopped: { Fore .RED } π True{ Style .RESET_ALL } ' )
54
+ printTool . join (f'Is Mouse Stopped: { Fore .RED } π True{ Style .RESET_ALL } ' )
53
55
else :
54
- print (f'Is Mouse Stopped: { Fore .GREEN } β
False{ Style .RESET_ALL } ' )
56
+ printTool . join (f'Is Mouse Stopped: { Fore .GREEN } β
False{ Style .RESET_ALL } ' )
55
57
56
- print (f'Mouse Sensitivity: { Fore .MAGENTA } Medium{ Style .RESET_ALL } ' )
58
+ printTool . join (f'Mouse Sensitivity: { Fore .MAGENTA } Medium{ Style .RESET_ALL } ' )
57
59
58
- print ('\n Color Intensity:' )
59
- print (f' Red Intensity: { Fore .RED } π΄ { mouse_color [0 ]} { Style .RESET_ALL } ' )
60
- print (f' Green Intensity: { Fore .GREEN } π’ { mouse_color [1 ]} { Style .RESET_ALL } ' )
61
- print (f' Blue Intensity: { Fore .BLUE } π΅ { mouse_color [2 ]} { Style .RESET_ALL } ' )
60
+ printTool . join ('\n Color Intensity:' )
61
+ printTool . join (f' Red Intensity: { Fore .RED } π΄ { mouse_color [0 ]} { Style .RESET_ALL } ' )
62
+ printTool . join (f' Green Intensity: { Fore .GREEN } π’ { mouse_color [1 ]} { Style .RESET_ALL } ' )
63
+ printTool . join (f' Blue Intensity: { Fore .BLUE } π΅ { mouse_color [2 ]} { Style .RESET_ALL } ' )
62
64
63
- print ('\n Window Information:' )
64
- print (f' Window Title: { window_title } ' )
65
+ printTool . join ('\n Window Information:' )
66
+ printTool . join (f' Window Title: { window_title } ' )
65
67
66
68
if window_title != prev_window_title :
67
- print (f' { Fore .YELLOW } π Window Changed!{ Style .RESET_ALL } ' )
69
+ printTool .join (f' { Fore .YELLOW } π Window Changed!{ Style .RESET_ALL } ' )
70
+ else :
71
+ printTool .join (f' { Fore .YELLOW } { Style .RESET_ALL } ' )
68
72
69
73
return cur_mouse_pos , cur_time , mouse_speed , window_title
70
-
71
- if __name__ == "__main__" :
72
- init ()
73
- prev_mouse_pos = None
74
- prev_time = None
75
- prev_speed = 0
76
- prev_window_title = ""
77
-
78
- while True :
79
- prev_mouse_pos , prev_time , prev_speed , prev_window_title = print_debug_info (prev_mouse_pos , prev_time , prev_speed , prev_window_title )
80
- time .sleep (0.5 )
0 commit comments