How to open chrome browser with given sizes

I am trying to launch chrome browser with a single tab window using this c# code:

Process process = new Process();
process.StartInfo.FileName = "chrome";
process.StartInfo.Arguments = url + " --new-window --window-size=640,480";
process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
process.Start();

The new window opens, but the size does not correspond to the size I passed along as argument. Does the command line switch of chrome "--window-size=x,y" not work?

Is there a different method available for this purpose.


Looks like there is a know bug in chrome commandline switch.

Ref: http://www.ericdlarson.com/misc/chrome_command_line_flags.html "... Start the browser maximized, regardless of any previous settings. TODO(pjohnson): Remove this once bug 1137420 is fixed. We are using this as a workaround for not being able to use moveTo and resizeTo on a top-level window. --start-maximized ..."

One of the workaround that I can think of is as suggested by sorpigal using cmdow. Set The Window Position of an application via command line

链接地址: http://www.djcxy.com/p/21166.html

上一篇: 在MySQL Workbench的结果网格中保存列的宽度

下一篇: 如何打开指定大小的Chrome浏览器