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.
Commands from External Scripts?
Moderators: fgagnon, nikos, Site Mods
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).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.
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}")
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.