recovered snapshot from suspended aaronjaworski710 (history unavailable)
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
# __portable_paths__ (auto-injected: portable, env-overridable paths)
|
||||
import os as _pos, sys as _psys
|
||||
from pathlib import Path as _PPath
|
||||
_ROOT = _PPath(__file__).resolve().parent
|
||||
_REPO = _ROOT
|
||||
for _ in range(4):
|
||||
if (_REPO / ".git").exists() or (_REPO / "README.md").exists():
|
||||
break
|
||||
if _REPO.parent == _REPO:
|
||||
break
|
||||
_REPO = _REPO.parent
|
||||
_DATA = _PPath(_pos.environ.get("TOOLKIT_DATA", str(_REPO / "data")))
|
||||
_WORK = _PPath(_pos.environ.get("TOOLKIT_WORK", str(_REPO / "_work")))
|
||||
try:
|
||||
_DATA.mkdir(parents=True, exist_ok=True)
|
||||
_WORK.mkdir(parents=True, exist_ok=True)
|
||||
except Exception:
|
||||
pass
|
||||
_PY = _pos.environ.get("PYTHON_BIN") or _psys.executable
|
||||
_USERPROFILE = _pos.environ.get("USERPROFILE") or str(_PPath.home())
|
||||
def _d(name, env=None):
|
||||
"""Data-file path under ./data (or $TOOLKIT_DATA); optional per-file env override."""
|
||||
if env and _pos.environ.get(env):
|
||||
return _PPath(_pos.environ[env])
|
||||
return _DATA / name
|
||||
def _w(name=""):
|
||||
"""Work-dir path under ./_work (or $TOOLKIT_WORK)."""
|
||||
return (_WORK / name) if name else _WORK
|
||||
# --- end portable prelude ---
|
||||
|
||||
import ctypes, ctypes.wintypes as wt, time
|
||||
user32=ctypes.windll.user32
|
||||
SendMessageW=user32.SendMessageW
|
||||
SendMessageW.restype=ctypes.c_long
|
||||
SendMessageW.argtypes=[wt.HWND,wt.UINT,wt.WPARAM,wt.LPARAM]
|
||||
FOLDER=str(_w("tmp/haze_testproj"))
|
||||
handles=[199774,34409320,85330480]
|
||||
EnumChild=ctypes.WINFUNCTYPE(wt.BOOL,wt.HWND,wt.LPARAM)
|
||||
|
||||
def get_class(hwnd):
|
||||
buf=ctypes.create_unicode_buffer(256)
|
||||
user32.GetClassNameW(hwnd,buf,256)
|
||||
return buf.value
|
||||
|
||||
for h in handles:
|
||||
if not user32.IsWindowVisible(h):
|
||||
print(h,"invisible, skip"); continue
|
||||
edits=[]; btns=[]
|
||||
def cb(ch,lp):
|
||||
c=get_class(ch)
|
||||
n=user32.GetWindowTextLengthW(ch)
|
||||
buf=ctypes.create_unicode_buffer(n+1)
|
||||
user32.GetWindowTextW(ch,buf,n+1)
|
||||
if c=="Edit": edits.append((ch,buf.value))
|
||||
if c=="Button" and buf.value: btns.append((ch,buf.value))
|
||||
return True
|
||||
user32.EnumChildWindows(h,EnumChild(cb),0)
|
||||
print(h,"edits:",[e[1][:40] for e in edits],"btns:",[b[1][:30] for b in btns][:8])
|
||||
if edits:
|
||||
e=edits[0][0]
|
||||
p=ctypes.create_unicode_buffer(FOLDER)
|
||||
SendMessageW(e,0x000C,0,ctypes.addressof(p))
|
||||
time.sleep(0.3)
|
||||
tgt=None
|
||||
for bh,txt in btns:
|
||||
if "\u043f\u0430\u043f\u043a\u0438" in txt.lower() or "select folder" in txt.lower():
|
||||
tgt=bh; break
|
||||
if tgt:
|
||||
SendMessageW(tgt,0x00F5,0,0)
|
||||
print(" clicked button on",h)
|
||||
else:
|
||||
user32.PostMessageW(h,0x0111,1,0)
|
||||
print(" posted IDOK on",h)
|
||||
time.sleep(1.5)
|
||||
else:
|
||||
user32.PostMessageW(h,0x0111,2,0)
|
||||
time.sleep(0.5)
|
||||
Reference in New Issue
Block a user