careca

Mouse not Over Tray delay in loop

3 posts in this topic

Hey there, having this issue that is puzzling me:

#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_AU3Check=y
#AutoIt3Wrapper_Run_Debug_Mode=n

#include <Constants.au3>
#include <TrayConstants.au3>

While 1
    $_Msg = TrayGetMsg()
    Switch $_Msg
        Case $TRAY_EVENT_MOUSEOVER
            ConsoleWrite(' $over_icon = 1 - ' & @MSEC & @CRLF)
            ;$begin = TimerInit()
        Case Else
            ConsoleWrite(' $over_icon = 0 - ' & @MSEC & @CRLF)
    EndSwitch
    ;=============================================================================
    ;$Dn = TimerDiff($begin)
    ;If $Dn >= 2000 Then
    ;=============================================================================
    Sleep(100)
WEnd

So if i only pass the mouse over the icon it works fine, detects the mouseover and console responds, but if i keep the mouse over for a few seconds, when i remove the mouse, it keeps outputing as if it's still hovering, and only after some time it responds, it's as if it lags.

How can i make it respond instantly? hover = 1 / not hover =0

Thanks


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Share this post


Link to post
Share on other sites



I think the Sleep(100) is not a good idea.
BTW, the $TRAY_EVENT_MOUSEOVER event is sent only when the mouse moves, so if the user keeps the mouse over the tray icon with moving it, you code won't know that mouse is still over.

I would use an Adlib function and the TrayOnEventMode option, but I think there is an easyer way :

 

#include <Constants.au3>
#include <TrayConstants.au3>

Global $aMousePos, $iMouseOver = 0

Opt("TrayOnEventMode", 1)

TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "_overTray")

While 1
    Sleep(100)
WEnd


Func _overTray()
    $aMousePos = MouseGetPos()
    If Not $iMouseOver Then AdlibRegister("_checkMouseOverTrayAdlib", 100)
    $iMouseOver = 1
EndFunc


Func _checkMouseOverTrayAdlib()
    $aMousePos2 = MouseGetPos()
    If $aMousePos2[0] <> $aMousePos[0] Or $aMousePos2[1] <> $aMousePos[1] Then
        $iMouseOver = 0
        AdlibUnRegister("_checkMouseOverTrayAdlib")
        ConsoleWrite("Mouse not over tray" & @CRLF)
        Return
    EndIf
    ConsoleWrite("Mouse over tray" & @CRLF)
EndFunc

 

Share this post


Link to post
Share on other sites

Ahhh i see, very nice! Thank you. :)


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

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