将剪贴板内容复制到字符串 - vbscript [英] Copy clipboard contents to string - vbscript

查看:89
本文介绍了将剪贴板内容复制到字符串 - vbscript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vbscript中,我最初将内容从pdf复制到剪贴板。

然后将剪贴板内容复制到字符串上。

代码在带有UFT的windows7机器上运行良好版本12.53,Adobe Acrobat DC阅读器版本15.1536。



但是,在具有UFT版本14,Adobe Acrobat的Windows10计算机中,从剪贴板复制到字符串相同的脚本失败读者版本18.2304



我不确定是否存在阻止脚本执行的版本冲突。



我尝试过:



脚本:

函数ReadPDF(文件名)

'调用KillByName(AcroRd32.exe)'''由Krupesh添加

设置oShell = CreateObject(wscript.shell)

'打开PDF文件

oShell.run文件名

等待(4)

窗口(AdobePdf)。激活

等待3

''使用'C'从PDF文件中选择所有数据ontrol + a'key

oShell.Sendkeys^ a

wait(2)

''使用PDF文件将数据移动到剪贴板'Control + c'键

oShell.Sendkeys^ c

等待(15)

'从剪贴板中提取数据

设置objClipboard = CreateObject(htmlfile)

strClipboard = objClipboard.ParentWindow.ClipboardData.GetData(Text)

'关闭PDF文件

'调用terminateProcess(AcroRd32.exe)

'返回剪贴板数据的值

等待4

ReadPDF = strClipboard

等待3

结束函数

解决方案

那是因为 -

 window.clipboardData.setData 





我有同样的问题,但我的目的不同 -



请参阅下面的博客我已经推荐并解决了我的问题



在Windows 10(build 14332)中,window.clipboardData.setData无法按预期工作。 ·问题#1071·Microsoft / ChakraCore·GitHub [ ^


In vbscript I am initally copying contents from pdf to clipboard.
And then copying clipboard contents onto a string.
The code works perfect on a windows7 machine with UFT version 12.53 , Adobe Acrobat DC reader version 15.1536.

However the same script fails at "Copy from clipboard to string" in a windows10 machine with UFT version 14, Adobe Acrobat reader version 18.2304

I am not sure if it is the version conflict that is blocking the script from executing.

What I have tried:

Script :
Function ReadPDF(Filename)
'Call KillByName("AcroRd32.exe") '''Added by Krupesh
Set oShell = CreateObject("wscript.shell")
'Open the PDF file
oShell.run Filename
wait(4)
Window("AdobePdf").Activate
wait 3
'' Select all data from PDF file using 'Control + a ' keys
oShell.Sendkeys "^a"
wait(2)
'' Move data from PDF file to clipboard using 'Control + c ' keys
oShell.Sendkeys "^c"
wait(15)
'Fetching data from clipboard
Set objClipboard = CreateObject("htmlfile")
strClipboard = objClipboard.ParentWindow.ClipboardData.GetData("Text")
'Close the PDF File
'Call terminateProcess("AcroRd32.exe")
'Return the value of clipboard data
wait 4
ReadPDF= strClipboard
wait 3
End Function

解决方案

That's because - there are different method for

window.clipboardData.setData



I had the same issue but my purpose was different -

See below blog which I had referred and that resolved my issue

In Windows 10 (build 14332) window.clipboardData.setData does not work as expected. · Issue #1071 · Microsoft/ChakraCore · GitHub[^]


这篇关于将剪贴板内容复制到字符串 - vbscript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆