Feature Request: Run macro w/o bringing XY to foreground

Features wanted...
klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by klownboy »

That's great. I tried your split and it works fine. I must of had too much extraneous code in the way I did it (i.e., I only broke out the the hotkey portion and the other script had the send message but also contained everything else I was doing in my startup file. Now I'll have to experiment on how I can set it up. I don't want to run my current startup file along with 2 others that's for sure. You're right about separating the send message especially since I'm using that elsewhere in my AHK startup file. I've got no clue on the "sending the message to that file via cli params", but I'll look into it. As you said, highend may possibly have a way to combine the two scripts and work them into my starup script. Thanks again jupe.

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

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by jupe »

Just as a demo of what I meant I have attached an example, only the hotkey.ahk needs to be running (which would be your normal resident ahk script), there is no benefit to doing it this way though over just using XY_Send.exe in combination with your current ahk script for the RButton parts, ie. it still has the hourglass, but it does work for me, if you wanted to test it, you may have to mess with the quoting for the run cmd.

I think I just saw a possible solution that looks superior though, here in example #8:

https://www.autohotkey.com/docs/v2/lib/ ... ExecScript

it says it runs a script in another process, which is what you need, possibly done this way it wouldn't have the same hourglass downside, hopefully highend can come up with a better solution for you though.
Attachments
ahk2.7z
(1.05 KiB) Downloaded 102 times

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by klownboy »

Hi jupe. I was able to get the "SendMSG.ahk" working with "hotkey.ahk" with the following quoting:
run 'D:\Tools\AutoHotkey2\AutoHotkey.exe D:\Tools\AutoHotkey2\Scripts\SendMSG.ahk "::load ""D:\Tools\XYplorer\Scripts\XYmenu_NESTED.xys"""'
As you mentioned it does have the hourgalss. I integrated the hotkey portion into my normal AHKstartup file, but I haven't been able to get it fully working yet. The menu comes up but the right click function doesn't work. As I mentioned, it worked when using your latest files running alone. Some other conflict I suppose. I thought I'd be able to replace my existing #HotIf statement for ^o:: with the new one and everything else could stay the same.

I'll take a closer look at the ExecScript. That does look promising. Thanks again.

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by klownboy »

Following up on my previous post instead of editing. I did get my normal AHKstart file working with SendMSG.ahk. Once I went back and found out that the actual "click" was commented out (I was testing other methods and hadn't removed the ";". :roll: So thumbs up with that method other than the pesky hour glass (which only seen when the mouse is over the menu not any where else on the screen and disappears after about 5 seconds). Now I'll take a look at your other recommendation, ExecScript. Thanks jupe.

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by klownboy »

Another followup. I was able to get it working using AHK ExecScript function, but there doesn't seem to be any benefit over using sendMSG.ahk. I can put the contents of the sendMSG in the "script" section below, but all the functions need to in there as well. Maybe by making the functions like Sendfunction(MessagetoXYplorer), DetectContextMenu(), and isMouseOver(controlName, controlNums) global somehow they would be seen within the ExecScript's script section such that they would need to be actually included in the section.

Code: Select all

#HotIf WinExist("ahk_class ThunderRT6FormDC")
^o::
{
script := '
(
 run 'D:\Tools\AutoHotkey2\AutoHotkey.exe D:\Tools\AutoHotkey2\Scripts\SendMSG.ahk "::load ""D:\Tools\XYplorer\Scripts\XYmenu_NESTED.xys"""'
)'
   ExecScript(script)
   return
}
#HotIf
ExecScript(script, Wait:=true) {
	shell := ComObject('WScript.Shell')
	exec := shell.Exec('D:\Tools\AutoHotkey2\AutoHotkey.exe /ErrorStdOut *')
	exec.stdin.Write(script)
	exec.StdIn.Close()
    if Wait
	return exec.StdOut.ReadAll()
}

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

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by jupe »

You don't want to use ExecScript to initiate the run cmd, you want to use it to just execute the DllCall in the local file, the SendMSG.ahk wouldn't be needed if ExecScript functioned like I thought it should have, but I just made the req mods (incl setting the Wait param to false) and tested it, and it is super laggy and still has the hourglass, and I haven't got the Rbutton part to work yet anyway. Sorry that seemed promising, nice work getting it implemented though.

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by klownboy »

Hi jupe thanks for checking on it. At one point, I did put the contents of the SendMSG file directly into the "script" section, but I needed all ths supporting functions like "DetectContextMenu()" for the right click to work in addition to SendFunction(MessagetoXYplorer). If I understood AHK globals better, maybe I could get it to work. It was too cumbersome in any case and the good old hourglass was there. Thanks again.

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

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by jupe »

The hourglass thing seems to either be a bug in XY, (or somehow unavoidable...), because notice if you just run the below script from a running XY instance, it comes up with the same hourglass, it is strange it doesn't when done from cmd, maybe it is because of the latter not having a GUI ao it runs in console mode. I haven't tested it, but maybe loading the AHK script "run" via cmd.exe would also avoid the hourglass, but it would add extra overhead even if it did work.

run """<xy>"" /feed=""D:\Tools\XYplorer\Scripts\XYmenu_NESTED.xys""";

edit: Actually it works fine like that for me, no hourglass with this ahk, eg.

Code: Select all

run A_ComSpec ' /c D:\Tools\AutoHotkey2\AutoHotkey.exe D:\Tools\AutoHotkey2\Scripts\SendMSG.ahk "::load ""D:\Tools\XYplorer\Scripts\XYmenu_NESTED.xys"""'

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

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by MBaas »

Just a question: does your script bring up a menu (ie. popupmenu) and if so, can you use the keyboard to select items?
_________________________________________________
Happy user with Screen scaling 100% and W11Pro 24H2 ;-)

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by klownboy »

jupe are you not getting the comspec (command box) coming up when you run it. I am using this AHK line.
^o:: run A_ComSpec ' /c D:\Tools\AutoHotkey2\AutoHotkey.exe D:\Tools\AutoHotkey2\Scripts\SendMSG.ahk "::load ""D:\Tools\XYplorer\Scripts\XYmenu_NESTED.xys"""'
How are you running it? I'm not sure why I'm getting it and not you. Are you using a hotkey to bring it up? I used the AHK documemtation example of using comspec a couple days ago when testing highend exe version to get rid of the hourglass but never got the quoting right.

I put that comspec line by itself in a new AHK file with no hotkey and ran it and also got the command box. I'll have to see if there's a Windows trick to eliminate it. There is XYplorer's SC run command.

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by klownboy »

Got it running without the command box
run(A_ComSpec ' /c D:\Tools\AutoHotkey2\AutoHotkey.exe D:\Tools\AutoHotkey2\Scripts\SendMSG.ahk "::load ""D:\Tools\XYplorer\Scripts\XYmenu_NESTED.xys"""',, "hide")
I'm curious though jupe, you must not have got the box when you ran it. Anything different in how you ran it? And thank you jupe for working that out.

@MBaas. I tried putting an accelerator in my script and it did not work. I'm not using SC popupmenu just simple XYplorer menu structure.

For highend's exe version using D:\Tools\XYplorer\Scripts\XY_Send script.exe in AHK, this works to eliminate the hourglass.

Code: Select all

#HotIf WinExist("ahk_class ThunderRT6FormDC")
^q::
{
    run(A_ComSpec ' /c ""D:\Tools\XYplorer\Scripts\XY_Send script.exe" "D:\Tools\XYplorer\Scripts\XYmenu_NESTED.xys""',,"Hide")
}
#HotIf

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

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by highend »

It is a business only trip. There will be another one in about 6 months, hopefully with a bit of free time (weather is bad atm) …
One of my scripts helped you out? Please donate via Paypal

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

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by jupe »

Whoops, yes of course I wasn't getting a cmd box, when I posted it I just grabbed all your paths and quoting from your earlier post, and forgot to add the hide param back in again, sorry.

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by klownboy »

No problem jupe. I was only wondering if there was some other setting, Windows or not, that would hide the command box.

It looks like everything with script and bringing up an Xyplorer menu without activating XY is working fine. The only issue, and it's very minor, is closing the menu when the user decides not to make a selection (and accelerator keys not working - I don't use them myself). If XY is active that's not a problem. I put in a hidden right click menu item to close it. You can also simply click in the menu and drag outward and that will close it. Thanks for all your help.

klownboy
Posts: 4403
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Feature Request: Run macro w/o bringing XY to foreground

Post by klownboy »

Hey highend, when you get back, don't bother pursuing this one any further as mentioned earlier in this thread, at least not for me. Jupe, with very little help from me, got it working fine (i.e., bringing up a menu without activating XYplorer). Thanks.

Post Reply