剪贴板老是一堆字符支持多少字符

函数: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该文章修订时间:
2023-05-08 18:53:49
}
复制字符串到系统剪切板/**
* 复制文本到剪切板
*
* @param text
* @return
*/
@SuppressWarnings("deprecation")
public boolean copyStringToSystem(String text) {
try {
if (android.os.Build.VERSION.SDK_INT > 11) {
android.content.ClipboardManager c = (android.content.ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
c.setText(text);
} else {
android.text.ClipboardManager c = (android.text.ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
c.setText(text);
}
} catch (Exception e) {
return false;
}
return true;
}获取系统剪贴板内容/**
* 获取剪切板数据
*
* @return
*/
@SuppressWarnings("deprecation")
public String pasteStringFromSystem() {
String clipResult = null;
if (android.os.Build.VERSION.SDK_INT > 11) {
android.content.ClipboardManager c = (android.content.ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData primaryClip = c.getPrimaryClip();
Item itemAt = null;
if (primaryClip != null) {
itemAt = primaryClip.getItemAt(0);
}
if (itemAt != null) {
String trim = itemAt.getText().toString().trim();
clipResult = trim;
}
} else {
android.text.ClipboardManager c = (android.text.ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
CharSequence text = c.getText();
if (text != null) {
clipResult = text.toString().trim();
}
}
return clipResult;
}}
免版税 插画
腋窝,会议室,字符,夹子,剪贴板,男,例证,大,男人,人们,人员,上升,小,空白,写道,文字
更多
较少
不限职位 (U-EL)
网络使用 (W-EL)
印刷使用 (P-EL)
出售版权 (SR-EL 1)
出售版权 (SR-EL 3)
出售版权 (SR-EL)
}

我要回帖

更多关于 剪贴板老是一堆字符 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信