SC: How to get item under mouse?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: SC: How to get item under mouse?

Post by TheQwerty »

No the cell SC does not support the tree.

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

Re: SC: How to get item under mouse?

Post by klownboy »

Hi TheQwerty, binocular222 or anyone else that may be using 'ItemUnderMouse' along with AHK, I've been using your ItemUnderMouse quite often now along with a few additions to my AHK file run at startup. It works great using a assignment like Ctrl-Enter to run an image editor or a graphics program like Irfanview if the file for example has a 'jpg' extension. Of course you could use it to trigger anything. My issue has to do with active window when using your script along with an AHK assignment for a mouse button via AHK. It works great, hold down the left ctrl and right click the mouse on a thumbnail and the image is brought up in Irfanview. However, unlike with the keyboard assignment of Crlt-Enter, when using the mouse, 'LControl & RButton' assignment (see below), 50% of the time or more, the image is opened in Irfanview but it's under XYplorer (i.e., it's the active window). I see in the script you do focusing in XY, but I'm not sure if it could be affecting the running of the program differently when using a mouse vs using the keyboard since the keyboard method works consistently all the time (Irfanview will become the active window). It may have something to do with the clicking on XY (LControl & RButton) vs not clicking when using Ctrl-Enter. Any ideas on why that may be? I tried all the different wait and show parameters combinations on SC run as well.

In ItemUnderMouse.xys:

Code: Select all

	  Sub '_toggleFocusPopping';
	  Sub '_popAllFocus';
   if (getpathcomponent ($result, "ext") == "jpg") {run "D:\Graphics\IrfanView\i_view32.exe $result /hide=15",,2,1}  // line 61
In User Defined Commands:

Code: Select all

Item Under Mouse	 [Ctrl+Enter]
Item Under Mouse	 [Ctrl+Shift+Alt+X]
In my AHK file:

Code: Select all

#Ifwinactive, ahk_class ThunderRT6FormDC
  LControl & RButton:: sendinput ^+!x
#IfWinActive
Thanks,
Ken

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: SC: How to get item under mouse?

Post by binocular222 »

Use AHK to activate your image viewer's window

Code: Select all

winactivate
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

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

Re: SC: How to get item under mouse?

Post by klownboy »

Thanks binocular22. I know about winactivate and after you mentioned it I did add in a few lines to my AHK startup script like this but it didn't help. I thinks it's a timing or sequencing issue, in that, AHK is providing the key/mouse substitute to XY, and the program is started properly, but the 'winactivate if not already' has to be sequenced such that it happens after XY's action of running Irfanviiew via ItemUnderMouse script. The script obviously works fine using the keyboard as in my example Crtl-Enter in lieu of 'LControl & RButton'. Maybe a pause in AHK until XY has done its thing? I was hoping there might be something I could do with out touching the ItemUnderMouse AHK file or exe, though I wouldn't mind tweaking the ItemUnderMouse XY script if that would work.

Code: Select all

#Ifwinactive, ahk_class ThunderRT6FormDC
LControl & RButton::
   sendinput ^+!x
   ;I put a "sleep 50" in this line and I think it helps but there must be a better way  
   IfWinNotActive, ahk_class IrfanView
   WinActivate, ahk_class IrfanView
#IfWinActive
Thanks,
Ken

Edit: Needs more testing but putting a sleep of 150 - 200 after the sendinput seems to be enough to ensure the program (in this example, Irfanview) is "active".

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: SC: How to get item under mouse?

Post by TheQwerty »

I'm pretty sure this is mostly a Windows bug - Don has seen and commented on similar issues in XY alone - which has to do with starting new processes while certain modifiers are held down and the new windows not getting activated. I've also seen it occur with Tortoise* shell extensions and Windows Explorer, so not an XY issue either.

I can say with certainty that it's not a bug in ItemUnderMouse.xys or ItemUnderMouse.ahk, or at least not the versions I released.

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

Re: SC: How to get item under mouse?

Post by klownboy »

Thanks TheQwerty, it's unfortunate that it behaves that way. I found out since the previous post that if I have an AHK 'KeyWait' as shown below, it opens the called program and it is active or remains/stays active.

Code: Select all

#Ifwinactive, ahk_class ThunderRT6FormDC
LControl & RButton::
   KeyWait, LControl, U
   sendinput ^+!x
#IfWinActive
It seems to be more reliable and consistent than using a sleep as I mentioned above. Although you have to remember to release the CTRL key and as soon as you do the program window activates above XY's window. I may try different modifiers to see if the behavior is the same
Thanks

Edit: I meant to say also that when using modifiers like CTRL or Shift along with a keyboard key (e.g., Enter or whatever) this is not an issue (i.e., there's no need for the KeyWait or Sleep). So I'm only experiencing this active window issue when a click of the mouse is used as in the above example, 'LControl & RButton'.

Post Reply