Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardX366 committed Jun 13, 2021
1 parent bd6ac45 commit eb6020e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
28 changes: 17 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,52 +337,58 @@ module.exports = async function(path, hotkeysList, options) {
},
/**
* Types out a string. Look at documentation for extra information.
* @param {{ msg: string, blind?: boolean}} x - The string to send
* @param {{ msg: string, blind?: boolean} | string} x - The string to send
*/
async send(x) {
var toSend = "{Text}";
if (typeof x === "string") x = { msg: x };
var toSend = "";
if (x.blind) toSend += "{Blind}";
toSend += x.msg
.replace(/!/g, "{!}")
.replace(/#/g, "{#}")
.replace(/\+/g, "{+}")
.replace(/\^/g, "{^}")
.replace(/\\{/g, "{{}")
.replace(/\\}/g, "{}}");
.replace(/\\}/g, "{}}")
.replace(/\n/g, "{enter}");
runner.stdin.write(`send;${toSend}\n`);
await wait();
},
/**
* Types out a string using SendInput. Look at documentation for extra information.
* @param {string} x - The string to send
* @param {{ msg: string, blind?: boolean} | string} x - The string to send
*/
async sendInput(x) {
var toSend = "{Text}";
if (typeof x === "string") x = { msg: x };
var toSend = "";
if (x.blind) toSend += "{Blind}";
toSend += x.msg
.replace(/!/g, "{!}")
.replace(/#/g, "{#}")
.replace(/\+/g, "{+}")
.replace(/\^/g, "{^}")
.replace(/\\{/g, "{{}")
.replace(/\\}/g, "{}}");
.replace(/\\}/g, "{}}")
.replace(/\n/g, "{enter}");
runner.stdin.write(`sendInput;${toSend}\n`);
await wait();
},
/**
* Types out a string using SendPlay. Look at documentation for extra information.
* @param {string} x - The string to send
* @param {{ msg: string, blind?: boolean} | string} x - The string to send
*/
async sendPlay(x) {
var toSend = "{Text}";
if (typeof x === "string") x = { msg: x };
var toSend = "";
if (x.blind) toSend += "{Blind}";
toSend += x.msg
.replace(/!/g, "{!}")
.replace(/#/g, "{#}")
.replace(/\+/g, "{+}")
.replace(/\^/g, "{^}")
.replace(/\\{/g, "{{}")
.replace(/\\}/g, "{}}");
.replace(/\\}/g, "{}}")
.replace(/\n/g, "{enter}");
runner.stdin.write(`sendPlay;${toSend}\n`);
await wait();
},
Expand Down Expand Up @@ -420,7 +426,7 @@ write(x) {
if (x.keys) {
ahk.hotkeys[x.keys.join(" ")] = function() {};
hotkeysString += `${x.keys.join(" & ")}::write("${x.keys.join(" ")}")
`;
`;
} else {
let mod = "";
if (x.modifiers) {
Expand All @@ -436,7 +442,7 @@ write(x) {
.replace(/\\}/g, "{}}");
ahk.hotkeys[mod + key] = function() {};
hotkeysString += `${mod + key}::write("${mod + key}")
`;
`;
}
}
});
Expand Down
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,36 +318,36 @@ var position = await ahk.getMousePos(positioning?);
**Returns** - If normal positioning is used, it returns [x, y] where x and y are the coordinates of the mouse. If percent positioning is used, it returns [x, y] where x and y are percentages of the screen.
***
### send
Sends the provided *string*.
Sends the provided *string* possibly wrapped in an *object*.
```js
await ahk.send({
msg: string,
blind?: boolean
});
} | msg);
```
**msg** - The message to send
**blind** - Whether or not [blind mode](https://www.autohotkey.com/docs/commands/Send.htm#Blind) will be used
***
### sendInput
Sends the provided *string* using [sendInput](https://www.autohotkey.com/docs/commands/Send.htm#SendInputDetail).
Sends the provided *string* using [sendInput](https://www.autohotkey.com/docs/commands/Send.htm#SendInputDetail) possibly wrapped in an *object*.
```js
await ahk.sendInput({
msg: string,
blind?: boolean
});
} | msg);
```
**msg** - The message to send
**blind** - Whether or not [blind mode](https://www.autohotkey.com/docs/commands/Send.htm#Blind) will be used
***
### sendPlay
Sends the provided *string* using [sendPlay](https://www.autohotkey.com/docs/commands/Send.htm#SendPlayDetail).
Sends the provided *string* using [sendPlay](https://www.autohotkey.com/docs/commands/Send.htm#SendPlayDetail) possibly wrapped in an *object*.
```js
await ahk.sendPlay({
msg: string,
blind?: boolean
});
} | msg);
```
**msg** - The message to send
Expand Down
2 changes: 1 addition & 1 deletion runner.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Loop {
ImageSearch, x, y, data[2], data[3], data[4], data[5], % data[6]
write(x " " y)
} else if (data[1] = "setKeyDelay") {
setKeyDelay, data[2], data[3], % data[4]
SetKeyDelay, data[2], data[3], % data[4]
write("done")
} else if (data[1] = "send") {
Send % data[2]
Expand Down

0 comments on commit eb6020e

Please sign in to comment.