[Request] Lock option
Disar opened this issue · 5 comments
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.
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);
}`
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.
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.
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.