How to programmatically open a window which I get from Electron DesktopCapurer.getSources

100 views Asked by At

I'm using MAC; Hi, I'm using DesktopCapturer to get all windows I can record and after using getSources method I get smth like

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

Which is a WebStorm application. How can programmatically open this of move this application on top of desktop.

1

There are 1 answers

0
Alex Kirillov On BEST ANSWER

Hi guys I found solution using applescripts First of all u should get all open app with window's titles

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

Than u sould find your application name by title in response

And do

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

To make in frontmost