From: "Marvin Gülker" Date: 2009-11-11T19:49:51+09:00 Subject: Re: Changing screen resolution through Ruby Saturn wrote: > On Nov 11, 12:26�am, Marvin G�lker wrote: >> >> 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 >> -- >> Posted viahttp://www.ruby-forum.com/. > > > > 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%28VS.85%29.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 -- Posted via http://www.ruby-forum.com/.