
标题: [其他] 【已解决】bat能够判断剪切板内容是字符还是文件(夹)吗?谢谢 [打印本页]
作者: yyz219 时间: 3 天前 13:31 标题: 【已解决】bat能够判断剪切板内容是字符还是文件(夹)吗?谢谢
本帖最后由 yyz219 于 2025-3-31 19:39 编辑
已解决:
<!-- :
@echo off
::数据类型是文本,则返回值=1,否则返回值=0
(for /f %%v in ('mshta "%~f0" ') do echo,%%v) &pause&exit/b
-->
<script> u=clipboardData.getData('text'), v=(u)? 1: 0;
new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(v); close(); </script>
=========================================
百度搜索剪切板内容:- <!-- :
- @echo off
- ::======================隐藏批处理窗口===========================================================
- if "%1"=="hide" goto CmdBegin
- start mshta vbscript:createobject("wscript.shell").run("""%~0"" hide",0)(window.close)&&exit
- :CmdBegin
- ::▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆下面检测剪切板上是不是文本▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆
- (for /f %%v in ('mshta "%~f0" ') do set 返回值=%%v) & ::(返回值:1--是文本, 0--文件【夹】)
- echo. %返回值% >%Temp%\#.txt
- ::==============================================================================================
- ::【检测 %Temp%\#.txt “有无”:"1"(有跳到:S,无跳到:T】
- type %Temp%\#.txt|findstr "1" >nul 2>&1
- if %errorlevel% equ 0 (goto :S) else goto :T
- ::==============================================================================================
- -->
- <script> u=clipboardData.getData('text'), v=(u)? 1: 0;
- new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(v); close(); </script>
- ::▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆下面百度搜索剪切板的内容▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆
- :S
- for /f "delims=" %%a in ('mshta "JavaScript:new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(clipboardData.getData('text'));close()"') do set "剪切板内容=%%a"
- start "" d:\1绿色软件\网络\浏览器\便携版百分3.2.4.23\chrome.exe "www.baidu.com/s?ie=UTF-8&wd=%剪切板内容%"
- :T
- exit
复制代码
==================================
原来的问题:
bat能够判断剪切板内容是字符还是文件(夹)吗?谢谢
作者: aloha20200628 时间: 3 天前 15:06
本帖最后由 aloha20200628 于 2025-3-31 15:07 编辑
回复 1# yyz219
鉴于 winPE 系统对脚本类型支持的有限性,给一个 mshta 版本简化一下解答结果,以下代码存为 test.bat 运行,若当前剪贴板数据类型是文本,则返回值=1,否则返回值=0- <!-- :
- @echo off &(for /f %%v in ('mshta "%~f0" ') do echo,%%v) &pause&exit/b
- -->
- <script> u=clipboardData.getData('text'), v=(u)? 1: 0;
- new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(v); close(); </script>
复制代码
作者: yyz219 时间: 3 天前 15:09
回复 2# aloha20200628
谢谢 我试一试先
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |