Jump to content

tray application that show popup GUI - need help


fizyk
 Share

Recommended Posts

Hi,

I'm trying to prepare tray application that show popup GUI. :) Problem is with event that shows/hides popup GUI. I don't know how to show popup GUI when cursor is on tray icon and how to hide it when cursor is out of tray icon.

I used "$TRAY_EVENT_MOUSEOVER" it shows popup but I can't hide it automaticaly.

Please help....

Link to comment
Share on other sites

  • Moderators

fizyk,

Firstly, do not bump a post within 24 hours again. These forums are not a 24/7 tech support - if someone can help you they will, but you need to be patient. If you are not....you will get no help! :-)

But you do get help this time. I think this is what you are looking for - the GUI appears when your cursor is over the icon and vanishes when you move away:

#include <GUIConstantsEx.au3>
#include <Constants.au3>
#Include <GuiToolBar.au3>

Global $aIcon[4]
Find_Icon()

$hWin = GUICreate("Test", 100, 100)
GUISetState(@SW_HIDE, $hWin)

$fShowing = False

While 1
    
    If GUIGetMsg() = -3 Then Exit
    
    $aMouse = MouseGetPos()
    
    If $aMouse[0] >= $aIcon[0] And $aMouse[0] <= $aIcon[2] And $aMouse[1] >= $aIcon[1] And $aMouse <= $aIcon[3] Then
    ; Over icon
        If $fShowing = False Then
            $fShowing = True
            GUISetState(@SW_SHOW, $hWin)
            ConsoleWrite("Showing" & @CRLF)
        EndIf
        
    Else
    ; Off icon
        If $fShowing Then
            ConsoleWrite("Hidden" & @CRLF)
            GUISetState(@SW_HIDE, $hWin)
            $fShowing = False
        EndIf
    EndIf
    
WEnd


Func Find_Icon()

; Find systray handle
$SysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
If @error Then
    MsgBox(16, "Error", "System tray not found")
    Exit
EndIf

; Get systray item count
$Systray_ButCount = _GUICtrlToolbar_ButtonCount($SysTray_Handle)
If $Systray_ButCount = 0 Then
    MsgBox(16, "Error", "No items found in system tray")
    Exit
EndIf

; Look for tooltip
$Tool_Tip = ""
For $Systray_ButtonNumber = 0 To $Systray_ButCount - 1
; Need to change "AutoIt" to name of your exe when compiled
    $Test = StringSplit(_GUICtrlToolbar_GetButtonText($SysTray_Handle, $Systray_ButtonNumber), "AutoIt" ,1)
    If $Test[0] <> 1 Then ExitLoop
Next

If $Systray_ButtonNumber = $Systray_ButCount Then
; Icon not found
    MsgBox(16, "Error", "AutoIt icon not found in system tray")
    Exit
Else
; Get absolute coords of icon
; get icon size
    $aIcon = _GUICtrlToolbar_GetButtonRect($SysTray_Handle, $Systray_ButtonNumber)
; get x coord of systray
    $aSysTray = ControlGetPos('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    $aIcon[0] = $aSysTray[0]
    $aIcon[2] = $aSysTray[0] + $aIcon[2]
; get y coord of taskbar
    $aTaskBar = WinGetPos('[Class:Shell_TrayWnd]', '')
    $aIcon[1] = $aTaskBar[1]
    $aIcon[3] = $aTaskBar[1] + $aIcon[3]
EndIf

EndFunc

Please ask if there is anything you do not understand.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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