Opening folders with RunShell

Started by bobj, March 25, 2014, 12:51:22 PM

Previous topic - Next topic

bobj

I have developed a program which displays a list of directory names and gives the user the option of double-clicking the display line to open a given folder. I've been using RunShell to start a copy of explorer.exe and provide the full path for the directory to be opened. That works fine, but I'd like to avoid opening multiple copies of explorer.exe, and I'd also prefer that any new folder selected would open in the original explorer window that was open. Any ideas on how to accomplish that?

Deana

IntControl 31 can be used to return a tab-delimited list of Window ID's for all open Windows Explorer windows. Here is my undebugged attempt:

Code (winbatch) Select
directory = 'C:\temp' ; or ShortcutDir("personal")
if WinVersion(5) >= "2-6-0"
   winclass = "CabinetWClass"
   classcode = 1
else
   winclass = "ExploreWClass"
   classcode = 0
endif
a = IntControl( 31, classcode, 0, 0, 0 )  ;return list of ids of explorer windows
c = ItemCount( a, @TAB )
If c == 0
ShellExecute( 'explorer.exe',  '/separate,/e,':directory,  directory, @Normal ,   '' )
while FindWindow( winclass ) == ""    ;wait for it to come up
   TimeDelay( 0.1 )
endwhile
Else ;c >= 1
   d = 1
   while c < 1 && d < 500
      TimeDelay( 0.1 )
      a = IntControl( 31, classcode, 0, 0, 0 )
      c = ItemCount( a, @TAB )
      d = d + 1
   endwhile
   id1 = ItemExtract( 1, a, @TAB)
   WinActivate( id1 )   
   SendKeysTo( id1, "!d" )
   SendKeysTo( id1, directory )
   SendKeysTo( id1, "{enter}" )
Endif


Deana F.
Technical Support
Wilson WindowWare Inc.

bobj

Thank you! I see what you're trying to do and I should be able to integrate that into the rest of my app. I'll give it a shot and see how it looks.