本帖最后由 CrLf 于 2016-11-10 11:04 编辑
bat+JS:- 1>1/* :
- @echo off
- cscript -nologo -e:jscript "%~0" 0
- pause & exit /b
- */
- var Shell = new ActiveXObject("Shell.Application")
- var win = new Enumerator(Shell.Windows())
-
- while (!win.atEnd()){
- var selected = new Enumerator(win.item().Document.SelectedItems())
-
- while (!selected.atEnd()){
- WSH.Echo(selected.item().Path)
- selected.moveNext()
- }
-
- win.moveNext()
- }
复制代码 bat+VBS:- <!-- :
- @echo off
- mshta "%~f0" | more
- pause & exit /b
- -->
-
- <script src="http://bathome.net/lib/diy/hide.js"></script>
- <script src="http://bathome.net/lib/diy/WSH.js"></script>
- <script language="VBScript">
- For Each win In CreateObject("Shell.Application").Windows
- For Each selected In win.Document.SelectedItems
- WSH.Echo(selected.Path)
- Next
- Next
- </script>
复制代码 日常使用的话,强烈推荐 ahk+VBS,我用的就是类似方案。按 win+shift+C,复制当前窗口中所选文件的路径:- --------------------------这部分保存为 ahk--------------------------
- #+c::
- hwnd := getActiveWindowHWND()
- run, ".\getSelectedFilePath.vbs" %hwnd%;
- return
-
- getActiveWindowHWND()
- {
- WinGetActiveTitle, title
- WinGet, hwnd, ID, %title%
- hwnd:=hwnd+0
- return hwnd
- }
- --------------这部分保存为 getSelectedFilePath.vbs---------------
- Set Shell = CreateObject("Shell.Application")
- hwnd = CInt(WSH.Arguments(0))
-
- For Each win In Shell.Windows
- If Not(hwnd) Or win.HWND Then
- For Each selected In win.Document.SelectedItems
- WSH.Echo(selected.Path)
- Next
- End If
- Next
复制代码
|