AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Popup menu by Left click on Tray icon

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
HuBa



Joined: 24 Feb 2007
Posts: 172
Location: Budapest, Hungary

PostPosted: Mon Dec 17, 2007 8:01 pm    Post subject: Popup menu by Left click on Tray icon Reply with quote

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:
Code:
Menu Tray, Click, 1           ; Enable single click action on tray
Gosub AddMenu                 ; Add new default menu
Return                        ; End of initialization

ShowMenu:
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
AddMenu:
Menu Tray, Add, ShowMenu      ; Add temporary menu item
Menu Tray, Default, ShowMenu  ; Set to default
Return

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:
Code:
Menu MyLeftClickMenu, Show


Last edited by HuBa on Mon Dec 17, 2007 10:12 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Mon Dec 17, 2007 8:29 pm    Post subject: Reply with quote

Clever! A different left-click tray menu is often useful. With this script it became easy.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group