MCPcopy Create free account
hub / github.com/amnweb/thide / send_command

Function send_command

src/cli.rs:47–66  ·  view source on GitHub ↗

Send an IPC command to the running THide instance

(message: u32, success_msg: &str)

Source from the content-addressed store, hash-verified

45
46/// Send an IPC command to the running THide instance
47fn send_command(message: u32, success_msg: &str) -> Result<(), Box<dyn std::error::Error>> {
48 unsafe {
49 let class_name: Vec<u16> = format!("{}\0", IPC_WINDOW_CLASS).encode_utf16().collect();
50
51 match FindWindowW(
52 windows::core::PCWSTR(class_name.as_ptr()),
53 windows::core::PCWSTR::null(),
54 ) {
55 Ok(hwnd) if !hwnd.0.is_null() => {
56 let _ = PostMessageW(hwnd, message, WPARAM(0), LPARAM(0));
57 println!("{}", success_msg);
58 Ok(())
59 }
60 _ => {
61 eprintln!("Error: THide is not running!");
62 std::process::exit(1);
63 }
64 }
65 }
66}
67
68/// Check if THide is currently running
69fn is_thide_running() -> bool {

Callers 1

handle_cli_commandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected