Page 1 of 4
Feature Request: Run macro w/o bringing XY to foreground
Posted: 26 Mar 2025 09:59
by MBaas
I have set up some system-wide hotkeys (using
LibreAutomate) that send WM_COPYDATA ::run commands to XY to execute macros (which bring up popupmenus).
This all works nice, smooth & fast
The only wish I have regarding the flow is: when receiving my msg, XY comes to foreground. I see that this is neccessary in most cases, but here it would be much nicer if XY stayed in the background and only showed the popupmenu in foreground. Clearly this is non-default behavior and I'd be happy to set flags in my macros or possibly include specific instructions (or flags) in the send command.
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 27 Mar 2025 04:30
by jupe
I am not sure of your exact scenario regarding what you describe as sending run cmds etc, but just FYI you can already use popupmenus via wmcopydata with XY staying in the background, eg

- 2025-03-27_103742.png (4.6 KiB) Viewed 2951 times
so something else might be causing it on your end, or the way you are implementing it. It's been my experience that when using copydata, XY usually only comes to the foreground when a dialog is called, unlike when using feed, then it always is shown.
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 27 Mar 2025 06:19
by MBaas
Ah, that's interesting. I can't call popupmeni directly - need to run it a .xys to build the menu first...
But...there is one simplet case where the menu should be in a file already, so I'll experiment with that.
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 27 Mar 2025 07:03
by jupe
Yeah I realize you were calling it via a script not directly, I was just demonstrating that the popupmenu itself wasn't the cause, it's the same when done via script, eg.

- 2025-03-27_165833.png (5.86 KiB) Viewed 2939 times
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 27 Mar 2025 08:36
by MBaas
Unfortunately I can't directy popupmenu, there is some work involved.
Here's is a simple case (which brings XY to foreground):
Code: Select all
/*******************************************************************************
@Author : Michael Baas
@Created : February 2, 2025
@Modified:
@Function: display the dyalog menu and launch selected
@Tags : AppLauncher,Projects,Dyalog
@Title : My AppLauncher (Project Menu)
@Version : v0.1
******************************************************************************/
if (exists("C:\Program Files\Dyalog")) {// if dyalog is not disabled atm
//$proj = regexreplace($proj," *\&Enable Dyalog.*\r?\n","");
$proj = readfile("<xyscripts>\AppLauncher-DyalogMenu_1.txt")
} else {// dyalog IS disabled...
// $proj = regexreplace($proj," *\&Disable Dyalog.*\r?\n","");
$proj = readfile("<xyscripts>\AppLauncher-DyalogMenu_0.txt")
}
$proj = $proj . readfile("<xyscripts>\AppLauncher-DyalogMenu.txt");
if ("<curitem>" == "") {
$proj = regexreplace($proj,"^.*<curi" . "tem>.*$","");// don't use <curitem> when looking for it as a string
}
$sel = popupnested($proj);
end $sel == "";
if (":" == substr($sel,0,1)) {
$sel = substr($sel,1,strlen($sel)-1);
$sel = replace($sel,"⋄⋄",";");
} else {
$sel = "run ". $sel;
}
load $sel, , "s";
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 27 Mar 2025 15:45
by MBaas
I experimented by trying to convert the initial phase of that macro to a one-liner that I'm passing through WM_COPYDATA - it worked (<phew>) - but also brought XY to foreground...
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 27 Mar 2025 16:03
by klownboy
Hi jupe, I noticed in your pic that you use
send.exe.
send.exe popupmenu("1,2,3") and
send "load '%CD%\pm.xys'" Is that a compiled AHK script or something similar using
Send_WM_COPYDATA or
viewtopic.php?p=227057#p227057?
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 27 Mar 2025 19:13
by jupe
Well we must have different ideas of what a simple case is, the script you posted isn't really runable for anyone without those text files, but anyway I left most of your script intact and just changed the readfiles to a file that should exist on anyones computer, and kept the rest of your script, but just added 1 line to create a popupmenu with a couple entries that are runable, and for me xy stays in the BG when I run it, if it doesn't work for you then you should be able to test it with the XY_Send that klownboy linked to, and if that works then you will know the issue is in your implementation of WM_COPYDATA. BTW the msg I am sending is just
::load 'file.xys';
Code: Select all
if (exists("C:\Program Files\Dyalog")) {// if dyalog is not disabled atm
//$proj = readfile("<xyscripts>\AppLauncher-DyalogMenu_1.txt")
$proj = readfile(<xytagdat);
} else {// dyalog IS disabled...
//$proj = readfile("<xyscripts>\AppLauncher-DyalogMenu_0.txt")
$proj = readfile(<xytagdat>);
}
$proj = listfolder(<xydata>, "*.ini", 1, <crlf>); // ADDED ONLY THIS LINE JUST TO POPULATE THE MENU EASILY
if ("<curitem>" == "") {
$proj = regexreplace($proj,"^.*<curi" . "tem>.*$","");// don't use <curitem> when looking for it as a string
}
$sel = popupnested($proj);
end $sel == "";
if (":" == substr($sel,0,1)) {
$sel = substr($sel,1,strlen($sel)-1);
$sel = replace($sel,"⋄⋄",";");
} else {
$sel = "run ". quote($sel);
}
load $sel, , "s";
@klownboy: It is actually an app my brother made for me with a lot of customization I asked him to implement, but I just tested the one you linked to, and it functions the same in this scenario. I used to use my own heavily customized ahk version I cobbled together from posts on the forum, I think the orig was called messenger, but I no longer do.
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 27 Mar 2025 19:59
by klownboy
Thanks jupe. Yes, I remember now, it's a version of "MessagetoXYplorer" that I have in my AHK startup file. I should be able to use what I currently have to display an XY script menu as long as XYplorer exists without "activating" it.
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 28 Mar 2025 07:16
by MBaas
@jupe Yeah, sory - that word "simple" was a bit off. (It was though, compared to the other candidates I have

- but I realize it was a bit oo much for the purpose of the excercise...
Thanks to you and @klownboy - I tried using highend's send - and indeed that works fine, so the issue was with my approach of sending

Case closed.
Re: Feature Request: Run macro w/o bringing XY to foreground
Posted: 28 Mar 2025 09:11
by MBaas
Finally I found it: this all happened in
LibreAutomate and the ignorant user

totally missed the fact that the
findOrRun Method - if that is set, it all works!
(Sorry Don, how could I assume XY would ne a change when it totally innocent and works perfectly

)
Re: Send script to topmost XY via WM_COPYDATA
Posted: 28 Mar 2025 18:14
by klownboy
Hey Highend, is this exe a compile AHK script? I was curious because I was able to use my AHKstartup fie to accomplish the same thing as your exe (i.e., bring up an XYplorer menu without XY being active (only running in the background). However, using my startup file which uses SendFunction(MessagetoXYplorer) that you're familiar with, I'm only able to get the normal left mouse click working on my menu. If you remember I am also using DetectContextMenu() and setting a perm variable message to XY
MessagetoXYplorer := "::perm $rmb=1;" to determine if a right click is performed on the context menu. Using your exe in this thread, my left and right click function works in the menu being raised. I'm not sure if it's because of how or what you are detecting (i.e., that XYplorer WinExist). Obviously I can run your exe from my startup file with something like ^o:: run "D:\Tools\XYplorer\Scripts\XY_Send script.exe D:\Tools\XYplorer\Scripts\XYmenu_NESTED.xys", but I was hoping to use the existing code in the AHK startup file.
By the way, could anything be done to eliminate the hour glass coming up for some time in a situation like this (i.e., when a menu displays)?
Re: Send script to topmost XY via WM_COPYDATA
Posted: 28 Mar 2025 18:38
by highend
Hi Ken,
no, ofc this isn't an AHK script (otherwise it would be a 1/2 MB large file).
It's written in PureBasic...
The XY detection is using the Windows API (e.g.: hWnd = GetWindow_(hWnd, #GW_HWNDNEXT))
GetWindow_ (reduced by the "_" is an API function)
I haven't seen an hourglass (yet) when sending a script via this tool?
Re: Send script to topmost XY via WM_COPYDATA
Posted: 28 Mar 2025 19:15
by klownboy
Thanks highend. I hope all is well. Looking back, I should have realized that it wasn't AHK. I looked at the file size yesterday and I remember how small it was.
So both using your exe and my AHK startup file's SendFunction(MessagetoXYplorer) bring up the menu fine and normal left click works in both methods, but my right click only works if the menu is brought up by your exe. It has to be something in the way the context menu WinExist("ahk_class #32768")) is being detected or the right click is recognized when done in the menu. I'll test some more using my AHK startup file. If I can't get it to recognize the right click I can go with your exe. Thanks.
Re: Send script to topmost XY via WM_COPYDATA
Posted: 29 Mar 2025 11:35
by klownboy
highend wrote: ↑28 Mar 2025 18:38
I haven't seen an hourglass (yet) when sending a script via this tool?
Yes, when I use the exe to display a XYplorer menu, I get the menu with an hourglass. The hourglass does not affect making a selection in the menu, but it does last about 5 seconds before it goes away.
Also, if I elect to cancel out (i.e., not use the menu) and click outside somewhere, the menu stays up and I am forced to actually make a selection to have the menu disappear. I've seen the same result in a few different menus. In case it make a difference, I'm opening the scripts via AHK
^o:: run "D:\Tools\XYplorer\Scripts\XY_Send script.exe D:\Tools\XYplorer\Scripts\XYmenu_NESTED.xys"