mandrigin / AlfredSwitchWindows

An application for using in Alfred workflow to enumerate and switch between windows on OSX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible raise single window to the front?

calfzhou opened this issue · comments

Sometimes there are several windows for one application, now it will bring every window to the front in a big stack, it would be better to be able to bring the single selected window.

Thanks for the awesome workflow!

this might work:

on alfred_script(q)

set argv to extract_argv(q, "|||||")

set proc to item 1 of argv
set tabIndex to item 2 of argv as integer
set windowName to item 3 of argv

try
	tell application "System Events"
		with timeout of 0.1 seconds
			tell process proc to perform action "AXRaise" of window windowName
			do shell script "open -a '" & (name of my application proc) & "'"
		end timeout
	end tell
end try

end alfred_script

on extract_argv(source_string, new_delimiter)
	set backup to AppleScript's text item delimiters
	set AppleScript's text item delimiters to new_delimiter
	set argv to every text item of source_string
	set AppleScript's text item delimiters to backup
	return argv
end extract_argv

@calfzhou Works for me, many thanks!

commented

@kerryj89 Is it still working on Big Sur?

@kerryj89 Is it still working on Big Sur?

I am not on Big Sur, sorry.

commented

@kerryj89 It works well on Big Sur. Thank you