diff --git a/README.md b/README.md index ed5df35..6fbfad6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Allen Wrench is a desktop tool to aid [Hexcorp](https://hexcorp.net) Drones in t * [ ] Ensure window appears within bounds of screen(s) when moved to cursor location * [ ] Keyboard control of the program -* [ ] Auto-send `return` on paste completion for pre-determined phrases +* [X] Auto-send `return` on paste completion for pre-determined phrases * [ ] Prevent showing window until on correct location ### Nice to Haves @@ -22,6 +22,7 @@ Allen Wrench is a desktop tool to aid [Hexcorp](https://hexcorp.net) Drones in t * [ ] [Unicode "font" options](https://lingojam.com/DiscordFonts) * [ ] Drone Speech Optimizations * [ ] Improve Launch Times +* [ ] Add Version Display in Config ### Misc notes diff --git a/package.json b/package.json index 2e9ff4c..594bb80 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "allenwrench-app", "private": true, - "version": "0.1.1", + "version": "0.2.0", "type": "module", "scripts": { "dev": "vite", diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 53af2ce..3489352 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -15,7 +15,7 @@ fn get_mouse_pos() -> String { } #[tauri::command] -fn type_str(input: String) { +fn type_str(input: String, autoSend: bool) { #[cfg(dev)] println!(">: {}", input); @@ -64,6 +64,12 @@ fn type_str(input: String) { enigo.key_up(Key::Control); } + thread::sleep(Duration::from_millis(200)); + + if (autoSend) { + enigo.key_click(Key::Return); + } + thread::sleep(Duration::from_millis(20)); // Close program diff --git a/src/App.tsx b/src/App.tsx index 84af724..3595311 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -44,6 +44,10 @@ function App() { let storedId = localStorage.getItem("droneId"); return (storedId ? storedId : "0000"); }); + const [autoSend, setAutoSend] = useState(() => { + let storedAutoSend = localStorage.getItem("autoSend"); + return (storedAutoSend ? storedAutoSend == "true" : false); + }); if (!codes){ resolveResource("resources/codes.json").then((path: string) => { @@ -102,7 +106,7 @@ function App() { if (filtered.length == 1) { let payload: string = generatePayload(filtered[0]); setSubTopic(""); - invoke('type_str', {input: payload}); + invoke('type_str', {input: payload, autoSend}); } } }; @@ -142,7 +146,7 @@ function App() { if (filtered.length == 1) { let assembledStr: string = generatePayload(filtered[0]); setSubTopic(""); - invoke('type_str', {input: assembledStr}); + invoke('type_str', {input: assembledStr, autoSend}); }else{ // Open Submenu for type setSubTopic(type); @@ -213,6 +217,21 @@ function App() { {/* TODO: Optional auto-send on pre-made messages */} +
+
+ Auto-Send +
+
+ { + setAutoSend(e.target.checked); + localStorage.setItem("autoSend", e.target.checked.toString()); + }} + /> +
+
{ let url = "https://git.corrupt.link/liz/AllenWrench";