Jump to content
Sign in to follow this  
Cusem

Detect window under mousecursor

Recommended Posts

Cusem

Hey guys,

have been searching the forum for a while now and found some stuff about getting the control under the mousecursor.

I just need to get the Windowtitle under the mousecursor when I call a function.

I'm writing a betpot script for Ongame (Pokerroom). Right now I click the window where I want to bet the pot and just use WinGetTitle("", ""), but the focus of the window is stolen if another window needs attention and this happens quite often when 12-tabling. So I want to start the BetPot function with some lines of code that get the window under the mousecursor.

Share this post


Link to post
Share on other sites
rasim

Try this:

$aMousePos = MouseGetPos()

$aWinList = WinList()

For $i = 1 To $aWinList[0][0]
    $aWinPos = WinGetPos($aWinList[$i][1])
    If ($aMousePos[0] >= $aWinPos[0]) And ($aMousePos[0] <= $aWinPos[0] + $aWinPos[2]) _
    And ($aMousePos[1] >= $aWinPos[1]) And ($aMousePos[1] <= $aWinPos[1] + $aWinPos[3]) Then
        MsgBox(0, "", $aWinList[$i][0])
        ExitLoop
    EndIf
Next

Share this post


Link to post
Share on other sites
Cusem

Works like a charm after some fiddling (Winlist($tablecommonstring, $tablecommonstring)) around.

Thanks a lot!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×