Jump to content

Recommended Posts

#include <Constants.au3>

    Opt("TrayMenuMode", 3) 
    Opt("TrayOnEventMode", 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")
$exitItem   = TrayCreateItem("Exit")

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

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

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


I have this code that will show the traymenu near the mouse when you click "t". (compile it and run it and click t).

Now the thing is, if i have another compiled autoit script running, it will no longer show the traymenu, instead it will show:




I thought I would solve the issue if I changed the classname "AutoIt v3 GUI", but that didn't solve it:


Edited by legend
Link to post
Share on other sites
1 hour ago, InnI said:

You can use some unique title for AutoIt window


$title = _WinAPI_CreateGUID()


Func ShowTrayMenu()
    DllCall("user32.dll", "int", "SendMessage", "hwnd", WinGetHandle($title), "int", $MY_WM_NOTIFYICON, "int", 0, "int", $WM_LBUTTONDOWN)


Thanks a lot lnnl :) learned something new, I didn't new those 2 commands, it works perfectly 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...