Auto-Send Feature
This commit is contained in:
		@@ -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
 | 
					* [ ] Ensure window appears within bounds of screen(s) when moved to cursor location
 | 
				
			||||||
* [ ] Keyboard control of the program
 | 
					* [ ] 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
 | 
					* [ ] Prevent showing window until on correct location
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Nice to Haves
 | 
					### 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)
 | 
					* [ ] [Unicode "font" options](https://lingojam.com/DiscordFonts)
 | 
				
			||||||
* [ ] Drone Speech Optimizations
 | 
					* [ ] Drone Speech Optimizations
 | 
				
			||||||
* [ ] Improve Launch Times
 | 
					* [ ] Improve Launch Times
 | 
				
			||||||
 | 
					* [ ] Add Version Display in Config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Misc notes
 | 
					### Misc notes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "allenwrench-app",
 | 
					  "name": "allenwrench-app",
 | 
				
			||||||
  "private": true,
 | 
					  "private": true,
 | 
				
			||||||
  "version": "0.1.1",
 | 
					  "version": "0.2.0",
 | 
				
			||||||
  "type": "module",
 | 
					  "type": "module",
 | 
				
			||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
    "dev": "vite",
 | 
					    "dev": "vite",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ fn get_mouse_pos() -> String {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[tauri::command]
 | 
					#[tauri::command]
 | 
				
			||||||
fn type_str(input: String) {
 | 
					fn type_str(input: String, autoSend: bool) {
 | 
				
			||||||
    #[cfg(dev)]
 | 
					    #[cfg(dev)]
 | 
				
			||||||
    println!(">: {}", input);
 | 
					    println!(">: {}", input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -64,6 +64,12 @@ fn type_str(input: String) {
 | 
				
			|||||||
        enigo.key_up(Key::Control);
 | 
					        enigo.key_up(Key::Control);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    thread::sleep(Duration::from_millis(200));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (autoSend) {
 | 
				
			||||||
 | 
					        enigo.key_click(Key::Return);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    thread::sleep(Duration::from_millis(20));
 | 
					    thread::sleep(Duration::from_millis(20));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Close program
 | 
					    // Close program
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								src/App.tsx
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/App.tsx
									
									
									
									
									
								
							@@ -44,6 +44,10 @@ function App() {
 | 
				
			|||||||
    let storedId = localStorage.getItem("droneId");
 | 
					    let storedId = localStorage.getItem("droneId");
 | 
				
			||||||
    return (storedId ? storedId : "0000");
 | 
					    return (storedId ? storedId : "0000");
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					  const [autoSend, setAutoSend] = useState<boolean>(() => {
 | 
				
			||||||
 | 
					    let storedAutoSend = localStorage.getItem("autoSend");
 | 
				
			||||||
 | 
					    return (storedAutoSend ? storedAutoSend == "true" : false);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!codes){
 | 
					  if (!codes){
 | 
				
			||||||
    resolveResource("resources/codes.json").then((path: string) => {
 | 
					    resolveResource("resources/codes.json").then((path: string) => {
 | 
				
			||||||
@@ -102,7 +106,7 @@ function App() {
 | 
				
			|||||||
      if (filtered.length == 1) {
 | 
					      if (filtered.length == 1) {
 | 
				
			||||||
        let payload: string = generatePayload(filtered[0]);
 | 
					        let payload: string = generatePayload(filtered[0]);
 | 
				
			||||||
        setSubTopic("");
 | 
					        setSubTopic("");
 | 
				
			||||||
        invoke('type_str', {input: payload});
 | 
					        invoke('type_str', {input: payload, autoSend});
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
@@ -142,7 +146,7 @@ function App() {
 | 
				
			|||||||
      if (filtered.length == 1) {
 | 
					      if (filtered.length == 1) {
 | 
				
			||||||
        let assembledStr: string = generatePayload(filtered[0]);
 | 
					        let assembledStr: string = generatePayload(filtered[0]);
 | 
				
			||||||
        setSubTopic("");
 | 
					        setSubTopic("");
 | 
				
			||||||
        invoke('type_str', {input: assembledStr});
 | 
					        invoke('type_str', {input: assembledStr, autoSend});
 | 
				
			||||||
      }else{
 | 
					      }else{
 | 
				
			||||||
        // Open Submenu for type
 | 
					        // Open Submenu for type
 | 
				
			||||||
        setSubTopic(type);
 | 
					        setSubTopic(type);
 | 
				
			||||||
@@ -213,6 +217,21 @@ function App() {
 | 
				
			|||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
          {/* TODO: Optional auto-send on pre-made messages */}
 | 
					          {/* TODO: Optional auto-send on pre-made messages */}
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div className="row">
 | 
				
			||||||
 | 
					          <div className="col-6 text-end">
 | 
				
			||||||
 | 
					            Auto-Send
 | 
				
			||||||
 | 
					          </div>
 | 
				
			||||||
 | 
					          <div className="col-6">
 | 
				
			||||||
 | 
					            <input 
 | 
				
			||||||
 | 
					              type="checkbox" 
 | 
				
			||||||
 | 
					              checked={autoSend}
 | 
				
			||||||
 | 
					              onChange={(e) => {
 | 
				
			||||||
 | 
					                setAutoSend(e.target.checked);
 | 
				
			||||||
 | 
					                localStorage.setItem("autoSend", e.target.checked.toString());
 | 
				
			||||||
 | 
					              }}
 | 
				
			||||||
 | 
					            />
 | 
				
			||||||
 | 
					          </div>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
        <div className="row modal-footer">
 | 
					        <div className="row modal-footer">
 | 
				
			||||||
          <div className="col-4" onClick={() => {
 | 
					          <div className="col-4" onClick={() => {
 | 
				
			||||||
            let url = "https://git.corrupt.link/liz/AllenWrench";
 | 
					            let url = "https://git.corrupt.link/liz/AllenWrench";
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user