我有以下代码,它将启动 Windows 资源管理器并选择一个文件并最大化资源管理器。然后它将查找 Windows 资源管理器并将其最小化。我做了最大化-最小化,这样我就不必手动执行此操作(我知道很懒)。我在代码中设置了此设置,仅在文件夹未打开时触发。如果它是打开的,则只需运行最小化部分。这是代码:
If Not FolderIsOpen Then
Dim curProcess As Process = New Process()
With curProcess
With .StartInfo
.FileName = "explorer.exe"
Dim MinimizeName As String = RegScoringWorkbookName.Replace(".xlsm", ".zip")
.Arguments = String.Format("/select, ""{0}""", MinimizeName)
.WindowStyle = ProcessWindowStyle.Maximized
End With
.Start()
End With
Thread.SpinWait(100000000)
For Each IWindow As InternetExplorer In SHWindows
If IWindow.Name = "Windows Explorer" Then
Dim GetURIPath As New Uri(IWindow.LocationURL)
If GetURIPath.LocalPath.ToLower.Equals(FolderName) Then
ShowWindow(CType(IWindow.HWND, IntPtr), SW_SHOWMINIMIZED)
Exit For
End If
End If
Next IWindow
Else
For Each IWindow As InternetExplorer In SHWindows
If IWindow.Name = "Windows Explorer" Then
Dim GetURIPath As New Uri(IWindow.LocationURL)
If GetURIPath.LocalPath.ToLower.Equals(FolderName) Then
'Code here to select the targeted file
ShowWindow(CType(IWindow.HWND, IntPtr), SW_SHOWMINIMIZED)
Exit For
End If
End If
Next IWindow
End If
所以,我的问题是,是否可以告诉资源管理器在已打开的 Windows 资源管理器上选择一个文件?
你可以直接把它掏出来。
Dim i = Shell("explorer /select, C:\Folder\File.exe", AppWinStyle.NormalFocus)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)