F1::
MsgBox % Explorer_GetSelection(hwnd)
return

; https://blog.csdn.net/liuyukuan/article/details/53399286
Explorer_GetSelection(hwnd="") {
  WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
  WinGetClass class, ahk_id %hwnd%
  if (process != "explorer.exe")
    return
  if (class ~= "Progman|WorkerW") {
    ControlGet, files, List, Selected Col1, SysListView321, ahk_class %class%
    Loop, Parse, files, `n, `r
      ToReturn .= A_Desktop "\" A_LoopField "`n"
  } else if (class ~= "(Cabinet|Explore)WClass") {
    for window in ComObjCreate("Shell.Application").Windows {
      try {
        if (window.hwnd==hwnd)
          sel := window.Document.SelectedItems
      } catch
        continue
    }
    for item in sel
      ToReturn .= item.path "`n"
  }
  return Trim(ToReturn,"`n")
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。