Jump to content

Recommended Posts

Posted

Is it possible to make some sort of deal where if you click on the traytip, the click can be picked up and then say, set a variable. Maybe like how controls act in the GUI for OnEvent mode if using GuiCtrlSetOnEvent.

Dim $var = 1
While 1
    If $var Then
        TrayTip("Traytip","Click here to stop seeing this traytip.",5)
    EndIf
WEnd

Func TraytipIsClicked()
    $var = 0
EndFunc
Posted (edited)

I think Psalty's suggestion is for Tray Menus, not tips...

The problem I ran into with traytips is that WinGetTitle, WinGetText, and WinList aren't able to read any info about them. (Au3Info.exe does, though)

Also, there are dozens of traytip windows hiding, waiting to be shown by their parent programs.

The good news is that under normal circumstances, only one traytip is visible at any given time.

Using this information, you can tell when your traytip disappears and compare it to the amount of time you were expecting it to be shown.

I often needed tips to stay for 3~5 seconds, but the supported range is 10-30. (A limitation of Windows, not of AutoIt)

I wrote this a while ago because I wanted to see if a traytip is clicked, and I wanted greater control of the display time.

I just updated it with the new [CLASS:xxx] syntax:

If _TrayTipWait("Test", "Click Me", 5) Then
    MsgBox(0, "Result", "You Clicked it!")
Else
    MsgBox(0, "Result", "Time's up!")
EndIf

Func _TrayTipWait($s_TrayTitle, $s_TrayText, $i_TimeOut, $i_Option = 0)
    Local $i_PrevMatchMode = Opt("WinTitleMatchMode", 4)
    Local $i_StartTimer, $aWindows, $h_TrayTip, $b_Clicked = 0
    
    If $s_TrayText = "" Then
        TrayTip("", "", 30)
    Else
        $i_StartTimer = TimerInit()
        TrayTip($s_TrayTitle, $s_TrayText, 30, $i_Option)
        
        $aWindows = WinList("[CLASS:tooltips_class32]")
        For $iX = 1 To $aWindows[0][0]
            If BitAND(WinGetState($aWindows[$iX][1]), 2) Then
                $h_TrayTip = $aWindows[$iX][1]
                ExitLoop
            EndIf
        Next
        
        While BitAND(WinGetState($h_TrayTip), 2) And (TimerDiff($i_StartTimer) < (1000 * $i_TimeOut))
            Sleep(100)
        WEnd
        If TimerDiff($i_StartTimer) < (1000 * $i_TimeOut) Then
            ConsoleWrite("Clicked at " & TimerDiff($i_StartTimer) & @CRLF)
            $b_Clicked = 1
        Else
            ConsoleWrite("Not Clicked, Elapsed: " & TimerDiff($i_StartTimer) & @CRLF)
            TrayTip("", "", 10)
            $b_Clicked = 0
        EndIf
    EndIf
    Opt("WinTitleMatchMode", $i_PrevMatchMode)
    Return $b_Clicked
EndFunc   ;==>_TrayTipWait

edit: Removed an unnecessary variable declaration

Edited by Skruge

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Posted (edited)

  Quote

I just updated it with the new [CLASS:xxx] syntax:

Great UDF :), but there is some correction needed:

...
$aWindows = WinList("[CLASS:tooltips_class32]")
...
oÝ÷ ÚÈhºW[y«­¢+Ø(¸¸¸(ÀÌØí]¥¹½ÝÌô]¥¹1¥ÍÐ ÅÕ½Ðí±Í͹µõѽ½±Ñ¥ÁÍ}±ÍÌÌÈÅÕ½Ðì¤(¸¸¸(

otherwise you get the message imidiatly (that user has clicked).

Edit: or maybe this syntax is good in the new versions of AutoIt (higher then 3.2.2.0)?

Thanks, i definitly going to use this one!

Edited by MsCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  Skruge said:

I think Psalty's suggestion is for Tray Menus, not tips...

Just so. I missed that the target was TrayTip.

I said it was a particularly good looking flightless waterfowl, not a very smart one... :">

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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
  • Recently Browsing   0 members

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