osascript System Events Failed to list Processes That Have The Same Name

I ran the following script while both VSCode and Windsurf were open.

tell application "System Events"
	set electronProcesses to every application process whose name is "Electron"
	set outputText to ""
	repeat with p in electronProcesses
		set outputText to outputText & "Process: " & name of p
		set outputText to outputText & ", Displayed name: " & displayed name of p
		set outputText to outputText & ", Frontmost: " & frontmost of p & "
"
	end repeat
	return outputText
end tell

The script incorrectly returned two Electron processes, where both were showing Windsurf as the displayed name. The output of the above script is:

Process: Electron, Displayed name: Windsurf, Frontmost: false
Process: Electron, Displayed name: Windsurf, Frontmost: false

Separately, both Windsurf and VSCode share the same process name (Electron) but have different displayed names. This issue appears to affect how the frontmost application is detected, when using the following script:

set frontApp to first application process whose frontmost is true

The frontApp is incorrectly returned when switching between VSCode and Windsurf.

Answered by DTS Engineer in 840096022

I recommend that you file a bug about this. Please post your bug number, just for the record.

In the meantime, what happens if you do this:

id of every application process whose name is "Electron"

Do you get unique IDs?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I recommend that you file a bug about this. Please post your bug number, just for the record.

In the meantime, what happens if you do this:

id of every application process whose name is "Electron"

Do you get unique IDs?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It does get unique IDs. The problem looks to be when i getting the process object directly like

set electronProcesses to every application process whose name is "Electron"

The processes output from the script above are identical but result from

id of every application process whose name is "Electron"

or

displayed name of processes whose name is "Electron"

are correctly identify different processes

Bug number: FB17672902

I can reproduce this error.

set theList to ( processes whose frontmost is true )
log ( get id of item 1 of theList )

and

set frontApp to first process  whose frontmost is true
log ( get id of frontApp)

gives different results then

repeat with theProcess in processes whose frontmost is true
       set frontApp to theProcess
end repeat
log ( get id of frontApp )

when multiple applications (i.e. VSCode and another electron app) are both running.

osascript System Events Failed to list Processes That Have The Same Name
 
 
Q