Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] windows support #2

Open
sassman opened this issue Oct 10, 2020 · 7 comments
Open

[FEAT] windows support #2

sassman opened this issue Oct 10, 2020 · 7 comments
Labels
Status: In Progress Status: Work has started, but not yet done Type: Enhancement New feature or request

Comments

@sassman
Copy link
Owner

sassman commented Oct 10, 2020

Implement window grabbing and screenshotting capabilities for windows.
The interface that needs to be implemented is very simple and straight forward:

pub fn get_window_id_for(_terminal: String) -> Option<u32> {
   // returns the window id / handle for a given name 
}

pub fn ls_win() {
  // prints out window name and id
}

pub fn capture_window_screenshot(_win_id: u32) -> anyhow::Result<ImageOnHeap> {
  // captures the screenshot for a given window id / handle and returns a result of a Box<FlatSamples> image
}

Additionally, some inspiration on the windows APIs in rust can be drawn from here

@sassman sassman added the Type: Enhancement New feature or request label Oct 10, 2020
@xobs
Copy link

xobs commented Dec 31, 2020

After seeing your announcement, I've started looking into this.

So far I have it listing windows, and I've started working on the capture steps.

Current issues are:

  1. Convert is the name of a standard program to convert disks to ntfs. Therefore, no longer depending on Imagemagick is mostly a prerequisite.
  2. The default command should be different - /bin/sh doesn't exist, but cmd.exe does.

@sassman
Copy link
Owner Author

sassman commented Dec 31, 2020

Nice, just a heads up, the API has evolved and must now implement this trait:

use crate::{ImageOnHeap, Result, WindowId, WindowList};

pub trait PlatformApi: Send {
    fn calibrate(&mut self, window_id: WindowId) -> Result<()>;
    fn window_list(&self) -> Result<WindowList>;
    fn capture_window_screenshot(&self, window_id: WindowId) -> Result<ImageOnHeap>;
    fn get_active_window(&self) -> Result<WindowId>;
}

Convert is the name of a standard program to convert disks to ntfs. Therefore, no longer depending on Imagemagick is mostly a prerequisite.

why is that an issue?

The default command should be different - /bin/sh doesn't exist, but cmd.exe does.

that should not be that hard, but good point.

@sassman
Copy link
Owner Author

sassman commented Dec 31, 2020

PS: convert is just sort of an alias, and the main command that can be used is magick like described here

@xobs
Copy link

xobs commented Jan 1, 2021

I have an initial build up at https://github.com/xobs/t-rec-rs/tree/win-support

It mostly steals from the winrt-rs example that is referred to in the previous iteration of the win module. However, it performs a continuous capture, which nicely places a bright yellow border around the window in question.

It doesn't handle borders right now, and the get_active_window() function gets the current active window, instead of the window that you're typing into. This becomes a problem if, for example, you alt-tab while compiling the project, or do sleep 5; cargo run and alt-tab. I'm uncertain of whether this is a problem.

@xobs
Copy link

xobs commented Jan 1, 2021

I'll also modify it to use the magick command directly, instead of using the alias. That should fix the issue I was seeing!

@sassman
Copy link
Owner Author

sassman commented Jan 3, 2021

There is now a dedicated feature branch for windows-support that is kept in sync with main and will be at some point mature enough to be ready for release.

@sassman sassman added the Status: In Progress Status: Work has started, but not yet done label Jan 5, 2021
@jos3s
Copy link

jos3s commented Apr 6, 2021

I discovered this project is good to see that windows support is planned, I would like to add that if a windows version becomes available, it would be interesting to make it available on the winget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Status: Work has started, but not yet done Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants