{"id":69313,"date":"2005-07-26T15:42:00","date_gmt":"2005-07-26T15:42:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/07\/26\/how-can-i-tile-the-windows-on-the-desktop\/"},"modified":"2005-07-26T15:42:00","modified_gmt":"2005-07-26T15:42:00","slug":"how-can-i-tile-the-windows-on-the-desktop","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-tile-the-windows-on-the-desktop\/","title":{"rendered":"How Can I Tile the Windows on the Desktop?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! I have a script that opens nine different command windows in order to monitor performance. How can I tile those windows horizontally after they\u2019ve all been opened?<BR><BR>&#8212; AM<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, AM. You know, one of the Scripting Guys might not be much when it comes to scripting, but he <I>is<\/I> a master of one thing: he has a near-monopoly on totally useless knowledge. For example, he knows all nine verses of <I>My Darlin\u2019 Clementine<\/I>; heck, he can sing <I>O Come All Ye Faithful<\/I> in Latin. He knows the first &#8211; and last &#8211; names of all the castaways on the original <I>Gilligan\u2019s Island<\/I>; he even knows Paul McCartney\u2019s first name. (And, no, it\u2019s <I>not<\/I> Paul.) Every day this Scripting Guy comes to work hoping someone will ask him who came up with the story of Rudolph the Red-Nosed Reindeer. Every day he goes home disappointed.<\/P>\n<P>But today is different. Many, many years ago this same Scripting Guy learned how to tile windows using a script. Not being particularly imaginative, he couldn\u2019t think of a scenario in which this might prove useful. Therefore, he decided he\u2019d just wait until someone asked him how to tile windows using a script. He\u2019s been waiting a long, long time.<\/P>\n<P>AM, you\u2019ve at last made this Scripting Guy one happy camper. You want to know how to horizontally tile windows? All you had to do was ask:<\/P><PRE class=\"codeSample\">Set objShell = CreateObject(&#8220;Shell.Application&#8221;)\nobjShell.TileHorizontally\n<\/PRE>\n<P>Good point: after all these years you\u2019d expect something more dramatic than just two lines of code. But that\u2019s all it takes. You simply create an instance of the <B>Shell.Application<\/B> object and then call the <B>TileHorizontally<\/B> method. If you want to tile your windows vertically, you can use this code:<\/P><PRE class=\"codeSample\">Set objShell = CreateObject(&#8220;Shell.Application&#8221;)\nobjShell.TileVertically\n<\/PRE>\n<P>And if you want to cascade your windows, use this code:<\/P><PRE class=\"codeSample\">Set objShell = CreateObject(&#8220;Shell.Application&#8221;)\nobjShell.CascadeWindows\n<\/PRE>\n<P>Pretty easy but, then again, no one said you had to be Professor Roy Hinkley in order to tile windows. (Yes, Roy Hinkley <I>was<\/I> the Professor on <I>Gilligan\u2019s Island<\/I>.)<\/P>\n<P>Two minor caveats here. First, these methods work only on the local computer; that\u2019s because you can\u2019t instantiate the Shell object on remote machines. But unless you were planning on having some fun by tiling and re-tiling the windows on someone else\u2019s computer that shouldn\u2019t make much difference.<\/P>\n<P>In addition, we should point out that this script will tile <I>all<\/I> the windows on the computer, not just the nine command windows you started with your script. But that\u2019s true even if you tile windows manually (by right-clicking the Taskbar and then clicking <B>Tile Windows Horizontally<\/B> or <B>Tile Windows Vertically<\/B>). Something you\u2019ll just have to live with.<\/P>\n<P>Just to show you what this might look like in real life, we\u2019ve created a script that opens nine command windows and then tiles the desktop. Note that we added a <B>Wscript.Sleep<\/B> statement and paused the script for 5 seconds (5,000 milliseconds) before tiling the windows; we did that to make sure all nine command windows were open and visible onscreen before we tiled them.<\/P>\n<P>Here\u2019s what the code looks like:<\/P><PRE class=\"codeSample\">Set objWSHShell = CreateObject(&#8220;Wscript.Shell&#8221;)<\/p>\n<p>For i = 1 to 9\n    objWSHShell.Run &#8220;%comspec% \/k&#8221;\nNext<\/p>\n<p>Wscript.Sleep 5000<\/p>\n<p>Set objShell = CreateObject(&#8220;Shell.Application&#8221;)\nobjShell.TileHorizontally\n<\/PRE>\n<P>And here\u2019s what the desktop looks like after running the script:<\/P><IMG border=\"0\" alt=\"Windows Desktop\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/tiles.jpg\" width=\"400\" height=\"300\"> \n<P><BR>We\u2019ve waited a long time to see a picture like that.<\/P>\n<P>Oh, and one more thing: it\u2019s James. James Paul McCartney. Thanks for asking!<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! I have a script that opens nine different command windows in order to monitor performance. How can I tile those windows horizontally after they\u2019ve all been opened?&#8212; AM Hey, AM. You know, one of the Scripting Guys might not be much when it comes to scripting, but he is a master of [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[16,3,707,5],"class_list":["post-69313","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-desktop-management","tag-scripting-guy","tag-shell-application","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! I have a script that opens nine different command windows in order to monitor performance. How can I tile those windows horizontally after they\u2019ve all been opened?&#8212; AM Hey, AM. You know, one of the Scripting Guys might not be much when it comes to scripting, but he is a master of [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=69313"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69313\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=69313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=69313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=69313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}