Get_path_from_dopus - Paste File Path Anywhere From Dopus

Tool Name: get_path_from_dopus.exe

Scenario: Very often you want to paste a file path somewhere (such as in a text editor or in a file dialog). However you want to use the familiar Dopus interface to choose the file. And so you want to minimize the keystrokes required to switch to Dopus, copy the path of the file, switch back to your original application, and paste the path of the file you chose in Dopus.

Usage: Run get_path_from_dopus.exe and the program will stay resident in a system tray icon. Then press ScrollLock in any application (herein named "original application"). The original application window ID will be saved and you will be switched to Dopus. A transparent message on the bottom right notifies you that you are in file selection mode and tells you the hotkeys to further use. Select a file in Dopus and press ScrollLock again - you will be switched back to the original application and the path of the file will be automatically copied from Dopus and pasted in the original application.

Download: get_path_from_dopus.zip (247 KB)
Written and compiled with Autohotkey Classic (source .ahk file is included if you want to change the Hotkeys and recompile).
You only need the file get_path_from_dopus.exe - you do not need AutoHotkey installed to use this tool - since the EXE file is already compiled with AutoHotkey Compiler.

AutoHotkey Source Code:

#NoEnv
#SingleInstance Force
SetBatchLines -1
ListLines Off
SetScrollLockState,AlwaysOff

;---------------------------------------------------------------
; get_path_from_dopus.ahk
;---------------------------------------------------------------
; Scenario -
; Very often you want to paste a file path somewhere (such as in a text editor or in a file dialog). However you want to use the familiar Dopus interface to choose the file. And so you want to minimize the keystrokes required to switch to Dopus, copy the path of the file, and switch back to your original application.
;---------------------------------------------------------------
; Usage -
; 1. Press ScrollLock in any application (herein named "original application"). You will be taken to Dopus.
; 2. Select a file in Dopus and then press:
;     3a. ScrollLock - to paste the selected file path (without quotes) back into your original application.
;     3b. Shift+ScrollLock - to paste the selected file path (with quotes) back into your original application.
;     3c. Alt+ScrollLock - to cancel the operation
;---------------------------------------------------------------
; Written in AutoHotkey Classic
;---------------------------------------------------------------

mode_get_path_from_dopus := false

Return ;end of auto-execute

*ScrollLock::

	If(GetKeyState("Alt", "P")) { ; Cancel get_path_from_dopus if modifier down
		If(mode_get_path_from_dopus) {
			WinActivate, ahk_id %get_path_from_dopus_winid%
			CornerNotify_ModifyTitle("get_path_from_dopus - cancelled")
			CornerNotify_ModifyMessage("")
			SetTimer, CornerNotify_FadeOut_Destroy, 10
			mode_get_path_from_dopus := false
		} Else {
			CornerNotify_ModifyTitle("get_path_from_dopus - can't cancel`, not running anyways")
			CornerNotify_ModifyMessage("")
			SetTimer, CornerNotify_FadeOut_Destroy, 10
		}
		Return
	}

	If(mode_get_path_from_dopus) {
		Clipboard= ;empty the clipboard so ClipWait has something to wait for
		Run, "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd Clipboard SET {filepath$}
		ClipWait, 0.1
		If ErrorLevel {
			CornerNotify_ModifyTitle("get_path_from_dopusT - error no file selected")
		} Else {
			file := Clipboard
			clipboardrewrite := 0
			If(GetKeyState("Shift", "P")) {
				pastewithquotes := true
			} Else {
				pastewithquotes := false
			}
			If(pastewithquotes) { ; Add quotes
				If(SubStr(file,0,1)<>"""") {
					file := """" . file
					clipboardrewrite := 1
				}
				If(SubStr(file,StrLen(file),1)<>"""") {
					file := file . """"
					clipboardrewrite := 1
				}
				If(clipboardrewrite) {
					Clipboard := file
				}
			} Else { ; Remove quotes
				If(SubStr(file,0,1)="""") {
					StringTrimLeft, file, file, 1
					clipboardrewrite := 1
				}
				If(SubStr(file,StrLen(file),1)="""") {
					StringTrimRight, file, file, 1
					clipboardrewrite := 1
				}
				If(clipboardrewrite) {
					Clipboard := file
				}
			}

			WinActivate, ahk_id %get_path_from_dopus_winid%
			WinWaitActive, ahk_id %get_path_from_dopus_winid%,,2 ; wait 2 seconds
			if(ErrorLevel) {
				CornerNotify_ModifyTitle("get_path_from_dopus - error`, cancelling")
				CornerNotify_ModifyMessage("Could not switch back to %get_path_from_dopus_process%")
				SetTimer, CornerNotify_FadeOut_Destroy, 10
			} Else {
				Send, ^v
				If(pastewithquotes) { ; Add quotes
					CornerNotify_ModifyTitle("get_path_from_dopus - done`, pasted with quotes")
					CornerNotify_ModifyMessage(file)
					SetTimer, CornerNotify_FadeOut_Destroy, 10
				} Else {
					CornerNotify_ModifyTitle("get_path_from_dopus - done`, pasted")
					CornerNotify_ModifyMessage(file)
					SetTimer, CornerNotify_FadeOut_Destroy, 10
				}
			}
			mode_get_path_from_dopus := false
		}

	} Else{
		WinGet, get_path_from_dopus_winid, ID, A
		WinGet, get_path_from_dopus_process, ProcessName, ahk_id %get_path_from_dopus_winid%
		IfWinExist, ahk_class dopus.lister
		{
			WinActivate, ahk_class dopus.lister
		} Else {
			Run, "C:\Program Files\GPSoftware\Directory Opus\dopus.exe"
			;Run, "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd Go C:\ newtab=findexisting
			Run, "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd Go LASTACTIVELISTER
		}
		CornerNotify_Create("get_path_from_dopus - waiting for selection in dopus", "Window To Paste In: " . get_path_from_dopus_process . "`nScrollLock - paste selected path`nShift+ScrollLock - paste selected path with quotes`nAlt+ScrollLock - cancel")
		mode_get_path_from_dopus := true
	}
Return

;---------------------------------------------------------------
; CORNERNOTIFY
;---------------------------------------------------------------
CornerNotify_Create(title, message) {
	global
	CornerNotify_Destroy() ; make sure an old instance isn't still running or fading out
	Gui,+AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
	cornernotify_hwnd := WinExist()
	;WinGet, get_path_from_dopus_winid, ID, A
	WinSet, ExStyle, +0x20 ; WS_EX_TRANSPARENT make the window transparent-to-mouse
	WinSet, Transparent, 160
	curtransp := 160
	Gui,Color, 202020 ;background color
	Gui,Font, c5C5CF0 s17 wbold, Arial
	Gui,Add, Text, x20 y12 vcornernotify_title, %title%
	Gui,Font, cF0F0F0 s15 wnorm
	Gui,Add, Text, x20 y56 vcornernotify_msg, %message%
	Gui,Show, NoActivate W700
	WinGetPos,ix,iy,w,h, ahk_id %cornernotify_hwnd%
	;x := A_ScreenWidth-w
	;y := A_ScreenHeight-h
	; Use MonitorWorkArea instead to get the area not taken by task bar
	SysGet, Mon, MonitorWorkArea
	x := MonRight - w
	y := MonBottom - h
	WinMove, ahk_id %cornernotify_hwnd%,,x,y
}
CornerNotify_ModifyTitle(title) {
	global
	GuiControl,Text,cornernotify_title, %title%
	GuiControl,Move,cornernotify_title, w%w% ;resize control width to width of GUI
}

CornerNotify_ModifyMessage(message) {
	global
	GuiControl,Text,cornernotify_msg, %message%
	GuiControl,Move,cornernotify_msg, w%w% ;resize control width to width of GUI
}

CornerNotify_Destroy() {
	global
	curtransp := 0
	Gui, Destroy
	SetTimer, CornerNotify_FadeOut_Destroy, Off
}

CornerNotify_FadeOut_Destroy:
	If(curtransp > 0) {
		curtransp := curtransp - 4
		WinSet, Transparent, %curtransp%, ahk_id %cornernotify_hwnd%
	} Else {
		Gui, Destroy
		SetTimer, CornerNotify_FadeOut_Destroy, Off
	}
Return

This looks handy, whats the procedure for installing into opus? newbe

You can place the exe in your /startup folder ("auto start"). So it works rather "external".

Run get_path_from_dopus.exe and the program will stay resident in a system tray icon. Then press ScrollLock in any application where you want to eventually paste a path that you select in Dopus.

If you could make some change, that will be a more useful tool:

  1. Use the same key to switch between the oringinal application and DOpus;
  2. "Esc" to cancel the operation;
  3. If there are more than one files are in choosed state, paste the links with format "D:\aaa.txt" "D:\bbb.txt" to the open dialog and send a {Enter}, so that we can use DOpus to choose files to open more confortabe.

This tool is useful but this tool can not copy Unicode Bangla Name. In my case
C:\Users\Khalid\Downloads\????? vs ?????? ????? ?? ??-???? ????????\
it's returns ? mark only
where Clipboard COPYNAMES=uncthis button returns this
C:\Users\Khalid\Downloads\খালিদ vs চান্দু মামলা নং ১৮-২০১৯ বাটোয়ারা
please update it if possible. Thanks for the tool by the way.