diff --git a/source/lsnput/.keep b/source/lsnput/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/source/lsnput/BIN/.keep b/source/lsnput/BIN/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/source/lsnput/BIN/ElsLib_lsnput_Windows_amd64.lsd b/source/lsnput/BIN/ElsLib_lsnput_Windows_amd64.lsd new file mode 100644 index 0000000000000000000000000000000000000000..4805c529d1d04083d45ca520497ea5c4a91dc099 Binary files /dev/null and b/source/lsnput/BIN/ElsLib_lsnput_Windows_amd64.lsd differ diff --git a/source/lsnput/ELS_lsnput.c b/source/lsnput/ELS_lsnput.c new file mode 100644 index 0000000000000000000000000000000000000000..e82f63215db4c1c645fa76a073d7d661d6b6d403 --- /dev/null +++ b/source/lsnput/ELS_lsnput.c @@ -0,0 +1,63 @@ +#include "ELS_lsnput.h" +#include "lsnput.h" + +#include + +int ELSAPI_lsnput_GetMousePosition(els_VmObj* vm) +{ + LosuObj output = obj_newunit(vm); + MousePosition p; + + //获取鼠标位置 + GetMousePosition(&p); + obj_setunit(vm, output, obj_newstr(vm, "x"), obj_newnum(vm, p.x)); + obj_setunit(vm, output, obj_newstr(vm, "y"), obj_newnum(vm, p.y)); + + arg_return(vm, output); + return 1; +} + +int ELSAPI_lsnput_SetMousePosition(els_VmObj* vm) +{ + MousePosition p; + + //获取要设置的坐标 + p.x = arg_getnum(vm, 2); + p.y = arg_getnum(vm, 3); + + //设置鼠标位置 + if (SetMousePosition(&p)) + arg_returnnum(vm, 1); + else + arg_returnnull(vm); + + return 1; +} + +int ELSAPI_lsnput_MouseAct(els_VmObj* vm) +{ + MouseEvent e; + + e.type = (uint32_t)arg_getnum(vm, 2) | (uint32_t)arg_getnum(vm, 3); //获取鼠标事件的类型 + e.slide = arg_getnum(vm, 4); //获取滑轮滚动的距离 + + if (MouseAct(&e)) + arg_returnnum(vm, 1); + else + arg_returnnull(vm); + + return 1; +} + +int ELSAPI_lsnput_click(els_VmObj *vm) +{ + MousePosition p; + uint8_t type = arg_getnum(vm, 2); + + GetMousePosition(&p); + if (MouseClick(&p, type)) + arg_returnnum(vm, 1); + else + arg_returnnull(vm); + return 1; +} diff --git a/source/lsnput/ELS_lsnput.h b/source/lsnput/ELS_lsnput.h new file mode 100644 index 0000000000000000000000000000000000000000..57ae55ebf246f554d2977963ec37008b48ebcd15 --- /dev/null +++ b/source/lsnput/ELS_lsnput.h @@ -0,0 +1,27 @@ +#ifndef ELS_LSINPUT_H_ +#define ELS_LSINPUT_H_ + +#include "els.h" +#include "lsnput_script.h" + +int ELSAPI_lsnput_GetMousePosition(els_VmObj* vm); +int ELSAPI_lsnput_SetMousePosition(els_VmObj* vm); +int ELSAPI_lsnput_MouseAct(els_VmObj* vm); +int ELSAPI_lsnput_click(els_VmObj *vm); + +void ElsLib_lsnput_libinit(els_VmObj *vm) +{ + LosuObj lib = obj_newunit(vm); + + vm_setval(vm, "lsnput", &lib); + + obj_setunit(vm, lib, obj_newstr(vm, "get_mouse_position"), obj_newfunction(vm, ELSAPI_lsnput_GetMousePosition)); + obj_setunit(vm, lib, obj_newstr(vm, "set_mouse_position"), obj_newfunction(vm, ELSAPI_lsnput_SetMousePosition)); + obj_setunit(vm, lib, obj_newstr(vm, "mouse_act"), obj_newfunction(vm, ELSAPI_lsnput_MouseAct)); + obj_setunit(vm, lib, obj_newstr(vm, "click"), obj_newfunction(vm, ELSAPI_lsnput_click)); + //obj_setunit(vm, lib, obj_newstr(vm, ""), obj_newfunction(vm, ELSAPI_lsnput_)); + + vm_dostring(vm, lsnput_script); +} + +#endif diff --git a/source/lsnput/Ubuntu/.keep b/source/lsnput/Ubuntu/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/source/lsnput/Ubuntu/makefile b/source/lsnput/Ubuntu/makefile new file mode 100644 index 0000000000000000000000000000000000000000..865925f41db1e688224976f03c84fea4edb17f74 --- /dev/null +++ b/source/lsnput/Ubuntu/makefile @@ -0,0 +1,14 @@ +OBJ = ElsLib_lsnput.lsd +BASE = Els_lsnput.o lsnput.o +CFLAGS= -O3 -std=c99 -Wall -DLOSU_LINUX -I ../buildenv -fPIC +CC=gcc +T=./ElsLib_lsnput.lsd + + +all: $T + +$T: $(OBJS) + $(CC) -o $@ $(OBJS) $(BASE) -shared -lm -s -lc -O3 + +clean: + rm -rf $T $(OBJS) $(BASE) core core.* \ No newline at end of file diff --git a/source/lsnput/WIKI/.keep b/source/lsnput/WIKI/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/source/lsnput/WIKI/c.md b/source/lsnput/WIKI/c.md new file mode 100644 index 0000000000000000000000000000000000000000..77d031359da3e8b2c6c5d14efb1aab074b9dd9d8 --- /dev/null +++ b/source/lsnput/WIKI/c.md @@ -0,0 +1,114 @@ +# lsnput C层文档 + +lsnput的C层被设计为是平台无关的,但是目前只有Windows实现。 +欲使用lsnput的C层代码,可包含lsnput.h,之后编译lsnput.c。 + +## 获取和设置鼠标位置 + +想要获取鼠标位置,需要先创建一个MousePosition对象,之后将MousePosition*传递给GetMousePosition。 +想要设置鼠标位置,需要填写好MousePosition对象,之后将它的指针传递给SetMousePosion。 + +这两个函数的使用例程如下 + +```c +#include "lsnput.h" + +#include + +int main() +{ + MousePosition p; + + GetMousePosition(&p); //获取坐标 + printf("the position of mouse is x:%u, y:%u.\n", p.x, p.y); //打印坐标。中文字面量有乱码等问题,此处采用英文。 + + //将坐标都向正方形移动5个像素 + p.x += 5; + p.y += 5; + + SetMousePosition(&p); //设置新坐标。此时鼠标应向右下角移动。 + + return 0; +} + +``` + +## 设置鼠标事件 + +设置鼠标事件,需要用到MouseAct函数和MouseEvent类型。其原型如下: + +```c +typedef struct { + uint8_t type; //鼠标事件的类型 + uint8_t slide; //鼠标中键滑动的距离。当type为LSNPUT_MOUSE_MID | LSNPUT_MOUSE_DOWN此值才有效。 +} MouseEvent; + + +bool MouseAct(MouseEvent *event); //设置鼠标事件 +``` + +MouseEvent的type成员可以有以下可能值: + ++ LSNPUT_MOUSE_LEFT 鼠标的左键 ++ LSNPUT_MOUSE_RIGHT 鼠标的右键 ++ LSNPUT_MOUSE_MID 鼠标的中键 ++ LSNPUT_MOUSE_UP 鼠标向上 ++ LSNPUT_MOUSE_DOWN 鼠标向下 + +这些值直接可以通过|运算符拼接 + +下面是一个例程 + +```c +#include "lsnput.h" + +int main() +{ + MouseEvent e; + + e.type = LSNPUT_MOUSE_LEFT | LSNPUT_MOUSE_DOWN; //类型为左键向下,即摁下左键 + MouseEvent(&e); + + e.type = LSNPUT_MOUSE_LEFT | LSNPUT_MOUSE_UP; //摁下左键后,要恢复左键 + MouseEvent(&e); + + return 0; +} + +``` + +## 高层API + +lsnput封装了MouseClick函数,将鼠标移到指定位置并摁下相应的键。该函数不能处理中键的滚动。 +MouseClick函数中会调用SetMousePosition、MouseAct,将鼠标移到对应位置,将对应键摁下并抬起。 + +原型如下 + +```c + +bool MouseClick(MousePosition *p, uint64_t type); //将鼠标移到指定位置,并点击相应的键 + +``` + +下面是一个例程 + +```c +#include "lsnput.h" + +int main() +{ + MousePosition p; + + GetMousePosition(&p); //获取当前位置 + + //移动鼠标位置 + p.x += 25; + p.y += 25; + + //按下鼠标左键 + MouseClick(&p, LSNPUT_MOUSE_LEFT); + + return 0; +} + +``` diff --git a/source/lsnput/WIKI/script.md b/source/lsnput/WIKI/script.md new file mode 100644 index 0000000000000000000000000000000000000000..9d7cbba7c16c6502dbb5cd8cdd2d3735896f8129 --- /dev/null +++ b/source/lsnput/WIKI/script.md @@ -0,0 +1,84 @@ +# lsnput脚本层文档 + +本模块提供了监听、操作键盘和鼠标的功能。目前仅实现Windows平台下鼠标的监听和操作。计划在2.0.0.1版本发布Windows平台下键盘的监听和操作功能。 + +## 获取鼠标位置 + +要获取鼠标位置,可以使用lsnput.get_mouse_position或“键鼠事件.获取鼠标坐标”来实现. + +该函数的返回值是一个单元,x轴值储存在x成员中,y轴值储存在y成员中. + +下面是例程 + +```c +引("lsnput") + +令 鼠标位置 = 键鼠事件.获取鼠标坐标() + +打印(鼠标位置.x) +打印(鼠标位置.y) + +``` + +## 更改鼠标位置 + +要更改鼠标位置,可以使用lsnput.set_mouse_position或“键鼠事件.设置鼠标坐标”. + +下面是例程 + +```c +引('lsnput') + +键鼠事件.设置鼠标坐标(0, 0) #鼠标会被设置到0, 0处 +``` + +## 设置鼠标事件 + +要设置鼠标事件,可以使用lsnput.mouse_act或“键鼠事件.鼠标操作” +这两个函数都对应同一个C接口函数。函数接受两个参数, + +下面是例程 + +```c +引("lsnput") + +#鼠标要摁下后抬起才算完成一次点击 +键鼠事件.鼠标操作(键鼠事件.鼠标.左, 键鼠事件.鼠标.摁下) +键鼠事件.鼠标操作(键鼠事件.鼠标.左, 键鼠事件.鼠标.抬起) + +``` + +## 控制鼠标点击 + +一次完整的鼠标点击包括鼠标摁下和抬起。lsnput封装了这两个操作。 +该函数名为lsnput.click或“键鼠事件.点击”. + +下面是例程 + +```c +引("lsnput") + +鼠标事件.点击(键鼠事件.鼠标.左) #会点击一下左键 + +``` + +## 关于鼠标事件类型 + +鼠标事件类型用于lsnput.mouse_act和lsnput.click中,有如下值 + +```c + +lsnput.mouse.LEFT = 1 +lsnput.mouse.RIGHT = 2 +lsnput.mouse.MID = 4 +lsnput.mouse.UP = 8 +lsnput.mouse.DOWN = 16 + +键鼠事件.鼠标.左 = 1 +键鼠事件.鼠标.右 = 2 +键鼠事件.鼠标.中 = 4 +键鼠事件.鼠标.抬起 = 8 +键鼠事件.鼠标.摁下 = 16 + +``` + diff --git "a/source/lsnput/WIKI/\345\216\206\345\217\262/.keep" "b/source/lsnput/WIKI/\345\216\206\345\217\262/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/source/lsnput/WIKI/\345\216\206\345\217\262/1.7.0.0.md" "b/source/lsnput/WIKI/\345\216\206\345\217\262/1.7.0.0.md" new file mode 100644 index 0000000000000000000000000000000000000000..4e7886e7a4508a6f5a98b09b4f8a21ca371a1078 --- /dev/null +++ "b/source/lsnput/WIKI/\345\216\206\345\217\262/1.7.0.0.md" @@ -0,0 +1,6 @@ +# 1.7.0.0 版本文档 + +这是lsnput的第一个发行版,只完成了Windows平台下的鼠标位置获取与设置、鼠标事件的设置。鼠标事件的监听和键盘系列的实现还在酝酿。 + +本模块在设计时的受众主要是Windows平台下的普通用户,并非开发者。但是C层代码为开发者精心设置了接口。这样lsnput的脚本层和C层都可以是一个跨平台的鼠标键盘处理模块,成为编程人员的好帮手。 + diff --git a/source/lsnput/Windows/.keep b/source/lsnput/Windows/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/source/lsnput/Windows/makefile b/source/lsnput/Windows/makefile new file mode 100644 index 0000000000000000000000000000000000000000..99cdbd29a70bf8463983c3faa0bccd5447ec5313 --- /dev/null +++ b/source/lsnput/Windows/makefile @@ -0,0 +1,9 @@ +OBJ = ElsLib_lsnput.lsd +BASE = Els_lsnput.o lsnput.o +CFLAGE = -O3 -std=c99 -Wall -DLOSU_WINDOWS -I ../buildenv -fPIC -L ../buildenv -l:libeasylosu.dll -lUrlmon -lUser32 -lkernel32 -lWininet -lm -static -shared -s +CC = gcc + +OBJ: + $(CC) Els_lsnput.c lsnput.c -c $(CFLAGE) + $(CC) -o $(OBJ) $(BASE) $(CFLAGE) + \ No newline at end of file diff --git a/source/lsnput/lsnput.c b/source/lsnput/lsnput.c new file mode 100644 index 0000000000000000000000000000000000000000..7e1508202e8c965d93f4ac7e8d5979166481fc77 --- /dev/null +++ b/source/lsnput/lsnput.c @@ -0,0 +1,171 @@ +#include "lsnput.h" + +/* + Windows系统实现 +*/ +#ifdef LOSU_WINDOWS + +#include + +inline bool GetMousePosition(MousePosition *position) +{ + /* + BOOL GetCursorPos( + [out] LPPOINT lpPoint + ); + + 检索鼠标光标的位置(以屏幕坐标为单位)。 + + 参数 + [out] lpPoint + 类型: LPPOINT + 指向接收光标屏幕坐标的 POINT 结构的指针。 + + 返回值 + 类型: BOOL + 如果成功,则返回非零值,否则返回零。 要获得更多的错误信息,请调用 GetLastError。 + + 注解 + 光标位置始终在屏幕坐标中指定,不受包含光标的窗口的映射模式的影响。 + 调用进程必须具有对窗口工作站 WINSTA_READATTRIBUTES 访问权限。 + 调用 GetCursorPos 时,输入桌面必须是当前桌面。 调用 OpenInputDesktop 以确定当前桌面是否为输入桌面。 + 如果不是,请使用 OpenInputDesktop 返回的 HDESK 调用 SetThreadDesktop 以切换到该桌面。 + */ + + bool output; + POINT pt; + + output = GetCursorPos(&pt); + position->x = pt.x; + position->y = pt.y; + + return output; +} + +inline bool SetMousePosition(MousePosition *position) +{ + /* + BOOL SetCursorPos( + [in] int X, + [in] int Y + ); + + 将光标移动到指定的屏幕坐标。 如果新坐标不在由最近的 ClipCursor 函数调用设置的屏幕矩形内,则系统会自动调整坐标,使光标停留在矩形内。 + + 参数 + [in] X + 类型: int + 光标的新 x 坐标(以屏幕坐标为单位)。 + + [in] Y + 类型: int + 光标的新 y 坐标(以屏幕坐标为单位)。 + + 返回值 + 类型: BOOL + 如果成功,则返回非零值,否则返回零。 要获得更多的错误信息,请调用 GetLastError。 + + 注解 + 游标是共享资源。 仅当光标位于窗口工作区时,窗口才应移动光标。 + 调用进程必须具有对窗口工作站 WINSTA_WRITEATTRIBUTES 访问权限。 + 调用 SetCursorPos 时,输入桌面必须是当前桌面。 调用 OpenInputDesktop 以确定当前桌面是否为输入桌面。 + 如果不是,请使用 OpenInputDesktop 返回的 HDESK 调用 SetThreadDesktop 以切换到该桌面。 + */ + return SetCursorPos(position->x, position->y); +} + +bool MouseAct(MouseEvent *event) +{ + /* + void mouse_event( + [in] DWORD dwFlags, + [in] DWORD dx, + [in] DWORD dy, + [in] DWORD dwData, + [in] ULONG_PTR dwExtraInfo + ); + + mouse_event 函数合成鼠标运动和按钮单击。 + + + */ + DWORD dwFlags, dwData; + + dwData = 0; + + switch (event->type) + { + case LSNPUT_MOUSE_LEFT | LSNPUT_MOUSE_DOWN: + //左键向下 + dwFlags = MOUSEEVENTF_LEFTDOWN; + break; + case LSNPUT_MOUSE_LEFT | LSNPUT_MOUSE_UP: + //左键向上 + dwFlags = MOUSEEVENTF_LEFTUP; + break; + case LSNPUT_MOUSE_RIGHT | LSNPUT_MOUSE_DOWN: + //右键向下 + dwFlags = MOUSEEVENTF_RIGHTDOWN; + break; + case LSNPUT_MOUSE_RIGHT | LSNPUT_MOUSE_UP: + //右键向上 + dwFlags = MOUSEEVENTF_RIGHTUP; + break; + case LSNPUT_MOUSE_MID | LSNPUT_MOUSE_DOWN: + //中键向下 + if (event->slide == 0) + //纯向下 + dwFlags = MOUSEEVENTF_MIDDLEDOWN; + else + { + //滚轮滑动 + dwFlags = MOUSEEVENTF_WHEEL; + dwData = event->slide; + } + break; + case LSNPUT_MOUSE_MID | LSNPUT_MOUSE_UP: + //中键向上 + dwFlags = MOUSEEVENTF_MIDDLEUP; + break; + default: + return false; + } + + mouse_event(dwFlags, 0, 0, dwData, 0); + + return true; +} + +#endif + +/* + Linux系统实现 +*/ + +#ifdef LOSU_LINUX + +#endif + + +/* + 通用操作系统实现 +*/ + +bool MouseClick(MousePosition *p, uint64_t type) +{ + MouseEvent e; + + e.slide = 0; + SetMousePosition(p); + + if (type & 0b00000111) + { + e.type = type | LSNPUT_MOUSE_DOWN; + MouseAct(&e); + e.type = type | LSNPUT_MOUSE_UP; + MouseAct(&e); + return true; + } + return false; +} + diff --git a/source/lsnput/lsnput.els b/source/lsnput/lsnput.els new file mode 100644 index 0000000000000000000000000000000000000000..f827efbd4384e6cf97427e1528cb0c41129d999f --- /dev/null +++ b/source/lsnput/lsnput.els @@ -0,0 +1,24 @@ +import('stdlib') + +lsnput.mouse = {} + +lsnput.mouse.LEFT = 1 +lsnput.mouse.RIGHT = 2 +lsnput.mouse.MID = 4 +lsnput.mouse.UP = 8 +lsnput.mouse.DOWN = 16 + +键鼠事件 = {} + +键鼠事件.鼠标 = {} + +键鼠事件.获取鼠标坐标 = lsnput.get_mouse_position +键鼠事件.设置鼠标坐标 = lsnput.set_mouse_position +键鼠事件.鼠标操作 = lsnput.mouse_act +键鼠事件.点击 = lsnput.click + +键鼠事件.鼠标.左 = 1 +键鼠事件.鼠标.右 = 2 +键鼠事件.鼠标.中 = 4 +键鼠事件.鼠标.抬起 = 8 +键鼠事件.鼠标.摁下 = 16 diff --git a/source/lsnput/lsnput.h b/source/lsnput/lsnput.h new file mode 100644 index 0000000000000000000000000000000000000000..916bab81fc272d6a6bc01bec1be0ecb300d4d0c1 --- /dev/null +++ b/source/lsnput/lsnput.h @@ -0,0 +1,36 @@ +#ifndef LSNPUT_H_ +#define LSNPUT_H_ + +/* + 洛书的监听、操作鼠标和键盘的模块 + 作者:Matriller + 立项时间:2023-9-29 + 历史维护者:Matriller + 版本:1.7.0.1 +*/ + +#include +#include + +#define LSNPUT_MOUSE_LEFT 0b00000001 +#define LSNPUT_MOUSE_RIGHT 0b00000010 +#define LSNPUT_MOUSE_MID 0b00000100 +#define LSNPUT_MOUSE_UP 0b00001000 +#define LSNPUT_MOUSE_DOWN 0b00010000 + +typedef struct { + uint32_t x; //鼠标的x轴坐标 + uint32_t y; //鼠标的y轴坐标 +} MousePosition; + +typedef struct { + uint8_t type; //鼠标事件的类型 + uint8_t slide; //鼠标中键滑动的距离。当type为LSNPUT_MOUSE_MID | LSNPUT_MOUSE_DOWN此值才有效。 +} MouseEvent; + +bool GetMousePosition(MousePosition *position); //获取鼠标位置 +bool SetMousePosition(MousePosition *position); //设置鼠标位置 +bool MouseAct(MouseEvent *event); //设置鼠标事件 +bool MouseClick(MousePosition *p, uint64_t type); //将鼠标移到指定位置,并点击相应的键 + +#endif \ No newline at end of file diff --git a/source/lsnput/lsnput_script.h b/source/lsnput/lsnput_script.h new file mode 100644 index 0000000000000000000000000000000000000000..3f079beca11eca800a158eeedee767f99a69feae --- /dev/null +++ b/source/lsnput/lsnput_script.h @@ -0,0 +1,30 @@ +#ifndef LSINPUT_SCRIPT_H_ +#define LSINPUT_SCRIPT_H_ + +const char lsnput_script[] = { +105, 109, 112, 111, 114, 116, 40, 39, 115, 116, 100, 108, 105, 98, 39, 41, 10, 10, 108, 115, 110, 112, 117, 116, +46, 109, 111, 117, 115, 101, 32, 61, 32, 123, 125, 10, 10, 108, 115, 110, 112, 117, 116, 46, 109, 111, 117, 115, +101, 46, 76, 69, 70, 84, 32, 61, 32, 49, 10, 108, 115, 110, 112, 117, 116, 46, 109, 111, 117, 115, 101, 46, +82, 73, 71, 72, 84, 32, 61, 32, 50, 10, 108, 115, 110, 112, 117, 116, 46, 109, 111, 117, 115, 101, 46, 77, +73, 68, 32, 61, 32, 52, 10, 108, 115, 110, 112, 117, 116, 46, 109, 111, 117, 115, 101, 46, 85, 80, 32, 61, +32, 56, 10, 108, 115, 110, 112, 117, 116, 46, 109, 111, 117, 115, 101, 46, 68, 79, 87, 78, 32, 61, 32, 49, +54, 10, 10, 233, 148, 174, 233, 188, 160, 228, 186, 139, 228, 187, 182, 32, 61, 32, 123, 125, 10, 10, 233, 148, +174, 233, 188, 160, 228, 186, 139, 228, 187, 182, 46, 233, 188, 160, 230, 160, 135, 32, 61, 32, 123, 125, 10, 10, +233, 148, 174, 233, 188, 160, 228, 186, 139, 228, 187, 182, 46, 232, 142, 183, 229, 143, 150, 233, 188, 160, 230, 160, +135, 229, 157, 144, 230, 160, 135, 32, 61, 32, 108, 115, 110, 112, 117, 116, 46, 103, 101, 116, 95, 109, 111, 117, +115, 101, 95, 112, 111, 115, 105, 116, 105, 111, 110, 10, 233, 148, 174, 233, 188, 160, 228, 186, 139, 228, 187, 182, +46, 232, 174, 190, 231, 189, 174, 233, 188, 160, 230, 160, 135, 229, 157, 144, 230, 160, 135, 32, 61, 32, 108, 115, +110, 112, 117, 116, 46, 115, 101, 116, 95, 109, 111, 117, 115, 101, 95, 112, 111, 115, 105, 116, 105, 111, 110, 10, +233, 148, 174, 233, 188, 160, 228, 186, 139, 228, 187, 182, 46, 233, 188, 160, 230, 160, 135, 230, 147, 141, 228, 189, +156, 32, 61, 32, 108, 115, 110, 112, 117, 116, 46, 109, 111, 117, 115, 101, 95, 97, 99, 116, 10, 233, 148, 174, +233, 188, 160, 228, 186, 139, 228, 187, 182, 46, 231, 130, 185, 229, 135, 187, 32, 61, 32, 108, 115, 110, 112, 117, +116, 46, 99, 108, 105, 99, 107, 10, 10, 233, 148, 174, 233, 188, 160, 228, 186, 139, 228, 187, 182, 46, 233, 188, +160, 230, 160, 135, 46, 229, 183, 166, 32, 61, 32, 49, 10, 233, 148, 174, 233, 188, 160, 228, 186, 139, 228, 187, +182, 46, 233, 188, 160, 230, 160, 135, 46, 229, 143, 179, 32, 61, 32, 50, 10, 233, 148, 174, 233, 188, 160, 228, +186, 139, 228, 187, 182, 46, 233, 188, 160, 230, 160, 135, 46, 228, 184, 173, 32, 61, 32, 52, 10, 233, 148, 174, +233, 188, 160, 228, 186, 139, 228, 187, 182, 46, 233, 188, 160, 230, 160, 135, 46, 230, 138, 172, 232, 181, 183, 32, +61, 32, 56, 10, 233, 148, 174, 233, 188, 160, 228, 186, 139, 228, 187, 182, 46, 233, 188, 160, 230, 160, 135, 46, +230, 145, 129, 228, 184, 139, 32, 61, 32, 49, 54, 10 +}; + +#endif \ No newline at end of file diff --git a/source/lsnput/readme.md b/source/lsnput/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..9d7cbba7c16c6502dbb5cd8cdd2d3735896f8129 --- /dev/null +++ b/source/lsnput/readme.md @@ -0,0 +1,84 @@ +# lsnput脚本层文档 + +本模块提供了监听、操作键盘和鼠标的功能。目前仅实现Windows平台下鼠标的监听和操作。计划在2.0.0.1版本发布Windows平台下键盘的监听和操作功能。 + +## 获取鼠标位置 + +要获取鼠标位置,可以使用lsnput.get_mouse_position或“键鼠事件.获取鼠标坐标”来实现. + +该函数的返回值是一个单元,x轴值储存在x成员中,y轴值储存在y成员中. + +下面是例程 + +```c +引("lsnput") + +令 鼠标位置 = 键鼠事件.获取鼠标坐标() + +打印(鼠标位置.x) +打印(鼠标位置.y) + +``` + +## 更改鼠标位置 + +要更改鼠标位置,可以使用lsnput.set_mouse_position或“键鼠事件.设置鼠标坐标”. + +下面是例程 + +```c +引('lsnput') + +键鼠事件.设置鼠标坐标(0, 0) #鼠标会被设置到0, 0处 +``` + +## 设置鼠标事件 + +要设置鼠标事件,可以使用lsnput.mouse_act或“键鼠事件.鼠标操作” +这两个函数都对应同一个C接口函数。函数接受两个参数, + +下面是例程 + +```c +引("lsnput") + +#鼠标要摁下后抬起才算完成一次点击 +键鼠事件.鼠标操作(键鼠事件.鼠标.左, 键鼠事件.鼠标.摁下) +键鼠事件.鼠标操作(键鼠事件.鼠标.左, 键鼠事件.鼠标.抬起) + +``` + +## 控制鼠标点击 + +一次完整的鼠标点击包括鼠标摁下和抬起。lsnput封装了这两个操作。 +该函数名为lsnput.click或“键鼠事件.点击”. + +下面是例程 + +```c +引("lsnput") + +鼠标事件.点击(键鼠事件.鼠标.左) #会点击一下左键 + +``` + +## 关于鼠标事件类型 + +鼠标事件类型用于lsnput.mouse_act和lsnput.click中,有如下值 + +```c + +lsnput.mouse.LEFT = 1 +lsnput.mouse.RIGHT = 2 +lsnput.mouse.MID = 4 +lsnput.mouse.UP = 8 +lsnput.mouse.DOWN = 16 + +键鼠事件.鼠标.左 = 1 +键鼠事件.鼠标.右 = 2 +键鼠事件.鼠标.中 = 4 +键鼠事件.鼠标.抬起 = 8 +键鼠事件.鼠标.摁下 = 16 + +``` + diff --git a/source/remote.lspro b/source/remote.lspro index 18d49408364564bde840b98e9549923fd1673aa9..8bc93e2c02b3e97dcfd5afc728258bb12e6e32e8 100755 --- a/source/remote.lspro +++ b/source/remote.lspro @@ -473,3 +473,29 @@ lpt.remote.rtt_w601_iot = { } } +# lsnput + +lpt.remote.lsnput = { + info = { + name = "lsnput", + text = "为洛书而编写的键盘鼠标控制库", + release = "1.7.0.0" + }, + source = { + all = { + "lsnput.h", + "lsnput.c", + "lsnput.els", + "readme.md", + "ELS_lsnput.h", + "ELS_lsnput.c", + "lsnput_script.h" + }, + Ubuntu = { + "makefile", + }, + Windows = { + "makefile", + } + } +}