Explorer: get name of file under cursor

Post your working scripts, libraries and tools
User avatar
jeeswg
Posts: 4956
Joined: 19 Dec 2016, 01:58
Location: UK

Explorer: get name of file under cursor

10 Jul 2018, 00:21

- In response to this:
[x64 & x32 fix] DeskIcons - Get/Set Desktop Icon Positions - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=3529&p=227874#p227874

- Here's a way to get the name of the file under the cursor via Acc:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


- If you experiment with AccViewer, you can get information for, and see the boundaries of, different GUI windows/controls/elements under the cursor.
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

- Also of interest:
.net - c# how to get window explorer Directory path under mouse cursor - Stack Overflow
https://stackoverflow.com/questions/17130743/c-sharp-how-to-get-window-explorer-directory-path-under-mouse-cursor
c# - Get the folder path under cursor? - Stack Overflow
https://stackoverflow.com/questions/7869944/get-the-folder-path-under-cursor
r2997790
Posts: 21
Joined: 02 Feb 2017, 02:46

Re: Explorer: get name of file under cursor

10 Jul 2018, 23:37

Hi Jesswg,

I was wondering if it was possible to retrieve (in real time) the menu text under a menu?

eg. You press File > Open (and the ACC script would return 'Open' as that is the text under the mouse?

I've had a look at ACC Viewer but it's not possible to have a menu open to interrogate it while using the tool?

Do you think it is possible? Thanks!

Many thanks
R
User avatar
jeeswg
Posts: 4956
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Explorer: get name of file under cursor

10 Jul 2018, 23:48

- Try this to get the text from the GUI element under the cursor.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

- Btw you can use Ctrl+/ to focus a GUI element with AccViewer.
r2997790
Posts: 21
Joined: 02 Feb 2017, 02:46

Re: Explorer: get name of file under cursor

10 Jul 2018, 23:58

Thank you... it works... wonderful!
r2997790
Posts: 21
Joined: 02 Feb 2017, 02:46

Re: Explorer: get name of file under cursor

11 Jul 2018, 00:59

Jesswg, I've had a play with this and it works pretty well... Thank you.

Is it possible to detect the menu state and only run it to detect menu items when the menu is open?

I also had some trouble getting it to work with Photoshop... seems a bit hit and miss... is there any tips/tricks to get it to be more stable with Adobe? Or perhaps they block/don't expose the menu information? I was working intermittently. Odd.

Thank you for your insights.. super helpful.
User avatar
jeeswg
Posts: 4956
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Explorer: get name of file under cursor

11 Jul 2018, 01:06

- Add these lines at the top between 'q::' and 'oAcc :='.

- This will end the subroutine early if no context menu window is detected.
- For Photoshop, which I don't use, I would recommend investigating with AccViewer, try to do the same thing a few times, and look for patterns for when it does/doesn't work.
- Also, try using the ToolTip command to inform you of what's happening, if using the script above.
- No problem, glad they're helpful.

- [EDIT:] Also, check the class of the menu by using MouseGetPos when the cursor is over the menu, the menu may be nonstandard, i.e. not of class #32768.

Code: [Select all] [Download] GeSHi © Codebox Plus

MouseGetPos, vCurX, vCurY, hWnd, vCtlClassNN
WinGetClass, vWinClass, % "ahk_id " hWnd
MsgBox, % vWinClass
- Also, perhaps a menu 'item' is made up of multiple parts (GUI elements), you can check the boundaries with AccViewer.
r2997790
Posts: 21
Joined: 02 Feb 2017, 02:46

Re: Explorer: get name of file under cursor

11 Jul 2018, 05:21

Thank you very much for this feedback... the use case I'm looking to implement is a 'real-time' text translation of menus.

Unfortunately I often have to us apps which don't have english as the first language (but which I am broadly familiar with) and I want to be able to display a (translated) tooltip of the menu item I am currently on top of.

Your input will help a lot.

Thank you.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 24 guests