{"id":4593,"date":"2013-04-22T07:00:00","date_gmt":"2013-04-22T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2013\/04\/22\/getting-the-current-selection-from-an-explorer-window\/"},"modified":"2013-04-22T07:00:00","modified_gmt":"2013-04-22T07:00:00","slug":"getting-the-current-selection-from-an-explorer-window","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20130422-00\/?p=4593","title":{"rendered":"Getting the current selection from an Explorer window"},"content":{"rendered":"<p><P>\nToday&#8217;s Little Program prints the current selection\nin all open Explorer windows.\n(This is an alternative to the\n<A HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2004\/07\/20\/188696.aspx\">\nC++ version<\/A> that involves a ridiculous amount of typing.)\n<\/P>\n<PRE>\nvar shellWindows = new ActiveXObject(&#8220;Shell.Application&#8221;).Windows();\nfor (var i = 0; i &lt; shellWindows.Count; i++) {\n var w = shellWindows.Item(i);\n WScript.StdOut.WriteLine(w.LocationName);\n var sel = w.Document.SelectedItems();\n for (var j = 0; j &lt; sel.Count; j++) {\n  var item = sel.Item(j);\n  WScript.StdOut.WriteLine(item.Name);\n  WScript.StdOut.WriteLine(item.Path);\n }\n}\n<\/PRE>\n<P>\nI have no idea why you would want to do this,\nbut there you have it.\n(If you want the focused item rather than the selection, then get the\n<CODE>Focused&shy;Item<\/CODE> property.)\n<\/P>\n<P>\nOkay, maybe you can use this as a quick-and-dirty way\nto\n<A HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2013\/02\/04\/10390725.aspx\">\nget the parsing name for a shell item<\/A>:\nOpen an Explorer window,\nselect the item you are interested in, then run the script to see\nwhat gets printed out as the <CODE>Path<\/CODE>.\n<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s Little Program prints the current selection in all open Explorer windows. (This is an alternative to the C++ version that involves a ridiculous amount of typing.) var shellWindows = new ActiveXObject(&#8220;Shell.Application&#8221;).Windows(); for (var i = 0; i &lt; shellWindows.Count; i++) { var w = shellWindows.Item(i); WScript.StdOut.WriteLine(w.LocationName); var sel = w.Document.SelectedItems(); for (var j = [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-4593","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Today&#8217;s Little Program prints the current selection in all open Explorer windows. (This is an alternative to the C++ version that involves a ridiculous amount of typing.) var shellWindows = new ActiveXObject(&#8220;Shell.Application&#8221;).Windows(); for (var i = 0; i &lt; shellWindows.Count; i++) { var w = shellWindows.Item(i); WScript.StdOut.WriteLine(w.LocationName); var sel = w.Document.SelectedItems(); for (var j = [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/4593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=4593"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/4593\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=4593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=4593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=4593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}