Skip to content

模拟CtrlV粘贴 - SendPaste3

函数简介

通过封装好的键鼠路径模拟 Ctrl+V(内部调用 KeyPressHotkey("ctrl+v")),覆盖 normal / dx / vnc / rdp / 驱动等绑定模式。

适用于不处理 WM_PASTE、但响应 Ctrl+V 的自定义控件。标准 Edit 优先用 SendPaste2;通用兜底可用 SendPaste

接口名称

SendPaste3

DLL调用

int SendPaste3(long ola, long hwnd);

参数说明

参数名类型说明
ola长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
hwnd长整数型目标窗口句柄。为 0 时使用当前 绑定窗口

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
ola.SetClipboard("要粘贴的文本");
int ret = ola.SendPaste3(hwnd);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
ola.SetClipboard("要粘贴的文本");
int ret = ola.SendPaste3(hwnd);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ola.SetClipboard("要粘贴的文本")
ret = ola.SendPaste3(hwnd)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
ola.SetClipboard("要粘贴的文本");
int ret = ola.SendPaste3(hwnd);
go
import "github.com/ola/olaplug/olaplug"

ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
ola.SetClipboard("要粘贴的文本")
ret := ola.SendPaste3(hwnd)
rust
use olaplug::OLAPlugServer;

let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
ola.set_clipboard("要粘贴的文本");
let ret = ola.send_paste3(&hwnd);
cpp
var ola = com("OlaPlug.OlaSoft")
ola.SetClipboard("要粘贴的文本")
var ret = ola.SendPaste3(hwnd)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.SetClipboard "要粘贴的文本"
ret = ola.SendPaste3(hwnd)
text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.SetClipboard (“要粘贴的文本”)
ret = ola.SendPaste3(hwnd)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.SetClipboard("要粘贴的文本");
var ret = ola.SendPaste3(hwnd);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.SetClipboard("要粘贴的文本")
整数 ret = ola.SendPaste3(hwnd)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
ola.SetClipboard("要粘贴的文本");
int32_t ret = ola.SendPaste3(hwnd);

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
SetClipboard(instance, "要粘贴的文本");
SendPaste3(instance, hwnd);
csharp
using System.Runtime.InteropServices;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int SetClipboard(long ola, string value);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int SendPaste3(long ola, long hwnd);

long instance = CreateCOLAPlugInterFace();
SetClipboard(instance, "要粘贴的文本");
SendPaste3(instance, hwnd);
python
from ctypes import CDLL, c_int64

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.SetClipboard(instance, "要粘贴的文本".encode("utf-8"))
ola.SendPaste3(instance, hwnd)

返回值

返回值说明
1成功投递按键消息。
0失败(句柄无效等)。

注意事项

项目说明
前置条件通常需先 SetClipboard
选型建议Edit → SendPaste2;不认 WM_PASTE → SendPaste3;最通用 → SendPaste
与真实按键走绑定窗口的 KeyDown/KeyUp(同 KeyPressHotkey),不是裸 PostMessage。
句柄说明hwnd 用于校验;实际按键发往当前绑定键盘目标(与 KeyDown 一致)。