您如何获得有关其他正在运行或重点关注的应用程序的信息? [英] How can you get information about other apps running or in focus?

查看:61
本文介绍了您如何获得有关其他正在运行或重点关注的应用程序的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的动力:我正在写一个应用程序来帮助解决一些量化的自我/时间跟踪类型的事情。我想使用电子来记录有关当前正在使用的应用程序的信息。

My motivation: I'm writing an app to help with some quantified self / time tracking type things. I'd like to use electron to record information about which app I am currently using.

是否可以在Electron中获取有关其他应用程序的信息?您至少可以提取有关当前关注的另一个应用程序的信息吗?例如,如果用户正在Chrome中浏览网页,那么很高兴知道A)他们正在使用Chrome浏览器,B)他们正在查看的网页标题。

Is there a way to get information about other apps in Electron? Can you at least pull information about another app that currently has focus? For instance, if the user is browsing a webpage in Chrome, it would be great to know that A) they're using chrome and B) the title of the webpage they're viewing.

在研究期间,我发现了以下问题:

During my research I found this question: Which app has the focus when a global shortcut is triggered

似乎作者使用nodObjc库获取了哪个应用程序的焦点?此信息在OSX上。除了其他人用来解决此问题的任何方法外,我特别好奇电子本身是否可以通过任何方式公开此信息而无需借助外部库。

It looks like the author there is using the nodObjc library to get this information on OSX. In addition to any approaches others are using to solve this problem, I'm particularly curious if electron itself has any way of exposing this information without resorting to outside libraries.

推荐答案

否,Electron不提供API来获取有关其他应用程序的信息。您需要直接访问本机平台API才能获取该信息。例如, Tockler 似乎是通过shell脚本执行的,尽管我个人更喜欢直接通过本机Node访问本机API。插件/模块或 node-ffi-napi

No, Electron doesn't provide an API to obtain information about other apps. You'll need to access the native platform APIs directly to obtain that information. For example Tockler seems to do so via shell scripts, though personally I prefer accessing native APIs directly via native Node addons/modules or node-ffi-napi.

这篇关于您如何获得有关其他正在运行或重点关注的应用程序的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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