Jump to content

Tray Tip Help


Recommended Posts

Hi All,

In VB.Net if we display some message as tray tip and if we click on the tray tip there is an option to set an action like open the tool. For example i am running a tool, when i minimize the tool i am getting a tray message stating "The X Tool is still running" now if i click on the tray tip it will restore the tool back. Do we have a similar type of setting here ? can we do that ?

Thanks in advance!

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

TrayTip() Or TraySetToolTip() in the Help file.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

quote name='guinness' timestamp='1312418959' post='915658']

TrayTip() Or TraySetToolTip() in the Help file.

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
Share on other sites

Hi Guinness,

I am talking about the tray tip. For example if i execute the below code i will get a baloon tip on tray... now if i click on the baloon tip the minimized tool should get restore... is that possible to do ? sorry for not unclear message i posted on top :mellow:

AutoIt uses a hidden window (CLASS AutoIt v3) for handling the tray icon, traytips and balloon tips

so that scripts without a gui can have a tray icon and tips.

There are no event notifications available to the user for the tray tips.

The AutoIt v3 window must be subclassed to get at the tip notifications.

Alternatively, you can create your own tray icon and tip message handler using code in Holgers Modern Menu UDF

I posted a solution for the native AutoIt tray tip a while ago.

here is another version of that code.

Tested in XP SP3 x86 and Vista Ultimate x86

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <Constants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt('MustDeclareVars', 1)
OnAutoItExitRegister("_OnAutoItExitAU3")

HotKeySet("{ESC}", "_Exit")

Global Const $TRAY_CALLBACK = $WM_USER + 1 ;AutoIt callback message value for tray icon (1025), can be retrieved with ReadProcessMemory and TRAYDATA struct
Global Const $NIN_BALLOONSHOW = $WM_USER + 2
Global Const $NIN_BALLOONHIDE = $WM_USER + 3
Global Const $NIN_BALLOONTIMEOUT = $WM_USER + 4
Global Const $NIN_BALLOONUSERCLICK = $WM_USER + 5

Global $hAU3, $hProcNew, $hProcOld, $iDLLUser32, $iTipMsg = -1
$iDLLUser32 = DllOpen("user32.dll") ;keep an open handle to user32.dll for calls to CallWindowProcW()

$hAU3 = _AutoItWinGetHandle()
If @error Then
    ConsoleWrite("-Error: Could not get handle to AutoIt v3 class hidden window" & @CRLF)
    Exit
Else
    $hProcNew = DllCallbackRegister("_AutoItWndProc", "int", "hwnd;uint;wparam;lparam")
    $hProcOld = _WinAPI_SetWindowLong($hAU3, $GWL_WNDPROC, DllCallbackGetPtr($hProcNew))
EndIf


;run a tray balloon tip continuously and receive tip events in main loop
TrayTip("", "I'm the message", 10)

While 1
    Sleep(10)
    ;use a global var and poll it in a loop, or if using a Gui, use event driven code
    ;with GUICtrlCreateDummy() and GUICtrlSendToDummy() using GUICtrlRead()
    ;in message loop mode or GUICtrlSetOnEvent() for event mode.
    Switch $iTipMsg
        Case $NIN_BALLOONTIMEOUT   ; tray balloon tip timeout or click on close X icon
            $iTipMsg = -1 ;must be reset to -1 on each event
            ConsoleWrite("! Balloon Tip Close or Timeout" & @CRLF)
            ;Exit
            TrayTip("I'm a title", "I'm the message", 10, 1)
        Case $NIN_BALLOONUSERCLICK ; click anywhere on balloon tip or tray icon while balloon showing
            $iTipMsg = -1 ;must be reset to -1 on each event
            ConsoleWrite("+ Balloon Tip Click" & @CRLF)
            TrayTip("I'm a title", "I'm the message", 10, 1)
            ;add your restore gui form code here
    EndSwitch
WEnd


Func _Exit()
    TrayTip("", "", 10)
    Exit
EndFunc   ;==>_Exit

;Use this function with OnAutoItExitRegister("_OnAutoItExitAU3") at the top of your script.
;This ensures the AutoIt v3 windows message handling procedure is restored before exiting.
;When windows or controls are subclassed they tend to crash the script on exit if this cleanup is not done.
Func _OnAutoItExitAU3()
    If $hProcOld > 0 Then _WinAPI_SetWindowLong($hAU3, $GWL_WNDPROC, $hProcOld);restore original wndproc
    If $hProcNew > 0 Then DllCallbackFree($hProcNew) ;free up handle to callback
    DllClose($iDLLUser32) ;close open handle to DLL library user32.dll
EndFunc   ;==>_OnAutoItExitAU3

Func _AutoItWndProc($hWnd, $Msg, $wParam, $lParam)
    ;#forceref $hWnd, $Msg, $wParam, $lParam
    Switch $Msg
        Case $TRAY_CALLBACK
            ;do not use blocking code in a subclassed window procedure or in a function called by GUIRegisterMsg().
            ;always return quickly from here.
            ;set a global variable or call GUICtrlSendToDummy() and nothing else
            Switch $lParam
                ;Case $NIN_BALLOONSHOW
                    ;ConsoleWrite('+$NIN_BALLOONSHOW' & @CRLF)
                ;Case $NIN_BALLOONHIDE
                    ;ConsoleWrite('-$NIN_BALLOONHIDE' & @CRLF)
                Case $NIN_BALLOONTIMEOUT; tray balloon tip timeout or click on close X icon
                    $iTipMsg = $lParam
                Case $NIN_BALLOONUSERCLICK ;click anywhere on balloon tip or tray icon while balloon showing
                    $iTipMsg = $lParam
            EndSwitch
    EndSwitch

    ;There is usually a continuous stream of messages in a window procedure handler.

    ;Use a handle to the user32.dll library kept open with DllOpen("user32.dll"),
    ;so that DllCall() does not open and close a new handle with every message.

    ;This is a recommended optimization when using DllCall() in a function where it may be called continuously.
    ;(e.g. a WM_TIMER message is received every 750ms here)

    ;pass the unhandled messages to default WindowProc
    Local $aResult = DllCall($iDLLUser32, "lresult", "CallWindowProcW", "ptr", $hProcOld, _
            "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    If @error Then Return -1
    Return $aResult[0]

EndFunc   ;==>_AutoItWndProc

;===============================================================================
;
; Function Name:   _AutoItWinGetHandle
; Description:: Returns the Windowhandle of AutoIT-Window
; Parameter(s): --
; Requirement(s):  --
; Return Value(s): Autoitwindow Handle
; Author(s):       Prog@ndy
; modified version: rover 2k11
;===============================================================================
;
Func _AutoItWinGetHandle()
    Local $oldTitle = AutoItWinGetTitle()
    Local $x = Random(1248578, 1249780)
    AutoItWinSetTitle("qwrzu" & $x)
    Local $hAv3 = WinGetHandle("[TITLE:qwrzu" & $x & "; CLASS:AutoIt v3]")
    AutoItWinSetTitle($oldTitle)
    If IsHWnd($hAv3) = 0 Then Return SetError(1, 0, 0)
    ;If WinGetProcess($hAv3) <> @AutoItPID Then Return SetError(1, 0, 0)
    Return SetError(0, 0, $hAv3)
EndFunc   ;==>_AutoItWinGetHandle

I see fascists...

Link to comment
Share on other sites

AutoIt uses a hidden window (CLASS AutoIt v3) for handling the tray icon, traytips and balloon tips

so that scripts without a gui can have a tray icon and tips.

There are no event notifications available to the user for the tray tips.

The AutoIt v3 window must be subclassed to get at the tip notifications.

Alternatively, you can create your own tray icon and tip message handler using code in Holgers Modern Menu UDF

I posted a solution for the native AutoIt tray tip a while ago.

here is another version of that code.

Tested in XP SP3 x86 and Vista Ultimate x86

#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <Constants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt('MustDeclareVars', 1)
OnAutoItExitRegister("_OnAutoItExitAU3")

HotKeySet("{ESC}", "_Exit")

Global Const $TRAY_CALLBACK = $WM_USER + 1 ;AutoIt callback message value for tray icon (1025), can be retrieved with ReadProcessMemory and TRAYDATA struct
Global Const $NIN_BALLOONSHOW = $WM_USER + 2
Global Const $NIN_BALLOONHIDE = $WM_USER + 3
Global Const $NIN_BALLOONTIMEOUT = $WM_USER + 4
Global Const $NIN_BALLOONUSERCLICK = $WM_USER + 5

Global $hAU3, $hProcNew, $hProcOld, $iDLLUser32, $iTipMsg = -1
$iDLLUser32 = DllOpen("user32.dll") ;keep an open handle to user32.dll for calls to CallWindowProcW()

$hAU3 = _AutoItWinGetHandle()
If @error Then
    ConsoleWrite("-Error: Could not get handle to AutoIt v3 class hidden window" & @CRLF)
    Exit
Else
    $hProcNew = DllCallbackRegister("_AutoItWndProc", "int", "hwnd;uint;wparam;lparam")
    $hProcOld = _WinAPI_SetWindowLong($hAU3, $GWL_WNDPROC, DllCallbackGetPtr($hProcNew))
EndIf


;run a tray balloon tip continuously and receive tip events in main loop
TrayTip("", "I'm the message", 10)

While 1
    Sleep(10)
    ;use a global var and poll it in a loop, or if using a Gui, use event driven code
    ;with GUICtrlCreateDummy() and GUICtrlSendToDummy() using GUICtrlRead()
    ;in message loop mode or GUICtrlSetOnEvent() for event mode.
    Switch $iTipMsg
        Case $NIN_BALLOONTIMEOUT   ; tray balloon tip timeout or click on close X icon
            $iTipMsg = -1 ;must be reset to -1 on each event
            ConsoleWrite("! Balloon Tip Close or Timeout" & @CRLF)
            ;Exit
            TrayTip("I'm a title", "I'm the message", 10, 1)
        Case $NIN_BALLOONUSERCLICK ; click anywhere on balloon tip or tray icon while balloon showing
            $iTipMsg = -1 ;must be reset to -1 on each event
            ConsoleWrite("+ Balloon Tip Click" & @CRLF)
            TrayTip("I'm a title", "I'm the message", 10, 1)
            ;add your restore gui form code here
    EndSwitch
WEnd


Func _Exit()
    TrayTip("", "", 10)
    Exit
EndFunc   ;==>_Exit

;Use this function with OnAutoItExitRegister("_OnAutoItExitAU3") at the top of your script.
;This ensures the AutoIt v3 windows message handling procedure is restored before exiting.
;When windows or controls are subclassed they tend to crash the script on exit if this cleanup is not done.
Func _OnAutoItExitAU3()
    If $hProcOld > 0 Then _WinAPI_SetWindowLong($hAU3, $GWL_WNDPROC, $hProcOld);restore original wndproc
    If $hProcNew > 0 Then DllCallbackFree($hProcNew) ;free up handle to callback
    DllClose($iDLLUser32) ;close open handle to DLL library user32.dll
EndFunc   ;==>_OnAutoItExitAU3

Func _AutoItWndProc($hWnd, $Msg, $wParam, $lParam)
    ;#forceref $hWnd, $Msg, $wParam, $lParam
    Switch $Msg
        Case $TRAY_CALLBACK
            ;do not use blocking code in a subclassed window procedure or in a function called by GUIRegisterMsg().
            ;always return quickly from here.
            ;set a global variable or call GUICtrlSendToDummy() and nothing else
            Switch $lParam
                ;Case $NIN_BALLOONSHOW
                    ;ConsoleWrite('+$NIN_BALLOONSHOW' & @CRLF)
                ;Case $NIN_BALLOONHIDE
                    ;ConsoleWrite('-$NIN_BALLOONHIDE' & @CRLF)
                Case $NIN_BALLOONTIMEOUT; tray balloon tip timeout or click on close X icon
                    $iTipMsg = $lParam
                Case $NIN_BALLOONUSERCLICK ;click anywhere on balloon tip or tray icon while balloon showing
                    $iTipMsg = $lParam
            EndSwitch
    EndSwitch

    ;There is usually a continuous stream of messages in a window procedure handler.

    ;Use a handle to the user32.dll library kept open with DllOpen("user32.dll"),
    ;so that DllCall() does not open and close a new handle with every message.

    ;This is a recommended optimization when using DllCall() in a function where it may be called continuously.
    ;(e.g. a WM_TIMER message is received every 750ms here)

    ;pass the unhandled messages to default WindowProc
    Local $aResult = DllCall($iDLLUser32, "lresult", "CallWindowProcW", "ptr", $hProcOld, _
            "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam)
    If @error Then Return -1
    Return $aResult[0]

EndFunc   ;==>_AutoItWndProc

;===============================================================================
;
; Function Name:   _AutoItWinGetHandle
; Description:: Returns the Windowhandle of AutoIT-Window
; Parameter(s): --
; Requirement(s):  --
; Return Value(s): Autoitwindow Handle
; Author(s):       Prog@ndy
; modified version: rover 2k11
;===============================================================================
;
Func _AutoItWinGetHandle()
    Local $oldTitle = AutoItWinGetTitle()
    Local $x = Random(1248578, 1249780)
    AutoItWinSetTitle("qwrzu" & $x)
    Local $hAv3 = WinGetHandle("[TITLE:qwrzu" & $x & "; CLASS:AutoIt v3]")
    AutoItWinSetTitle($oldTitle)
    If IsHWnd($hAv3) = 0 Then Return SetError(1, 0, 0)
    ;If WinGetProcess($hAv3) <> @AutoItPID Then Return SetError(1, 0, 0)
    Return SetError(0, 0, $hAv3)
EndFunc   ;==>_AutoItWinGetHandle

This is cool and which i wanted! Also bit complex for my knowledge :) but i will take my own time and will understand how it works :mellow: Thanks a lot rover!

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

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