Code Monkey home page Code Monkey logo

active-win-pos-rs's Introduction

active-win-pos-rs

Build status

A small Rust library that lets you get position, size, title and a few other properties of the active window on Windows, MacOS and Linux

Usage

Add to Cargo.toml:

[dependencies]
active-win-pos-rs = "0.7"

Use:

use active_win_pos_rs::get_active_window;

fn main() {
    match get_active_window() {
        Ok(active_window) => {
            println!("active window: {:#?}", active_window);
        },
        Err(()) => {
            println!("error occurred while getting the active window");
        }
    }
}

Would give you an instance of ActiveWindow struct with unique window id, process id, window position and window title.

Or use active_win_pos_rs::get_position to get the WindowPosition only.

Window title on MacOS

On MacOS title property will always return an empty string unless you Enable Screen Recording permission for your app.

Build

% git clone https://github.com/dimusic/active-win-pos-rs.git
% cd active-win-pos-rs
% cargo build

Example

% cargo run --example active-window

Output:

active window: ActiveWindow {
    title: "cmd - cargo  run --example active-window",
    process_name: "WindowsTerminal",
    window_id: "HWND(9700584)",
    process_id: 8460,
    position: WindowPosition {
        x: 6.0,
        y: 296.0,
        width: 1129.0,
        height: 635.0,
    },
}

active-win-pos-rs's People

Contributors

dimusic avatar gertdreyer avatar isala404 avatar julyj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.