Compare commits
2 Commits
47e6b2a125
...
ac2f526d8a
Author | SHA1 | Date |
---|---|---|
Elizabeth Cray | ac2f526d8a | |
Elizabeth Cray | 49b11741cb |
File diff suppressed because it is too large
Load Diff
|
@ -18,6 +18,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||
serde_json = "1.0"
|
||||
enigo = "0.1.2"
|
||||
arboard = "3.2.0"
|
||||
tauri-plugin-positioner = "1.0.4"
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use enigo::{Enigo, Key, KeyboardControllable};
|
||||
use enigo::{Enigo, Key, KeyboardControllable, MouseControllable};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use arboard::Clipboard;
|
||||
|
||||
#[tauri::command]
|
||||
fn get_mouse_pos() -> String {
|
||||
let enigo = Enigo::new();
|
||||
let (x, y) = enigo.mouse_location();
|
||||
format!("{{ \"x\": {}, \"y\": {} }}", x, y).into()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn type_str(input: String) {
|
||||
#[cfg(dev)]
|
||||
|
@ -17,15 +24,40 @@ fn type_str(input: String) {
|
|||
// Load input into clipboard
|
||||
clipboard.set_text(input).unwrap();
|
||||
|
||||
// TODO: Multi-platform window switch
|
||||
enigo.key_down(Key::Alt);
|
||||
enigo.key_click(Key::Tab);
|
||||
enigo.key_up(Key::Alt);
|
||||
// TODO: Set the Command/Alt key configured by user
|
||||
#[cfg(target_os = "macos")] {
|
||||
enigo.key_down(Key::Command);
|
||||
enigo.key_click(Key::Tab);
|
||||
enigo.key_up(Key::Command);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")] {
|
||||
enigo.key_down(Key::Alt);
|
||||
enigo.key_click(Key::Tab);
|
||||
enigo.key_up(Key::Alt);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")] {
|
||||
enigo.key_down(Key::Alt);
|
||||
enigo.key_click(Key::Tab);
|
||||
enigo.key_up(Key::Alt);
|
||||
}
|
||||
|
||||
thread::sleep(Duration::from_millis(200));
|
||||
|
||||
// TODO: Multi-platform paste
|
||||
#[cfg(not(dev))]{
|
||||
#[cfg(target_os = "windows")]{
|
||||
enigo.key_down(Key::Control);
|
||||
enigo.key_click(Key::Layout('v'));
|
||||
enigo.key_up(Key::Control);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]{
|
||||
enigo.key_down(Key::Command);
|
||||
enigo.key_click(Key::Layout('v'));
|
||||
enigo.key_up(Key::Command);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]{
|
||||
enigo.key_down(Key::Control);
|
||||
enigo.key_click(Key::Layout('v'));
|
||||
enigo.key_up(Key::Control);
|
||||
|
@ -40,9 +72,9 @@ fn type_str(input: String) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
// TODO: Set Window location on launch
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![type_str])
|
||||
.plugin(tauri_plugin_positioner::init())
|
||||
.invoke_handler(tauri::generate_handler![type_str, get_mouse_pos])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
|
|
@ -18,11 +18,23 @@
|
|||
"sidecar": true,
|
||||
"execute": true,
|
||||
"open": true,
|
||||
"scope": [{
|
||||
"name" : "open-link",
|
||||
"cmd": "powershell.exe",
|
||||
"args": ["-Command", "Start-Process", {"validator": "\\S+"}]
|
||||
}]
|
||||
"scope": [
|
||||
{
|
||||
"name" : "open-link-win",
|
||||
"cmd": "powershell.exe",
|
||||
"args": ["-Command", "Start-Process", {"validator": "\\S+"}]
|
||||
},
|
||||
{
|
||||
"name" : "open-link-linux",
|
||||
"cmd": "/bin/sh",
|
||||
"args": ["-c", "xdg-open", {"validator": "\\S+"}]
|
||||
},
|
||||
{
|
||||
"name" : "open-link-macos",
|
||||
"cmd": "/bin/bash",
|
||||
"args": ["-c", "open", {"validator": "\\S+"}]
|
||||
}
|
||||
]
|
||||
},
|
||||
"fs": {
|
||||
"all": true,
|
||||
|
@ -30,6 +42,9 @@
|
|||
},
|
||||
"path": {
|
||||
"all": true
|
||||
},
|
||||
"os": {
|
||||
"all": true
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
|
@ -52,7 +67,11 @@
|
|||
"windows": [
|
||||
{
|
||||
"fullscreen": false,
|
||||
"resizable": true,
|
||||
"resizable": false,
|
||||
"maximizable": false,
|
||||
"minimizable": false,
|
||||
"alwaysOnTop": true,
|
||||
"decorations": true,
|
||||
"title": "Drone Input",
|
||||
"width": 400,
|
||||
"height": 320
|
||||
|
|
35
src/App.tsx
35
src/App.tsx
|
@ -3,11 +3,12 @@ import { resolveResource } from "@tauri-apps/api/path";
|
|||
import { readTextFile } from "@tauri-apps/api/fs";
|
||||
import { invoke } from '@tauri-apps/api/tauri'
|
||||
import Modal from "react-modal";
|
||||
import { platform } from '@tauri-apps/api/os';
|
||||
import "./App.css";
|
||||
import { Command } from '@tauri-apps/api/shell'
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faGitAlt } from "@fortawesome/free-brands-svg-icons/faGitAlt";
|
||||
|
||||
import { PhysicalPosition, appWindow } from "@tauri-apps/api/window";
|
||||
|
||||
// TODO: Keyboard usage
|
||||
|
||||
|
@ -22,6 +23,17 @@ Modal.setAppElement("#root");
|
|||
|
||||
function App() {
|
||||
|
||||
// Set window to above the mouse cursor
|
||||
invoke('get_mouse_pos', {}).then((posJson: any) => {
|
||||
let pos = JSON.parse(posJson);
|
||||
appWindow.innerSize().then((size: any) => {
|
||||
pos.y -= size.height + 32 /*Standard windows titlebar height*/;
|
||||
console.log(JSON.stringify(pos));
|
||||
appWindow.setPosition(new PhysicalPosition(pos.x, pos.y));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
const [subTopic, setSubTopic] = useState<string>("");
|
||||
const [configModalOpen, setConfigModalOpen] = useState<boolean>(false);
|
||||
const [droneId, setDroneId] = useState<string>(() => {
|
||||
|
@ -152,12 +164,29 @@ function App() {
|
|||
}}
|
||||
/>
|
||||
</div>
|
||||
{/* TODO: Optional auto-send on pre-made messages */}
|
||||
</div>
|
||||
<div className="row modal-footer">
|
||||
<div className="col-4" onClick={() => {
|
||||
let url = "https://git.corrupt.link/liz/AllenWrench";
|
||||
// TODO: Make multi-platform
|
||||
new Command("open-link", ["-Command", "Start-Process", `${url}`]).spawn();
|
||||
platform().then((os: string) => {
|
||||
switch(os) {
|
||||
case "win32":
|
||||
new Command("open-link-win", ["-Command", "Start-Process", `${url}`]).spawn();
|
||||
break;
|
||||
case "linux":
|
||||
new Command("open-link-linux", ["-c", "xdg-open", `${url}`]).spawn();
|
||||
break;
|
||||
case "macos":
|
||||
new Command("open-link-macos", ["-c", "open", `${url}`]).spawn();
|
||||
break;
|
||||
default:
|
||||
console.log(`Unknown OS: ${os}`);
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}}>
|
||||
<FontAwesomeIcon className="icon" icon={faGitAlt} size="2x" />
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue