!D.X_Size / !D.Y_Size

Reports the width and height of the current graphics window in pixels. The values are updated when the window is resized.