canot run xyplorer script in background (using existing instance)

Things you’d like to miss in the future...
Post Reply
xen
Posts: 37
Joined: 27 Mar 2013 03:57

canot run xyplorer script in background (using existing instance)

Post by xen » 01 Aug 2020 17:22

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

admin
Site Admin
Posts: 49463
Joined: 22 May 2004 16:48
Location: Cologne, Win 8.1, Win 10
Contact:

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

Post by admin » 04 Aug 2020 15:12

Why not simply use a new instance?
FAQ | XY News RSS | XY Twitter | Stay home! 🎸 Or wear a mask! 😷

xen
Posts: 37
Joined: 27 Mar 2013 03:57

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

Post by xen » 08 Aug 2020 18:23

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

highend
Posts: 9262
Joined: 06 Feb 2011 00:33

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

Post by highend » 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...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

xen
Posts: 37
Joined: 27 Mar 2013 03:57

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

Post by xen » 10 Aug 2020 03:55

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)

highend
Posts: 9262
Joined: 06 Feb 2011 00:33

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

Post by highend » 10 Aug 2020 07:38

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)...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

xen
Posts: 37
Joined: 27 Mar 2013 03:57

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

Post by xen » 10 Aug 2020 13:00

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

Post Reply