This seems like a simple task but I cannot seem to produce the results looking for.
currently I have this code
Dim folderpath As String
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
folderpath = "C:\epds\WIP"
Process.Start("explorer.exe", folderpath)
End Sub
That's fine and it opens my folder path as indicated, however, if the instance of that folder is already open in the explorer how do I just make that window current instead of opening a new window explorer?
EDIT: This seemed to do the trick, thanks for pointing me in the right direction @Okuma.Scott
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindow( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowByClass( _
ByVal lpClassName As String, _
ByVal zero As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindowByCaption( _
ByVal zero As IntPtr, _
ByVal lpWindowName As String) As IntPtr
End Function
Dim folderpath As String
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
folderpath = "C:\epds\WIP"
'Process.Start("explorer.exe", folderpath)
Dim nWnd As IntPtr
Dim ceroIntPtr As New IntPtr(0)
Dim Wnd_name As String
Wnd_name = "WIP"
nWnd = FindWindow(Nothing, Wnd_name)
'show the info
If nWnd.Equals(ceroIntPtr) Then
Process.Start("explorer.exe", folderpath)
Else
AppActivate(Wnd_name)
SendKeys.SendWait("~")
End If
End Sub