Jump to content

Traymenu open via hotkey


legend
 Share

Recommended Posts

Unbelievably ugly, I really hope someone has a nicer method....

Opt("WinSearchChildren", 1)
Opt("WinTitleMatchMode", 4)

HotKeySet("{F10}", "TrayIconClick")

While 1
    sleep (100)
WEnd

Func TrayIconClick()
  WinActivate("[CLASS:TrayNotifyWnd]")
  Send("{ENTER}")
EndFunc

 

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Link to comment
Share on other sites

18 hours ago, Danp2 said:

Have you reviewed this thread?

 

This one works pretty good, it does what i want, the problem is i'm using a tray menu udf, witch will not work with the following code:

#include <Constants.au3>

Opt("TrayMenuMode", 1)
Opt("WinTitleMatchMode", 4)

Global Const $WM_USER           = 0x0400
Global Const $MY_WM_NOTIFYICON  = $WM_USER + 1
Global Const $WM_LBUTTONDOWN    = 0x0201

$aboutItem  = TrayCreateItem("About")
TrayCreateItem("")
$exitItem   = TrayCreateItem("Exit")

HotKeySet("^!t", "ShowTrayMenu") ; Ctrl + Alt + t

While 1
    $Msg = TrayGetMsg()
    Switch $Msg
        Case $exitItem
            ExitLoop
        Case $aboutItem
            Msgbox(0, "Info", "Just for fun...")
    EndSwitch
WEnd

Exit

Func ShowTrayMenu()
    DllCall("user32.dll", "int", "SendMessage", _
                                "hwnd", WinGetHandle("classname=AutoIt v3"), _
                                "int", $MY_WM_NOTIFYICON, _
                                "int", 0, _
                                "int", $WM_LBUTTONDOWN)
EndFunc

 

 

UDF: 

 

I'm having a simple tray menu with icons:

 

#include "ModernMenuRaw.au3"

#NoTrayIcon
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 7)

_SetFlashTimeOut(250)
$nTrayIcon = _TrayIconCreate("My program", "shell32.dll", -209) 

_TrayCreateContextMenu()
$bUseAdvTrayMenu = False

$nExit = _TrayCreateItem('Exit')
GUICtrlSetOnEvent(-1, "_Quit")
_TrayItemSetIcon(-1, "shell32.dll", -216)

_TrayIconSetState()

While 1
    Sleep(10000)
WEnd

Func _Quit()
    _TrayIconDelete($nTrayIcon)
    Exit
EndFunc

 

Edited by legend
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...