温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

VBScript设置和获取剪切板内容的方法

发布时间:2020-06-16 13:23:17 来源:网络 阅读:2098 作者:孤月2012 栏目:软件技术

 Automation中经常需要程序和剪切板交互,还在使用键盘一个一个input?内容多的话,岂不是太慢了,使用剪切板的黏贴复制,so fast,so easy……具体需要调用Microsoft Forms 2.0 Object Library的对象和方法,用它轻松实现设置和获取剪切板的内容,下面写了2个设置和获取剪切板内容的函数,需要的时候直接调用~

 'operating clipboard
Function setClipboard(str)
    'setting clipboard's content
    Dim Form, TextBox
    Set Form = CreateObject("Forms.Form.1")
    Set TextBox = Form.Controls.Add("Forms.TextBox.1").Object
    TextBox.MultiLine = True
    TextBox.Text = str
    TextBox.SelStart = 0
    TextBox.SelLength = TextBox.TextLength
    TextBox.Copy
End Function
Function getClipboard
    'getting clipboard's content
    Dim Form, TextBox
    Set Form = CreateObject("Forms.Form.1")
    Set TextBox = Form.Controls.Add("Forms.TextBox.1").Object
    TextBox.MultiLine = True
    If TextBox.CanPaste Then
        TextBox.Paste
        getClipboard = TextBox.Text
    End If
End Function

 

 

更多方法参考链接:http://demon.tw/programming/vbs-clipboard.html

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI