delay and text macros
This commit is contained in:
33
config-serializer/config-items/DelayMacroAction.ts
Normal file
33
config-serializer/config-items/DelayMacroAction.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
class DelayMacroAction extends MacroAction {
|
||||||
|
|
||||||
|
// @assertUInt16
|
||||||
|
delay: number;
|
||||||
|
|
||||||
|
_fromJsObject(jsObject: any): DelayMacroAction {
|
||||||
|
this.assertMacroActionType(jsObject);
|
||||||
|
this.delay = jsObject.delay;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fromBinary(buffer: UhkBuffer): DelayMacroAction {
|
||||||
|
this.readAndAssertMacroActionId(buffer);
|
||||||
|
this.delay = buffer.readUInt16();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_toJsObject(): any {
|
||||||
|
return {
|
||||||
|
macroActionType: macroActionType.DelayMacroAction,
|
||||||
|
delay: this.delay
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
_toBinary(buffer: UhkBuffer) {
|
||||||
|
buffer.writeUInt8(MacroActionId.DelayMacroAction);
|
||||||
|
buffer.writeUInt16(this.delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
toString(): string {
|
||||||
|
return `<DelayMacroAction delay="${this.delay}">`;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,10 @@ class MacroActions extends ClassArray<MacroAction> {
|
|||||||
return new MoveMouseMacroAction().fromJsObject(jsObject);
|
return new MoveMouseMacroAction().fromJsObject(jsObject);
|
||||||
case macroActionType.ScrollMouseMacroAction:
|
case macroActionType.ScrollMouseMacroAction:
|
||||||
return new ScrollMouseMacroAction().fromJsObject(jsObject);
|
return new ScrollMouseMacroAction().fromJsObject(jsObject);
|
||||||
|
case macroActionType.DelayMacroAction:
|
||||||
|
return new DelayMacroAction().fromJsObject(jsObject);
|
||||||
|
case macroActionType.TextMacroAction:
|
||||||
|
return new TextMacroAction().fromJsObject(jsObject);
|
||||||
default:
|
default:
|
||||||
throw `Invalid MacroAction.macroActionType: "${jsObject.macroActionType}"`;
|
throw `Invalid MacroAction.macroActionType: "${jsObject.macroActionType}"`;
|
||||||
}
|
}
|
||||||
@@ -61,6 +65,10 @@ class MacroActions extends ClassArray<MacroAction> {
|
|||||||
return new MoveMouseMacroAction().fromBinary(buffer);
|
return new MoveMouseMacroAction().fromBinary(buffer);
|
||||||
case MacroActionId.ScrollMouseMacroAction:
|
case MacroActionId.ScrollMouseMacroAction:
|
||||||
return new ScrollMouseMacroAction().fromBinary(buffer);
|
return new ScrollMouseMacroAction().fromBinary(buffer);
|
||||||
|
case MacroActionId.DelayMacroAction:
|
||||||
|
return new DelayMacroAction().fromBinary(buffer);
|
||||||
|
case MacroActionId.TextMacroAction:
|
||||||
|
return new TextMacroAction().fromBinary(buffer);
|
||||||
default:
|
default:
|
||||||
throw `Invalid MacroAction first byte: ${macroActionFirstByte}`;
|
throw `Invalid MacroAction first byte: ${macroActionFirstByte}`;
|
||||||
}
|
}
|
||||||
|
|||||||
32
config-serializer/config-items/TextMacroAction.ts
Normal file
32
config-serializer/config-items/TextMacroAction.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
class TextMacroAction extends MacroAction {
|
||||||
|
|
||||||
|
text: string;
|
||||||
|
|
||||||
|
_fromJsObject(jsObject: any): TextMacroAction {
|
||||||
|
this.assertMacroActionType(jsObject);
|
||||||
|
this.text = jsObject.text;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_fromBinary(buffer: UhkBuffer): TextMacroAction {
|
||||||
|
this.readAndAssertMacroActionId(buffer);
|
||||||
|
this.text = buffer.readString();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_toJsObject(): any {
|
||||||
|
return {
|
||||||
|
macroActionType: macroActionType.TextMacroAction,
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
_toBinary(buffer: UhkBuffer) {
|
||||||
|
buffer.writeUInt8(MacroActionId.TextMacroAction);
|
||||||
|
buffer.writeString(this.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
toString(): string {
|
||||||
|
return `<TextMacroAction text="${this.text}">`;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,3 +28,5 @@
|
|||||||
/// <reference path="ReleaseMouseButtonsMacroAction.ts" />
|
/// <reference path="ReleaseMouseButtonsMacroAction.ts" />
|
||||||
/// <reference path="MoveMouseMacroAction.ts" />
|
/// <reference path="MoveMouseMacroAction.ts" />
|
||||||
/// <reference path="ScrollMouseMacroAction.ts" />
|
/// <reference path="ScrollMouseMacroAction.ts" />
|
||||||
|
/// <reference path="DelayMacroAction.ts" />
|
||||||
|
/// <reference path="TextMacroAction.ts" />
|
||||||
|
|||||||
@@ -244,6 +244,14 @@
|
|||||||
"macroActionType": "scrollMouse",
|
"macroActionType": "scrollMouse",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 20000
|
"y": 20000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"macroActionType": "delay",
|
||||||
|
"delay": 40000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"macroActionType": "text",
|
||||||
|
"text": "this is a text"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user