Sample Header Ad - 728x90

How to switch to the 1st 2nd or 3rd app with specific name? (all 3 have the same name)

0 votes
2 answers
108 views
**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. -- 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
Asked by Oneechan69 (249 rep)
Dec 3, 2024, 02:54 AM
Last activity: Dec 4, 2024, 06:19 AM