Jump to content
Sign in to follow this  
legend

Traymenu open via hotkey

Recommended Posts

legend

im looking for a way to set a hotkey to a traymenu, the hotkey will open the traymenu.

Does anyone know how that can be done? :)

Edited by legend

Share this post


Link to post
Share on other sites
SlackerAl

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.

Share this post


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

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.