如何把VB的运行结果复制到剪贴板中
发布网友
发布时间:2022-05-20 18:38
我来回答
共5个回答
热心网友
时间:2023-11-10 17:10
VB妮可 的方法确实可行
Shell "notepad", 1
SendKeys "^" + "V"
不过这样用很容易由于系统延迟出问题
Ctrl+V不一定使用在记事本上
推荐用API,效果较好,不容易出错
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_PASTE = &H302
Private Sub Command1_Click()
a = "abcd"
b = "efgh"
d = a & b
Shell "notepad", vbNormalFocus
Call SendMessage(FindWindowEx(FindWindow(vbNullString, "无标题 - 记事本"), 0, "Edit", vbNullString), WM_PASTE, 0, 0&)
End Sub
热心网友
时间:2023-11-10 17:11
clipboard.settext d '复制d这个变量到剪贴板中,clipboard为剪贴板
open 文本文件地址(包括扩展名) for output as 1
print #1,clipboard.gettext
close #1
上面为新建一个文本,路径自设,再将剪贴板内容复制保存
若想用shell的话,可以这样
Shell "notepad.exe " & xx, vbNormalFocus
SendKeys "^" + "V" '发送ctrl+V (粘贴)
xx为文本文件的地址,要绝对路径。
自己参考一下吧!很多方法
热心网友
时间:2023-11-10 17:11
Shell "notepad", 1
SendKeys "^" + "V"
不过这样用很容易由于系统延迟出问题
Ctrl+V不一定使用在记事本上
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_PASTE = &H302
Private Sub Command1_Click()
a = "abcd"
b = "efgh"
d = a & b
Shell "notepad", vbNormalFocus
Call SendMessage(FindWindowEx(FindWindow(vbNullString, "无标题 - 记事本"), 0, "Edit", vbNullString), WM_PASTE, 0, 0&)
End Sub
热心网友
时间:2023-11-10 17:12
Clipboard.SetText d
就行了
热心网友
时间:2023-11-10 17:12
Private Sub Command1_Click()
a = "abcd"
b = "efgh"
d = a & b
Print d
Clipboard.Clear
Clipboard.SetText d
Shell "notepad", 1
SendKeys "^" + "V"
End Sub