node.js - 如何使用 Electron 在桌面上打开外部应用程序

标签 node.js reactjs electron desktop-application

我的 Electron 应用程序中有页面,我可以在其中显示可以记录的打开应用程序
apps page
我使用 DescktopCapturer.getSources() 方法获得的这些应用程序并在那里显示屏幕的 ID 和图标。
我想在选择其中一个后将它们显示在桌面顶部,例如我选择 Chrome 并且我需要使用 Electron 打开 chrome,我该怎么做?谢谢!)

最佳答案

我找到了我的问题的答案。

tell application "System Events" to tell process "${appName}"
   set frontmost to true
    windows where title contains "${name}"
    if result is not {} then perform action "AXRaise" of item 1 of result
end tell
如果您不需要按标题过滤,您可以这样做
tell application "System Events" to tell process "${appName}"
       set frontmost to true
       perform action "AXRaise" of item 1 of result
  end tell

关于node.js - 如何使用 Electron 在桌面上打开外部应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65989124/

相关文章:

audio - 如何将蓝牙音频 A2DP 路由到音频设备 MediaStream 中? (来自 Electron 应用程序)

node.js - 如何正确地将 Electron nodejs程序构建为.exe?

javascript - 使用nodejs,一个用户的更改可以同时反射(reflect)到其他用户

javascript - Android Socket客户端 Node js服务器

javascript - React Server Side Rendering App - 如何更新元数据

reactjs - react-highcharts 如何调用回流?

javascript - Electron - Firebase 不支持的浏览器

node.js - 在 node.js 中 require 如何与 new 运算符一起工作?

javascript - 在 Mocha 中 before 的范围问题

javascript - 在 React Native 中提升状态时卡住