如何以编程方式打开从 Electron DesktopCapurer.getSources 获得的窗口

问题描述

我正在使用 MAC; 嗨,我正在使用 DesktopCapturer 来获取我可以记录的所有窗口,并且在使用 getSources 方法之后,我得到了类似

appIcon: null
display_id: ""
id: "window:2643:0"
name: "cast – preload.ts"
thumbnail: {toPNG: ƒ,toJPEG: ƒ,toBitmap: ƒ,getBitmap: ƒ,getScaleFactors: ƒ,…}
__proto__: Object

这是一个 WebStorm 应用程序。如何以编程方式打开此应用程序在桌面上移动。

解决方法

大家好,我找到了使用 applescripts 的解决方案 首先你应该得到所有打开的带有窗口标题的应用

set tmpList to {}
set windowTitles to {}
set visibleProcesses to {}
set visibleProcessesWithWindows to {}
set processNamesAndWindowTitles to {}
set processNamesAndWindowTitlesLists to {}
tell application "System Events"
    set visibleProcesses to name of (every process whose visible is true)
    repeat with processName in visibleProcesses
        if (count windows of process processName) is not 0 then
            set end of visibleProcessesWithWindows to processName
        end if
    end repeat
    repeat with processName in visibleProcessesWithWindows
        set end of windowTitles to (name of every window of process processName)
        set end of tmpList to (processName as list) & windowTitles
        set end of processNamesAndWindowTitles to tmpList
        set windowTitles to {}
        set tmpList to {}
    end repeat
end tell
repeat with aItem in processNamesAndWindowTitles
    set end of processNamesAndWindowTitlesLists to item 1 of aItem
end repeat
return processNamesAndWindowTitlesLists

您应该通过标题找到您的应用程序名称作为响应

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

制作在最前面

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...