Page 1 of 1

canot run xyplorer script in background (using existing instance)

Posted: 01 Aug 2020 17:22
by xen
it seems that xyplorer not support run script in background (using existing instance)

i use single xyplorer instance and i want to run the script in background using the existing instance
i tried run with /win=tray parameter not works.

how to reproduce
set xyplorer single instance

i paste in cmd window (or .cmd file)

Code: Select all

"E:\Program Files\xy\XYplorer.exe" /win=tray /script="::new('R:\test.txt', 'file');"
and run , the xyplorer window is activated automatically (although it was minimized before)

related :
https://www.xyplorer.com/xyfc/viewtopi ... 11#p179511

Re: canot run xyplorer script in background (using existing instance)

Posted: 04 Aug 2020 15:12
by admin
Why not simply use a new instance?

Re: canot run xyplorer script in background (using existing instance)

Posted: 08 Aug 2020 18:23
by xen
admin wrote: 04 Aug 2020 15:12 Why not simply use a new instance?
i want to call it many times from another script (autohotkey ) so i dont want to start new instance and close
i just want to have it if it's not difficult
Thanks

Re: canot run xyplorer script in background (using existing instance)

Posted: 08 Aug 2020 18:47
by highend
so i dont want to start new instance and close
That isn't necessary, you could open one new instance in the tray, send all your scripts to this one (via its window handle) and close it once you're done with all of them...

Re: canot run xyplorer script in background (using existing instance)

Posted: 10 Aug 2020 03:55
by xen
highend wrote: 08 Aug 2020 18:47
so i dont want to start new instance and close
That isn't necessary, you could open one new instance in the tray, send all your scripts to this one (via its window handle) and close it once you're done with all of them...
Thanks for the help, how to send script to that instance via window handle? (i use autohotkey)

Re: canot run xyplorer script in background (using existing instance)

Posted: 10 Aug 2020 07:38
by highend

Code: Select all

#NoEnv
#SingleInstance force
#Persistent

; Return this script's hidden hwdn id. +0 to convert from Hex to Dec
ownHwnd := A_ScriptHwnd + 0

xyScript =
( LTrim Join
    ::<things to do in that instance>;
)

Send_WM_COPYDATA(xyScript)

return


Send_WM_COPYDATA(message)
{
    global xyHwnd

    if WinExist("ahk_id" . xyHwnd") {
        size := StrLen(message)
        if !(A_IsUnicode) {
            VarSetCapacity(data, size * 2, 0)
            StrPut(message, &data, "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", &COPYDATA, "Ptr")
    }
    return
}
Ofc you need a Receive_WM_COPYDATA() function as well to get the hwnd from xyplorer (invoke it once with a command line parameter to send back its hwnd to ownHwnd)...

Re: canot run xyplorer script in background (using existing instance)

Posted: 10 Aug 2020 13:00
by xen
highend wrote: 10 Aug 2020 07:38\
Ofc you need a Receive_WM_COPYDATA() function as well to get the hwnd from xyplorer (invoke it once with a command line parameter to send back its hwnd to ownHwnd)...
Thank you very much, currently i dont know how to do that , i searched and found this topic ,i guess it would tell me how ,i will take a look
viewtopic.php?t=9233
thanks again