move and scroll mouse actions
This commit is contained in:
@@ -20,6 +20,10 @@ class MacroActions extends ClassArray<MacroAction> {
|
||||
return new HoldMouseButtonsAction().fromJsObject(jsObject);
|
||||
case macroActionType.ReleaseMouseButtonsAction:
|
||||
return new ReleaseMouseButtonsAction().fromJsObject(jsObject);
|
||||
case macroActionType.MoveMouseAction:
|
||||
return new MoveMouseAction().fromJsObject(jsObject);
|
||||
case macroActionType.ScrollMouseAction:
|
||||
return new ScrollMouseAction().fromJsObject(jsObject);
|
||||
default:
|
||||
throw `Invalid MacroAction.macroActionType: "${jsObject.macroActionType}"`;
|
||||
}
|
||||
@@ -53,6 +57,10 @@ class MacroActions extends ClassArray<MacroAction> {
|
||||
return new HoldMouseButtonsAction().fromBinary(buffer);
|
||||
case MacroActionId.ReleaseMouseButtonsAction:
|
||||
return new ReleaseMouseButtonsAction().fromBinary(buffer);
|
||||
case MacroActionId.MoveMouseAction:
|
||||
return new MoveMouseAction().fromBinary(buffer);
|
||||
case MacroActionId.ScrollMouseAction:
|
||||
return new ScrollMouseAction().fromBinary(buffer);
|
||||
default:
|
||||
throw `Invalid MacroAction first byte: ${macroActionFirstByte}`;
|
||||
}
|
||||
|
||||
40
config-serializer/config-items/MoveMouseAction.ts
Normal file
40
config-serializer/config-items/MoveMouseAction.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
class MoveMouseAction extends MacroAction {
|
||||
|
||||
// @assertInt16
|
||||
x: number;
|
||||
|
||||
// @assertInt16
|
||||
y: number;
|
||||
|
||||
_fromJsObject(jsObject: any): MoveMouseAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.x = jsObject.x;
|
||||
this.y = jsObject.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): MoveMouseAction {
|
||||
this.readAndAssertMacroActionId(buffer);
|
||||
this.x = buffer.readInt16();
|
||||
this.y = buffer.readInt16();
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
macroActionType: macroActionType.MoveMouseAction,
|
||||
x: this.x,
|
||||
y: this.y
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(MacroActionId.MoveMouseAction);
|
||||
buffer.writeInt16(this.x);
|
||||
buffer.writeInt16(this.y);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<MoveMouseAction pos="(${this.x},${this.y})">`;
|
||||
}
|
||||
}
|
||||
40
config-serializer/config-items/ScrollMouseAction.ts
Normal file
40
config-serializer/config-items/ScrollMouseAction.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
class ScrollMouseAction extends MacroAction {
|
||||
|
||||
// @assertInt16
|
||||
x: number;
|
||||
|
||||
// @assertInt16
|
||||
y: number;
|
||||
|
||||
_fromJsObject(jsObject: any): ScrollMouseAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.x = jsObject.x;
|
||||
this.y = jsObject.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): ScrollMouseAction {
|
||||
this.readAndAssertMacroActionId(buffer);
|
||||
this.x = buffer.readInt16();
|
||||
this.y = buffer.readInt16();
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
macroActionType: macroActionType.ScrollMouseAction,
|
||||
x: this.x,
|
||||
y: this.y
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(MacroActionId.ScrollMouseAction);
|
||||
buffer.writeInt16(this.x);
|
||||
buffer.writeInt16(this.y);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<ScrollMouseAction pos="(${this.x},${this.y})">`;
|
||||
}
|
||||
}
|
||||
@@ -26,3 +26,5 @@
|
||||
/// <reference path="PressMouseButtonsAction.ts" />
|
||||
/// <reference path="HoldMouseButtonsAction.ts" />
|
||||
/// <reference path="ReleaseMouseButtonsAction.ts" />
|
||||
/// <reference path="MoveMouseAction.ts" />
|
||||
/// <reference path="ScrollMouseAction.ts" />
|
||||
|
||||
@@ -234,6 +234,16 @@
|
||||
{
|
||||
"macroActionType": "releaseMouseButtons",
|
||||
"mouseButtonsMask": 104
|
||||
},
|
||||
{
|
||||
"macroActionType": "moveMouse",
|
||||
"x": 123,
|
||||
"y": 123
|
||||
},
|
||||
{
|
||||
"macroActionType": "scrollMouse",
|
||||
"x": 123,
|
||||
"y": 123
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user