[Update/TMP] Hotkey Alt+Y will active VRCT when VRChat is the active window.

This commit is contained in:
Sakamoto Shiina
2025-01-05 14:10:48 +09:00
parent ffa1319b5b
commit 47126bf5c8
10 changed files with 830 additions and 426 deletions

1114
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,11 +11,13 @@ edition = "2021"
tauri-build = { version = "1", features = [] }
[dependencies]
tauri = { version = "1", features = [ "window-set-size", "window-set-position", "window-unmaximize", "window-close", "window-maximize", "window-minimize", "window-unminimize", "window-start-dragging", "window-set-decorations", "window-set-always-on-top", "shell-sidecar", "shell-open", "devtools"] }
tauri = { version = "1", features = [ "window-hide", "window-set-focus", "global-shortcut-all", "window-set-size", "window-set-position", "window-unmaximize", "window-close", "window-maximize", "window-minimize", "window-unminimize", "window-start-dragging", "window-set-decorations", "window-set-always-on-top", "shell-sidecar", "shell-open", "devtools"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
font-kit = "0.14.2"
window-shadows = { git = "https://github.com/tauri-apps/window-shadows.git" }
windows = { version = "0.38", features = ["Win32_Foundation", "Win32_UI_WindowsAndMessaging", "Win32_System_Threading"] }
[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!

View File

@@ -1,9 +1,8 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
// use tauri::command;
use tauri::Manager;
use window_shadows::set_shadow;
use windows::Win32::UI::WindowsAndMessaging::{GetForegroundWindow, GetWindowTextW};
use std::collections::HashSet;
fn main() {
tauri::Builder::default()
.setup(|app| {
@@ -13,18 +12,16 @@ fn main() {
{ main_window.open_devtools(); }
#[cfg(any(windows, target_os = "macos"))]
set_shadow(main_window, true).unwrap();
set_shadow(main_window, true).unwrap()
Ok(())
})
.invoke_handler(tauri::generate_handler![get_font_list])
.invoke_handler(tauri::generate_handler![get_font_list, get_active_window_title])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
use font_kit::{source::SystemSource};
use std::collections::HashSet;
#[tauri::command]
async fn get_font_list() -> Vec<String> {
@@ -41,3 +38,27 @@ async fn get_font_list() -> Vec<String> {
font_families.into_iter().collect()
}
use windows::Win32::Foundation::HWND;
#[tauri::command]
fn get_active_window_title() -> String {
unsafe {
// Get the handle of the foreground (active) window
let hwnd = GetForegroundWindow();
if hwnd == HWND(0) { // `HWND(0)` は null ハンドルを表します
return "No active window".to_string();
}
// Create a buffer to hold the window title
let mut buffer: [u16; 512] = [0; 512];
// Get the window title
let length = GetWindowTextW(hwnd, &mut buffer);
if length > 0 {
// Convert the result to a Rust string
return String::from_utf16_lossy(&buffer[..length as usize]);
}
}
"Failed to retrieve window title".to_string()
}

View File

@@ -15,8 +15,10 @@
"window": {
"all": false,
"setAlwaysOnTop": true,
"setFocus": true,
"setDecorations": true,
"close": true,
"hide": true,
"setPosition": true,
"setSize": true,
"maximize": true,
@@ -24,7 +26,10 @@
"unmaximize": true,
"unminimize": true,
"startDragging": true
},
},
"globalShortcut": {
"all": true
},
"shell": {
"all": false,
"open": true,