Skip to content

注册鼠标滚轮快捷键 - RegisterMouseWheel

函数简介

注册鼠标滚轮快捷键监听,可监听滚动方向及滚动量。

接口名称

RegisterMouseWheel

DLL调用

int RegisterMouseWheel(long ola, MouseWheelCallback callback);

参数说明

参数名类型说明
ola长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
callback回调函数回调函数 void MouseWheelCallback(int x, int y, int amount, int rotation),x/y 为鼠标坐标,amount 为滚动量,rotation 为滚动方向。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.StartHotkeyHook();
if (ret == 1) {
    int wheelRet = ola.RegisterMouseWheel([](int x, int y, int amount, int rotation) {});
}
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.StartHotkeyHook();
if (ret == 1)
{
    int wheelRet = ola.RegisterMouseWheel((x, y, amount, rotation) => { });
}
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.StartHotkeyHook()
if ret == 1:
    def on_wheel(x, y, amount, rotation):
        pass
    wheel_ret = ola.RegisterMouseWheel(on_wheel)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.StartHotkeyHook();
if (ret == 1) {
    int wheelRet = ola.RegisterMouseWheel(null);
}
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.StartHotkeyHook()
if(ret == 1) {
    var wheelRet = ola.RegisterMouseWheel(0)
}
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.StartHotkeyHook()
If ret = 1 Then
    wheelRet = ola.RegisterMouseWheel(0)
End If
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.StartHotkeyHook ()
.如果真 (ret = 1)
    wheelRet = ola.RegisterMouseWheel (0)
.如果真结束
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.StartHotkeyHook();
if(ret == 1){
    var wheelRet = ola.RegisterMouseWheel(function(x,y,amount,rotation){});
}
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.StartHotkeyHook()
如果真 (ret = 1)
{
    整数 wheelRet = ola.RegisterMouseWheel(0)
}
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.StartHotkeyHook();
if (ret == 1) {
    int32_t wheelRet = ola.RegisterMouseWheel(nullptr);
}

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
StartHotkeyHook(instance);
RegisterMouseWheel(instance, 0);
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 StartHotkeyHook(long ola);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int RegisterMouseWheel(long ola, long callback);

long instance = CreateCOLAPlugInterFace();
StartHotkeyHook(instance);
RegisterMouseWheel(instance, 0);
python
from ctypes import CDLL, c_int, c_int64

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
StartHotkeyHook(instance);
RegisterMouseWheel(instance, 0);

返回值

整数型。1 成功,0 失败。

注意事项

  • 注册前需先调用 StartHotkeyHook 安装键盘鼠标钩子。
  • 参考 Windows 函数 SetWindowsHookExW 实现。