我如何开发像 Deskshade 的 DeskLock 这样的东西?

发布于 2024-08-23 02:08:28 字数 414 浏览 6 评论 0原文

抱歉打扰了,但我还有另一个问题。我如何从 macrabbit 的 Deskshade 应用程序中执行类似 DeskLock 的操作?我已经制作了小窗户,这就是我所做的。我知道如何在 10.6 中使用PresentationOptions“锁定”屏幕,但我不想冒险,因为上次它不会让我返回;]

编辑:DeskShade 应用程序实际上是为了覆盖您的桌面,隐藏所有图标。它还允许您通过多次淡入淡出/滑动来随机化壁纸图案。还有一项名为 DeskLock 的额外功能,它实际上呈现一个带有锁定图标的半透明黑色斜面(类似于 Mac 中内置的 AppSwitcher),并且您可以放置​​个人文本。当您单击锁定图标时,它会显示一个模式,要求您​​输入可以设置的密码。您也可以只输入此密码而不按任何键,然后按 Enter 键,即可解锁屏幕。这也使用了隐藏桌面的 DeskShade 功能。

谢谢!

Sorry to be a nuisance, but I have yet ANOTHER question. How would I do something like DeskLock from macrabbit's Deskshade app? I've made the little window and that's as far as I've come. I know how to "lock" the screen in 10.6 with PresentationOptions, but I don't want to risk it because last time it wouldn't let me back in ;]

EDIT: The DeskShade app actually is meant to cover your desktop, hiding all icons. It also allows you to randomize wallpaper patterns with several fade/swipes. There is one extra feature called DeskLock that actually presents a translucent black bevel (similar to AppSwitcher build into Mac) with a lock icon, and you can place personal text. When you click the lock icon, it presents a modal that asks for a password you can set. You can also just type this password without pressing anything, followed by the Enter key, and it unlocks the screen. This uses the DeskShade feature of hiding the desktop as well.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜你已久 2024-08-30 02:08:28

要创建覆盖窗口,您必须子类化 NSWindow 并设置其样式掩码和背景颜色:

@implementation BigTransparentWindow
- (id)initWithContentRect:(NSRect)contentRect 
                styleMask:(NSUInteger)windowStyle 
                  backing:(NSBackingStoreType)bufferingType 
                    defer:(BOOL)deferCreation
{
    self = [super initWithContentRect:contentRect 
                            styleMask:NSBorderlessWindowMask //this makes the window transparent
                              backing:bufferingType
                                defer:deferCreation];
    if(self)
    {
        [self setOpaque:NO];
        [self setHasShadow:NO];
        [self setBackgroundColor:[[NSColor blackColor] colorWithAlphaComponent:0.5]];
    }
    return self;
}
@end

然后需要设置窗口的框架,以便它覆盖所有屏幕,并且需要适当地设置其窗口级别:

- (IBAction)showWindow:(id)sender
{
    //set the window so it covers all available screens
    NSRect screensRect = NSZeroRect;
    for(NSScreen* screen in [NSScreen screens])
    {
        screensRect = NSUnionRect(screensRect,[screen frame]);
    }
    [yourWindow setFrame:screensRect display:YES];

    if(coverScreen)
    {
        //set the window so it is above all other windows
        [yourWindow setLevel:kCGMaximumWindowLevel];
    }
    else
    {
        //set the window so it sits just above the desktop icons
        [yourWindow setLevel:kCGDesktopIconWindowLevel + 1];
    }
}

正如您所提到的,您可以使用 NSAppNSApplicationPresentationOptions 设置来控制用户与系统交互的方式。在不锁定自己的情况下进行测试的一种简单方法是设置一个 NSTimer ,该方法调用一个方法,在超时后将应用程序从 kiosk 模式中拉出来。

To create the overlay window you have to subclass NSWindow and set its style mask and background color:

@implementation BigTransparentWindow
- (id)initWithContentRect:(NSRect)contentRect 
                styleMask:(NSUInteger)windowStyle 
                  backing:(NSBackingStoreType)bufferingType 
                    defer:(BOOL)deferCreation
{
    self = [super initWithContentRect:contentRect 
                            styleMask:NSBorderlessWindowMask //this makes the window transparent
                              backing:bufferingType
                                defer:deferCreation];
    if(self)
    {
        [self setOpaque:NO];
        [self setHasShadow:NO];
        [self setBackgroundColor:[[NSColor blackColor] colorWithAlphaComponent:0.5]];
    }
    return self;
}
@end

You then need to set the window's frame so that it covers all screens, and you need to set its window level appropriately:

- (IBAction)showWindow:(id)sender
{
    //set the window so it covers all available screens
    NSRect screensRect = NSZeroRect;
    for(NSScreen* screen in [NSScreen screens])
    {
        screensRect = NSUnionRect(screensRect,[screen frame]);
    }
    [yourWindow setFrame:screensRect display:YES];

    if(coverScreen)
    {
        //set the window so it is above all other windows
        [yourWindow setLevel:kCGMaximumWindowLevel];
    }
    else
    {
        //set the window so it sits just above the desktop icons
        [yourWindow setLevel:kCGDesktopIconWindowLevel + 1];
    }
}

As you've mentioned, you can use the NSApplicationPresentationOptions settings for NSApp to control how the user can interact with the system. An easy way to test this without locking yourself out is to set an NSTimer that calls a method that pulls the app out of kiosk mode after a timeout period.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文