nitekram

TrayCreateItem setting ToolTips

16 posts in this topic

I have tried _GUIToolTip_AddTool() & GUICtrlSetTip() & TrayItemGetHandle()  but have had no luck...is there a way that I have missed, or is it not possible to create a ToolTip for an individual item in the Tray?

1 person likes this

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites



I have tried this, with no success. It is only an example, so you with have to kill the process to kill the script.

 

#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.


Global $tAlarmItem = TrayCreateItem("test")
;GUICtrlSetTip($tAlarmItem, "tip of my label")

Global $hAlarmItemTrayTip = TrayItemGetHandle($tAlarmItem)
GUICtrlSetTip($hAlarmItemTrayTip, "tip of my label")

While 1

WEnd

 


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

It's a good question.

Sorry I could not help.

Here's what I was trying for the record.

#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.
#include <GuiToolTip.au3>
HotKeySet("{Esc}", "_Exit")

Opt("TrayMenuMode", 7) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayIconHide", 0)
TraySetToolTip(" ")


$hwnd = WinGetHandle(AutoItWinGetTitle())
Global $tAlarmItem = TrayCreateItem("test")
$chwnd = ControlGetHandle($hwnd, "", $tAlarmItem) ;GUICtrlGetHandle($tAlarmItem)
$tt = _GUIToolTip_Create($chwnd)
_GUIToolTip_AddTool($tt, $chwnd, "Tip Text")

While 1
    Sleep(1000)
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

GUICtrl functions generally work with control IDs and not handles to controls.Also, the TrayItemGetHandle function doesn't seem to work on TrayItems, only on TrayCreate IDs. Sounds like it's either misnamed, or not working as it should.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It's a good question.

Sorry I could not help.

Here's what I was trying for the record.

#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.
#include <GuiToolTip.au3>
HotKeySet("{Esc}", "_Exit")

Opt("TrayMenuMode", 7) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayIconHide", 0)
TraySetToolTip(" ")


$hwnd = WinGetHandle(AutoItWinGetTitle())
Global $tAlarmItem = TrayCreateItem("test")
$chwnd = ControlGetHandle($hwnd, "", $tAlarmItem) ;GUICtrlGetHandle($tAlarmItem)
$tt = _GUIToolTip_Create($chwnd)
_GUIToolTip_AddTool($tt, $chwnd, "Tip Text")

While 1
    Sleep(1000)
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

I have tried that as well, no luck, and that is what I actually tried first as my GUI already was using this same process/function with no issues

 

EDIT

I also tried the same code with the TrayItemGetHandle with no luck either

 

 

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

A way to do it is to use a WH_MSGFILTER hook procedure to catch the messages from the tray menu:

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Global Const $tagMSG = "hwnd hwnd;uint message;wparam wParam;lparam lParam;dword time;int X;int Y"
Global $iDisplay, $iPrinter, $iAbout, $iExit

Example()

Func Example()
  Local $iSettings = TrayCreateMenu("Settings") ; Create a tray menu sub menu with two sub items.
  $iDisplay = TrayCreateItem("Display", $iSettings)
  $iPrinter = TrayCreateItem("Printer", $iSettings)
  TrayCreateItem("") ; Create a separator line.

  $iAbout = TrayCreateItem("About")
  TrayCreateItem("") ; Create a separator line.

  $iExit = TrayCreateItem("Exit")
  
  Local $hMessageHandler = DllCallbackRegister( "MessageHandler", "long", "int;wparam;lparam" )
  Local $hMessageHook = _WinAPI_SetWindowsHookEx( $WH_MSGFILTER, DllCallbackGetPtr( $hMessageHandler ), 0, _WinAPI_GetCurrentThreadId() )

  TraySetState(1) ; Show the tray menu.

  While 1
    Switch TrayGetMsg()
      Case $iAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
        MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
            "Version: " & @AutoItVersion & @CRLF & _
            "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

      Case $iDisplay, $iPrinter
        MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.")

      Case $iExit ; Exit the loop.
        ExitLoop
    EndSwitch
  WEnd

  DllCallbackFree( $hMessageHandler )
  _WinAPI_UnhookWindowsHookEx( $hMessageHook )
EndFunc   ;==>Example

Func MessageHandler( $nCode, $wParam, $lParam )
  Local $tMSG = DllStructCreate( $tagMSG, $lParam )
  Local $iMsg = DllStructGetData( $tMSG, "message" )
  If $iMsg = $WM_MENUSELECT Then
    Local $iwParam = DllStructGetData( $tMSG, "wParam" )
    Local $idMenu = BitAND( $iwParam, 0xFFFF )
    Switch $idMenu
      Case $iDisplay
        ToolTip( "Tooltip for Display menu" )
      Case $iPrinter
        ToolTip( "Tooltip for Printer menu" )
      Case $iAbout
        ToolTip( "Tooltip for About menu" )
      Case $iExit
        ToolTip( "Tooltip for Exit menu" )
      Case Else
        ToolTip( "" )
    EndSwitch
  EndIf
EndFunc

 

1 person likes this

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

A way to do it is to use a WH_MSGFILTER hook procedure to catch the messages from the tray menu:

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Global Const $tagMSG = "hwnd hwnd;uint message;wparam wParam;lparam lParam;dword time;int X;int Y"
Global $iDisplay, $iPrinter, $iAbout, $iExit

Example()

Func Example()
  Local $iSettings = TrayCreateMenu("Settings") ; Create a tray menu sub menu with two sub items.
  $iDisplay = TrayCreateItem("Display", $iSettings)
  $iPrinter = TrayCreateItem("Printer", $iSettings)
  TrayCreateItem("") ; Create a separator line.

  $iAbout = TrayCreateItem("About")
  TrayCreateItem("") ; Create a separator line.

  $iExit = TrayCreateItem("Exit")
  
  Local $hMessageHandler = DllCallbackRegister( "MessageHandler", "long", "int;wparam;lparam" )
  Local $hMessageHook = _WinAPI_SetWindowsHookEx( $WH_MSGFILTER, DllCallbackGetPtr( $hMessageHandler ), 0, _WinAPI_GetCurrentThreadId() )

  TraySetState(1) ; Show the tray menu.

  While 1
    Switch TrayGetMsg()
      Case $iAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
        MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
            "Version: " & @AutoItVersion & @CRLF & _
            "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

      Case $iDisplay, $iPrinter
        MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.")

      Case $iExit ; Exit the loop.
        ExitLoop
    EndSwitch
  WEnd

  DllCallbackFree( $hMessageHandler )
  _WinAPI_UnhookWindowsHookEx( $hMessageHook )
EndFunc   ;==>Example

Func MessageHandler( $nCode, $wParam, $lParam )
  Local $tMSG = DllStructCreate( $tagMSG, $lParam )
  Local $iMsg = DllStructGetData( $tMSG, "message" )
  If $iMsg = $WM_MENUSELECT Then
    Local $iwParam = DllStructGetData( $tMSG, "wParam" )
    Local $idMenu = BitAND( $iwParam, 0xFFFF )
    Switch $idMenu
      Case $iDisplay
        ToolTip( "Tooltip for Display menu" )
      Case $iPrinter
        ToolTip( "Tooltip for Printer menu" )
      Case $iAbout
        ToolTip( "Tooltip for About menu" )
      Case $iExit
        ToolTip( "Tooltip for Exit menu" )
      Case Else
        ToolTip( "" )
    EndSwitch
  EndIf
EndFunc

 

This is closer than I have got, so it will work, but a single question...I notice that the message comes up and is cut off, is there someway I can have it pop to from the left, rather than the right?

 

EDIT - it appears that depending on where you first interact with the control that it places it to the right, so going all the way to the right of the control, will cut off even more of the displayed tooltip.

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Yes, set the x and y parameters of ToolTip()

That is the ticket...thanks for everyone's help!!!


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

And you can get the current mouse position as the X and Y members of the $tagMSG structure.

I have not worked with this type of variable before...I tried to use Msgbox to get the info, but that did not work, as I just got over lapping Msgboxes. How would I pull that info?
I have also tried:

ConsoleWrite(DllStructGetData($tagMSG, 'x') & @CRLF)
ConsoleWrite(DllStructGetData($tagMSG, 'y') & @CRLF)

I have also tried this:

 

Func MessageHandler($nCode, $wParam, $lParam)
    Local $tMSG = DllStructCreate($tagMSG, $lParam)
    Local $iMsg = DllStructGetData($tMSG, "message")

    Local $x, $y


Local $iMouse_X = DllStructCreate($tagMSG, $x)
Local $iMouse_Y = DllStructCreate($tagMSG, $y)
    ConsoleWrite(DllStructGetData($tagMSG, $iMouse_X) & ' x ' & @CRLF)
    ConsoleWrite(DllStructGetData($tagMSG, 'y') & @CRLF)

I would say I am a real noob when it comes to pointers, so any further help would be appreciative. For the time being, I am just using the desktop width as a way of getting it to a somewhat readable area - would use also stringlen() after creating the string for each tooltip

 

Actually a real noob at Structs - looking to use this as a way of maybe learning it a little better. Thanks again for your help.

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I got it now...took a bit, thanks again everyone

 

Func MessageHandler($nCode, $wParam, $lParam)
    Local $tMSG = DllStructCreate($tagMSG, $lParam)
    Local $iMsg = DllStructGetData($tMSG, "message")
    Local $iX = DllStructGetData($tMSG, "X")
    Local $iY = DllStructGetData($tMSG, "Y")

 

EDIT not resolved yet

Okay, that was giving me the mouse cords, but I was not able to get the tooltip to show...also I was getting (not every time, but at least once while hovering mouse over the toolbaritem - X = 1476462617 Y = -180939672

 

I do not think my screen is that large lol, so I must be doing something wrong?

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Yeah I get weird results with 

Case $iPrinter
        ToolTip( DllStructGetData($tMSG, "X") & "," & DllStructGetData($tMSG, "Y"))

I just used

Case $iDisplay
        ToolTip( "Tooltip for Display menu", MouseGetPos(0) - 150,  MouseGetPos(1) - 20)

 


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

It seems as if X and Y is only the current mouse position if it's a mouse related message eg. $WM_MOUSEMOVE. For other messages X and Y seems to be undefined. This should work:

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Global Const $tagMSG = "hwnd hwnd;uint message;wparam wParam;lparam lParam;dword time;int X;int Y"
Global $iDisplay, $iPrinter, $iAbout, $iExit

Example()

Func Example()
  Local $iSettings = TrayCreateMenu("Settings") ; Create a tray menu sub menu with two sub items.
  $iDisplay = TrayCreateItem("Display", $iSettings)
  $iPrinter = TrayCreateItem("Printer", $iSettings)
  TrayCreateItem("") ; Create a separator line.

  $iAbout = TrayCreateItem("About")
  TrayCreateItem("") ; Create a separator line.

  $iExit = TrayCreateItem("Exit")
  
  Local $hMessageHandler = DllCallbackRegister( "MessageHandler", "long", "int;wparam;lparam" )
  Local $hMessageHook = _WinAPI_SetWindowsHookEx( $WH_MSGFILTER, DllCallbackGetPtr( $hMessageHandler ), 0, _WinAPI_GetCurrentThreadId() )

  TraySetState(1) ; Show the tray menu.

  While 1
    Switch TrayGetMsg()
      Case $iAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
        MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
            "Version: " & @AutoItVersion & @CRLF & _
            "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

      Case $iDisplay, $iPrinter
        MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.")

      Case $iExit ; Exit the loop.
        ExitLoop
    EndSwitch
  WEnd

  DllCallbackFree( $hMessageHandler )
  _WinAPI_UnhookWindowsHookEx( $hMessageHook )
EndFunc   ;==>Example

Func MessageHandler( $nCode, $wParam, $lParam )
  Local Static $iMouseX, $iMouseY
  Local $tMSG = DllStructCreate( $tagMSG, $lParam )
  Local $iMsg = DllStructGetData( $tMSG, "message" )
  Switch $iMsg
    Case $WM_MENUSELECT
      Local $iwParam = DllStructGetData( $tMSG, "wParam" )
      Local $idMenu = BitAND( $iwParam, 0xFFFF )
      Switch $idMenu
        Case $iDisplay
          ToolTip( "Tooltip for Display menu", $iMouseX - 100, $iMouseY )
        Case $iPrinter
          ToolTip( "Tooltip for Printer menu", $iMouseX - 100, $iMouseY )
        Case $iAbout
          ToolTip( "Tooltip for About menu", $iMouseX - 100, $iMouseY )
        Case $iExit
          ToolTip( "Tooltip for Exit menu", $iMouseX - 100, $iMouseY )
        Case Else
          ToolTip( "" )
      EndSwitch
    Case $WM_MOUSEMOVE
      $iMouseX = DllStructGetData( $tMSG, "X" )
      $iMouseY = DllStructGetData( $tMSG, "Y" )
  EndSwitch
EndFunc

 

Share this post


Link to post
Share on other sites

That worked great...thanks - I had to add the stringlen() though, as each tool tip message was different in size, so some still extended outside of the display.

I thank you again for your help, but I wish it was as easy as adding tooltips to a GUI.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

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

  • Similar Content

    • Skysnake
      By Skysnake
      Local $idRep = GUICtrlCreateMenuItem(">My First Report", $idReportmenu) GUICtrlSetTip($idRep, "Standard Report") Nothing appears obvious.  It may be impossible to set a tip to a menu Item... ?
      Any ideas please?
    • nitekram
      By nitekram
      Looked around, but could not find anything, and thought I would just ask if it was possible. Looking to pop a png or jpg file on hover over a TrayCreateItem - is that possible (similar to HTML, where you hover over an item, and either a larger pic or a different pic shows while hover (just as a reference to what I am looking to achieve)?
    • TrickyDeath
      By TrickyDeath
      Hello everyone,
      i do have a simple question what i do not realy understand what hapend and why.
      I did made a small program, what is converting Valuta prices to other type, cause i got tired of use all the time google for it. After that i "convert" it into an exe file. All the Valute prices are in INI file, and work perfect.
      I did made another small script (Tray menu) and then when i click on the proper TrayItem it should run the Valute exchanger exe file, but something is wrong. The exe is running, but when i calculate with it, it give me only 0 resoults. If i run the exe manualy it is work properly. How does it come, from Tray menu item wont work, and from manualy run it work hot it have to work?
      Case $iValutaCalculator Run("C:\Users\asd\Desktop\EU_USD.exe") Best Regards,
      Tricky
    • Tankbuster
      By Tankbuster
      Could someone please explain where my thoughts went wrong?

      GUICtrlSetTip($arrTemp[$i][0],$arrTemp[$i][1])
      I searched the forum and I found of course some posts, but I didn't found the right idea/hint.
      I fear it's a face palm for me.....

      I stripped down everything to this:

      #include <Debug.au3> #include <array.au3> _DebugSetup(@ScriptName,False,2) #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 351, 270, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 64, 32, 217, 65) $Button2 = GUICtrlCreateButton("Button2", 64, 112, 217, 65) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### local $MessageBundletextfile="MSGBUNDLE.INI" local $arrTemp $arrTemp=IniReadSection($MessageBundletextfile,"CONTROLTIP") _ArrayDisplay($arrTemp) for $i = 1 to $arrTemp[0][0] _debugout($arrTemp[$i][0]&":"&$arrTemp[$i][1]) GUICtrlSetTip($arrTemp[$i][0],$arrTemp[$i][1]) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd

      File Conent of $MessageBundletextfile="MSGBUNDLE.INI"

      [CONTROLTIP] $hGui = "Hello" $Button1 = "Tip on Button1" $Button2 = "Tip on Button2"
    • johnmcloud
      By johnmcloud
      Hi guys, i have this script:

      #NoTrayIcon #include <GuiConstantsEx.au3> #include <Constants.au3> Global $About, $Exit Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 3) TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "SpecialEvent") TraySetOnEvent($TRAY_EVENT_SECONDARYUP,"TrayMenu") GUICreate("TestGUI", 392, 316, -1, -1) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) TraySetState(1) ; show Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func TrayMenu() Local $About = TrayCreateItem("About") TrayCreateItem("") ; Create a separator line. Local $Exit = TrayCreateItem("Exit") While 1 Switch TrayGetMsg() Case $About MsgBox(0,0,"Test") Case $Exit ; Exit the loop. ExitLoop EndSwitch WEnd EndFunc Func SpecialEvent() GUISetState(@SW_SHOW) TraySetState(2) ; hide EndFunc ;==>SpecialEvent
      I want to minimize the GUI ( work ) and, when minimized, add a menu to the tray icon ( i see the menù but don't work )

      Second question, i have a Func with a MsgBox at the end. I'd like to have a MsgBox only if the GUI isn't minimized, so how to check the status of the GUI? Example if not minimized do a MsgBox, if is minimized do a TrayTip.

      Thanks for support