rodrigocfd / winsafe

Windows API and GUI in safe, idiomatic Rust.
https://crates.io/crates/winsafe
MIT License
518 stars 30 forks source link

Add missing API to open app in foreground? #121

Closed binChris closed 7 months ago

binChris commented 7 months ago

First of all, thanks for this lib, it is so much better to code against than the native Windows API!

I am trying to start and open an app in foreground and this needs functions currently not covered by winsafe:

Would it be ok to create a pull request for there functions? Plus struct ShellExecuteEx internally, I think it's better to disect it in the public interface as its members are mixed input / output.

rodrigocfd commented 7 months ago

I pushed an implementation for WaitForInputIdle, which is not complicated.

ShellExecuteEx, however, will need some thought... it's fine to create a pull request, but it's often useful to brainstorm such APIs. Do you have anything in mind?

binChris commented 7 months ago

That's great, thanks for adding WaitForInputIdle!

I can understand you want to keep the winsafe API stable and avoid breaking changes. The original Windows API for ShellExecuteEx is quite horrible, mixing input/output fields in the same struct.

Let me think about this a little and we can discuss a possible API design here before making a PR.

rodrigocfd commented 7 months ago

Hi Chris,

I pushed an unsafe implementation of ShellExecuteEx with a very bare-bones SHELLEXECUTEINFO. If we keep thinking about the perfect design, we probably would never finish it, the API is terrible.

So my idea is that, from this starting point, you try to write your stuff. Then we can discuss your pain points and make small improvements to SHELLEXECUTEINFO, until we reach a reasonable implementation.

If you find any difficulties, just reply down here and I'll be glad to help you.