Sizing and locating window for any application.

I use the following script in a service workflow to locate and size the active window for Safari:

on run {input, parameters}

tell application "Safari"
	tell window 1
		set bounds to {0, 0, 1250, 930}
	end tell
end tell

return input

end run

I would like to have a single service that would apply to the active window of whichever application I was using at the moment. Is this possible?

Thanks for your help Fredrik71. When running the script I now get an error message “Can’t set bounds of window to {0, 0, 1250, 930}”. This occurs regardless of the app from which the workflow is activated. This is a copy of the new script:

on run {input, parameters}

tell application "System Events" to set currentApplication to name of first application process whose frontmost is true

tell application currentApplication
	tell window
		set bounds to {0, 0, 1250, 930}
	end tell
end tell

return input

end run

This variation should work for you

property theBounds : {{0, 0}, {1250, 930}}

tell application "System Events" to tell window 1 of (process 1 whose it is frontmost) to ¬
	set {position, size} to theBounds

Thanks again! In addition to ignorance I was careless! Adding “1” solved the problem and I now have the script I wanted.