方法参考(1) presskey 按下键盘按键或组合键。 plaintext await session.computer.presskey({ key: 'Enter' }); await session.computer.presskey({ key: 'ctrl c' }); typetext 输入文本。 plaintext await session.computer.typetext({ text: 'Hello World' }); screenshot 截取当前桌面屏幕。 plaintext const result await session.computer.screenshot(); getcursorposition 获取当前鼠标位置。 plaintext const result await session.computer.getcursorposition(); 成功时,data 中通常包含: plaintext { "PositionX": 500, "PositionY": 300 } FileSystemAPI createdirectory 创建目录。 plaintext await session.filesystem.createdirectory({ path: 'C:/aiusertest' }); readfile 读取文本文件。 plaintext const result await session.filesystem.readfile({ path: 'C:/aiusertest/demo.txt', offset: 0, length: 1024 }); writefile 写入文本文件。 plaintext await session.filesystem.writefile({ path: 'C:/aiusertest/result.txt', mode: 'overwrite', content: 'result content' }); movefile 移动或重命名文件、目录。 plaintext await session.filesystem.movefile({ source: 'C:/aiusertest/result.txt', destination: 'C:/aiusertest/archive/result.txt' }); searchfiles 搜索文件。 plaintext const result await session.filesystem.searchfiles({ path: 'C:/aiusertest', pattern: '.txt', matchMode: 'wildcard' }); close 关闭当前会话。 plaintext await session.close(); 建议在 finally 中调用,确保异常场景也能释放会话。 常见错误码 错误码 说明 52060 指定桌面不属于当前用户 92006 桌面不在线 92100 通过 sessionId 找不到 session 92101 消息发送失败 92102 请求内容长度超过限制 92103 找不到消息记录 92104 功能未开放,请联系管理员 92105 功能未开放,请联系管理员
来自: