Jump to content

Traytip, recognize if it's been pressed


Recommended Posts

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

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]

Link to comment
Share on other sites

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

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

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
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...