Page 1 of 1

External program run #1003 does not work

Posted: 25 Jan 2023 19:07
by Norn
Executing this AHK script does not execute the #1003 command:

Code: Select all

Ctrl & R::
randFile := "E:\Test.png"
Run, "D:\Tools\XYplorer\XYplorer.exe" /feed="::tab('new'`, gpc('%randFile%'`, 'path'))`; selectitems '%randFile%'`; wait 500`; `#1003"
It's the same with cmd:

Code: Select all

"D:\Tools\XYplorer\XYplorer.exe" /feed="::tab('new', 'E:\'); selectitems 'E:\Test.png'; wait 500; #1003"
If using #178 command will work. Is it possible to make the #1003 command work?

Re: External program run #1003 does not work

Posted: 25 Jan 2023 19:11
by admin
Moved the topic. Leave it here.

Re: External program run #1003 does not work

Posted: 25 Jan 2023 19:21
by Norn
Well, I thought I just posted wrong. :oops:

Re: External program run #1003 does not work

Posted: 25 Jan 2023 19:32
by admin
I figured :)

Re: External program run #1003 does not work

Posted: 25 Jan 2023 20:10
by highend
It seems the command doesn't like a file that was selected via selectitems, even with focus set to the list view. Click on the file once XY has started up and then execute #1003; from the address bar.
Don?

Re: External program run #1003 does not work

Posted: 25 Jan 2023 20:24
by admin
The file should be focused and selected.

SC selectitems() does this, but not fully. Next beta will work better.

Re: External program run #1003 does not work

Posted: 25 Jan 2023 23:13
by Norn
admin wrote: 25 Jan 2023 19:32I figured :)
Works fine with v24.00.0005 :tup:

Re: External program run #1003 does not work

Posted: 05 Mar 2023 17:52
by Norn
This AHK script works fine.

Code: Select all

#Requires AutoHotkey v2.0.2

^r::
{

 lst:= "D:\Pics\220502.png`nD:\Pics\220625.png"
 lstArray := StrSplit(lst, "`n")
 randFile := lstArray[Random(1, lstArray.Length)]
 Run '"D:\XYplorer\XYplorer.exe" /feed=|::tab("close"); tab("new", gpc("' randFile '", "path")); if(get("view") != 6) {#308}; goto "' randFile '"; if(get("#178") == 0) {#1003}|'

}
But it only works the first time with SendMessage, it would be nice to have it work with SendMessage every time, because it seems faster.

Code: Select all

#Requires AutoHotkey v2.0.2

^r::
{

 lst:= "D:\Pics\220502.png`nD:\Pics\220625.png"
 lstArray := StrSplit(lst, "`n")
 randFile := lstArray[Random(1, lstArray.Length)]
 if(xyHwnd:=GetXYHWND())
    Send_WM_COPYDATA(xyHwnd, '::tab("close"); tab("new", gpc("' randFile '", "path")); if(get("view") != 6) {#308}; goto "' randFile '"; if(get("#178") == 0) {#1003}')

}



GetXYHWND() {
	static xyClass := 'ahk_class ThunderRT6FormDC'

	if hwnd := WinActive(xyClass)
		return hwnd
	else if WinExist(xyClass)
		return WinGetList(xyClass)[1]
}


Send_WM_COPYDATA(xyHwnd, message) {

   size := StrLen(message)
   if !(StrLen(Chr(0xFFFF))) {
      data := Buffer(size * 2, 0)
      StrPut(message, &data, size, "UTF-16")
   } else {
      data := message
   }

   COPYDATA := Buffer(A_PtrSize * 3)
   NumPut("Ptr", 4194305, COPYDATA, 0)
   NumPut("UInt", size * 2, COPYDATA, A_PtrSize)
   NumPut("Ptr", StrPtr(data), COPYDATA, A_PtrSize * 2)

   return DllCall("User32.dll\SendMessageW", "Ptr", xyHwnd, "UInt", 74, "Ptr", 0, "Ptr", COPYDATA, "Ptr")
}