How can I get screen resolution (height, width) in pixels?
You could use commad-line interface to WMI
> system("wmic desktopmonitor get screenheight")
ScreenHeight
900
You could capture result with system
(scr_width <- system("wmic desktopmonitor get screenwidth", intern=TRUE))
# [1] "ScreenWidth \r" "1440 \r" "\r"
(scr_height <- system("wmic desktopmonitor get screenheight", intern=TRUE))
# [1] "ScreenHeight \r" "900 \r" "\r"
With multiple screens, the output is, e.g.,
[1] "ScreenWidth \r" "1600 \r" "1600 \r" ""
We want all but the first and last values, converted to numbers
as.numeric(c(
scr_width[-c(1, length(scr_width))],
scr_height[-c(1, length(scr_height))]
))
# [1] 1440 900
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With