Commands from External Scripts?

Support for xplorer² free lite version

Moderators: fgagnon, nikos, Site Mods

Post Reply
tasmith
New Member
Posts: 1
Joined: 2012 Mar 01, 19:46

Commands from External Scripts?

Post by tasmith »

I've been writing some personal programs, and I was wondering if there were any decent tricks for issuing commands to Xplorer2 from another application.  I only know the basics of COM interop and other such technologies, but I assume nothing like that is available.  (I imagine it would be a lot of work for little payout...maybe even security issues? Probably not a feature any small developers implement.)

At the moment I am merely try to get Xplorer to navigate to a filepath specified by my script.  I know this only takes a moment to do by hand, but it would really make the workflow nice and clean to do it automatically.

I am aware of the command line flags for specifying panes at launch, but I would like this to not open a new window.  I am currently using VB on Windows, so SendKeys is an option, but that seems to be a messy route at best.

If there aren't any good tricks available, oh well.  'Tis a wonderful product nonetheless, and you have my praise (As well as my forthcoming upgrade to pro!) for such thoughtful work.
Kilmatead
Platinum Member
Platinum Member
Posts: 4580
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

tasmith wrote:At the moment I am merely try to get Xplorer to navigate to a filepath specified by my script. ~ I am currently using VB on Windows, so SendKeys is an option, but that seems to be a messy route at best.
You are correct in thinking that there's no open API for x2, however, scripters have been having fun working around that by using the languages AutoIt and AutoHotKey (which one you like better tends to boil down to syntax-preference).

The benefit of these languages is that they are designed to communicate directly with specific control ID's within specific windows, rather than (as you pointed out) "blindly" sending keystrokes to an instance and "hoping they hit something".  Communicating directly with a control is much more reliable.  I don't know if VB has equivalent commands, but you'll get the gist of it.

For example, using AutoIt, to navigate to a specific folderpath (as you wished), you'd do something like this (being sure the x2 address-bar is visible first, of course):

Code: Select all

ControlFocus("[CLASS:ATL:ExplorerFrame]", "", "[CLASS:Edit; INSTANCE:1]")
ControlSend("[CLASS:ATL:ExplorerFrame]", "", "[CLASS:Edit; INSTANCE:1]", "C:" & "{ENTER}")
Now, to be fair, no matter how tricky we get, controlling x2 in this fashion is still the bull-in-a-china-shop approach (even a well-mannered bull) - which is why it's easier to just use bookmarks. :shrug:  That said, for a more robust example using this method to open a new tab by middle-mouse-clicking on it, see this example (written in AutoHotKey), so almost anything is possible if you put your mind to it.

While the most common use of this scripting approach is using (the x2 user-base created) MenuHack (or Menu++) utilities for making toolbar buttons out of any x2 command (not just the "common" ones available by default) integrating scripts into x2 to process files any way you wish is fairly easy (see this or this as more complex examples).  And, of course, you could always write your own shell extensions to really interact properly, but that's (obviously) a rather advanced thing to do.  (You may also of course directly interact with Window's shell COM elements via your scripts should you so desire.)

Also, just to snub the nose of authority, some enterprising users have found more funky methods of bending x2 to our iron will, enabling all sorts of fun for a rainy day's experimentation. :wink:
Post Reply