How to get screen resolution (height, width) in ruby script?
On Linux:
x, y = `xrandr`.scan(/current (\d+) x (\d+)/).flatten
On windows, use WIN32OLE and such.
This is how I solved my problem of getting resolution. As I was using Ruby 2.3.0, I cannot use DL module(as its been depricated). Following is by using Fiddle
usr32=Fiddle::dlopen("user32")
gsm=Fiddle::Function.new(usr32["GetSystemMetrics"],[Fiddle::TYPE_LONG],Fiddle::TYPE_LONG)
x= gsm.call(0)
y= gsm.call(1)
puts x,y
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