Open source Loom alternative. Beautiful, shareable screen recordings.
Cap Cursor Info
A cross-platform Rust crate for detecting cursor shapes and providing accurate cursor assets with hotspot information.
Features
- π±οΈ Cross-platform cursor detection - Support for macOS and Windows
- π― Accurate hotspot information - Precise cursor positioning data
- π¨ High-quality SVG assets - Scalable cursor graphics for all supported shapes
- π Real-time cursor monitoring - Track cursor changes as they happen
- π¦ Serialization support - Built-in serde and specta support
- π οΈ Development tools - Interactive viewer and CLI monitoring
Installation
Add this to your Cargo.toml:
[dependencies]
cap-cursor-info = "0.0.0"
Platform-specific dependencies
The crate automatically includes platform-specific dependencies:
- macOS: Uses
objc2andobjc2-app-kitfor cursor detection - Windows: Uses
windowscrate for Win32 API integration
Usage
Basic Usage
use cap_cursor_info::{CursorShape, CursorShapeMacOS, CursorShapeWindows};
// Create a cursor shape
let cursor = CursorShape::MacOS(CursorShapeMacOS::Arrow);
// Resolve to get SVG asset and hotspot
if let Some(resolved) = cursor.resolve() {
println!("SVG: {}", resolved.raw);
println!("Hotspot: ({}, {})", resolved.hotspot.0, resolved.hotspot.1);
}
// Display cursor information
println!("Cursor: {}", cursor); // Output: "MacOS|Arrow"
Platform-specific Detection
macOS
#[cfg(target_os = "macos")]
use cap_cursor_info::CursorShapeMacOS;
// Detect cursor from hash (macOS uses image hashing)
let hash = "de2d1f4a81e520b65fd1317b845b00a1c51a4d1f71cca3cd4ccdab52b98d1ac9";
if let Some(cursor) = CursorShapeMacOS::from_hash(hash) {
println!("Detected cursor: {:?}", cursor);
}
Windows
#[cfg(target_os = "windows")]
use cap_cursor_info::CursorShape;
use windows::Win32::UI::WindowsAndMessaging::HCURSOR;
// Convert from Windows HCURSOR
let hcursor: HCURSOR = get_current_cursor(); // Your implementation
if let Ok(cursor) = CursorShape::try_from(&hcursor) {
println!("Detected cursor: {}", cursor);
}
Serialization
The crate supports serde serialization:
use cap_cursor_info::CursorShape;
use serde_json;
let cursor = CursorShape::MacOS(CursorShapeMacOS::Arrow);
let json = serde_json::to_string(&cursor).unwrap();
println!("{}", json); // "MacOS|Arrow"
let deserialized: CursorShape = serde_json::from_str(&json).unwrap();
Supported Cursors
macOS Cursors
Arrow- Standard arrow pointerContextualMenu- Context menu indicatorClosedHand- Closed hand for draggingCrosshair- Precision crosshairDragCopy- Copy operation indicatorDragLink- Link operation indicatorIBeam- Text selection cursorIBeamVerticalForVerticalLayout- Vertical text cursorOpenHand- Open hand for grabbable itemsOperationNotAllowed- Prohibited operationPointingHand- Clickable link pointerResizeDown/Up/Left/Right- Directional resize cursorsResizeLeftRight/UpDown- Bidirectional resize cursors
Windows Cursors
Arrow- Standard arrow pointerIBeam- Text selection cursorWait- Loading/busy indicatorCross- Crosshair cursorUpArrow- Vertical selectionSizeNWSE/NESW/WE/NS/All- Various resize cursorsNo- Prohibited operationHand- Clickable link pointerAppStarting- Application loadingHelp- Help/question cursorPin/Person- Specialized cursorsPen- Drawing/writing cursor
Development Tools
Interactive Cursor Viewer
Open cursors.html in your browser to:
- View all cursor assets with accurate scaling
- See hotspot positions visually
- Copy hotspot coordinates for development
- Test cursor appearance on different backgrounds
CLI Monitoring Tool
Run the example to monitor cursor changes in real-time:
cargo run --example cli
This will:
- Display current cursor information
- Show hash values (macOS) or handle info (Windows)
- Update in real-time as you move between applications
Platform Details
macOS Implementation
macOS cursor detection uses SHA-256 hashing of the cursor's TIFF image data. This approach is necessary because:
NSCursorinstances cannot be compared directly- Cursors are resolution-independent
- Hash comparison provides reliable identification
Windows Implementation
Windows cursor detection uses HCURSOR handle comparison with a cached lookup table of system cursors loaded at runtime.
Asset Information
All cursor assets are:
- Format: SVG for scalability
- Quality: High-fidelity reproductions of system cursors
- Hotspots: Precisely measured for accurate positioning
- License: See individual asset licenses in
assets/directories
Hotspot Coordinates
Hotspot coordinates are normalized (0.0 to 1.0) relative to the cursor's dimensions:
(0.0, 0.0)= Top-left corner(1.0, 1.0)= Bottom-right corner(0.5, 0.5)= Center
Contributing
We welcome contributions! Please:
- Test on both macOS and Windows when possible
- Include hotspot measurements for new cursor assets
- Update the HTML viewer when adding new cursors
- Run the CLI example to verify cursor detection
License
This project is released under the Apple User Agreement for macOS assets. See individual license files in the assets directories for specific terms.