Can this ahk script apply to XYplorer be converted to StrokesPlus script, and apply to other similar software?
/*
XYGetPath() - paths of target window's selected items
XYGetAll() - paths of all items in the target window's folder
XYGetSelected() - path of target window's folder
example:
F10::
path := XYGetPath()
all := XYGetAll()
sel := XYGetSelected()
MsgBox % path
MsgBox % all
MsgBox % sel
return
*/
; Get our own HWND (we have no visible window)
DetectHiddenWindows, On
G_OwnHWND := WinExist("Ahk_PID " DllCall("GetCurrentProcessId"))
G_OwnHWND += 0
; Get messages back from XYplorer
OnMessage(0x4a, "Receive_WM_COPYDATA")
$F10::
path := XYGetPath()
all := XYGetAll()
sel := XYGetSelected()
MsgBox % path
MsgBox % all
MsgBox % sel
return
XYGetPath()
{
return XY_Get()
}
XYGetAll()
{
return XY_Get(true)
}
XYGetSelected()
{
return XY_Get(, true)
}
XY_Get(bAll:=false, bSelection:=false)
{
global dataReceived, G_OwnHWND
xyQueryScript =
( LTrim Join
::
if (!%bAll% && !%bSelection%) {
$return = "<curpath>";
} elseif (%bAll%) {
$return = listpane(, , , "<crlf>");
} elseif (%bSelection%) {
$return = get("SelectedItemsPathNames", "<crlf>");
}
copydata %G_OwnHWND%, "$return", 2;
)
Send_WM_COPYDATA(xyQueryScript)
return dataReceived
}
GetXYHWND() {
IfWinActive, ahk_class ThunderRT6FormDC
{
WinGet, xyHwnd, ID, ahk_class ThunderRT6FormDC
} else {
WinGet, xyHwnd, List, ahk_class ThunderRT6FormDC
if (xyHwnd)
xyHwnd := xyHwnd1
}
return xyHwnd
}
Send_WM_COPYDATA(message) {
xyHwnd := GetXYHWND()
if !(xyHwnd)
return
size := StrLen(message)
if !(A_IsUnicode) {
VarSetCapacity(data, size * 2, 0)
StrPut(message, &data, size, "UTF-16")
} else {
data := message
}
VarSetCapacity(COPYDATA, A_PtrSize * 3, 0)
NumPut(4194305, COPYDATA, 0, "Ptr")
NumPut(size * 2, COPYDATA, A_PtrSize, "UInt")
NumPut(&data, COPYDATA, A_PtrSize * 2, "Ptr")
result := DllCall("User32.dll\SendMessageW", "Ptr", xyHWND, "UInt", 74, "Ptr", 0, "Ptr", ©DATA, "Ptr")
return
}
Receive_WM_COPYDATA(wParam, lParam) {
global dataReceived
stringAddress := NumGet(lParam + 2 * A_PtrSize)
copyOfData := StrGet(stringAddress)
cbData := NumGet(lParam + A_PtrSize) / 2
StringLeft, dataReceived, copyOfData, cbData
return
}