Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Oneechan69

macrumors 6502
Original poster
Mar 29, 2022
285
34
US
NOT three windows of one app, I use Neohub which launches instances of the Neovide app, which can't have multiple windows. There are 3 instances of Neovide on my dock, and it shows 3 times in Activity Monitor. I want 3 hotkeys to switch to the 1st 2nd or 3rd instance. I asked an LLM for an AppleScript to do so and this is what it came up with, but it doesn't work when I changes the number 2 to a 1 or 3.


AppleScript:
-- Define the search string
set searchString to "Neovide"

-- Get the list of running applications
tell application "System Events"
set appList to name of every application process
end tell

-- Filter the list to find applications whose names contain the search string
set matchingApps to {}
repeat with appName in appList
if appName contains searchString then
copy appName to the end of the matchingApps
end if
end repeat

-- Get the second matching application
set secondApp to item 2 of matchingApps
-- Switch to the second matching application
tell application secondApp
activate
end tell
 
Why not just add a "1", "2", and "3" AFTER the existing (same) name?

I change app names now and then, doesn't seem to matter much...
 
I think the OP is trying to find a way to distinguish between separate instances of the Neovide app.
Can you change the names of multiple instances of one app, so you can use hotkeys to switch between separate instances of the same app?
@Oneechan69: Am I understanding what you want to do?

Seems like you would need to set up hotkeys, every time you launch multiple instances.
 
Looks like in the AppleScript, it's the
Code:
copy appName to the end of the matchingApps
line that is the problem, because that will presumably just produce a list like: "Neovide", "Neovide", "Neovide". You need to build a list of PIDs (process IDs) or something else that's unique and distinguishing.
 
Last edited:
Looks like in the AppleScript, it's the
Code:
copy appName to the end of the matchingApps
line that is the problem, because that will presumably just produce a list like: "Neovide", "Neovide", "Neovide". You need to build a list of PIDs (process IDs) or something else that's unique and distinguishing.
Oh that's why it doesn't work, and I checked that's what the scriipt is doing, the list is just Neovide Neovide Neovide.
 
Does that even work? Can you change the name of an instance of an app (or, in this case 3 separate instances) without changing the name of the app itself?
 
Here's a thought:
I would try to make a separate 'space', some call it 'desktop', for each of the instances. Then I'd use two-finger swipe (on mouse) or opt-arrow to move between them.

Hit F3 (mission control) and move the mouse up top to reveal current spaces.
Click the plus sign three times to create three new empty spaces.
(Enable this in System settings: Desktop&Dock: Group spaces by app.)
Now, when you go to Mission Control, you'll see the available spaces at the top, and any active app and its open windows grouped by app, and with a little app symbol underneath.
Drag one Neovide symbol to an empty space, and another, and another. Each instance of Neovide and its windows will reside on its own space, and you can quickly move between them with a two-finger swipe or opt-arrow, even if they're all called 'Neovide'.

Here's a video from Macmost on Mission Control:
 
I got an answer on StackExchange to use AppleScript which works. I edited it to toggle the window rather than just show it.

AppleScript:
set searchString to "Neovide"
set theIndex to 2

tell application "System Events"
    try
        set theId to id of process theIndex whose name is searchString
        if frontmost of process id theId then
            set visible of process id theId to false
        else
            set frontmost of process id theId to true
        end if
    end try
end tell
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.