标题: [文本处理] 读取剪贴板内容生成二维码 [打印本页]
作者: yuboabc 时间: 2017-9-1 23:33 标题: 读取剪贴板内容生成二维码
脚本使用的是百度的API,方便电脑与手机 pad等设备传递一些文字、连接信息。
感谢老刘的指导。。。
本人也是个渣,看代码就知道了。。。不过这个脚本用着还行。。。送给有需要的!- @echo off
- if exist %tmp%\indexqr.html del /f/q %tmp%\indexqr.html >nul 2>nul
- >%tmp%\qr_getdata.vbs echo Call GetTextData
- >>%tmp%\qr_getdata.vbs echo function GetTextData
- >>%tmp%\qr_getdata.vbs echo Set objHTML=CreateObject("htmlfile")
- >>%tmp%\qr_getdata.vbs echo ClipboardText=objHTML.ParentWindow.ClipboardData.GetData("text")
- >>%tmp%\qr_getdata.vbs echo If VarType(ClipboardText)^<^>8 Or ClipboardText=Empty Then MsgBox "请复制一些内容再运行本程序^!",vbOKOnly + vbExclamation,"警告":exit function End If
- >>%tmp%\qr_getdata.vbs echo Set fso=wscript.createobject("scripting.filesystemobject")
- >>%tmp%\qr_getdata.vbs echo Set file=fso.opentextfile("%tmp%\qr_data.txt",2,true)
- >>%tmp%\qr_getdata.vbs echo file.writeline ClipboardText
- >>%tmp%\qr_getdata.vbs echo end function:Wscript.Quit
- call %tmp%\qr_getdata.vbs
- if not exist %tmp%\qr_data.txt goto :eof
- >%tmp%\qr_UrlEncode.js echo var str=encodeURIComponent(WScript.Arguments(0));
- >>%tmp%\qr_UrlEncode.js echo WScript.echo(str);
- (for /f "usebackq delims=" %%i in ("%tmp%\qr_data.txt") do cscript -nologo %tmp%\qr_UrlEncode.js "%%i")>%tmp%\qr_urlcode.txt
- for /f %%i in (%tmp%\qr_urlcode.txt) do set n=%%i&call set m=%%m%%%%n%%%%%%0A
- >%tmp%\indexqr.html echo ^<html^>
- >>%tmp%\indexqr.html echo ^<head^>
- >>%tmp%\indexqr.html echo ^<title^>二维码生成^</title^>
- >>%tmp%\indexqr.html echo ^<script language=javascript^>function hero(){var herowidth=400;var heroheight=450;window.resizeTo(herowidth,heroheight)}hero();^</script^>
- >>%tmp%\indexqr.html echo ^<script language=javascript^>^</script^>
- >>%tmp%\indexqr.html echo ^<style type="text/css"^>body{overflow-x:hidden;overflow-y:hidden;text-align:center;}^</style^>
- >>%tmp%\indexqr.html echo ^</head^>
- >>%tmp%\indexqr.html echo ^<body style="background:#C7C7C7" onresize=hero(); onkeypress=window.close() ^>
- >>%tmp%\indexqr.html echo ^<p style="text-align:center"^>^<img border="1" width="350" height="350" alt="按任意键关闭窗口" src="http://pan.baidu.com/share/qrcode?w=350&h=350&url=%m%"^>^</p^>
- >>%tmp%\indexqr.html echo ^<p style="text-align:center"^>^<b^>By.DcrClub^</b^>^</p^>
- >>%tmp%\indexqr.html echo ^</body^>
- >>%tmp%\indexqr.html echo ^</html^>
- start mshta "%tmp%\indexqr.html"
- del /f/q %tmp%\qr_* >nul 2>nul
- goto :eof
复制代码
是不是有点low。。。。这脚本写的!~~~
打包了一个exe文件。
链接: https://pan.baidu.com/s/19r6YRIChKNkgRuZc6nCTTg 提取码: nmnv
作者: 0000 时间: 2017-9-2 10:36
本帖最后由 0000 于 2017-9-3 12:47 编辑
觉得非常实用!
这代码风格......- @echo off
-
- >%tmp%\qr_getdata.vbs (
- echo Set objHTML=CreateObject("htmlfile"^)
- echo ClipboardText=objHTML.ParentWindow.ClipboardData.GetData("text"^)
- echo If VarType(ClipboardText^)^<^>8 Or ClipboardText=Empty Then
- echo MsgBox "请复制一些内容再运行本程序!",vbOKOnly + vbExclamation,"警告"
- echo WScript.Quit
- echo End If
- echo Set fso=WScript.CreateObject("scripting.filesystemobject"^)
- echo Set file=fso.OpenTextFile("%tmp%\qr_data.txt",2,true^)
- echo file.WriteLine ClipboardText
- echo WScript.Quit
- )
- call %tmp%\qr_getdata.vbs
- if not exist %tmp%\qr_data.txt goto :eof
-
- >%tmp%\qr_UrlEncode.js (
- echo var str=encodeURIComponent(WScript.Arguments(0^)^);
- echo WScript.echo(str^);
- )
-
- >%tmp%\qr_urlcode.txt (
- for /f "usebackq delims=" %%i in ("%tmp%\qr_data.txt") do (
- cscript -nologo %tmp%\qr_UrlEncode.js "%%i"
- ) )
-
- for /f %%i in (%tmp%\qr_urlcode.txt) do (
- set n=%%i
- call set m=%%m%%%%n%%%%%%0A
- )
-
- >%tmp%\indexqr.html (
- echo ^<html^>
- echo ^<head^>
- echo ^<title^>二维码生成^</title^>
- echo ^<script language=javascript^>
- echo function hero(^){
- echo var herowidth=400;
- echo var heroheight=450;
- echo window.resizeTo(herowidth,heroheight^)
- echo }
- echo hero(^);
- echo ^</script^>
- echo ^<script language=javascript^>^</script^>
- echo ^<style type="text/css"^>
- echo body{
- echo overflow-x:hidden;
- echo overflow-y:hidden;
- echo text-align:center;
- echo }
- echo ^</style^>
- echo ^</head^>
- echo ^<body style="background:#C7C7C7" onresize=hero(^); onkeypress=window.close(^) ^>
- echo ^<p style="text-align:center"^>
- echo ^<img
- echo border="1"
- echo width="350"
- echo height="350"
- echo alt="按任意键关闭窗口"
- echo src="http://pan.baidu.com/share/qrcode?w=350&h=350&url=%m%"
- echo ^>
- echo ^</p^>
- echo ^<p style="text-align:center"^>
- echo ^<b^>By.DcrClub^</b^>
- echo ^</p^>
- echo ^</body^>
- echo ^</html^>
- )
-
- start mshta "%tmp%\indexqr.html"
- del /f/q %tmp%\qr_* >nul 2>nul
- goto :eof
复制代码
作者: 563406396 时间: 2017-9-2 20:26
点赞,很好用
作者: fonyin 时间: 2022-9-29 22:52
回复 1# yuboabc
^<title^>二维码生成^</title^>
这里如何增加一个序号id呢 ^<title^>二维码生成id^</title^>
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |