Sign in to follow this  
Followers 0
Zinthose

Mouse Tracking ToolTip w/ Marquee

2 posts in this topic

I'm experimenting with ways to notify the user of a software installs status and came up with a mouse tracking tool tip with a scrolling Marquee. It's a bit too obtrusive for constant display but some someone here might find a use for it.

#Region MouseMove_Event
    #include <String.au3>
    Global Const $WH_MOUSE_LL                   = 14
    Global Const $MOUSE_MOVE_EVENT              = 512

    Dim $hKey_Proc
    Dim $hM_Module
    Dim $hM_Hook
    
    Func _EnableMouseCapture()
        $hKey_Proc  = DllCallbackRegister("_Mouse_Move_Handler", "int", "int;ptr;ptr")
        $hM_Module  = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)
        $hM_Hook    = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0)   
    EndFunc
    
    Func _DisableMouseCapture()
        OnAutoItExit()
    EndFunc
    
    Func _Mouse_Move_Handler($nCode, $wParam, $lParam)
        
        If $MOUSE_MOVE_EVENT = BitAND($wParam, 0xFFFF) Then
            ;ConsoleWrite('Mouse Pad' & @CRLF)
            ToolTip($ToolTip, Default, Default, 'HRAO Software Update')
        EndIf
        
        Return 0
    EndFunc

    Func OnAutoItExit()
        If IsArray($hM_Hook) And $hM_Hook[0] > 0 Then
            DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0])
            $hM_Hook[0] = 0
        EndIf
        
        If IsPtr($hKey_Proc) Then
            DllCallbackFree($hKey_Proc)
            $hKey_Proc = 0
        EndIf
    EndFunc
#EndRegion

Const $Title    = "But why is the rum gone?  "
Const $MarqueeLen = 32

Dim $Caption    = '                "I am dishonest. And a dishonest man you can always trust to be dishonest. Honestly, it''s the honest ones you ought to watch out for, because you can never predict when they''re about to do something incredibly stupid." ~Captain Jack Sparrow'
Dim $ToolTip    = '  ' & _Marquee($Caption, $MarqueeLen)

_EnableMouseCapture()

While True
    Sleep(120)
    $ToolTip =  '  ' & _Marquee($Caption, $MarqueeLen)
    ToolTip($ToolTip, Default, Default, $Title, 2);, 4)
Wend

Func _Marquee(ByRef $StringToScroll, $Length)
    
    If StringLen($StringToScroll) <= $Length Then Return $StringToScroll
    
    If Not IsDeclared('MarqueePosition') Then
        Global $MarqueePosition = 1
    ElseIf $MarqueePosition > StringLen($MarqueePosition) Then
        $MarqueePosition = 1
    Else
        $MarqueePosition += 1
    EndIf
    
    $StringToScroll = Stringmid($StringToScroll, 2) & StringLeft($StringToScroll, 1)
    
    Return stringleft($StringToScroll, $Length)
EndFunc

--- TTFN

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Very Nice! Could be handy for something like an alert for a group of people alerting them of some msg to where they must see it and acknowledge a tray button to get rid of it.. Thanks!

edit: type-O

Edited by gesller

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  
Followers 0