From 18b089dccf157487635870236b809eb6c9c31375 Mon Sep 17 00:00:00 2001 From: tusharvyavahare Date: Tue, 22 Jul 2025 18:14:38 +0530 Subject: [PATCH] dedicated interactivity/click-through toggle --- README.md | 3 ++ electron/main.ts | 37 +++++++++++++++++++++- electron/shortcuts.ts | 8 +++++ src/components/Settings/SettingsDialog.tsx | 3 ++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 47aeaf6..e26f2f7 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ All it takes is modest JavaScript/TypeScript knowledge and understanding of the The application uses unidentifiable global keyboard shortcuts that won't be detected by browsers or other applications: - Toggle Window Visibility: [Control or Cmd + B] +- Toggle Window Interactivity: [Control or Cmd + U] - Move Window: [Control or Cmd + Arrow keys] - Take Screenshot: [Control or Cmd + H] - Delete Last Screenshot: [Control or Cmd + L] @@ -145,6 +146,7 @@ chmod +x stealth-run.sh ``` **IMPORTANT**: The application window will be invisible by default! Use Ctrl+B (or Cmd+B on Mac) to toggle visibility. + The application window will be non-interactive by default! Use Ctrl+U (or Cmd+U on Mac) to toggle interactivity. ### Building Distributable Packages @@ -244,6 +246,7 @@ The packaged applications will be available in the `release` directory. 5. **Window Management** - Move window using [Control or Cmd + Arrow keys] - Toggle visibility with [Control or Cmd + B] + - Toggle interactivity with [Control or Cmd + U] - Adjust opacity with [Control or Cmd + [] and [Control or Cmd + ]] - Window remains invisible to specified screen sharing applications - Start a new problem using [Control or Cmd + R] diff --git a/electron/main.ts b/electron/main.ts index 0eae187..be5cf6e 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -17,6 +17,7 @@ const state = { // Window management properties mainWindow: null as BrowserWindow | null, isWindowVisible: false, + isWindowClickThrough: true, windowPosition: null as { x: number; y: number } | null, windowSize: null as { width: number; height: number } | null, screenWidth: 0, @@ -81,6 +82,7 @@ export interface IShortcutsHelperDeps { setView: (view: "queue" | "solutions" | "debug") => void isVisible: () => boolean toggleMainWindow: () => void + toggleClickThrough: () =>void moveWindowLeft: () => void moveWindowRight: () => void moveWindowUp: () => void @@ -101,6 +103,7 @@ export interface IIpcHandlerDeps { takeScreenshot: () => Promise getView: () => "queue" | "solutions" | "debug" toggleMainWindow: () => void + toggleClickThrough: () => void clearQueues: () => void setView: (view: "queue" | "solutions" | "debug") => void moveWindowLeft: () => void @@ -138,6 +141,7 @@ function initializeHelpers() { setView, isVisible: () => state.isWindowVisible, toggleMainWindow, + toggleClickThrough, moveWindowLeft: () => moveWindowHorizontal((x) => Math.max(-(state.windowSize?.width || 0) / 2, x - state.step) @@ -239,6 +243,7 @@ async function createWindow(): Promise { } state.mainWindow = new BrowserWindow(windowSettings) + state.mainWindow.setIgnoreMouseEvents(true, { forward: true }); // Add more detailed logging for window events state.mainWindow.webContents.on("did-finish-load", () => { @@ -408,7 +413,7 @@ function showMainWindow(): void { ...state.windowSize }); } - state.mainWindow.setIgnoreMouseEvents(false); + //state.mainWindow.setIgnoreMouseEvents(false); state.mainWindow.setAlwaysOnTop(true, "screen-saver", 1); state.mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true @@ -431,6 +436,34 @@ function toggleMainWindow(): void { } } + +function enableClickThrough(): void { + if (!state.mainWindow?.isDestroyed()) { + state.mainWindow.setIgnoreMouseEvents(true, { forward: true }); + state.isWindowClickThrough=true; + console.log('Window is click-through'); + } +} + +function disableClickThrough(): void { + if (!state.mainWindow?.isDestroyed()) { + state.mainWindow.setIgnoreMouseEvents(false); + state.isWindowClickThrough=false; + console.log('Window is not click-through'); + } +} + +//dedicated toggle for interactivity with main-window +//so that the mouse interactions with the main-window can be turned off and pointer will stay as it is +function toggleClickThrough(): void { + console.log(`Toggling window. Current state: ${state.isWindowClickThrough ? 'click-through' : 'not click-through'}`); + if (state.isWindowClickThrough) { + disableClickThrough(); + } else { + enableClickThrough(); + } +} + // Window movement functions function moveWindowHorizontal(updateFn: (x: number) => number): void { if (!state.mainWindow) return @@ -543,6 +576,7 @@ async function initializeApp() { takeScreenshot, getView, toggleMainWindow, + toggleClickThrough, clearQueues, setView, moveWindowLeft: () => @@ -692,6 +726,7 @@ export { hideMainWindow, showMainWindow, toggleMainWindow, + toggleClickThrough, setWindowDimensions, moveWindowHorizontal, moveWindowVertical, diff --git a/electron/shortcuts.ts b/electron/shortcuts.ts index a6fa5eb..b1e4b22 100644 --- a/electron/shortcuts.ts +++ b/electron/shortcuts.ts @@ -148,6 +148,14 @@ export class ShortcutsHelper { mainWindow.webContents.setZoomLevel(currentZoom + 0.5) } }) + + globalShortcut.register("CommandOrControl+U", () => { + console.log("Command/Ctrl + U pressed. Click-through enabled.") + const mainWindow = this.deps.getMainWindow() + if (mainWindow) { + this.deps.toggleClickThrough() + } + }) // Delete last screenshot shortcut globalShortcut.register("CommandOrControl+L", () => { diff --git a/src/components/Settings/SettingsDialog.tsx b/src/components/Settings/SettingsDialog.tsx index 463ea12..2a2c4f6 100644 --- a/src/components/Settings/SettingsDialog.tsx +++ b/src/components/Settings/SettingsDialog.tsx @@ -463,6 +463,9 @@ export function SettingsDialog({ open: externalOpen, onOpenChange }: SettingsDia
Toggle Visibility
Ctrl+B / Cmd+B
+ +
Toggle Interactivity
+
Ctrl+U / Cmd+U
Take Screenshot
Ctrl+H / Cmd+H