From 158696b96dfddf60c1408d4e8c1544b2bf7e77b4 Mon Sep 17 00:00:00 2001 From: borislav nikolov Date: Thu, 5 Oct 2023 17:27:25 +0200 Subject: [PATCH] text_follow_mouse --- projects/panic/cards/text_follow_mouse.py | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 projects/panic/cards/text_follow_mouse.py diff --git a/projects/panic/cards/text_follow_mouse.py b/projects/panic/cards/text_follow_mouse.py new file mode 100644 index 00000000..c240ef28 --- /dev/null +++ b/projects/panic/cards/text_follow_mouse.py @@ -0,0 +1,33 @@ +# pip install pywin32 +import random,time +import win32gui as g +import win32api as a +from ctypes import windll +from ctypes import wintypes +from ctypes import byref + +dc = windll.user32.GetDC(0) +font = g.LOGFONT() +font.lfFaceName = "Consolas" +fnt = g.CreateFontIndirect(font) +g.SelectObject(dc,fnt) +g.SetBkColor(dc, a.RGB(0,0,0)) + +def get_cursor_pos(): + cursor = wintypes.POINT() + r = byref(cursor) + windll.user32.GetCursorPos(r) + return (cursor.x, cursor.y) + +dc = g.GetDC(0) +text = "Hello?" + +while True: + (x,y) = get_cursor_pos() + g.DrawText(dc, + text, + len(text), + (x,y,x+40,y+40), + 0) + time.sleep(1) +