钉钉会议+腾讯元宝=AI监督自习室

autohotkey自动操作:截屏,然后发送到腾讯元宝,再将回答输出
image

点击查看代码
#Requires AutoHotkey v2.0
#SingleInstance Force
SendMode "Input"
SetWorkingDir A_ScriptDir
CoordMode "Pixel", "Screen"
CoordMode "Mouse", "Screen"
Loop{
; 1. 激活钉钉会议窗口
try {
    WinActivateBottom "ahk_exe tblive.exe"
    if !WinWaitActive("ahk_exe tblive.exe", , 3) {  ; v2.0使用返回值替代ErrorLevel
        throw Error("钉钉窗口激活失败")
    }

    ; 2. 截取活动窗口
    Send "!{PrintScreen}"
    
    ; 3. 等待截图完成
    A_Clipboard := ""  ; v2.0使用A_Clipboard替代Clipboard
    if !ClipWait(2, 1) {  ; v2.0返回布尔值
        throw Error("截图失败或超时")
    }

    ; 4. 激活腾讯元宝窗口
    WinActivate "ahk_exe yuanbao.exe"
    if !WinWaitActive("ahk_exe yuanbao.exe", , 5) {
        throw Error("腾讯元宝窗口激活失败")
    }

    if !FileExist("C:\Users\Monte\Documents\AutoHotkey\ls.png") {
        throw Error("搜索图片文件不存在")
    }
    
    if ImageSearch(&FoundX, &FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, "C:\Users\Monte\Documents\AutoHotkey\ls.png") {
        Click FoundX+20, FoundY+20  ; v2.0直接使用变量
        Sleep 1000
    } else {
        throw Error("未找到目标图片")
    }

    ; 5. 粘贴并发送消息
    Send "{Esc}"
    Send "^v"
    Sleep 200
    SendText "无需分析依据,谁不在认真写作业"  ; v2.0推荐SendText发送文字
    Sleep 2000
    Send "{Enter}"
    
    ; 6. 等待响应并搜索图片
    Sleep 30000
    if !FileExist("C:\Users\Monte\Documents\AutoHotkey\next.png") {
        throw Error("搜索图片文件不存在")
    }
    
    if ImageSearch(&FoundX, &FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, "C:\Users\Monte\Documents\AutoHotkey\next.png") {
        Click FoundX+20, FoundY+20  ; v2.0直接使用变量
        Sleep 1000
    } else {
        throw Error("未找到目标图片")
    }

    Sleep 1000
    if !FileExist("C:\Users\Monte\Documents\AutoHotkey\fz.png") {
        throw Error("搜索图片文件不存在")
    }
    
    if ImageSearch(&FoundX, &FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, "C:\Users\Monte\Documents\AutoHotkey\fz.png") {
        Click FoundX+20, FoundY+20  ; v2.0直接使用变量
        Sleep 1000
    } else {
        throw Error("未找到目标图片")
    }


    if !FileExist("C:\Users\Monte\Documents\AutoHotkey\lsa.png") {
        throw Error("搜索图片文件不存在")
    }
    
    if ImageSearch(&FoundX, &FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, "C:\Users\Monte\Documents\AutoHotkey\lsa.png") {
        Click FoundX+20, FoundY+20  ; v2.0直接使用变量
        Sleep 1000
    } else {
        throw Error("未找到目标图片")
    }
    ; 7. 返回钉钉窗口
    WinActivateBottom "ahk_exe tblive.exe ahk_id 396186"
    if !WinWaitActive("ahk_exe tblive.exe", , 3) {
        throw Error("钉钉窗口二次激活失败")
    }

} catch as err {
    MsgBox err.Message, "错误", 0x10  ; 0x10表示错误图标
    ExitApp 1
}
Click 2056, 1289
Send "^v"
Send "{Enter}"
}
posted @ 2025-05-31 16:33  meny  阅读(70)  评论(0)    收藏  举报