Is possible to replace Explorer with XYplorer in file selection?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MIRKOSOFT
Posts: 334
Joined: 23 Sep 2014, 14:29

Is possible to replace Explorer with XYplorer in file selection?

14 Jan 2018, 20:03

Hi!

Longer time ago provided me my friend from this forum function with code which checks if is any file or files selected and use it in script. It works with Windows Explorer and Desktop.
Here's code:

Code: Select all

Selected_Files()
{
  ; Handles Explorer
  IfWinActive, ahk_class CabinetWClass
  {
    for window in ComObjCreate("Shell.Application").Windows
      if window.HWND = WinExist("A")
        this_window := window
    
    ; If multiple Items selected
    if(this_window.Document.SelectedItems.Count > 1)
    {
      these_files := ""
      for item in this_window.Document.SelectedItems
        these_files .= item.Path . "`n"
      
      return these_files
    }
    else
      return this_window.Document.FocusedItem.Path
  }
  
  ; Handles Desktop
  if(WinActive("ahk_class Progman") || WinActive("ahk_class WorkerW"))
  {
    ControlGet, selectedFiles, List, Selected Col1, SysListView321, A
    
    ; If multiple Items selected
    if InStr(selectedFiles, "`n")
    {
      these_files := ""
      Loop, Parse, selectedFiles, `n, `r
        these_files .= A_Desktop . "\" . A_LoopField . "`n"
    
      return these_files
    }
    else
      return A_Desktop . "\" . selectedFiles
  }
  else
    return false
}
by this function is possible to open selected file(s) in any app.
for example - by this code can open Notepad empty or with selected file(s):

Code: Select all

F1::
this_path := Selected_Files()		; get selected files(s)
if (this_path)
	Run, Notepad "%this_path%"	; if selected, Notepad opens selected file(s)
else
	Run, Notepad			; if nothing selected, opens clear empty Notepad
return
I'm using now as default explorer XYplorer and my Q is:
Is possible to modify code of function to use with XYplorer and leave desktop handling untouched?

Here's XYplorer info:

Code: Select all

Title:	D:\Commodore\Z64K\_SW\NEW - XYplorer 18.60.0100
class:	ahk_class ThunderRT6FormDC
exe:	ahk_exe XYplorer.exe
If anyone can help I'm thankful.
Miro

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, mikeyww and 181 guests