How to diagnose WM_COPYDATA problems?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
MBaas
Posts: 682
Joined: 15 Feb 2016 21:08

How to diagnose WM_COPYDATA problems?

Post by MBaas »

Claude wrote me a small C# thingy to have an easily scriptable way to send commands to xy (mostly :goto😉)
It works fine when I run it from the console, but when it's embedded in the EverythingToolbar, xy doesn't change. I've logged it to see that xy returns a 0 to the WM_COPYDATA call, while it returns 1 for the working calls. (The content is the same)

So how I can I debug this further - what logging does xy have for these calls? (so far I only know <get copieddata ..>)
Does anyone have suggestions what's happening?
____________________________________________________________________________________
Happy user. Screen scaling 100% and W11Pro [Version 10.0.26200.7922], XY 28.30.0600 * * LinkTree

highend
Posts: 14922
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to diagnose WM_COPYDATA problems?

Post by highend »

Full command line call of your .exe with arguments from the console?
What does show text <get copieddata>; on both calls?
How does Everything receives the XY window handle?
Configuration of Everything regarding the XY call?
One of my scripts helped you out? Please donate via Paypal

MBaas
Posts: 682
Joined: 15 Feb 2016 21:08

Re: How to diagnose WM_COPYDATA problems?

Post by MBaas »

The commandline is something like

Code: Select all

xysend -goto c:\this is my path
very pragmatic - everything that follows "goto" is considered to be a path...

I added code to append the text command and now it get this:

Code: Select all

0|4194305|::goto "c:\Users\mb\Documents\Claude\Projects\xysend\bin\Release\net8.0\win-x64\xysend.exe";text <get copieddata>;
But that's for the working call only. The one that doesn't work shows the same data being sent, but the return value is 0 and XY's copieddata still has the data from the previous run.

This is not about Everything, it's about EverythingToolbar (which then uses Everything). The config of the user defined action is simply "xysend.exe goto=%file%" We don't care about window handles at that level - that's done in my (Claude's) code by searching a window named "ThunderRT6FormDC".
____________________________________________________________________________________
Happy user. Screen scaling 100% and W11Pro [Version 10.0.26200.7922], XY 28.30.0600 * * LinkTree

highend
Posts: 14922
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to diagnose WM_COPYDATA problems?

Post by highend »

xysend -goto <path>
vs.
xysend.exe goto=%<path>%

So:
Restart XY, execute _exactly this_ from dos box:
xysend.exe goto=c:\Users\mb\Documents\Claude\Projects\xysend\bin\Release\net8.0\win-x64\xysend.exe
What does text <get copieddata>; report now?
One of my scripts helped you out? Please donate via Paypal

MBaas
Posts: 682
Joined: 15 Feb 2016 21:08

Re: How to diagnose WM_COPYDATA problems?

Post by MBaas »

Sorry, I had a -log switch in the original command which I took out when I posted the statement - but the dash survived. It's goto=%path%
BTW, I didn't even have to restart xy, xysend does that for me if it doesn't find a running instance.

And then I got this:

Code: Select all

0|4194305|::goto "c:\Users\mb\Documents\Claude\Projects\xysend\bin\Release\net8.0\win-x64\xysend.exe";text <get copieddata>;
____________________________________________________________________________________
Happy user. Screen scaling 100% and W11Pro [Version 10.0.26200.7922], XY 28.30.0600 * * LinkTree

highend
Posts: 14922
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: How to diagnose WM_COPYDATA problems?

Post by highend »

?

So it's using a named argument "goto"?
And it expects a "=" after the path to go to?
And the code automatically prepends everything with: ::goto ?

Thanks for letting people guess instead of posting a link to the source code^^
In other words: Debug it yourself

This is a ahk v1 script, that (compiled) does the job correctly (apart that it expects the full script to be sent instead of prepending anything)
EverythingToolbar custom action command (ofc it expects xysend.exe to be in %PATH%): xysend.exe ::goto %file%

Code: Select all

#NoEnv
#SingleInstance Force
SetBatchLines, -1

xyQueryScript := GetCommandLineArgString()

if (xyQueryScript = "")
{
    MsgBox, 16, Error, Missing command line argument.`n`nPass the XYplorer script after the executable name.
    ExitApp
}

MsgBox % xyQueryScript
Send_WM_COPYDATA(xyQueryScript, GetXYHWND())
ExitApp

GetCommandLineArgString() {
    if (%0% = 0)
        return ""

    cmdLine := DllCall("GetCommandLineW", "Str")
    self := A_ScriptName
    pos := 0

    if (SubStr(cmdLine, 1, 1) = """") {
        pos := InStr(cmdLine, self, false, 2)
        if (pos)
            return Trim(SubStr(cmdLine, pos + StrLen(self) + 1))
    } else {
        pos := InStr(cmdLine, self, false, 1)
        if (pos)
            return Trim(SubStr(cmdLine, pos + StrLen(self)))
    }

    return ""
}

GetXYHWND() {
    IfWinActive, ahk_class ThunderRT6FormDC
    {
        WinGet, xyHwnd, ID, ahk_class ThunderRT6FormDC
    } else {
        WinGet, xyHwnd, List, ahk_class ThunderRT6FormDC
        if (xyHwnd)
            xyHwnd := xyHwnd1
    }
    return xyHwnd
}

; 4194305 => Send the data as an XYplorer script
Send_WM_COPYDATA(message, hWnd) {
    size := StrLen(message)
    if (A_IsUnicode) {
        data := message
    } else {
        VarSetCapacity(data, size * 2, 0)
        StrPut(message, &data, size, "UTF-16")
    }
    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")
    DllCall("User32.dll\SendMessageW", "Ptr", hWnd, "UInt", 74, "Ptr", 0, "Ptr", &COPYDATA, "Ptr")
}
One of my scripts helped you out? Please donate via Paypal

jupe
Posts: 3446
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: How to diagnose WM_COPYDATA problems?

Post by jupe »

If you are using this in EverythingToobar just for goto as in your example, why even use it, and not just XYplorer.exe "%file%"

Post Reply