How can I get the screen resolution?

You can use the command screen list, from Jon’s Commands:

screen size of (screen list)'s item 1

Which will return the resolution of the first monitor in your system.

You can also try this vanilla solution:

{word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number, Ã?¬
	word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height") as number}