You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AutoHotkey脚本读取info.xlsx信息无输出问题排查求助

AutoHotkey脚本信息插入故障排查与修复

核心故障原因

脚本第二部分(Alt+小键盘触发)无法输出信息,由三个代码逻辑错误导致:

  1. 关联数组引用路径错误
    初始化函数init()中,客户子表数据是以三维关联数组形式存储:clientData[i, sheetName, "data"] := data,但action()函数错误使用了嵌套对象的引用方式clientData[clientId][match1].data[row][match3],无法定位到实际数据。

  2. 变量取值错误
    action()中row := match1 "Id"仅拼接出变量名字符串,未获取OpposingId/CourtId等变量的实际数值,无法定位目标数据行。

  3. 窗口焦点丢失
    弹出选择对话框后,焦点停留在Gui窗口,直接执行SendInput会把内容发送到Gui而非目标文档。

修复方案

修改action()函数代码如下:

action()
{
    global
    ; 记录当前激活的目标窗口
    WinGet, targetWindow, ID, A
    Gui Submit

    RegExMatch(A_GuiControl, "(\w+)_(\d)_(\d+)", match)

    if match2
    {
        %match1%Id := match3
        if (match1 != "Client")
            createGui(match1, 0)
    }
    else
    {
        ; 获取实际行号变量值
        row := %match1%Id
        ; 修正数组引用路径
        outputText := clientData[clientId, match1, "data"][row, match3]
        ; 激活目标窗口后发送内容
        WinActivate, ahk_id %targetWindow%
        SendInput % "{Raw}" outputText
    }
    Gui Destroy
}

额外验证点

  • 确认info.xlsx对应工作表(如Opposing、Court)数据格式正确:首行为表头,后续行是有效数据,无空行干扰readSheet()函数读取。
  • 检查客户子目录路径与clients.xlsx中客户名称完全一致,避免路径匹配失败导致数据未加载。

内容的提问来源于stack exchange,提问作者jimkirk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 15:34:56