how to get the address of the excel cell under the current mouseover

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cgx5871
Posts: 315
Joined: 26 Jul 2018, 14:02

how to get the address of the excel cell under the current mouseover

Post by cgx5871 » 27 Jan 2022, 04:42

ahk how to get the address of the excel cell under the current mouseover

cgx5871
Posts: 315
Joined: 26 Jul 2018, 14:02

Re: how to get the address of the excel cell under the current mouseover

Post by cgx5871 » 27 Jan 2022, 06:07

Code: Select all

xl :=	ComObj("Excel.Application")
MouseGetPos x,y,A
ToolTip % xl.ActiveWindow.RangeFromPoint(x,y).Address

User avatar
boiler
Posts: 16957
Joined: 21 Dec 2014, 02:44

Re: how to get the address of the excel cell under the current mouseover

Post by boiler » 27 Jan 2022, 08:55

The A you have in your MouseGetPos statement isn’t identifying the active window. You identified A as the variable in which to store the HWND/unique ID of the window under the mouse (and then not use it).

Unless your Excel window is full screen or otherwise is located at 0,0, then you need to specify CoordMode, Mouse, Screen, as in this demo:

Code: Select all

xl := ComObj("Excel.Application")
Coordmode, Mouse, Screen

loop {
	MouseGetPos x,y
	ToolTip % xl.ActiveWindow.RangeFromPoint(x,y).Address
	Sleep, 50
}
return

Esc::Exitapp

Post Reply

Return to “Ask for Help (v1)”