Initial commit: Screen Leads app
Screen-capture lead tool: capture agent, Claude vision extractor with pluggable site recipes (LinkedIn), canonical funnel model, SQLite storage, FastAPI backend, dashboard, and setup/run scripts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""OS-level scrolling of the focused window via pyautogui.
|
||||
|
||||
We drive real scroll input rather than the DOM, so it works over a plain
|
||||
screenshot pipeline on any OS. Needs Accessibility permission on macOS and an
|
||||
X11 session on Linux.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
||||
from config import SCROLL_AMOUNT, SCROLL_PAUSE
|
||||
|
||||
|
||||
class ScrollError(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
def _pyautogui():
|
||||
try:
|
||||
import pyautogui
|
||||
|
||||
pyautogui.FAILSAFE = False
|
||||
return pyautogui
|
||||
except Exception as e: # pragma: no cover
|
||||
raise ScrollError(
|
||||
f"pyautogui not available ({e}). On macOS grant Accessibility; "
|
||||
f"on Linux use X11."
|
||||
)
|
||||
|
||||
|
||||
def scroll_to_top() -> None:
|
||||
pg = _pyautogui()
|
||||
# A large upward scroll reliably returns most pages to the top.
|
||||
for _ in range(10):
|
||||
pg.scroll(SCROLL_AMOUNT)
|
||||
time.sleep(SCROLL_PAUSE)
|
||||
|
||||
|
||||
def scroll_down(amount: int = SCROLL_AMOUNT) -> None:
|
||||
pg = _pyautogui()
|
||||
pg.scroll(-abs(amount))
|
||||
time.sleep(SCROLL_PAUSE)
|
||||
Reference in New Issue
Block a user