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 

Single click vs Double click on tray icon

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Compumyst



Joined: 10 Oct 2007
Posts: 8
Location: Portland, OR

PostPosted: Tue Oct 21, 2008 6:04 pm    Post subject: Single click vs Double click on tray icon Reply with quote

Is there a method to differentiate between a single click and double click, and possibly somethink like a shift-click, on the tray icon, so that I could perform different functions depending on which click type was received?

If you want a good example of the effect I'm going for, take a look at the volume icon (WinXP version) -- single click brings up the volume slider, double click brings up the "Volume Control" application.

I know this last part is probably impossible, but if I could set the "Default" item to either something not in the menu list or be the double click action (like the volume icon does), that would be wonderful.
_________________
Work is work; Life is life; Fair is not
Back to top
View user's profile Send private message
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Tue Oct 21, 2008 7:36 pm    Post subject: Reply with quote

Compumyst wrote:
Is there a method to differentiate between a single click and double click, and possibly somethink like a shift-click, on the tray icon, so that I could perform different functions depending on which click type was received?


Code:
OnMessage(0x404, "AHK_NOTIFYICON") ; WM_USER + 4
Return

AHK_NOTIFYICON(wParam, lParam)
{
   Global click

   If lParam = 0x201 ; WM_LBUTTONUP
   {
      click = 1
      SetTimer, clickcheck, -250
      Return 0
   }
   Else If lParam = 0x203 ; WM_LBUTTONDBLCLK   
   {
      click = 2
      Return 0
   }
}

clickcheck:
If (GetKeyState("Shift", "P") && click = 1)
{
   Msgbox Shift+1
}   
Else If (GetKeyState("Shift", "P") && click = 2)
{
   Msgbox Shift+2
}   
Else If click = 1
{
   Msgbox 1
}
Else If click = 2
{
   Msgbox 2
}
Return

_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Tue Oct 21, 2008 7:59 pm    Post subject: Reply with quote

Here is another way to do it, this determine as many clicks as you like:

Code:
#Persistent
Menu, Tray, Add, TEST, TEST
Menu, Tray,Default, TEST
Menu, Tray, Click, 1
Return

TEST:
If x = 5 ;here you can set how many clicks user can do max
   Return
x++
SetTimer, Run, 300 ;here you need to experiment to suit you
SetTimer, DEL, 350
Return

Run:
SetTimer, Run, Off
MsgBox % x
Return


DEL:
SetTimer, DEL, Off
x=
Return

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
Compumyst



Joined: 10 Oct 2007
Posts: 8
Location: Portland, OR

PostPosted: Tue Oct 21, 2008 8:56 pm    Post subject: Reply with quote

@Serenity: That is exactly what I was looking for. Thank you. I was figuring that I would need to use timers somewhere in there, but I wasn't quite sure how to impliment them properly.
_________________
Work is work; Life is life; Fair is not
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 8255
Location: Maywood, IL

PostPosted: Wed Oct 22, 2008 4:58 am    Post subject: Reply with quote

@Serenity: very elegant.
_________________

(Common Answers)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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