Changing screen resolution through Ruby

S

Saturn

Hi All,
Thanks in advance to all the helpers.

I want to change screen resolution using ruby or selenium.

Please help me and let me know if it is possible in either way.
 
M

Marnen Laibow-Koser

Saturn said:
Hi All,
Thanks in advance to all the helpers.

I want to change screen resolution using ruby or selenium.

Please help me and let me know if it is possible in either way.

Do you need to change screen resolution, or simply window size?
Best,
 
M

Marvin Gülker

Saturn said:
Hi All,
Thanks in advance to all the helpers.

I want to change screen resolution using ruby or selenium.

Please help me and let me know if it is possible in either way.

For Windows, there's a WinAPI function I think, but I don't know about
Linux or Mac OS.

Btw. is there any good reference on how to manipulate the X server? I'd
like to add some more automation functions to my xdo gem, but I wasn't
able to find out how to interact directly with X...

Marvin
 
S

Saturn

For Windows, there's a WinAPI function I think, but I don't know about
Linux or Mac OS.

Btw. is there any good reference on how to manipulate the X server? I'd
like to add some more automation functions to my xdo gem, but I wasn't
able to find out how to interact directly with X...

Marvin



Yes I need to change screen resolution itself like from 1280 X 800 to
800 X 600.
I can read the resolutions through win API but can't write
If you any way to change please let me know
- thanks
 
M

Marvin Gülker

Saturn said:
Yes I need to change screen resolution itself like from 1280 X 800 to
800 X 600.
I can read the resolutions through win API but can't write
If you any way to change please let me know
- thanks

I've searched through Google and the Windows API, and found that this
function can do the trick: ChangeDisplaySettings
http://msdn.microsoft.com/en-us/library/dd183411(VS.85).aspx

An article on how to use it I found here:
http://msdn.microsoft.com/en-us/library/ms812499.aspx

You could use the function itself easily, but building up the DEVMODE
struct seems to be very complex (note that I'm using the win32-api gem
for such tasks). In C, you only have to change the values of a DEVMODE
you want to change, but since you can't access a struct from within
Ruby, you have to build up the whole struct and then use Array#pack to
turn it into a string which you can pass into the WinAPI function.
That's no problem with easy structs like the POINT struct - just do [0,
0].pack('LL') - but I've never found out how to manage that with complex
ones, especially with ones containing other structs. If someone knows
how to simplify that (besides a C extension written for the
MSVC-compiled Ruby version), please let me know.

Marvin
 
S

Saturn

Thanks Marvin,
As you said problem is same here, I am unable to make it's arguments:
I tried following:
require 'Win32API'
@e = Win32API.new("user32","ChangeDisplaySettings", ['I','I'], 'I' )
p @e.call(800, 600)

it's giving me error Or nothing if I remove p from the last line.

If any body has a clean solution like initialized all other DEVMODE
settings with default and changing only resolution part please let me
know.
Thanks for helping me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top