From 5643bfb5f05eff687839bff37eea8c058e915af3 Mon Sep 17 00:00:00 2001 From: Liang Jiaqing Date: Tue, 24 Mar 2026 00:00:20 +0800 Subject: [PATCH] =?UTF-8?q?code=5Frun=E8=87=AA=E5=8A=A8=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E5=B8=B8=E7=94=A8import+memory=E8=B7=AF=E5=BE=84;=20ljqCtrl=5F?= =?UTF-8?q?sop=E8=A1=A5=E5=85=85=E6=96=87=E6=9C=AC=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ga.py | 3 ++- memory/ljqCtrl_sop.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ga.py b/ga.py index 12c2486..537a885 100644 --- a/ga.py +++ b/ga.py @@ -20,7 +20,8 @@ def code_run(code, code_type="python", timeout=60, cwd=None, code_cwd=None, stop cwd = cwd or os.path.join(script_dir, 'temp'); tmp_path = None if code_type == "python": tmp_file = tempfile.NamedTemporaryFile(suffix=".ai.py", delete=False, mode='w', encoding='utf-8', dir=code_cwd) - tmp_file.write(code) + _mem = os.path.join(script_dir, 'memory') + tmp_file.write(f"import sys, os, json, re, time; sys.path.append(r'{_mem}')\n" + code) tmp_path = tmp_file.name tmp_file.close() cmd = [sys.executable, "-X", "utf8", "-u", tmp_path] diff --git a/memory/ljqCtrl_sop.md b/memory/ljqCtrl_sop.md index ae36f7e..dde0e04 100644 --- a/memory/ljqCtrl_sop.md +++ b/memory/ljqCtrl_sop.md @@ -41,4 +41,5 @@ ljqCtrl.Click(px, py) - **物理验证**:模拟操作前必须确保窗口已通过 `activate()` 置于前台。 - **偏移量**:所有的相对偏移像素值(如“向右移动 10 像素”)同样需要除以 `dpi_scale`。 - **坐标对齐**: 物理坐标 = 截图坐标;ljqCtrl 自动处理 DPI 换算,禁止手动重复计算。 -- **⚠️ 窗口坐标转换陷阱**:使用 `win32gui.GetWindowRect(hwnd)` 获取的矩形包含标题栏和边框,而截图内容是客户区。点击截图内元素时,必须用 `win32gui.ClientToScreen(hwnd, (0, 0))` 获取客户区原点的屏幕坐标,再加上截图内坐标。禁止直接用 GetWindowRect 左上角 + 截图坐标。 \ No newline at end of file +- **⚠️ 窗口坐标转换陷阱**:使用 `win32gui.GetWindowRect(hwnd)` 获取的矩形包含标题栏和边框,而截图内容是客户区。点击截图内元素时,必须用 `win32gui.ClientToScreen(hwnd, (0, 0))` 获取客户区原点的屏幕坐标,再加上截图内坐标。禁止直接用 GetWindowRect 左上角 + 截图坐标。 +- **文本输入**:ljqCtrl 无 TypeText/SendKeys。向输入框键入文本:先点击/三击选中字段,再 `pyperclip.copy('文本'); ljqCtrl.Press('ctrl+v')`。 \ No newline at end of file