Skip to content

Add app exclusion UI with drag-and-drop functionality to macOS and Windows OpenKey#3

Merged
f97 merged 4 commits intomasterfrom
copilot/fix-4337c9f5-7af3-4199-b89c-157219314f5d
Sep 7, 2025
Merged

Add app exclusion UI with drag-and-drop functionality to macOS and Windows OpenKey#3
f97 merged 4 commits intomasterfrom
copilot/fix-4337c9f5-7af3-4199-b89c-157219314f5d

Conversation

Copy link

Copilot AI commented Sep 7, 2025

This PR implements the requested app exclusion feature for both macOS and Windows versions of OpenKey, adding a user-friendly interface that allows users to exclude specific applications from Vietnamese input processing.

Key Changes

1. Three Dots Button Implementation

Changed the app exclusion selection button from text/icon to "..." (three dots) as specifically requested. The button is prominently displayed in both platforms:

  • macOS: New dedicated section within the System tab
  • Windows: Main dialog and enhanced exclusion dialog

2. Drag-and-Drop App Selection

Implemented innovative cursor-based app selection functionality for both platforms:

macOS Implementation:

  • Click the "..." button to activate selection mode
  • Cursor automatically changes to crosshair for precise targeting
  • Global mouse event monitoring detects clicks on any application window
  • Uses CGWindowListCopyWindowInfo API for accurate app identification at cursor position
  • Automatic detection and addition of app names to exclusion list

Windows Implementation:

  • Click the "..." button to activate selection mode
  • Cursor changes to crosshair using SetCursor(LoadCursor(NULL, IDC_CROSS))
  • Global mouse hook using SetWindowsHookEx(WH_MOUSE_LL) for mouse tracking
  • Uses WindowFromPoint, GetWindowThreadProcessId, and GetModuleBaseName APIs for app detection
  • Automatic cleanup after 10 seconds with timer functionality

3. Complete UI Integration

macOS: Added a new "Loại trừ ứng dụng" (App Exclusion) section to the System tab featuring:

  • Table view displaying currently excluded applications
  • Remove button for deleting apps from exclusion list
  • Clear instructional text explaining the drag-and-drop workflow
  • Seamless integration with existing macOS interface design

Windows: Enhanced exclusion dialog with:

  • New "..." button alongside traditional file selection
  • Repositioned existing buttons for better layout
  • Added instructional text explaining drag-and-drop functionality
  • Maintained compatibility with existing file-based selection

4. Backend Integration

Connected the new UI to the existing SmartSwitchKey exclusion engine on both platforms:

  • Created C++ wrapper functions for Objective-C integration (macOS)
  • Leveraged existing exclusion data management system
  • Real-time updates when applications are added or removed
  • Data persistence across app sessions

Technical Implementation

macOS Components:

  • UI Components: New storyboard elements with proper outlet connections
  • Event Handling: Global mouse monitoring with automatic cleanup after 10 seconds
  • App Detection: Window list analysis to identify applications at specific coordinates
  • Localization: Vietnamese language support for all new UI elements
  • Data Management: Integration with existing isAppExcluded(), addAppToExclusionList(), and removeAppFromExclusionList() functions

Windows Components:

  • UI Components: Enhanced resource file with new button controls and layout adjustments
  • Event Handling: Low-level mouse hook with SetWindowsHookEx for global mouse tracking
  • App Detection: Windows API integration for process identification at cursor position
  • Memory Management: Proper hook cleanup and timer management for resource safety
  • Data Management: Same backend integration as macOS using existing exclusion functions

User Experience

macOS Users can now:

  1. Navigate to System tab in OpenKey preferences
  2. View the new app exclusion section with a table of excluded apps
  3. Click the "..." button to start app selection mode
  4. Receive clear visual feedback (crosshair cursor) and instructions
  5. Click on any application to automatically add it to the exclusion list
  6. Remove apps from the exclusion list using the table selection and remove button

Windows Users can now:

  1. Open the exclusion dialog from OpenKey settings
  2. Use either traditional file selection ("Thêm ứng dụng...") or new drag-drop method ("...")
  3. Click the "..." button for crosshair cursor mode
  4. Click on any running application to automatically detect and add it
  5. Manage excluded apps using the enhanced dialog interface

App Exclusion UI

This implementation fully addresses the Vietnamese requirement: "Button chọn loại trừ ứng dụng đổi thành 3 dấu chấm, thêm tính năng trong loại trừ app bằng cách kéo thả con trỏ vào vị trí app sẽ tự động chọn app name" by providing both the three dots button and the drag-and-drop cursor functionality for automatic app name selection across both macOS and Windows platforms.

Files Modified

macOS:

  • Sources/OpenKey/macOS/ModernKey/Base.lproj/Main.storyboard - Added exclusion UI elements
  • Sources/OpenKey/macOS/ModernKey/ViewController.h/.m - Implemented app exclusion functionality
  • Sources/OpenKey/macOS/ModernKey/SmartSwitchKeyWrapper.mm - Created C++ integration wrapper
  • Sources/OpenKey/macOS/ModernKey/vi-VN.lproj/Main.strings - Added Vietnamese localization

Windows:

  • Sources/OpenKey/win32/OpenKey/OpenKey/ExclusionDialog.h/.cpp - Implemented drag-drop functionality
  • Sources/OpenKey/win32/OpenKey/OpenKey/OpenKey.rc - Enhanced UI with new button and layout
  • Sources/OpenKey/win32/OpenKey/OpenKey/resource.h - Added new button constants

Shared:

  • .gitignore - Added build artifact exclusions

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits September 7, 2025 06:14
Co-authored-by: f97 <143237992+f97@users.noreply.github.com>
Co-authored-by: f97 <143237992+f97@users.noreply.github.com>
Copilot AI changed the title [WIP] Button chọn loại trừ ứng dụng đổi thành 3 dấu chấm, thêm tính năng trong loại trừ app bằng cách kéo thả con trỏ vào vị trí app sẽ tự động chọn app name. Add app exclusion UI with drag-and-drop functionality to macOS OpenKey Sep 7, 2025
Copilot AI requested a review from f97 September 7, 2025 06:17
@f97
Copy link
Owner

f97 commented Sep 7, 2025

@copilot update cho cả win

…e dots button

Co-authored-by: f97 <143237992+f97@users.noreply.github.com>
Copy link
Author

Copilot AI commented Sep 7, 2025

@copilot update cho cả win

I've implemented the same app exclusion functionality for Windows! The changes include:

Three dots button ("...") - Changed from icon to text on both main dialog and exclusion dialog
Drag-and-drop app selection - Click "..." to start crosshair cursor mode, then click any app to add it
Windows API integration - Uses SetWindowsHookEx, WindowFromPoint, and GetModuleBaseName for app detection
Enhanced UI - Added instructional text and repositioned buttons in the exclusion dialog
Auto-cleanup - 10-second timeout with proper resource management

The Windows implementation provides the same user experience as macOS using platform-specific APIs. Commit: 9e68f0c

Copilot AI changed the title Add app exclusion UI with drag-and-drop functionality to macOS OpenKey Add app exclusion UI with drag-and-drop functionality to macOS and Windows OpenKey Sep 7, 2025
@f97 f97 marked this pull request as ready for review September 7, 2025 07:01
@f97 f97 merged commit 5b67585 into master Sep 7, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants