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- and double-click of scripts Tray icon

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



Joined: 03 Nov 2004
Posts: 51

PostPosted: Sat Aug 06, 2005 12:27 pm    Post subject: Single- and double-click of scripts Tray icon Reply with quote

The script illustrates a method of recognition of single- and double-click an icon in system tray.

The basic difficulty - definition of a source of users select (an icon or the menu). The first variant: with definition of event " the right key of the mouse has been pressed, so the menu has been shown "

Code:
#Persistent

   Hotkey, RButton, RightClick

   Menu, Tray, Click, 1
   Menu, Tray, NoStandard
   Menu, Tray, Add, Single Click,    SingleClick
   Menu, Tray, Add, Double Click, DoubleClick
   Menu, Tray, Default, Double Click
   Menu, Tray, Add, Exit
   Return

DoubleClick:
   If RClicked <> Yes
      {
         If Clicks =
            {
               SetTimer, SingleClick, 500
               Clicks = 1
               Return
            }
      }
   SetTimer, SingleClick, Off
   MsgBox, 0, Message, Double Click Detected!
   Clicks =
   RClicked =
   Return

SingleClick:   
   SetTimer, SingleClick, Off
   MsgBox, 0, Message, Single Click Detected!
   Clicks =
   RClicked =
   Return
   
RightClick:
   RClicked = Yes
   GetKeyState, state, RButton, P
   If state = D
      {
         Send, {RButton down}
         KeyWait, RButton
         Send, {RButton up}
      }
   Else
      {
         Send, {RButton}
      }
   RClicked =
   Return
   
Exit:
   ExitApp


The second variant: with definition of event " after the first click the mouse is not above a system tray, so the menu has been shown and the item of the menu was selected"

Code:
#Persistent

   Menu, Tray, Click, 1
   Menu, Tray, NoStandard
   Menu, Tray, Add, Single Click,    SingleClick
   Menu, Tray, Add, Double Click, DoubleClick
   Menu, Tray, Default, Double Click
   Menu, Tray, Add, Exit
   Return

DoubleClick:
   MouseGetPos, , , WhichWindow, WhichControl
   WinGetClass, WhichClass, ahk_id %WhichWindow%
   If WhichClass = Shell_TrayWnd
      {
         IfInString, WhichControl, ToolbarWindow32
            {
               If Clicks =
                  {
                     SetTimer, SingleClick, 500
                     Clicks = 1
                     Return
                  }
            }
      }
   SetTimer, SingleClick, Off
   Sleep, 500   
   MsgBox, 0, Message, Double Click Detected!
   Clicks =
   Return

SingleClick:   
   SetTimer, SingleClick, Off
   MsgBox, 0, Message, Single Click Detected!
   Clicks =
   Return
   
Exit:
   ExitApp


It is necessary only to exclude threefold- and multiply-clicks (sorry, but I donīt know). Any ideas?
Back to top
View user's profile Send private message Visit poster's website
skrommel



Joined: 30 Jul 2004
Posts: 178

PostPosted: Sat Aug 06, 2005 10:25 pm    Post subject: Yes! Reply with quote

Yes!

Skrommel
Back to top
View user's profile Send private message Visit poster's website
user



Joined: 05 Oct 2006
Posts: 423

PostPosted: Tue Jun 12, 2007 3:22 pm    Post subject: Reply with quote

didnt get what this script does, can you tell me please
Back to top
View user's profile Send private message
skrommel



Joined: 30 Jul 2004
Posts: 178

PostPosted: Fri Jun 15, 2007 3:35 am    Post subject: Reply with quote

Smile It executes one action when you singleclick, and another action when you doubleclick the tray icon. Very handy.
_________________
www.1HourSoftware.com
Back to top
View user's profile Send private message Visit poster's website
user



Joined: 05 Oct 2006
Posts: 423

PostPosted: Fri Jun 15, 2007 1:41 pm    Post subject: Reply with quote

yes, it sounds very handy indeed

but I dont think ahk can distinguish different tray icons

this script does? can I select different tray icons and set single click and double click (right, left, middle click) actions?

how can I do this?

thanks
Back to top
View user's profile Send private message
skrommel



Joined: 30 Jul 2004
Posts: 178

PostPosted: Fri Jun 22, 2007 2:07 am    Post subject: Only your own Reply with quote

Smile No, only your own tray icon.
_________________
www.1HourSoftware.com
Back to top
View user's profile Send private message Visit poster's website
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