主题
注册鼠标拖动快捷键 - RegisterMouseDrag
函数简介
注册鼠标拖动快捷键监听,可监听鼠标拖动坐标。
接口名称
RegisterMouseDragDLL调用
int RegisterMouseDrag(long ola, MouseDragCallback callback);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| callback | 回调函数 | 回调函数 void MouseDragCallback(int x, int y),x 为鼠标X坐标,y 为鼠标Y坐标。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.StartHotkeyHook();
if (ret == 1) {
int dragRet = ola.RegisterMouseDrag([](int x, int y) {});
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.StartHotkeyHook();
if (ret == 1)
{
int dragRet = ola.RegisterMouseDrag((x, y) => { });
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.StartHotkeyHook()
if ret == 1:
def on_drag(x, y):
pass
drag_ret = ola.RegisterMouseDrag(on_drag)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
int ret = ola.StartHotkeyHook();
if (ret == 1) {
int dragRet = ola.RegisterMouseDrag(null);
}cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.StartHotkeyHook()
if(ret == 1) {
var dragRet = ola.RegisterMouseDrag(0)
}vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.StartHotkeyHook()
If ret = 1 Then
dragRet = ola.RegisterMouseDrag(0)
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.StartHotkeyHook ()
.如果真 (ret = 1)
dragRet = ola.RegisterMouseDrag (0)
.如果真结束aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.StartHotkeyHook();
if(ret == 1){
var dragRet = ola.RegisterMouseDrag(function(x,y){});
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.StartHotkeyHook()
如果真 (ret = 1)
{
整数 dragRet = ola.RegisterMouseDrag(0)
}cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t ret = ola.StartHotkeyHook();
if (ret == 1) {
int32_t dragRet = ola.RegisterMouseDrag(nullptr);
}原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
StartHotkeyHook(instance);
RegisterMouseDrag(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 RegisterMouseDrag(long ola, long callback);
long instance = CreateCOLAPlugInterFace();
StartHotkeyHook(instance);
RegisterMouseDrag(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);
RegisterMouseDrag(instance, 0);返回值
整数型。1 成功,0 失败。
注意事项
- 注册前需先调用 StartHotkeyHook 安装键盘鼠标钩子。
- 参考 Windows 函数 SetWindowsHookExW 实现。
