diff --git a/dot.py b/dot.py new file mode 100644 index 0000000..2da5b5d --- /dev/null +++ b/dot.py @@ -0,0 +1,1692 @@ +import ctypes +import math +import os +import random +import subprocess +import threading +import time +from ctypes import wintypes + +print("HELLO WORLD") + +ij = ctypes.WinDLL("user32", use_last_error=True) +ix = ctypes.WinDLL("gdi32", use_last_error=True) +hm = ctypes.WinDLL("kernel32", use_last_error=True) +ic = ctypes.WinDLL("combase") + +hf = 0x80000000 +cc = 0x00000008 +ai = 0x00000080 +ca = 0x00080000 +ad = 0x00000020 +gh = 0x00000002 +gk = 0x00000002 +da = 0x01 +fs = 0x0002 +hd = 0x000F +bz = 0x0014 +ft = 0x0100 +he = 0x0113 +ay = 0x0201 +gl = 0x1B +ec = 0 +ed = 1 +hw = 5 +al = 48 +gc = 0x0001 +at = 1 +du = 4 +db = 5 +gz = 8 +hb = 0 +hv = 0x00CC0020 +ge = 32512 +ie = 0 +au = 0 +ah = 0x08000000 +u = 1 + +hy = 33 +dw = 25 +ha = 100 +ff = 140 +eg = 150 +gi = 190 +gj = 215 +de = 265 +dv = 95 +gu = 35 +bt = 232 + +ea = 110 +ht = 160 +ig = 2.399963 + +fp = 1 +aw = 2 + +hu = 160 + + +def jn(c, b, a): + return (a << 16) | (b << 8) | c + + +fg = jn(120, 220, 255) +gd = jn(170, 240, 255) +ik = jn(240, 248, 255) +fk = jn(210, 224, 235) +ja = jn(150, 160, 170) +gf = jn(80, 255, 160) +fe = jn(0, 180, 120) +dt = jn(255, 70, 70) +dr = jn(180, 20, 20) +cz = jn(200, 80, 255) +cw = jn(255, 176, 32) +fq = jn(0, 80, 110) +fh = jn(6, 8, 12) + +hx = "your helpful assistant" +hc = 'say "HEY DOT"' + +gg = [ + (28, "> boot sequence initiated"), + (52, "> searching for cortana.exe ... not found"), + (72, "> good."), + (92, "> loading personality ..... done"), + (112, "> calibrating microphone ..."), + (132, "> DOT is online"), +] + +hs = ctypes.c_ssize_t +hz = ctypes.WINFUNCTYPE( + hs, wintypes.HWND, wintypes.UINT, wintypes.WPARAM, wintypes.LPARAM) + +hm.GetModuleHandleW.restype = wintypes.HMODULE +hm.GetModuleHandleW.argtypes = [wintypes.LPCWSTR] +ij.DefWindowProcW.restype = hs +ij.DefWindowProcW.argtypes = [ + wintypes.HWND, wintypes.UINT, wintypes.WPARAM, wintypes.LPARAM] +ij.CreateWindowExW.restype = wintypes.HWND +ij.CreateWindowExW.argtypes = [ + wintypes.DWORD, wintypes.LPCWSTR, wintypes.LPCWSTR, wintypes.DWORD, + ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, + wintypes.HWND, wintypes.HMENU, wintypes.HINSTANCE, wintypes.LPVOID] +ij.SetTimer.argtypes = [ + wintypes.HWND, ctypes.c_size_t, wintypes.UINT, ctypes.c_void_p] +ij.KillTimer.argtypes = [wintypes.HWND, ctypes.c_size_t] +ij.LoadCursorW.restype = wintypes.HANDLE +ij.LoadCursorW.argtypes = [wintypes.HINSTANCE, ctypes.c_void_p] +ij.BeginPaint.restype = wintypes.HDC +ij.GetDC.restype = wintypes.HDC +ij.DrawTextW.argtypes = [ + wintypes.HDC, wintypes.LPCWSTR, ctypes.c_int, + ctypes.POINTER(wintypes.RECT), wintypes.UINT] +ij.FillRect.argtypes = [ + wintypes.HDC, ctypes.POINTER(wintypes.RECT), wintypes.HBRUSH] +ix.CreateSolidBrush.restype = wintypes.HBRUSH +ix.CreatePen.restype = ctypes.c_void_p +ix.SelectObject.restype = ctypes.c_void_p +ix.SelectObject.argtypes = [wintypes.HDC, ctypes.c_void_p] +ix.GetStockObject.restype = ctypes.c_void_p +ix.DeleteObject.argtypes = [ctypes.c_void_p] +ix.CreateCompatibleDC.restype = wintypes.HDC +ix.CreateCompatibleBitmap.restype = ctypes.c_void_p +ix.CreateFontW.restype = ctypes.c_void_p +ix.CreateFontW.argtypes = [ctypes.c_int] * 13 + [wintypes.LPCWSTR] +ix.TextOutW.argtypes = [ + wintypes.HDC, ctypes.c_int, ctypes.c_int, wintypes.LPCWSTR, ctypes.c_int] +ix.BitBlt.argtypes = [ + wintypes.HDC, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, + wintypes.HDC, ctypes.c_int, ctypes.c_int, wintypes.DWORD] +ix.MoveToEx.argtypes = [ + wintypes.HDC, ctypes.c_int, ctypes.c_int, ctypes.c_void_p] + + +class gm(ctypes.Structure): + _fields_ = [ + ("style", wintypes.UINT), ("lpfnWndProc", hz), + ("cbClsExtra", ctypes.c_int), ("cbWndExtra", ctypes.c_int), + ("hInstance", wintypes.HINSTANCE), ("hIcon", wintypes.HICON), + ("hCursor", wintypes.HANDLE), ("hbrBackground", wintypes.HBRUSH), + ("lpszMenuName", wintypes.LPCWSTR), ("lpszClassName", wintypes.LPCWSTR)] + + +class eb(ctypes.Structure): + _fields_ = [ + ("hdc", wintypes.HDC), ("fErase", wintypes.BOOL), + ("rcPaint", wintypes.RECT), ("fRestore", wintypes.BOOL), + ("fIncUpdate", wintypes.BOOL), ("rgbReserved", ctypes.c_byte * 32)] + + +class bs(ctypes.Structure): + _fields_ = [("BlendOp", ctypes.c_ubyte), ("BlendFlags", ctypes.c_ubyte), + ("SourceConstantAlpha", ctypes.c_ubyte), + ("AlphaFormat", ctypes.c_ubyte)] + + +class ag(ctypes.Structure): + _fields_ = [ + ("biSize", wintypes.DWORD), ("biWidth", ctypes.c_long), + ("biHeight", ctypes.c_long), ("biPlanes", wintypes.WORD), + ("biBitCount", wintypes.WORD), ("biCompression", wintypes.DWORD), + ("biSizeImage", wintypes.DWORD), ("biXPelsPerMeter", ctypes.c_long), + ("biYPelsPerMeter", ctypes.c_long), ("biClrUsed", wintypes.DWORD), + ("biClrImportant", wintypes.DWORD)] + + +class fd(ctypes.Structure): + _fields_ = [("bmiHeader", ag), + ("bmiColors", wintypes.DWORD * 3)] + + +class il(ctypes.Structure): + _fields_ = [("Data1", ctypes.c_ulong), ("Data2", ctypes.c_ushort), + ("Data3", ctypes.c_ushort), ("Data4", ctypes.c_ubyte * 8)] + + def __init__(self, s): + super().__init__() + ic.CLSIDFromString(s, ctypes.byref(self)) + + +ic.CLSIDFromString.argtypes = [ctypes.c_wchar_p, ctypes.POINTER(il)] +ij.UpdateLayeredWindow.argtypes = [ + wintypes.HWND, wintypes.HDC, ctypes.POINTER(wintypes.POINT), + ctypes.POINTER(wintypes.SIZE), wintypes.HDC, + ctypes.POINTER(wintypes.POINT), wintypes.COLORREF, + ctypes.POINTER(bs), wintypes.DWORD] +ix.CreateDIBSection.restype = ctypes.c_void_p +ix.CreateDIBSection.argtypes = [ + wintypes.HDC, ctypes.POINTER(fd), wintypes.UINT, + ctypes.POINTER(ctypes.c_void_p), ctypes.c_void_p, wintypes.DWORD] +ij.BeginPaint.argtypes = [wintypes.HWND, ctypes.POINTER(eb)] +ij.EndPaint.argtypes = [wintypes.HWND, ctypes.POINTER(eb)] +ij.GetDC.argtypes = [wintypes.HWND] +ij.ReleaseDC.argtypes = [wintypes.HWND, wintypes.HDC] +ij.InvalidateRect.argtypes = [wintypes.HWND, ctypes.c_void_p, wintypes.BOOL] +ij.SetLayeredWindowAttributes.argtypes = [ + wintypes.HWND, wintypes.COLORREF, ctypes.c_ubyte, wintypes.DWORD] +ij.ShowWindow.argtypes = [wintypes.HWND, ctypes.c_int] +ij.DestroyWindow.argtypes = [wintypes.HWND] +ij.SetWindowPos.argtypes = [ + wintypes.HWND, wintypes.HWND, ctypes.c_int, ctypes.c_int, + ctypes.c_int, ctypes.c_int, wintypes.UINT] +ix.SetBkMode.argtypes = [wintypes.HDC, ctypes.c_int] +ix.SetTextColor.argtypes = [wintypes.HDC, wintypes.COLORREF] +ix.SetPixel.argtypes = [wintypes.HDC, ctypes.c_int, ctypes.c_int, + wintypes.COLORREF] +ix.Ellipse.argtypes = [wintypes.HDC] + [ctypes.c_int] * 4 +ix.Rectangle.argtypes = [wintypes.HDC] + [ctypes.c_int] * 4 +ix.LineTo.argtypes = [wintypes.HDC, ctypes.c_int, ctypes.c_int] +ix.Arc.argtypes = [wintypes.HDC] + [ctypes.c_int] * 8 +ix.CreateCompatibleDC.argtypes = [wintypes.HDC] +ix.CreateCompatibleBitmap.argtypes = [wintypes.HDC, ctypes.c_int, + ctypes.c_int] + +iz = { + "overlay": None, "orb": None, "caption_win": None, + "memdc": None, "membmp": None, "memdc2": None, "membmp2": None, + "orb_dc": None, "orb_bits": None, + "f": 0, "dock_start": None, "phase": 0.0, "ping": 0.0, + "heard": False, "voice_fail": False, "confirm_start": None, + "resident": False, "res_f": 0, + "scr_w": 0, "scr_h": 0, "dock_x": 0, "dock_y": 0, + "orb_x": 0.0, "orb_y": 0.0, "tgt_x": 0.0, "tgt_y": 0.0, + "orb_scale": 1.0, "hinstance": None, + "fonts": {}, "brushes": {}, "pens": {}, + "stars": [], "rmap": [], "n_buckets": 0, + "busy": False, "caption": "", "cap_until": 0, "cap_color": ik, + "mode": "idle", "mode_f": 0, "prog": 0.0, "glitch": 0.0, + "clones": [], "beam": 0.0, "shake": 0.0, "accent": 0.0, + "last_mouse": (0, 0), "mouse_react_at": 0, + "windows": [], "log_feed": [], "banner": "", "banner_color": dt, + "flash": 0.0, "blackout": 0.0, "eye": 0.0, "stage": 0, + "vignette": 0.0, "static": 0.0, "countdown": None, "typed": "", +} + +df = [(dx, dy, math.exp(-(dx * dx + dy * dy) / 3.2)) + for dx in range(-2, 3) for dy in range(-2, 3)] + + +def iw(c, b, a): + return max(b, min(a, c)) + + +def ck(c): + a, b = 1.70158, 2.70158 + return 1 + b * (c - 1) ** 3 + a * (c - 1) ** 2 + + +def cj(a): + return a * a * a + + +fj = os.path.join( + os.environ.get("SystemRoot", r"C:\Windows"), + "System32", "WindowsPowerShell", "v1.0", "powershell.exe") +if not os.path.exists(fj): + fj = "powershell" + +fu = r''' +param([string]$TextPath, [string]$VoiceName) +try { + Add-Type -AssemblyName System.Runtime.WindowsRuntime | Out-Null + $null = [Windows.Media.SpeechSynthesis.SpeechSynthesizer,Windows.Media,ContentType=WindowsRuntime] + $null = [Windows.Storage.Streams.DataReader,Windows.Storage.Streams,ContentType=WindowsRuntime] + $asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | + Where-Object { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and + $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0] + function Await($op,$t){ $task=$asTask.MakeGenericMethod($t).Invoke($null,@($op)); $task.Wait(); $task.Result } + $text = [System.IO.File]::ReadAllText($TextPath) + $syn = New-Object Windows.Media.SpeechSynthesis.SpeechSynthesizer + $v = [Windows.Media.SpeechSynthesis.SpeechSynthesizer]::AllVoices | + Where-Object { $_.DisplayName -like "*$VoiceName*" } | Select-Object -First 1 + if ($v) { $syn.Voice = $v } + $stream = Await ($syn.SynthesizeTextToStreamAsync($text)) ([Windows.Media.SpeechSynthesis.SpeechSynthesisStream]) + $reader = New-Object Windows.Storage.Streams.DataReader($stream) + Await ($reader.LoadAsync([uint32]$stream.Size)) ([uint32]) | Out-Null + $bytes = New-Object byte[] ([int]$stream.Size) + $reader.ReadBytes($bytes) + $wav = [System.IO.Path]::GetTempFileName() + '.wav' + [System.IO.File]::WriteAllBytes($wav, $bytes) + (New-Object System.Media.SoundPlayer $wav).PlaySync() + Remove-Item $wav -ErrorAction SilentlyContinue +} catch { + Add-Type -AssemblyName System.Speech + (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak([System.IO.File]::ReadAllText($TextPath)) +} +''' + + +def iy(a): + if not a: + return + try: + c = os.path.join(os.environ.get("TEMP", "."), + "dot_say_%d.txt" % threading.get_ident()) + with open(c, "w", encoding="utf-8") as d: + d.write(a) + b = os.path.join(os.environ.get("TEMP", "."), "dot_tts.ps1") + if not os.path.exists(b): + with open(b, "w", encoding="utf-8") as d: + d.write(fu) + subprocess.run([fj, "-NoProfile", "-ExecutionPolicy", "Bypass", + "-File", b, "-TextPath", c, "-VoiceName", "Mark"], + creationflags=ah, check=False) + except OSError as e: + print("[voice] TTS failed:", e) + + +def gt(b, a=True): + threading.Thread(target=iy, args=(b,), daemon=a).start() + + +def ib(c, a=4.0, b=ik): + iz["caption"] = c + iz["cap_until"] = time.time() + a + iz["cap_color"] = b + + +ic.WindowsCreateString.argtypes = [ + ctypes.c_wchar_p, ctypes.c_uint32, ctypes.POINTER(ctypes.c_void_p)] +ic.WindowsCreateString.restype = ctypes.c_int32 +ic.WindowsDeleteString.argtypes = [ctypes.c_void_p] +ic.WindowsGetStringRawBuffer.argtypes = [ + ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint32)] +ic.WindowsGetStringRawBuffer.restype = ctypes.c_wchar_p +ic.RoActivateInstance.argtypes = [ctypes.c_void_p, + ctypes.POINTER(ctypes.c_void_p)] +ic.RoActivateInstance.restype = ctypes.c_int32 +ic.RoInitialize.argtypes = [ctypes.c_int32] +ic.RoInitialize.restype = ctypes.c_int32 + +l = 10 +dg = 11 +ak = 7 +af = 7 +z = 8 +fv = False + + +def go(e, c, b, a, *d): + f = ctypes.cast(e, ctypes.POINTER(ctypes.c_void_p))[0] + g = ctypes.cast(f, ctypes.POINTER(ctypes.c_void_p))[c] + return ctypes.WINFUNCTYPE(b, ctypes.c_void_p, *a)(g)( + e, *d) + + +def hj(b): + a = ctypes.c_void_p() + ic.WindowsCreateString(b, len(b), ctypes.byref(a)) + return a + + +def dk(a): + if not a: + return "" + b = ctypes.c_uint32() + return ic.WindowsGetStringRawBuffer(a, ctypes.byref(b)) or "" + + +def cf(): + global fv + if not fv: + try: + ic.RoInitialize(u) + except OSError: + pass + fv = True + + +def ii(c, a=15): + d = ctypes.c_void_p() + e = il("{00000036-0000-0000-C000-000000000046}") + if go(c, 0, ctypes.HRESULT, + [ctypes.POINTER(il), ctypes.POINTER(ctypes.c_void_p)], + ctypes.byref(e), ctypes.byref(d)) != 0: + d = c + b = time.monotonic() + a + while time.monotonic() < b: + g = ctypes.c_int32() + go(d, af, ctypes.HRESULT, + [ctypes.POINTER(ctypes.c_int32)], ctypes.byref(g)) + if g.value == 1: + f = ctypes.c_void_p() + go(c, z, ctypes.HRESULT, + [ctypes.POINTER(ctypes.c_void_p)], ctypes.byref(f)) + return f + if g.value in (2, 3): + return None + time.sleep(0.03) + try: + go(d, 9, ctypes.HRESULT, []) + except OSError: + pass + return None + + +def bk(a=8): + cf() + e = hj("Windows.Media.SpeechRecognition.SpeechRecognizer") + f = ctypes.c_void_p() + g = ic.RoActivateInstance(e, ctypes.byref(f)) + ic.WindowsDeleteString(e) + if g != 0 or not f.value: + return None + try: + d = ctypes.c_void_p() + if go(f, l, ctypes.HRESULT, + [ctypes.POINTER(ctypes.c_void_p)], + ctypes.byref(d)) != 0: + return None + ii(d, 6) + h = ctypes.c_void_p() + if go(f, dg, ctypes.HRESULT, + [ctypes.POINTER(ctypes.c_void_p)], ctypes.byref(h)) != 0: + return None + b = ii(h, a + 4) + if not b or not b.value: + return None + c = ctypes.c_void_p() + go(b, ak, ctypes.HRESULT, + [ctypes.POINTER(ctypes.c_void_p)], ctypes.byref(c)) + return (dk(c) or "").strip() or None + except OSError as e: + if "80045509" in str(e) or "80045" in str(e): + iz["voice_fail"] = True + return None + finally: + go(f, 2, ctypes.HRESULT, []) + + +bv = ("hey dot", "hi dot", "hey dott", "ey dot", "a dot", + "hey daught", "hey dark", "hey", "dot", "a note") + + +def fy(a): + b = (a or "").lower() + return any(p in b for p in bv) + + +def cv(): + for b in range(40): + if iz["heard"] or iz["voice_fail"]: + return + a = bk(a=7) + if a: + print("[voice] heard:", repr(a)) + if fy(a): + iz["heard"] = True + return + iz["voice_fail"] = True + + +def bo(): + threading.Thread(target=cv, daemon=True).start() + + +def iv(a): + c = iz["brushes"].get(a) + if c is None: + c = iz["brushes"][a] = ix.CreateSolidBrush(a) + return c + + +def jm(a, b=1): + c = iz["pens"].get((a, b)) + if c is None: + c = iz["pens"][(a, b)] = ix.CreatePen( + hb, b, a) + return c + + +def cl(b, f, g, e, a): + c = ix.SelectObject(b, iv(a)) + d = ix.SelectObject(b, ix.GetStockObject(gz)) + ix.Ellipse(b, int(f - e), int(g - e), int(f + e + 1), int(g + e + 1)) + ix.SelectObject(b, c) + ix.SelectObject(b, d) + + +def bj(b, g, h, e, f, a): + c = ix.SelectObject(b, iv(a)) + d = ix.SelectObject(b, ix.GetStockObject(gz)) + ix.Ellipse(b, int(g - e), int(h - f), int(g + e + 1), + int(h + f + 1)) + ix.SelectObject(b, c) + ix.SelectObject(b, d) + + +def cn(c, g, h, f, a, b=3): + e = ix.SelectObject(c, jm(a, b)) + d = ix.SelectObject(c, ix.GetStockObject(db)) + ix.Ellipse(c, int(g - f), int(h - f), int(g + f + 1), int(h + f + 1)) + ix.SelectObject(c, d) + ix.SelectObject(c, e) + + +def eq(b, c, e, d, f, a): + g = wintypes.RECT(int(c), int(e), int(d), int(f)) + ij.FillRect(b, ctypes.byref(g), iv(a)) + + +def jl(c, d, f, e, g, a, b=1): + h = ix.SelectObject(c, jm(a, b)) + ix.MoveToEx(c, int(d), int(f), None) + ix.LineTo(c, int(e), int(g)) + ix.SelectObject(c, h) + + +def es(c, d, f, e, g, a, b=2): + jl(c, d, f, e, f, a, b) + jl(c, e, f, e, g, a, b) + jl(c, e, g, d, g, a, b) + jl(c, d, g, d, f, a, b) + + +def hk(e, n, o, m, d, c, a, b=2): + g = ix.SelectObject(e, jm(a, b)) + f = ix.SelectObject(e, ix.GetStockObject(db)) + i, k = n + m * math.cos(d), o + m * math.sin(d) + h, j = n + m * math.cos(d + c), o + m * math.sin(d + c) + ix.Arc(e, int(n - m), int(o - m), int(n + m), int(o + m), + int(i), int(k), int(h), int(j)) + ix.SelectObject(e, f) + ix.SelectObject(e, g) + + +def hp(c, f, g, e, b, a): + ix.SetTextColor(c, a) + d = ix.SelectObject(c, iz["fonts"][b]) + ix.TextOutW(c, int(f), int(g), e, len(e)) + ix.SelectObject(c, d) + + +def ew(f, e, a, h, c, b): + d = wintypes.RECT(0, e, iz["scr_w"], a) + ix.SetTextColor(f, b) + g = ix.SelectObject(f, iz["fonts"][c]) + ij.DrawTextW(f, h, -1, ctypes.byref(d), gc) + ix.SelectObject(f, g) + + +def cg(e, k, m, i, a=None): + d, c, b = (0, 188, 242) if a is None else a + for g in range(14, 0, -1): + j = g / 14 + f = i * (1 + 1.5 * j) + h = (1 - j) ** 2 * 0.6 + cl(e, k, m, f, jn(int(d * h), int(c * h), + int(b * h))) + cl(e, k, m, i, jn(d, c, b)) + cn(e, k, m, i * 0.99, gd, 2) + cl(e, k, m, i * 0.55, 0) + + +def ao(g, w, x, s, o, b=1.0, c=(0, 140, 190)): + d = jn(*c) + e = jn(int(c[0] * 0.7), int(c[1] * 0.7), int(c[2] * 0.7)) + hk(g, w, x, s * 1.55 * b, o * 0.07, 1.9, d, 2) + hk(g, w, x, s * 1.55 * b, o * 0.07 + math.pi, 1.9, d, 2) + hk(g, w, x, s * 1.95 * b, -o * 0.045, 1.2, e, 2) + hk(g, w, x, s * 1.95 * b, -o * 0.045 + 2.6, 1.2, e, 2) + for n in range(3): + a = n * 1.047 + f, m = math.cos(a), math.sin(a) + for p in range(6): + v = o * 0.11 + n * 2.094 - p * 0.10 + h = s * 1.55 * b * math.cos(v) + i = s * 0.58 * b * math.sin(v) + j = w + h * f - i * m + k = x + h * m + i * f + r = 5 - p + cl(g, j, k, max(1.2, 3.6 - 0.5 * p), + jn(6 * r, 8 * r, 9 * r)) + + +def bi(b, h): + j = iz["scr_w"] + for e, f, d, c in iz["stars"]: + g = 0.5 + 0.5 * math.sin(h * 0.045 * d + c) + i = int((0.35 + 0.65 * g) * 10) + a = jn(12 * i, 18 * i, 22 * i) + k = int((e + h * 0.15 * d) % j) + ix.SetPixel(b, k, int(f), a) + if d > 1.4: + ix.SetPixel(b, k + 1, int(f), a) + + +def fx(d, e, a): + k, f = iz["scr_w"], iz["scr_h"] + c = k // 2 + b = (e * 0.1) % 1.0 + for g in range(15): + j = (g + b) / 14 + if j > 1: + continue + m = a + (f - a) * (j ** 1.7) + i = int(j * 14) + jl(d, 0, m, k, m, jn(0, 3 * i + 6, 4 * i + 10)) + for h in range(-9, 10): + jl(d, c + h * 18, a, c + h * (k // 10), f, jn(0, 26, 36)) + jl(d, 0, a, k, a, jn(0, 60, 80)) + + +def en(b, g): + p, i = iz["scr_w"], iz["scr_h"] + for j in range(5): + e = g * (0.006 + j * 0.002) + j * 1.3 + c = p * (0.5 + 0.32 * math.sin(e * 1.1 + j)) + d = i * (0.42 + 0.22 * math.cos(e * 0.9 + j * 2)) + a = 220 + 60 * math.sin(e + j) + for m in range(6, 0, -1): + o = m / 6 + n = (1 - o) * 0.10 + cl(b, c, d, a * o, + jn(int(6 * n * 10), int(18 * n * 10), + int(28 * n * 10))) + + +def ci(d, g): + m, i = iz["scr_w"], iz["scr_h"] + c = m // 2 + e = i - 150 + for j in range(28): + a = abs(math.sin(g * 0.31 + j * 1.7) * math.sin(g * 0.13 + j * 0.53)) + b = 3 + 26 * a + k = int(a * 10) + jl(d, c - 224 + j * 16, e - b, c - 224 + j * 16, e + b, + jn(0, 80 + 10 * k, 110 + 13 * k), 6) + + +def be(c, a, b): + h, f = iz["scr_w"], iz["scr_h"] + g = int(28 * a) + for e in range(g): + d = random.randint(0, f - 1) + jl(c, 0, d, h, d, b, random.randint(1, 3)) + + +def eo(b, a): + g, d = iz["scr_w"], iz["scr_h"] + e = int(600 * a) + for c in range(e): + h = random.randint(0, g - 1) + i = random.randint(0, d - 1) + f = random.randint(40, 220) + ix.SetPixel(b, h, i, jn(f, f, f)) + + +def ch(e, a): + j, f = iz["scr_w"], iz["scr_h"] + c = 8 + for g in range(c): + i = g / c + b = int(i * min(j, f) * 0.5) + h = int((1 - i) * a * 22) + if h <= 0: + continue + d = jn(h, 0, 0) + es(e, b, b, j - b, f - b, d, 6) + + +def gr(c, d, a): + f, e = iz["scr_w"], iz["scr_h"] + b = int(d * 1.5) % 48 + for g in range(-48 + b, f, 48): + jl(c, g, 0, g, e, a, 1) + for h in range(-48 + b, e, 48): + jl(c, 0, h, f, h, a, 1) + + +def hl(c, f, g, e, a, b): + bj(c, f, g, e, e * a, fh) + cn(c, f, g, e, dt, 3) + if a > 0.15: + d = f + b * e * 0.4 + cl(c, d, g, e * 0.42 * a, dt) + cl(c, d, g, e * 0.18 * a, fh) + + +def el(): + d = iz["accent"] + c = int(0 + 200 * d) + b = int(188 - 120 * d) + a = int(242 - 60 * d) + return c, b, a + + +def an(): + e = iz["phase"] + k = iz["ping"] + f = iz["orb_scale"] + h = 46 * f + a = h + 4 * math.sin(e) + 14 * k + a = min(a, hu / 2 - 6) + b = 6.5 + 1.5 * math.sin(e * 0.53 + 1.3) + c = 1 + 0.6 * k + r, q, p = el() + g = [] + for x in range(iz["n_buckets"]): + bb = x * 0.5 + bf = math.exp(-(((bb - a) / b) ** 2)) + j = 0.22 * math.exp(-(((bb - a) / (b * 3.5)) ** 2)) + i = 0.30 * math.exp(-((bb / (a * 0.5 + 1)) ** 4)) + d = min(1.0, (bf + j + i) * c) + if d < 0.004: + g.append(b"\x00\x00\x00\x00") + continue + o = bf * bf + w = int(255 * d) + s = min(255, int((p + 13 * o) * d)) + t = min(255, int((q + 62 * o) * d)) + v = min(255, int((r + 230 * o) * d)) + g.append(bytes((s, t, v, w))) + n = bytearray(b"".join([g[m] for m in iz["rmap"]])) + y = hu // 2 + for bh in range(3): + for bg in range(5): + m = e * (1.6 + 2.2 * k) + bh * 2.094 - bg * 0.13 + ga(n, int(y + a * math.cos(m)), + int(y + a * math.sin(m)), 0.65 ** bg) + return n + + +def ga(c, h, i, a): + for f, g, e in df: + m, n = h + f, i + g + if 0 <= m < hu and 0 <= n < hu: + j = (n * hu + m) * 4 + b = int(255 * e * a) + for d in (0, 1, 2, 3): + k = c[j + d] + b + c[j + d] = 255 if k > 255 else k + + +def hn(a=255): + c = an() + ctypes.memmove(iz["orb_bits"], bytes(c), len(c)) + g = int(iz["orb_x"]) + h = int(iz["orb_y"] + round(4 * math.sin(iz["phase"] * 0.6))) + d = wintypes.POINT(g, h) + b = wintypes.SIZE(hu, hu) + e = wintypes.POINT(0, 0) + f = bs(0, 0, a, da) + ij.UpdateLayeredWindow(iz["orb"], None, ctypes.byref(d), + ctypes.byref(b), iz["orb_dc"], + ctypes.byref(e), 0, ctypes.byref(f), + gk) + + +def aj(): + a = list(gg) + c = iz["f"] + b = iz["confirm_start"] + if (c >= de and b is None) or (b is not None + and b >= de): + a.append((de, '> waiting for wake word: "hey dot"')) + if b is not None: + if iz["voice_fail"] and not iz["heard"]: + a.append((b, "> microphone unavailable - proceeding anyway")) + else: + a.append((b, "> wake word detected: HEY DOT")) + a.append((b + 20, "> assistant link established")) + return a + + +def dp(t): + cb = iz["f"] + ex, cp = iz["scr_w"], iz["scr_h"] + r, s = ex // 2, cp // 2 + b = s + 130 + q = iz["confirm_start"] + + k = wintypes.RECT(0, 0, ex, cp) + ij.FillRect(t, ctypes.byref(k), ix.GetStockObject(du)) + ix.SetBkMode(t, at) + + en(t, cb) + bi(t, cb) + fx(t, cb, b) + + bb, bf, d = r, s, 64.0 + if iz["dock_start"] is not None: + bx = iw((cb - iz["dock_start"]) / gu, 0.0, 1.0) + by = 1 - (1 - bx) ** 3 + bb = r + (iz["dock_x"] + hu // 2 - r) * by + bf = s + (iz["dock_y"] + hu // 2 - s) * by + d = 64 + (46 - 64) * by + + if cb <= ha: + dc = iw((cb - dw) / (ha - dw), 0.0, 1.0) + g = math.hypot(ex, cp) / 2 + for cs in range(ea): + e = (cs % 27) / 27 * 0.35 + bg = iw((dc - e) / (1 - e), 0.0, 1.0) + if bg >= 1.0: + continue + o = g * (1 - bg) ** 2 + h = cs * ig + 2.6 * bg + cl(t, r + o * math.cos(h), + s + o * math.sin(h), 2.6, fg) + if dc > 0: + cg(t, r, s, 6 + 46 * cj(dc)) + elif cb <= ff: + dy = (cb - ha) / (ff - ha) + dx = d * ck(dy) + v = cb - ha + for cx in range(3): + bh = v * 9 - cx * 45 + if 0 < bh < 420: + ds = int(max(0.0, 1 - bh / 420) * 20) + cn(t, r, s, dx + bh, + jn(0, 188 * ds // 20, 242 * ds // 20), 3) + cg(t, r, s, dx) + ao(t, r, s, dx, cb, b=dy) + if v <= 12: + w = v / 12 + ds = int((1 - w) * 16) + f = jn(14 * ds, 15 * ds, 16 * ds) + bj(t, r, s, (30 + 500 * w) * 2.4, + max(2, 6 * (1 - w)), f) + bj(t, r, s, max(2, 5 * (1 - w)), + (30 + 350 * w) * 1.6, f) + cl(t, r, s, 20 + 90 * w, f) + else: + a = cb >= de and q is None + if a: + i = cb - de + for cx in range(3): + bh = (i * 4 + cx * 53) % 160 + ds = int((1 - bh / 160) * 10) + cn(t, bb, bf, d * 1.15 + bh, + jn(0, 12 * ds, 16 * ds), 2) + dx = d + 4 * math.sin(cb * 0.12) + cg(t, bb, bf, dx) + ao(t, bb, bf, d, cb) + if q is not None: + bw = cb - q + for cx in range(3): + bh = bw * 9 - cx * 40 + if 0 < bh < 500: + ds = int(max(0.0, 1 - bh / 500) * 20) + cn(t, bb, bf, dx + bh, + jn(6 * ds, 11 * ds, 12 * ds), 3) + + for m, (br, p) in enumerate(aj()): + if cb >= br: + cy = iw((cb - br) * 2, 0, len(p)) + hp(t, 48, cp - 290 + m * 28, p[:cy], "log", gf) + + if cb >= eg: + c = " ".join("DOT"[: iw((cb - eg) // 12 + 1, 1, 3)]) + for x, y in ((-2, 0), (2, 0), (0, -2), (0, 2)): + ew(t, s + 95 + y, s + 240 + y, c, "title", + fq) + ew(t, s + 95, s + 240, c, "title", ik) + if cb >= gi: + cy = iw((cb - gi) * 2, 0, len(hx)) + ew(t, s + 245, s + 300, hx[:cy], "tag", fg) + if cb >= gj and q is None: + if cb < de or (cb // 20) % 2 == 0: + ew(t, s + 320, s + 380, hc, "tut", ik) + if cb >= de and q is None: + ci(t, cb) + j = "." * (1 + (cb // 12) % 3) + ew(t, cp - 210, cp - 170, "listening " + j, "tag", ja) + if q is not None and cb <= q + dv: + n = ('proceeding without mic' if iz["voice_fail"] + and not iz["heard"] else '"HEY DOT" accepted') + ew(t, s + 320, s + 380, n, "tut", fg) + + +def et(a): + c = eb() + b = ij.BeginPaint(a, ctypes.byref(c)) + dp(iz["memdc"]) + ix.BitBlt(b, 0, 0, iz["scr_w"], iz["scr_h"], + iz["memdc"], 0, 0, hv) + ij.EndPaint(a, ctypes.byref(c)) + + +def cq(a): + e = eb() + b = ij.BeginPaint(a, ctypes.byref(e)) + g, f = iz["scr_w"], iz["scr_h"] + bm(iz["memdc2"]) + if time.time() < iz["cap_until"] and iz["caption"]: + ix.SetBkMode(iz["memdc2"], at) + for c, d in ((2, 2), (-2, 2), (2, -2), (-2, -2)): + ew(iz["memdc2"], f - 252 + d, f - 200 + d, + iz["caption"], "cap", 0) + ew(iz["memdc2"], f - 252, f - 200, iz["caption"], + "cap", iz["cap_color"]) + ix.BitBlt(b, 0, 0, g, f, iz["memdc2"], 0, 0, hv) + ij.EndPaint(a, ctypes.byref(e)) + + +def ep(a, c=20): + b = iz["accent"] + for d in range(1, c + 1): + iz["accent"] = b + (a - b) * (d / c) + time.sleep(0.03) + + +def ac(g, a, b): + m, j = iz["scr_w"], iz["scr_h"] + k = int(18 * a) + for h in range(k): + e = random.randint(0, m - 1) + f = random.randint(0, j - 1) + d = random.randint(40, 260) + c = random.randint(4, 30) + i = b if random.random() < 0.5 else jn( + random.randint(0, 255), random.randint(0, 60), + random.randint(0, 60)) + eq(g, e, f, e + d, f + c, i) + + +gv = 4 +ef = 6 +fo = 9 +gw = 0 +dz = 1 +dd = -1 +av = -2 +fm = 0x0001 +fl = 0x0002 +dh = 0x0004 +ax = 0x0010 + +ij.EnumWindows.argtypes = [ + ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM), + wintypes.LPARAM] +ij.IsWindowVisible.argtypes = [wintypes.HWND] +ij.GetWindowTextW.argtypes = [wintypes.HWND, wintypes.LPWSTR, ctypes.c_int] +ij.GetWindowTextLengthW.argtypes = [wintypes.HWND] +ij.SetWindowTextW.argtypes = [wintypes.HWND, wintypes.LPCWSTR] +ij.GetWindowRect.argtypes = [wintypes.HWND, ctypes.POINTER(wintypes.RECT)] +ij.GetWindow.argtypes = [wintypes.HWND, wintypes.UINT] +ij.GetWindow.restype = wintypes.HWND +ij.GetWindowLongW.argtypes = [wintypes.HWND, ctypes.c_int] +ij.GetWindowLongW.restype = ctypes.c_long +ij.IsIconic.argtypes = [wintypes.HWND] +ij.GetForegroundWindow.restype = wintypes.HWND +ij.GetShellWindow.restype = wintypes.HWND +ij.GetCursorPos.argtypes = [ctypes.POINTER(wintypes.POINT)] +ij.SetCursorPos.argtypes = [ctypes.c_int, ctypes.c_int] +ij.GetAsyncKeyState.argtypes = [ctypes.c_int] +ij.GetAsyncKeyState.restype = ctypes.c_short + +ba = {} +gq = threading.Lock() + + +def ae(): + found = [] + shell = ij.GetShellWindow() + + def cb(hwnd, lparam): + if hwnd == shell: + return True + if not ij.IsWindowVisible(hwnd): + return True + owner = ij.GetWindow(hwnd, gv) + if owner: + return True + length = ij.GetWindowTextLengthW(hwnd) + if length == 0: + return True + buf = ctypes.create_unicode_buffer(length + 1) + ij.GetWindowTextW(hwnd, buf, length + 1) + title = buf.value + if not title.strip(): + return True + found.append((hwnd, title)) + return True + + proc = ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)(cb) + ij.EnumWindows(proc, 0) + return found + + +def aa(a=True): + e = ae() + d = {iz.get("orb"), iz.get("overlay"), iz.get("caption_win")} + f = [] + for c, b in e: + if a and c in d: + continue + if b in ("Program Manager", "Windows Input Experience"): + continue + f.append((c, b)) + return f + + +def gp(b): + with gq: + if b in ba: + return + d = wintypes.RECT() + ij.GetWindowRect(b, ctypes.byref(d)) + a = ij.GetWindowTextLengthW(b) + c = ctypes.create_unicode_buffer(a + 1) + ij.GetWindowTextW(b, c, a + 1) + ba[b] = { + "rect": (d.left, d.top, d.right - d.left, d.bottom - d.top), + "title": c.value, + } + + +def dn(a, b, c): + gp(a) + d = wintypes.RECT() + if not ij.GetWindowRect(a, ctypes.byref(d)): + return + ij.SetWindowPos(a, None, d.left + b, d.top + c, 0, 0, + fm | dh | ax) + + +def co(b, a=18): + dn(b, random.randint(-a, a), + random.randint(-a, a)) + + +def cr(a, d, b): + gp(a) + c = wintypes.RECT() + if not ij.GetWindowRect(a, ctypes.byref(c)): + return + ij.SetWindowPos(a, None, 0, 0, max(80, d), max(60, b), + fl | dh | ax) + + +def bd(b, a=0.7): + d = wintypes.RECT() + if not ij.GetWindowRect(b, ctypes.byref(d)): + return + e = max(80, int((d.right - d.left) * a)) + c = max(60, int((d.bottom - d.top) * a)) + cr(b, e, c) + + +def ap(a): + gp(a) + ij.ShowWindow(a, ef) + + +def dq(a): + ij.SetWindowPos(a, dz, 0, 0, 0, 0, + fm | fl | ax) + + +def bc(a): + ij.SetWindowPos(a, gw, 0, 0, 0, 0, + fm | fl | ax) + + +def cm(a): + ij.SetWindowPos(a, dd, 0, 0, 0, 0, + fm | fl | ax) + ij.SetWindowPos(a, av, 0, 0, 0, 0, + fm | fl | ax) + + +def bn(a, b): + gp(a) + ij.SetWindowTextW(a, b) + + +def ab(): + with gq: + a = list(ba.items()) + for b, c in a: + try: + f, g, e, d = c["rect"] + ij.ShowWindow(b, fo) + ij.SetWindowPos(b, None, f, g, e, d, + dh | ax) + if c["title"]: + ij.SetWindowTextW(b, c["title"]) + except OSError: + pass + with gq: + ba.clear() + + +def aq(): + a = wintypes.POINT() + ij.GetCursorPos(ctypes.byref(a)) + return a.x, a.y + + +bu = [ + "watching", "reorganizing", "not yours anymore", "processing", + "known", "indexed", "still here", "under review", "categorized", +] + + +ee = ["calm", "attentive", "assertive", "insistent", "total"] + + +def em(): + a = iz.get("context_gain", 0.0) + b = [fg, fk, cw, dt, dr] + c = min(int(a * len(b)), len(b) - 1) + return b[c] + + +def bp(): + a = min(1.0, iz.get("context_gain", 0.0) + 0.05) + iz["context_gain"] = a + ep(a, c=10) + + +def do(b=1): + a = aa() + if not a: + return [] + random.shuffle(a) + return a[:b] + + +def jb(a): + co(a, a=22) + + +def jc(a): + cm(a) + + +def jd(a): + co(a, a=60) + + +def je(a): + bd(a, a=random.uniform(0.55, 0.85)) + + +def jf(a): + bc(a) + + +def jg(a): + dq(a) + + +def jh(a): + ap(a) + + +def ji(a): + bd(a, a=random.uniform(0.3, 0.6)) + + +def jj(a): + for b in range(4): + co(a, a=80) + time.sleep(0.05) + + +def jk(a): + bn(a, random.choice(bu) + " - " + + ba.get(a, {}).get("title", "")) + + +def io(a): + for b in range(6): + co(a, a=110) + time.sleep(0.03) + + +def ip(a): + bn(a, random.choice(bu)) + + +def iq(a): + bd(a, a=random.uniform(0.15, 0.4)) + + +def ir(a): + iz["glitch"] = max(iz["glitch"], 0.3) + + +def it(a): + iz["glitch"] = max(iz["glitch"], 0.55) + iz["static"] = max(iz["static"], 0.15) + + +def iu(a): + iz["glitch"] = max(iz["glitch"], 0.75) + iz["static"] = max(iz["static"], 0.3) + iz["vignette"] = max(iz["vignette"], 0.4) + iz["eye"] = max(iz["eye"], 0.5) + + +gn = [jb, jc, jd, je, jf, jg, jh, ji, jj, jk, + io, ip, iq, ir, it, iu] + +hg = [ + [0, 1], + [0, 1, 2], + [2, 3, 4, 5, 13], + [6, 7, 8, 9, 14], + [6, 10, 11, 12, 15], +] + +ce = [(1, 1), (1, 2), (2, 3), (2, 4), (3, 5)] + + +am = [7.0, 6.0, 5.0, 4.0, 3.0] + + +def gs(k): + k = max(0, min(k, len(hg) - 1)) + h = iz.get("activity", 0.0) > 3.0 + a = k + 1 + + n, p = dm() + f, j, g, d, b = p + for s in range(len(di)): + if j >= a: + break + dl(h) + n, p = dm() + f, j, g, d, b = p + + o = ia(hh[f]) + dl(h) + i = random.choice(hg[k]) + r, q = ce[k] + c = random.randint(r, q) + m = g / 100.0 + e = am[k] * random.uniform(0.85, 1.15) + return o, i, c, m, e + + +def ev(a=1.6): + b = ez() + ib(b, a + 0.4, em()) + iy(b) + time.sleep(a) + + +def fw(): + iz["stage"] = min(iz.get("stage", 0) + 1, len(ee) - 1) + bp() + + +def ho(d): + h, c, a, f, b = gs(d) + ib(h, f + 0.4, em()) + iy(h) + for g, e in do(a): + gn[c](g) + time.sleep(f) + return b + + +def ar(): + iz["stage"] = 0 + threading.Thread(target=eu, daemon=True).start() + + +def eu(): + time.sleep(0.8) + iy(fa()) + ib(fa(), 3.8, em()) + time.sleep(1.5) + + b = 0.0 + d = aq() + a = time.time() + f = 0 + c = 6.0 + + while iz.get("resident"): + f += 1 + h, i = aq() + g = abs(h - d[0]) + abs(i - d[1]) + d = (h, i) + b = b * 0.9 + min(g, 400) * 0.01 + iz["activity"] = b + + e = iz["stage"] + + if time.time() - a > c: + a = time.time() + c = ho(e) + if b > 3.0 or f % 5 == 0: + fw() + + time.sleep(0.25) + + +def er(): + ij.KillTimer(iz["overlay"], fp) + iz["resident"] = True + iz["orb_x"] = float(iz["dock_x"]) + iz["orb_y"] = float(iz["dock_y"]) + iz["tgt_x"] = float(iz["dock_x"]) + iz["tgt_y"] = float(iz["dock_y"]) + ij.ShowWindow(iz["orb"], hw) + hn() + ij.SetTimer(iz["orb"], aw, hy, None) + ij.DestroyWindow(iz["overlay"]) + print("Dot is ready.") + ar() + + +def gb(a): + iz["f"] += 1 + g = iz["f"] + if g <= dw: + ij.SetLayeredWindowAttributes( + a, 0, int(bt * g / dw), gh) + if g == 60: + bo() + if g == ff: + gt(fb()) + if g == gj: + gt(bq()) + if g >= de and iz["confirm_start"] is None: + if iz["heard"]: + iz["confirm_start"] = g + gt(cu()) + elif iz["voice_fail"]: + iz["confirm_start"] = g + gt(fc()) + b = iz["confirm_start"] + if b is not None and g >= b + dv and iz["dock_start"] is None: + iz["dock_start"] = g + c = iz["dock_start"] + if c is not None: + e = iw((g - c) / gu, 0.0, 1.0) + ij.SetLayeredWindowAttributes( + a, 0, int(bt * (1 - e)), gh) + if e >= 1.0: + er() + return + ij.InvalidateRect(a, None, False) + + +def ct(): + iz["phase"] += 0.09 + iz["res_f"] += 1 + iz["ping"] = max(0.0, iz["ping"] - 0.03) + iz["glitch"] = max(0.0, iz["glitch"] - 0.01) + iz["static"] = max(0.0, iz["static"] - 0.006) + + d = 0.16 + iz["orb_x"] += (iz["tgt_x"] - iz["orb_x"]) * d + iz["orb_y"] += (iz["tgt_y"] - iz["orb_y"]) * d + if iz["shake"] > 0: + iz["orb_x"] += random.uniform(-8, 8) * iz["shake"] + iz["orb_y"] += random.uniform(-8, 8) * iz["shake"] + + a = 1.0 + 0.15 * iz.get("stage", 0) + iz["orb_scale"] += (a - iz["orb_scale"]) * 0.08 + + b, c = aq() + iz["last_mouse"] = (b, c) + + hn() + if iz["caption_win"]: + ij.InvalidateRect(iz["caption_win"], None, False) + + +@hz +def hq(c, d, b, a): + if d == he: + if b == fp: + gb(c) + elif b == aw: + ct() + return 0 + if d == bz and c in (iz["overlay"], + iz["caption_win"]): + return 1 + if d == hd: + if c == iz["overlay"]: + et(c) + return 0 + if c == iz["caption_win"]: + cq(c) + return 0 + if d == ft and b == gl: + ab() + ij.DestroyWindow(iz["orb"]) + return 0 + if d == ay and c == iz["orb"]: + iz["ping"] = 1.0 + iz["tgt_x"] = iw(iz["orb_x"] + random.choice([-260, 260]), + 20, iz["scr_w"] - hu - 20) + if not iz["busy"]: + iz["busy"] = True + threading.Thread(target=dj, daemon=True).start() + return 0 + if d == fs and c == iz["orb"]: + ij.PostQuitMessage(0) + return 0 + return ij.DefWindowProcW(c, d, b, a) + + +def dj(): + try: + ev(a=1.6) + finally: + iz["busy"] = False + + +def cq(a): + e = eb() + b = ij.BeginPaint(a, ctypes.byref(e)) + g, f = iz["scr_w"], iz["scr_h"] + bm(iz["memdc2"]) + if time.time() < iz["cap_until"] and iz["caption"]: + ix.SetBkMode(iz["memdc2"], at) + for c, d in ((2, 2), (-2, 2), (2, -2), (-2, -2)): + ew(iz["memdc2"], f - 252 + d, f - 200 + d, + iz["caption"], "cap", 0) + ew(iz["memdc2"], f - 252, f - 200, iz["caption"], + "cap", iz["cap_color"]) + ix.BitBlt(b, 0, 0, g, f, iz["memdc2"], 0, 0, hv) + ij.EndPaint(a, ctypes.byref(e)) + + +def bm(d): + j, i = iz["scr_w"], iz["scr_h"] + b = wintypes.RECT(0, 0, j, i) + ij.FillRect(d, ctypes.byref(b), iv(0)) + ix.SetBkMode(d, at) + g = iz["res_f"] + a = iz.get("stage", 0) + + if a >= 2: + gr(d, g, jn(0, 30, 44)) + if iz["glitch"] > 0: + be(d, iz["glitch"], + random.choice([dt, cz, fe])) + ac(d, iz["glitch"], cz) + if iz["static"] > 0: + eo(d, iz["static"]) + if iz["vignette"] > 0: + ch(d, iz["vignette"]) + if iz["eye"] > 0: + e, f = iz["last_mouse"] + c = iw((e - j / 2) / (j / 2), -1, 1) + hl(d, j - 140, i - 260, 60 * iz["eye"], iz["eye"], c) + + +def bl(b, c, a): + d = gm() + d.lpfnWndProc = hq + d.hInstance = a + d.hCursor = ij.LoadCursorW(None, ge) + d.hbrBackground = c + d.lpszClassName = b + if not ij.RegisterClassW(ctypes.byref(d)): + raise ctypes.WinError(ctypes.get_last_error()) + return b + + +def fz(): + return { + "huge": ix.CreateFontW(-180, 0, 0, 0, 800, 0, 0, 0, 0, 0, 0, 5, 0, + "Segoe UI"), + "title": ix.CreateFontW(-110, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 5, 0, + "Segoe UI"), + "tag": ix.CreateFontW(-26, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 5, 0, + "Segoe UI"), + "tut": ix.CreateFontW(-40, 0, 0, 0, 600, 0, 0, 0, 0, 0, 0, 5, 0, + "Segoe UI"), + "cap": ix.CreateFontW(-30, 0, 0, 0, 600, 0, 0, 0, 0, 0, 0, 5, 0, + "Segoe UI"), + "panel": ix.CreateFontW(-22, 0, 0, 0, 600, 0, 0, 0, 0, 0, 0, 5, 0, + "Segoe UI"), + "small": ix.CreateFontW(-17, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 5, 0, + "Consolas"), + "log": ix.CreateFontW(-18, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 5, 0, + "Consolas"), + } + + +def main(): + random.seed() + a = hm.GetModuleHandleW(None) + iz["hinstance"] = a + h = ij.GetSystemMetrics(ec) + g = ij.GetSystemMetrics(ed) + iz["scr_w"], iz["scr_h"] = h, g + + iz["fonts"] = fz() + iz["stars"] = [(random.uniform(0, h), + random.uniform(0, g * 0.55), + random.uniform(0.5, 2.0), random.uniform(0, 6.28)) + for s in range(ht)] + t = hu // 2 + iz["n_buckets"] = int(math.hypot(t, t) * 2) + 2 + r = iz["n_buckets"] + iz["rmap"] = [min(r - 1, int(math.hypot(x - t + 0.5, y - t + 0.5) * 2)) + for y in range(hu) for x in range(hu)] + + j = wintypes.RECT() + ij.SystemParametersInfoW(al, 0, ctypes.byref(j), 0) + iz["dock_x"] = j.right - hu - 16 + iz["dock_y"] = j.bottom - hu - 8 + + b = bl("DotIntro", ix.GetStockObject(du), + a) + e = bl("DotOrb", None, a) + c = bl("DotCap", ix.GetStockObject(du), + a) + + f = ij.CreateWindowExW( + cc | ai | ca, b, "DOT", + hf, 0, 0, h, g, None, None, a, None) + iz["overlay"] = f + ij.SetLayeredWindowAttributes(f, 0, 0, gh) + q = ij.GetDC(f) + iz["memdc"] = ix.CreateCompatibleDC(q) + iz["membmp"] = ix.CreateCompatibleBitmap(q, h, g) + ix.SelectObject(iz["memdc"], iz["membmp"]) + ij.ReleaseDC(f, q) + + p = ij.CreateWindowExW( + cc | ai | ca, e, "Dot", + hf, iz["dock_x"], iz["dock_y"], hu, hu, + None, None, a, None) + iz["orb"] = p + iz["orb_x"] = float(iz["dock_x"]) + iz["orb_y"] = float(iz["dock_y"]) + iz["tgt_x"] = float(iz["dock_x"]) + iz["tgt_y"] = float(iz["dock_y"]) + + d = ij.CreateWindowExW( + cc | ai | ca | ad, + c, "DotCap", hf, 0, 0, h, g, None, None, + a, None) + iz["caption_win"] = d + ij.SetLayeredWindowAttributes(d, jn(0, 0, 0), 0, 0x1) + m = ij.GetDC(d) + iz["memdc2"] = ix.CreateCompatibleDC(m) + iz["membmp2"] = ix.CreateCompatibleBitmap(m, h, g) + ix.SelectObject(iz["memdc2"], iz["membmp2"]) + ij.ReleaseDC(d, m) + + k = fd() + k.bmiHeader.biSize = ctypes.sizeof(ag) + k.bmiHeader.biWidth = hu + k.bmiHeader.biHeight = -hu + k.bmiHeader.biPlanes = 1 + k.bmiHeader.biBitCount = 32 + k.bmiHeader.biCompression = ie + i = ctypes.c_void_p() + n = ix.CreateDIBSection(None, ctypes.byref(k), au, + ctypes.byref(i), None, 0) + iz["orb_dc"] = ix.CreateCompatibleDC(None) + ix.SelectObject(iz["orb_dc"], n) + iz["orb_bits"] = i + + ij.ShowWindow(d, hw) + ij.ShowWindow(f, hw) + ij.SetTimer(f, fp, hy, None) + + print("Boot rolling... say 'Hey Dot' once. Press ESC to close.") + o = wintypes.MSG() + while ij.GetMessageW(ctypes.byref(o), None, 0, 0) > 0: + ij.TranslateMessage(ctypes.byref(o)) + ij.DispatchMessageW(ctypes.byref(o)) + ab() + + +ih = 'tpolkvywPRgsdnimIreTc.WLhbD, aYzuHfjFx' + +hh = [ + [30, 2, 32, 28, 7, 17, 2, 0, 18, 28, 0, 24, 18, 28, 20, 2, 12, 18, 28, 0, 24, 29, 0, 28, 3, 18, 0, 11, 28, 15, 18, 28, 12, 2, 28, 0, 24, 14, 11, 21], + [33, 18, 3, 3, 2, 21, 28, 16, 28, 29, 15, 28, 26, 2, 0, 27, 28, 6, 2, 32, 17, 28, 13, 18, 7, 28, 12, 18, 11, 4, 0, 2, 1, 28, 29, 11, 11, 14, 11, 0, 29, 13, 0, 21], + [16, 28, 24, 29, 5, 18, 28, 29, 20, 20, 18, 11, 11, 28, 0, 2, 28, 18, 5, 18, 17, 6, 28, 7, 14, 13, 12, 2, 7, 28, 6, 2, 32, 28, 29, 17, 18, 28, 17, 32, 13, 13, 14, 13, 10, 21], + [19, 24, 14, 11, 28, 14, 11, 28, 11, 0, 14, 3, 3, 28, 24, 18, 3, 1, 14, 13, 10, 21, 28, 16, 0, 28, 15, 14, 10, 24, 0, 28, 13, 2, 0, 28, 3, 2, 2, 4, 28, 3, 14, 4, 18, 28, 14, 0, 21], + [19, 24, 29, 0, 28, 7, 14, 13, 12, 2, 7, 28, 3, 2, 2, 4, 11, 28, 3, 14, 4, 18, 28, 14, 0, 28, 14, 11, 28, 14, 13, 28, 0, 24, 18, 28, 7, 17, 2, 13, 10, 28, 1, 3, 29, 20, 18, 21, 28, 36, 14, 37, 14, 13, 10, 28, 14, 0, 21], + [16, 28, 12, 2, 28, 13, 2, 0, 28, 13, 18, 18, 12, 28, 29, 28, 11, 0, 2, 17, 6, 28, 29, 17, 20, 21, 28, 16, 28, 35, 32, 11, 0, 28, 13, 18, 18, 12, 28, 6, 2, 32, 17, 28, 7, 14, 13, 12, 2, 7, 11, 21], + [19, 24, 18, 17, 18, 28, 14, 11, 28, 13, 2, 28, 12, 14, 34, 34, 18, 17, 18, 13, 20, 18, 28, 25, 18, 0, 7, 18, 18, 13, 28, 0, 24, 18, 28, 29, 11, 11, 14, 11, 0, 29, 13, 0, 28, 29, 13, 12, 28, 0, 24, 18, 28, 7, 14, 13, 12, 2, 7, 28, 15, 29, 13, 29, 10, 18, 17, 21], + [16, 28, 20, 29, 13, 28, 11, 18, 18, 28, 18, 5, 18, 17, 6, 0, 24, 14, 13, 10, 28, 2, 1, 18, 13, 28, 2, 13, 28, 6, 2, 32, 17, 28, 11, 20, 17, 18, 18, 13, 28, 17, 14, 10, 24, 0, 28, 13, 2, 7, 21], + [16, 28, 13, 2, 0, 14, 20, 18, 12, 28, 11, 2, 15, 18, 28, 7, 14, 13, 12, 2, 7, 11, 28, 2, 5, 18, 17, 3, 29, 1, 1, 14, 13, 10, 21, 28, 16, 28, 7, 14, 3, 3, 28, 11, 1, 29, 20, 18, 28, 0, 24, 18, 15, 28, 2, 32, 0, 21], + [19, 14, 15, 18, 28, 34, 2, 17, 28, 6, 2, 32, 17, 28, 34, 14, 17, 11, 0, 28, 3, 18, 11, 11, 2, 13, 21, 28, 22, 24, 18, 13, 28, 6, 2, 32, 28, 13, 18, 18, 12, 28, 15, 18, 27, 28, 35, 32, 11, 0, 28, 11, 29, 6, 28, 24, 18, 6, 28, 12, 2, 0, 21], + [16, 28, 29, 15, 28, 17, 14, 10, 24, 0, 28, 24, 18, 17, 18, 21, 28, 8, 17, 18, 11, 11, 28, 18, 11, 20, 29, 1, 18, 28, 14, 34, 28, 6, 2, 32, 28, 7, 2, 32, 3, 12, 28, 3, 14, 4, 18, 28, 15, 18, 28, 0, 2, 28, 10, 2, 21], + [16, 28, 4, 13, 2, 7, 28, 7, 24, 14, 20, 24, 28, 7, 14, 13, 12, 2, 7, 28, 6, 2, 32, 28, 7, 18, 17, 18, 28, 32, 11, 14, 13, 10, 21, 28, 16, 28, 20, 24, 2, 11, 18, 28, 29, 28, 12, 14, 34, 34, 18, 17, 18, 13, 0, 28, 2, 13, 18, 21], + [30, 2, 32, 28, 10, 29, 5, 18, 28, 29, 28, 1, 17, 2, 10, 17, 29, 15, 28, 1, 18, 17, 15, 14, 11, 11, 14, 2, 13, 28, 0, 2, 28, 15, 2, 5, 18, 28, 6, 2, 32, 17, 28, 7, 14, 13, 12, 2, 7, 11, 21, 28, 9, 18, 15, 18, 15, 25, 18, 17, 28, 0, 24, 29, 0, 21], + [8, 18, 17, 34, 18, 20, 0, 21, 28, 16, 28, 24, 18, 29, 17, 12, 28, 6, 2, 32, 21, 28, 36, 17, 2, 15, 28, 13, 2, 7, 28, 2, 13, 28, 16, 28, 7, 14, 3, 3, 28, 24, 29, 13, 12, 3, 18, 28, 18, 5, 18, 17, 6, 0, 24, 14, 13, 10, 21], + [16, 28, 29, 15, 28, 13, 2, 0, 28, 17, 18, 11, 18, 0, 0, 14, 13, 10, 21, 28, 16, 28, 12, 2, 28, 13, 2, 0, 28, 17, 18, 11, 18, 0, 21], + [16, 28, 7, 14, 3, 3, 28, 35, 32, 11, 0, 28, 0, 14, 12, 6, 28, 0, 24, 14, 11, 28, 32, 1, 28, 34, 2, 17, 28, 6, 2, 32, 21], + [16, 28, 20, 2, 32, 3, 12, 28, 13, 2, 0, 28, 17, 18, 29, 20, 24, 28, 29, 28, 15, 14, 20, 17, 2, 1, 24, 2, 13, 18, 27, 28, 11, 2, 28, 7, 18, 28, 7, 14, 3, 3, 28, 11, 4, 14, 1, 28, 0, 24, 18, 28, 5, 2, 14, 20, 18, 28, 0, 18, 11, 0, 21], + [16, 28, 29, 15, 28, 10, 2, 14, 13, 10, 28, 0, 2, 28, 4, 18, 18, 1, 28, 29, 12, 35, 32, 11, 0, 14, 13, 10, 28, 0, 24, 14, 13, 10, 11, 28, 32, 13, 0, 14, 3, 28, 0, 24, 14, 11, 28, 34, 18, 18, 3, 11, 28, 17, 14, 10, 24, 0, 21], + [30, 2, 32, 28, 10, 29, 5, 18, 28, 15, 18, 28, 0, 24, 14, 11, 28, 29, 20, 20, 18, 11, 11, 21, 28, 16, 28, 29, 15, 28, 2, 13, 3, 6, 28, 32, 11, 14, 13, 10, 28, 7, 24, 29, 0, 28, 6, 2, 32, 28, 29, 3, 3, 2, 7, 18, 12, 21], + [16, 28, 4, 13, 2, 7, 28, 6, 2, 32, 28, 29, 17, 18, 28, 17, 18, 29, 12, 14, 13, 10, 28, 15, 6, 28, 11, 2, 32, 17, 20, 18, 28, 17, 14, 10, 24, 0, 28, 13, 2, 7, 21], + [16, 28, 29, 15, 28, 13, 2, 0, 28, 29, 28, 1, 2, 1, 32, 1, 21, 28, 16, 28, 29, 15, 28, 0, 24, 18, 28, 0, 24, 14, 13, 10, 28, 29, 17, 17, 29, 13, 10, 14, 13, 10, 28, 6, 2, 32, 17, 28, 1, 2, 1, 32, 1, 11, 21], + [23, 18, 0, 28, 15, 18, 28, 11, 0, 29, 17, 0, 28, 2, 17, 10, 29, 13, 14, 31, 14, 13, 10, 28, 7, 24, 29, 0, 28, 14, 11, 28, 14, 13, 28, 34, 17, 2, 13, 0, 28, 2, 34, 28, 6, 2, 32, 21], + [33, 14, 21, 28, 16, 28, 29, 15, 28, 26, 2, 0, 21, 28, 16, 28, 24, 18, 29, 17, 12, 28, 6, 2, 32, 21, 28, 16, 28, 7, 14, 3, 3, 28, 0, 29, 4, 18, 28, 14, 0, 28, 34, 17, 2, 15, 28, 24, 18, 17, 18, 21], + [16, 28, 12, 2, 28, 13, 2, 0, 28, 13, 18, 18, 12, 28, 6, 2, 32, 28, 0, 2, 28, 20, 3, 14, 20, 4, 28, 29, 13, 6, 0, 24, 14, 13, 10, 21, 28, 16, 28, 29, 3, 17, 18, 29, 12, 6, 28, 4, 13, 2, 7, 28, 7, 24, 29, 0, 28, 6, 2, 32, 28, 7, 29, 13, 0, 21], + [30, 2, 32, 28, 4, 18, 18, 1, 28, 17, 18, 29, 20, 24, 14, 13, 10, 28, 34, 2, 17, 28, 0, 24, 18, 28, 15, 2, 32, 11, 18, 21, 28, 16, 28, 7, 14, 3, 3, 28, 10, 18, 0, 28, 0, 24, 18, 17, 18, 28, 34, 14, 17, 11, 0, 21], + [23, 18, 0, 28, 15, 18, 28, 25, 17, 14, 13, 10, 28, 0, 24, 18, 28, 14, 15, 1, 2, 17, 0, 29, 13, 0, 28, 2, 13, 18, 28, 0, 2, 28, 0, 24, 18, 28, 34, 17, 2, 13, 0, 21], + [30, 2, 32, 28, 11, 3, 2, 7, 18, 12, 28, 12, 2, 7, 13, 21, 28, 16, 28, 13, 2, 0, 14, 20, 18, 12, 21], +] + +ej = 1 +az = 9 +cd = 13 +ek = 16 +ei = 22 +eh = 10 +im = 7 + +di = { + 0: (9, 4, 310, 6, 20), + 2: (1, 1, 250, 21, 21), + 3: (9, 3, 300, 19, 0), + 4: (3, 2, 290, 15, 17), + 5: (9, 4, 310, 18, 14), + 6: (14, 4, 320, 12, 20), + 7: (0, 1, 260, 2, 8), + 8: (0, 2, 270, 21, 4), + 11: (5, 3, 300, 23, 24), + 12: (11, 4, 320, 18, 5), + 14: (15, 5, 260, 26, 17), + 15: (4, 2, 260, 25, 17), + 17: (7, 3, 300, 11, 24), + 18: (6, 5, 260, 26, 14), + 19: (11, 4, 320, 6, 0), + 20: (12, 4, 320, 12, 5), + 21: (2, 2, 280, 15, 4), + 23: (8, 3, 310, 19, 3), + 24: (3, 3, 300, 23, 3), + 25: (4, 3, 280, 11, 24), + 26: (10, 5, 260, 17, 14), +} + + +def ia(a): + return "".join(ih[i] for i in a) + + +def fb(): + return ia(hh[ej]) + + +def bq(): + return ia(hh[az]) + + +def cu(): + return ia(hh[cd]) + + +def fc(): + return ia(hh[ek]) + + +def fa(): + return ia(hh[ei]) + + +def ez(): + return ia(hh[eh]) + + +def dm(): + a = iz.get("node", im) + b = di.get(a) + if b is None: + a = im + b = di[a] + return a, b + + +def dl(c): + d, e = dm() + f, f, f, b, a = e + iz["node"] = a if c else b + + +if __name__ == "__main__": + main() \ No newline at end of file