Anonymous wrote:
how to determine the control Class NN at specific coordinates.
Code:
; Ascertaining Control's hWnd/ClassNN for given coordinates ; By SKAN | 28-March-2010
; Forum Topic : www.autohotkey.com/forum/viewtopic.php?t=45186
If ! WinExist( "Calculator ahk_class SciCalc" ) {
Run Calc
WinWait, Calculator ahk_class SciCalc
}
hWnd := WinExist( "Calculator ahk_class SciCalc" )
hCtrl := Control_ByPos( hWnd,10,10 )
ClassNN := Control_GetClassNN( hWnd,hCtrl )
MsgBox, 0, Control @10`,10, %ClassNN%
Return ; // End of auto-execute section //
Control_ByPos( hPar, x=0, y=0 ) { ; www.autohotkey.com/forum/viewtopic.php?p=343110#343110
hWnd := ( ID := WinExist( "ahk_id" hPar) ) ? ID : WinExist( hPar )
Return WinExist( "ahk_id" DllCall( "ChildWindowFromPoint", UInt,hWnd, Int,x, Int,y ) )
}
Control_GetClassNN( hPar,hCtrl ){ ; www.autohotkey.com/forum/viewtopic.php?p=301151#301151
hWnd := ( ID := WinExist( "ahk_id" hPar) ) ? ID : WinExist( hPar )
WinGet, CH, ControlListHwnd, ahk_id %hWnd%
WinGet, CN, ControlList, ahk_id %hWnd%
LF:= "`n", CH:= LF CH LF, CN:= LF CN LF, S:= SubStr( CH, 1, InStr( CH, LF hCtrl LF ) )
StringReplace, S, S,`n,`n, UseErrorLevel
StringGetPos, P, CN, `n, L%ErrorLevel%
Return SubStr( CN, P+2, InStr( CN, LF, 0, P+2 ) -P-2 )
}