Jump to content

MouseOver for any control


bshoenhair
 Share

Recommended Posts

Through this together real quick, nothing special, might come in handy some day.

Code with basic example:

Opt("MouseCoordMode",2)
Run('explorer ' & @TempDir)

$Title = 'Temp'
$Text = FileGetLongName(@TempDir)
$Con = 'SysListView321'

While 1   
   If _IsMouseOverControl($Title,$Text,$Con) Then MsgBox(0,'Mouse Over','Mouse is over control "' & $Con & '"')
   Sleep(10)
WEnd

Func _IsMouseOverControl($WinTitle,$WinText,$Control)
    $C = ControlGetPos($WinTitle,$WinText,$Control)
    If @error Then
        SetError(-1) 
        Return 0
    Else
        $C_X        = $C[0] 
        $C_Y        = $C[1] 
        $C_Width    = $C[2]  
        $C_Height   = $C[3]
    
        $M          = MouseGetPos()
        $M_X        = $M[0]
        $M_Y        = $M[1]
        If WinActive($WinTitle,$WinText) And (($M_X >= $C_X And $M_X <= $C_X + $C_Width) And ($M_Y >= $C_Y And $M_Y <= $C_Y + $C_Height)) Then 
            Return 1
        Else
            Return 0
        EndIf
    EndIf
EndFunc
Link to comment
Share on other sites

Hmmm.... One major problem lol, not really, but its quite annoying.

It open up your @TempDir, then a message box comes up saying what its over... The message box is over the control! So as soon as you click "OK" on the message box you get another one straight away!

qq

Link to comment
Share on other sites

Hmmm.... One major problem lol, not really, but its quite annoying.

It open up your @TempDir, then a message box comes up saying what its over... The message box is over the control! So as soon as you click "OK" on the message box you get another one straight away!

<{POST_SNAPBACK}>

LOL, maybe I should have used "ToolTip" instead of a msgbox, anyway you can see how it works

:) Just move mouse off listview then hit enter.

Link to comment
Share on other sites

Heres a basic example that uses the "tooltip"

Opt("MouseCoordMode",2)
Run('explorer ' & @TempDir)

$Title = 'Temp'
$Text = FileGetLongName(@TempDir)
$Con = 'SysListView321'

While 1  
   If _IsMouseOverControl($Title,$Text,$Con) Then 
       ToolTip('Mouse is over control "' & $Con & '"')
   Else
       ToolTip('')
    EndIf
   Sleep(10)
WEnd

Func _IsMouseOverControl($WinTitle,$WinText,$Control)
    $C = ControlGetPos($WinTitle,$WinText,$Control)
    If @error Then
        SetError(-1)
        Return 0
    Else
        $C_X         = $C[0]
        $C_Y         = $C[1]
        $C_Width    = $C[2]  
        $C_Height    = $C[3]
    
        $M           = MouseGetPos()
        $M_X         = $M[0]
        $M_Y         = $M[1]
        If WinActive($WinTitle,$WinText) And (($M_X >= $C_X And $M_X <= $C_X + $C_Width) And ($M_Y >= $C_Y And $M_Y <= $C_Y + $C_Height)) Then
            Return 1
        Else
            Return 0
        EndIf
    EndIf
EndFunc

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...