函数:writePasteboard 写入剪贴板

函数名称:写入剪贴板

函数功能:对系统剪贴板进行写入操作

函数方法

writePasteboard(str, kind);

参数 类型 必填 说明
str string 写入剪贴板字符串
kind number 当 kind 为 1 时,str 参数为一个图片路径
(仅支持引擎版本 iOS v2.3.6 以上)

函数用例

从文件中读入一行并储存到剪贴板

--以只读方式打开文件
file = io.open(userPath().."/res/test.txt" ,"r");    
--如果打开成功
if file then    
    --储存到剪贴板
    writePasteboard(file:read());    
else
    toast("Cannot open: test.txt",0);
end
--关闭文件
file:close();

iOS 系统:粘贴图片

writePasteboard("1.png",1)
keyDown("RightGUI")
keyDown("v")
keyUp("v")
keyUp("RightGUI")

注意事项

  • 参数 kind 仅支持引擎版本 iOS v2.3.6 以上。

  • 安卓 12 及其以上系统仅支持在当前应用进行读写剪贴板,切换到其他应用将无效。

  • 该函数将覆盖系统剪贴板,如有重要数据储存在剪贴板请及时备份。

  • 当脚本要上传到企业版和小精灵平台时,请使用 userPath 函数自动获取路径。

Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""