import sys
sys.path.insert(0, ".")
import time
import ctypes
import src.common.win32_window as w

h = w.find_poe2_window()
u = ctypes.windll.user32
VK_W = 0x57
SC_W = 0x11

print(f"Sending repeated W to HWND {h} for 1.2s...")
u.SendMessageW(h, 0x0006, 1, 0) # WM_ACTIVATE WA_ACTIVE
u.SendMessageW(h, 0x0007, 0, 0) # WM_SETFOCUS

for i in range(35):
    lparam = (1) | (SC_W << 16) | (0 if i == 0 else (1 << 30))
    u.PostMessageW(h, 0x0100, VK_W, lparam)
    time.sleep(0.035)

u.PostMessageW(h, 0x0101, VK_W, 1 | (SC_W << 16) | (1 << 30) | (1 << 31))
print("Finished W sequence.")
