SC: How to get item under mouse?
SC: How to get item under mouse?
Hi all,
Is there a way in XY-scripting how to get the item (in list) currently under the mouse cursor (without sending a click e.g. through ahk or similar)?
Is there a way in XY-scripting how to get the item (in list) currently under the mouse cursor (without sending a click e.g. through ahk or similar)?
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
Re: SC: How to get item under mouse?
XY doesn't expose the content of any pane so to get what you want you could only try to compute it...
AHK
- Get the current mouse coordinates & size of XY's window
- Send a script to XY that reports back the current active pane, all of it's files and folders, the current font and font size for "Main contents", the current line spacing value, status bar visible / not, breadcrumb bar visible / not, menu visible / not, button bar visible / not, visual filter...
- Build internal values of fonts + sizes and their height in pixels. Add line spacing
- Read the visible element (ThunderRT6PictureBoxDC56 / 67)
- Multiply each entry with the height (former step), use the mouse coordinates to see which element would be under it (depending on active pane)...
Ofc you get in trouble if somebody uses the windows font scaling or if the second pane is at the bottom (instead of right to it), horizontal scroll bar visible / not, etc....
Imho not worth the trouble
AHK
- Get the current mouse coordinates & size of XY's window
- Send a script to XY that reports back the current active pane, all of it's files and folders, the current font and font size for "Main contents", the current line spacing value, status bar visible / not, breadcrumb bar visible / not, menu visible / not, button bar visible / not, visual filter...
- Build internal values of fonts + sizes and their height in pixels. Add line spacing
- Read the visible element (ThunderRT6PictureBoxDC56 / 67)
- Multiply each entry with the height (former step), use the mouse coordinates to see which element would be under it (depending on active pane)...
Ofc you get in trouble if somebody uses the windows font scaling or if the second pane is at the bottom (instead of right to it), horizontal scroll bar visible / not, etc....
Imho not worth the trouble
One of my scripts helped you out? Please donate via Paypal
Re: SC: How to get item under mouse?
thx for the brainstorm, highend,
besides the problems you mentioned I also think it would be a problem if the user simply scrolled down a list (if the content is longer than the display), which happens most of the time.
at least I now am confirmed that I did not overlook anything, thx.
besides the problems you mentioned I also think it would be a problem if the user simply scrolled down a list (if the content is longer than the display), which happens most of the time.
at least I now am confirmed that I did not overlook anything, thx.
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
Re: SC: How to get item under mouse?
It can be done!
I use a compiled AutoHotkey script to get the mouse coordinates and focus the underlying control if it is over XY - this eliminates the headache caused by the controls changing classNN.
It sends the data back to XY using binoccular222's messenger example.
The XY script then uses the undocumented cell (+ update) SC and takes the painstaking effort of enumerating all items in the list checking to see if the mouse falls within their bounds.
Rather than repeat myself, it's all on GitHub.
Latest Release
I use a compiled AutoHotkey script to get the mouse coordinates and focus the underlying control if it is over XY - this eliminates the headache caused by the controls changing classNN.
It sends the data back to XY using binoccular222's messenger example.
The XY script then uses the undocumented cell (+ update) SC and takes the painstaking effort of enumerating all items in the list checking to see if the mouse falls within their bounds.
Rather than repeat myself, it's all on GitHub.
Latest Release
Re: SC: How to get item under mouse?
Autocart and TheQwerty, excellent idea and implementation. It works great and quite snappy considering what's going on in the background. Now, to think of ways to use it. Another case where AHK and XY play so nicely together. Too bad Don couldn't incorporate the AHK.dll library and have it all in one basket. Of course Norton Anti-virus picked the exec file up as "reputation.1" virus and of course it's false positive, but I figured I let you know. Thanks.
Edit: I wanted to add that it works fine also if the mouse is over a thumbnail (i.e., the thumbnail itself). It doesn't have to be over the filename below the thumb. That may bring some nice possibilities.
Edit: I wanted to add that it works fine also if the mouse is over a thumbnail (i.e., the thumbnail itself). It doesn't have to be over the filename below the thumb. That may bring some nice possibilities.
Last edited by klownboy on 23 Oct 2014 13:33, edited 2 times in total.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: SC: How to get item under mouse?
*sigh* It's been quite a while since I've dealt with compiling AHKs. Any suggestions on the "best" way to compile them to avoid false-positive headaches?klownboy wrote:Of course Norton Anti-virus picked the exec file up as "reputation.1" virus and of course it's false positive, but I figured I let you know.
Is just disabling compression/UPX enough?
Re: SC: How to get item under mouse?
Great
I'll probably port that to PureBasic (when I have enough^^ time). Would drop down the filesize to between 25-50 kb and speed up the loading time... I already have a working Send_WM_COPYDATA snippet so it shouldn't require much work.
I'll probably port that to PureBasic (when I have enough^^ time). Would drop down the filesize to between 25-50 kb and speed up the loading time... I already have a working Send_WM_COPYDATA snippet so it shouldn't require much work.
Yes, just disable UPX / mpress compression*sigh* It's been quite a while since I've dealt with compiling AHKs
One of my scripts helped you out? Please donate via Paypal
Re: SC: How to get item under mouse?
I was going to say the same thing. I've used upx http://upx.sourceforge.net/ without any issues before in lieu of the autohotkey/mpress compiler.
By the way, it was only an issue when I extracted it from the zip. No issues after, when I "ran" it with Norton back on line. Of course that may be because I have Norton ignore my XYplorer folders.
By the way, it was only an issue when I extracted it from the zip. No issues after, when I "ran" it with Norton back on line. Of course that may be because I have Norton ignore my XYplorer folders.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: SC: How to get item under mouse?
Which doesn't seem to be enabled anyhow, so I'm not sure what's going on there.highend wrote:Yes, just disable UPX / mpress compression*sigh* It's been quite a while since I've dealt with compiling AHKs
Over half of that size is due to including the icon and I had Compile_AHK including it for everything which is probably overkill. Using ahk2exe instead I get it to 958 KB or 483.50 KB with mpress.
I was going to write the helper in C but decided it wasn't worth the extra effort.
I welcome improvements!
Re: SC: How to get item under mouse?
Thx very much, The Qwerty,
unfortunately I am too dumb to make it work.
I put
::load "ItemUnderMouse.xys"
(and also tried other formats too) into the address bar, moved the mouse over an item in the list, pressed enter with focus still on AB but nothing happened.
ItemUnderMouse.exe was also in script folder (as was ItemUnderMouse.xys)
I tested it on vista32bit and compiled the exe myself.
What did I do wrong?
unfortunately I am too dumb to make it work.
I put
::load "ItemUnderMouse.xys"
(and also tried other formats too) into the address bar, moved the mouse over an item in the list, pressed enter with focus still on AB but nothing happened.
ItemUnderMouse.exe was also in script folder (as was ItemUnderMouse.xys)
I tested it on vista32bit and compiled the exe myself.
What did I do wrong?
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
Re: SC: How to get item under mouse?
And it doesn't spit out any message at all?
I've just did what you did and it worked fine.
I've just did what you did and it worked fine.
One of my scripts helped you out? Please donate via Paypal
Re: SC: How to get item under mouse?
The best way I found to use / test the script is to assign a user defined command. User | User Defined Commands | Load script file. From there just put in the script name with full path and then Assign Keyboard Shortcut. I used Control Enter to test. Worked great even on a thumbnail well away from the filename. Setting it up this way you don't have to worry about mouse placement...just put the mouse where you want it and hit the key assigned.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: SC: How to get item under mouse?
alright, I tried the "normal" download from github now. this one works as expected.
the "source code" download does not work. in the status bar it says "Invalid script:" if I try to load it.
I also found the reason: The xys-script that works ok has CR+LF as line seperator (DOS-style). The one that does not work has only LF (UNIX-style).
Thank you, The Qwerty, another gem for scripting purposes!!!!!
This one should immediately be added to the scripts-overview!!! Please.
the "source code" download does not work. in the status bar it says "Invalid script:" if I try to load it.
I also found the reason: The xys-script that works ok has CR+LF as line seperator (DOS-style). The one that does not work has only LF (UNIX-style).
Thank you, The Qwerty, another gem for scripting purposes!!!!!
This one should immediately be added to the scripts-overview!!! Please.
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList
Re: SC: How to get item under mouse?
Doh... indeed XY doesn't like that. That's my fault, I have autocrlf enabled in Git so it converts them to LF for storing in the repo, which means the source-archive automatically included by GitHub is wrong, while I built the other archive locally (and thus with CRLF) and uploaded it for the release.autocart wrote:I also found the reason: The xys-script that works ok has CR+LF as line seperator (DOS-style). The one that does not work has only LF (UNIX-style).
*sigh* What a mess releasing this has been!
Re: SC: How to get item under mouse?
could this be done also for the tree view?
right now it only returns: "The mouse is not over a list pane."
right now it only returns: "The mouse is not over a list pane."
[AHK] redirecting Windows Explorer to XY, [XYS] Mini Tree with open tabs (cur loc expanded, tab folders highlighted), [AHK] customInlineRenameKeys, [AHK] clipboardHelper_and_XYEscToList