AlfredSwitchWindows icon indicating copy to clipboard operation
AlfredSwitchWindows copied to clipboard

Is it possible raise single window to the front?

Open calfzhou opened this issue 5 years ago • 5 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!

calfzhou avatar Apr 21 '20 15:04 calfzhou

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 avatar Apr 21 '20 16:04 calfzhou

@calfzhou Works for me, many thanks!

kerryj89 avatar Jun 29 '20 18:06 kerryj89

@kerryj89 Is it still working on Big Sur?

mohok avatar Dec 25 '20 12:12 mohok

@kerryj89 Is it still working on Big Sur?

I am not on Big Sur, sorry.

kerryj89 avatar Dec 25 '20 15:12 kerryj89

@kerryj89 It works well on Big Sur. Thank you

mohok avatar Jan 04 '21 07:01 mohok