Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Popup menu by Left click on Tray icon

  • Please log in to reply
3 replies to this topic
  • Members
  • 175 posts
  • Last active: Feb 13 2012 09:51 AM
  • Joined: 24 Feb 2007
I recently bought a TabletPC. This is a very interesting gadget because the user interface is mainly restricted to one button: the stylus tap on the touchscreen.
It is really struggling to configure the system to be able to work with only the left mouse button.

As an AHK developer, my first challenge was to popup the script's tray menu by clicking with the left mouse button on the script's tray icon.
Here is my solution:
Menu Tray, Click, 1           ; Enable single click action on tray
Gosub AddMenu                 ; Add new default menu
Return                        ; End of initialization

Menu Tray, Delete, ShowMenu   ; Delete temporary default menu item
MouseGetPos MouseX, MouseY    ; Get current mouse position
Menu Tray, Show, %MouseX%, % MouseY - 10  ; Show menu a little upper to enable next click on icon
Menu Tray, Add, ShowMenu      ; Add temporary menu item
Menu Tray, Default, ShowMenu  ; Set to default
After the menu appears the default menu item restores to Open standard menu.
So clicking on the tray icon again while the menu is shown allows you to show the script's main window (which is doubleclick afterall).

The temporary menu item remains invisible as long as you are using the left mouse button on tray icon.

For general purpose, this script can be used to assign two different menus for the script's tray icon: One with the left click, one with the right.
Just replace the 8th line in the original script to:
Menu MyLeftClickMenu, Show

  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Clever! A different left-click tray menu is often useful. With this script it became easy.

  • Members
  • 1 posts
  • Last active: Apr 01 2009 09:06 AM
  • Joined: 01 Apr 2009
Really helpful!


  • Members
  • 389 posts
  • Last active: Oct 11 2015 09:24 PM
  • Joined: 13 Oct 2009

The problem of this code is that it adds an extra menuitem to the menu, that can be seen if you rightclick the icon.

How to bind deleting that menuitem to the rightclick?