有没有办法让Java应用程序检测屏幕是否被锁定? [英] Is there a way for a Java application to detect if the screen is locked?

查看:128
本文介绍了有没有办法让Java应用程序检测屏幕是否被锁定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在Java应用程序中知道的方法(没有 JNI - 它是一个多平台应用程序)可以检测屏幕是否被锁定。

I'm looking for a way to know in a Java application (without JNI - it's a multi-platform application) can detect if the screen is locked.

有关信息...我们的应用程序记录用户工作时间 - 我们希望它在屏幕被锁定时自动停止录制而不是用户必须明确地停止录制。

For information... our application records time while a user is working - we want it to automatically stop recording when the screen is locked instead of the user having to do so explicitly.

推荐答案

我认为没有一个API,甚至没有办法做到这一切。解析java.awt.Robot生成的屏幕截图既不是平台也不是版本甚至是配置独立的,一般来说,我不认为屏幕被锁定是一个足够明确的概念,在这个意义上使用 - 在Linux上,可以有不止一个屏幕(X服务器),你可以切换到控制台终端,你可以让运行一台(或多台)机器的应用程序通过网络在另一台机器上显示它们的GUI ...

I don't think there is an API for that or even a way to do it all. Parsing screenshots generated by java.awt.Robot is neither platform- nor version- or even configuration-independant, and in general, I don't think "screen is locked" is a well-enough defined concept to be used in this sense - on Linux, there can be more than just one "screen" (X server), you can switch to console terminals, you can have applications running one (or more) machines display their GUIs on another machine over the network...

这篇关于有没有办法让Java应用程序检测屏幕是否被锁定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆