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

[Request] Lock option #51

Open
Disar opened this issue Aug 13, 2017 · 5 comments
Open

[Request] Lock option #51

Disar opened this issue Aug 13, 2017 · 5 comments

Comments

@Disar
Copy link

Disar commented Aug 13, 2017

I'd like to have a lock feature disabling clicking (mouse clicks pass trough) and moving the visual timer.
Additionally if I hover over when locked it should go fully transparent.
Unlocking/Locking can be set by right clicking the icon in the taskbar as additional options.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@floatas
Copy link
Collaborator

floatas commented Aug 14, 2017

Hey, did some research, doesn't seem to be very difficult to implement this feature.

Will throw snippet here for later:
Set on MainWindow
WindowStyle="None" AllowsTransparency="True"

` public const int WS_EX_TRANSPARENT = 0x00000020;
public const int GWL_EXSTYLE = (-20);

    [DllImport("user32.dll")]
    public static extern int GetWindowLong(IntPtr hwnd, int index);

    [DllImport("user32.dll")]
    public static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);

    [DllImport("user32.dll")]
    public static extern int GetWindowLongPtr(IntPtr hwnd, int index);

    [DllImport("user32.dll")]
    public static extern int SetWindowLongPtr(IntPtr hwnd, int index, int newStyle);

    int extendedStyle;
    private bool is64Bit;
    private IntPtr hwnd;

    protected override void OnSourceInitialized(EventArgs e)
    {
         is64Bit = (Marshal.SizeOf(typeof(IntPtr))) == 8;
        hwnd = new WindowInteropHelper(this).Handle;

        if (is64Bit)
            extendedStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
        else
            extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);

        base.OnSourceInitialized(e);
    }

    private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
    {
        if (is64Bit)
            SetWindowLongPtr(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
        else
            SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
    }`

@fghber
Copy link
Contributor

fghber commented Aug 14, 2017

If not absolute necessary I would stay away from importing unsecure win32 code. E.g. if you ever plan to put the app on the store, it will be rejected.

@floatas
Copy link
Collaborator

floatas commented Aug 18, 2017

I'm not very keen on adding more options to YAPA, it already looks like space ship control panel...
For YAPA 2.0, we should add this as plugin, so we can easily remove it if needed.

@lukaszbanasiak
Copy link
Owner

lukaszbanasiak commented Aug 18, 2017 via email

@Disar
Copy link
Author

Disar commented Aug 18, 2017

I don't see how it looks like a spaceship control panel. It barely offers any options or features.

But whatever works. Plugins sound good too ( although I'd argue a plug-in would detract from being minimalistic).

I just think the timer shouldn't be blocking mouse clicks all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants