Skip to content

绑定窗口 - BindWindow

函数简介

绑定指定的窗口,并指定这个窗口的屏幕颜色获取方式,鼠标仿真模式,键盘仿真模式,以及模式设定

支持绑定沙盒程序(如 Sandboxie-Plus / 经典 Sandboxie)。若目标在沙盒内运行时出现绑定失败或 IPC 受限,可在沙盒配置(例如 Templates.ini 或当前沙盒的 Sandboxie.ini 中对应条目)的 [GlobalSettings] 段追加 OpenIpcPath 配置。路径中的 * 为沙盒通配符(匹配包含该片段的路径);请按实际要放行的进程名或路径修改其中的 TSVN 片段。可以通过SetConfig中的SharedMemoryNamePrefix来修改IPC前缀

配置示例:

ini
[GlobalSettings]
OpenIpcPath=*TSVN*

接口名称

BindWindow

DLL调用

int BindWindow(long ola, long hwnd, string display, string mouse, string keyboard, int mode)

参数说明

参数名类型说明
ola长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
hwnd长整数型指定的窗口句柄。
display字符串屏幕颜色获取方式,详见下方说明。
mouse字符串鼠标仿真模式,详见下方说明。
keyboard字符串键盘仿真模式,详见下方说明。
public字符串通用绑定模式,详见下方说明。
mode整数型模式设定,详见下方说明。

display 屏幕颜色获取方式

说明
"normal"正常模式,前台截屏模式。
"gdi"GDI模式。
"gdi2"GDI2模式,兼容性较强但速度较慢。
"gdi3"GDI3模式,兼容性较强但速度较慢。
"gdi4"GDI4模式,支持小程序和浏览器截图。
"gdi5"GDI5模式,支持小程序和浏览器截图。
"dxgi"DXGI模式,支持小程序和浏览器截图,Windows10 1903及以上版本支持。
"vnc"VNC模式 (需要SetConfig接口中设置虚拟机端口)
"dx"DX模式 (需要管理员权限)
"vmware"虚拟机模式 (需要管理员权限。高级版功能,普通版无法使用)

mouse 鼠标仿真模式

说明
"normal"正常模式,前台鼠标模式。
"windows"Windows模式,模拟windows消息。
"windows3"Windows3模式,模拟windows消息,适用于多窗口的进程。
"vnc"VNC模式 (需要SetConfig接口中设置虚拟机端口)
dx模式组合(使用``连接):
说明
"dx.mouse.position.lock.api"通过API锁定鼠标位置。
"dx.mouse.position.lock.message"通过消息锁定鼠标位置。
"dx.mouse.focus.input.api"通过API锁定鼠标输入焦点。
"dx.mouse.focus.input.message"通过消息锁定鼠标输入焦点。
"dx.mouse.clip.lock.api"通过API锁定刷新区域。
"dx.mouse.input.lock.api"通过API锁定鼠标输入接口。
"dx.mouse.state.api"通过API锁定鼠标输入状态。
"dx.mouse.state.message"通过消息锁定鼠标输入状态。
"dx.mouse.api"通过API模拟DX鼠标输入。
"dx.mouse.cursor"后台获取鼠标特征码。
"dx.mouse.raw.input"特殊窗口鼠标操作支持。
"dx.mouse.input.lock.api2"前台鼠标移动控制。
"dx.mouse.input.lock.api3"前台鼠标移动控制。
"dx.mouse.raw.input.active"配合raw.input的后台支持。
"dx.mouse.vmware"虚拟机鼠标穿透模式,目前只支持vm16、vm17 (高级版功能,普通版无法使用)

keyboard 键盘仿真模式

说明
"normal"正常模式,前台键盘模式。
"windows"Windows模式,模拟windows消息。
"vnc"VNC模式 (需要SetConfig接口中设置虚拟机端口)
dx模式组合(使用``连接):
说明
"dx.keypad.input.lock.api"通过API锁定键盘输入接口。
"dx.keypad.state.api"通过API锁定键盘输入状态。
"dx.keypad.api"通过API模拟DX键盘输入。
"dx.keypad.raw.input"特殊窗口键盘操作支持。
"dx.keypad.raw.input.active"配合raw.input的后台支持。
"dx.keypad.api2"新的后台模拟形式。
"dx.keypad.vmware"虚拟机键盘穿透模式,目前只支持vm16、vm17 (高级版功能,普通版无法使用)

mode 模式设定

说明
0推荐模式,通用性最好,后台效果最佳。
1远程线程注入。
2驱动注入模式1,当0、1无法使用时使用;内置欧拉驱动会自动加载
3驱动注入模式2,当0、1无法使用时使用;内置欧拉驱动会自动加载
4驱动注入模式3,当0、1无法使用时使用;内置欧拉驱动会自动加载

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long hwnd = ola.FindWindow("", "记事本");
if (hwnd != 0) {
    int ret = ola.BindWindow(hwnd, "normal", "normal", "normal", 0);
      if (ret == 1) {
        // 绑定成功,可进行后台截图与键鼠操作
      }
}
csharp
using OLAPlug;

var ola = new OLAPlugServer();
long hwnd = ola.FindWindow("", "记事本");
if (hwnd != 0)
{
    int ret = ola.BindWindow(hwnd, "normal", "normal", "normal", 0);
      if (ret == 1)
    {
        // 绑定成功,可进行后台截图与键鼠操作
    }
}
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
hwnd = ola.FindWindow("", "记事本")
if hwnd != 0:
    ret = ola.BindWindow(hwnd, "normal", "normal", "normal", 0)
      if ret == 1:
        # 绑定成功,可进行后台截图与键鼠操作
        pass
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
long hwnd = ola.FindWindow("", "记事本");
if (hwnd != 0) {
    int ret = ola.BindWindow(hwnd, "normal", "normal", "normal", 0);
      if (ret == 1) {
        // 绑定成功,可进行后台截图与键鼠操作
      }
}
cpp
var ola = com("OlaPlug.OlaSoft")
var hwnd = ola.FindWindow("", "记事本")
if (hwnd != 0) {
    var ret = ola.BindWindow(hwnd, "normal", "normal", "normal", 0)
      if (ret == 1) {
        // 绑定成功,可进行后台截图与键鼠操作
      }
}
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
hwnd = ola.FindWindow("", "记事本")
If hwnd <> 0 Then
    ret = ola.BindWindow(hwnd, "normal", "normal", "normal", 0)
      If ret = 1 Then
        ' 绑定成功,可进行后台截图与键鼠操作
    End If
End If
text
.局部变量 ola, OLAPlug
ola.创建 ()
hwnd = ola.FindWindow(““, “记事本“)
.如果真 (hwnd ≠ 0)
    ret = ola.BindWindow(hwnd, “normal“, “normal“, “normal“, 0)
      .如果真 (ret = 1)
        ' 绑定成功,可进行后台截图与键鼠操作
    .如果真结束
.如果真结束
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var hwnd = ola.FindWindow("", "记事本");
if (hwnd != 0) {
    var ret = ola.BindWindow(hwnd, "normal", "normal", "normal", 0);
      if (ret == 1) {
        // 绑定成功,可进行后台截图与键鼠操作
      }
}
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 hwnd = ola.FindWindow("", "记事本")
if (hwnd != 0) {
    整数 ret = ola.BindWindow(hwnd, "normal", "normal", "normal", 0)
      if (ret == 1) {
        // 绑定成功,可进行后台截图与键鼠操作
      }
}
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long hwnd = ola.FindWindow("", "记事本");
if (hwnd != 0) {
    int ret = ola.BindWindow(hwnd, "normal", "normal", "normal", 0);
      if (ret == 1) {
        // 绑定成功,可进行后台截图与键鼠操作
      }
}

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long hwnd = 0;
// hwnd 可通过 FindWindow / EnumWindowByProcess 获取
BindWindow(instance, hwnd, "normal", "normal", "normal", 0);
csharp
long instance = CreateCOLAPlugInterFace();
long hwnd = 0;
// hwnd 可通过 FindWindow / EnumWindowByProcess 获取
BindWindow(instance, hwnd, "normal", "normal", "normal", 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
hwnd = 0
# hwnd 可通过 FindWindow / EnumWindowByProcess 获取
BindWindow(instance, hwnd, "normal", "normal", "normal", 0)

返回值

返回值说明
1成功。
0失败。
-2需要管理员权限。