Jump to content
Sign in to follow this  
ActualAkshay

Different Tray menus for left and right mouse click

Recommended Posts

ActualAkshay

Is it possible to show different menus for left click and right on tray icon simultaneously, if yes, please tell how, hoping for a reply soon :bye:

Share this post


Link to post
Share on other sites
Exit

#include <constants.au3>
#include <Misc.au3>
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1) ;0=disable, 1=enable
Global $traymode = "Primary", $Item1, $Item2
$Item1 = TrayCreateItem("Item 1")
TrayItemSetOnEvent(-1, "_Tray")
$Item2 = TrayCreateItem("Item 2")
TrayItemSetOnEvent(-1, "_Tray")
$exit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_Tray")
TraySetClick(18)
TraySetState()
Exit _Main()
Func _Main()
While Sleep(10)
If _IsPressed("01") Then
$traymode = "Primary"
TrayItemSetText($Item1, $traymode & " 1")
TrayItemSetText($Item2, $traymode & " 2")
EndIf
If _IsPressed("02") Then
$traymode = "Secondary"
TrayItemSetText($Item1, $traymode & " 1")
TrayItemSetText($Item2, $traymode & " 2")
EndIf
WEnd
EndFunc ;==>_Main
Func _Tray()
TrayItemSetState(@TRAY_ID, $TRAY_UNCHECKED)
Local $Text
Switch @TRAY_ID & $traymode
Case $Item1 & "Primary"
$Text = "Primary 1"
Case $Item1 & "Secondary"
$Text = "Secondary 1"
Case $Item2 & "Primary"
$Text = "Primary 2"
Case $Item2 & "Secondary"
$Text = "Secondary 2"
Case Else
Exit MsgBox(262144, "", @LF & " Exit" & @LF, 1)
EndSwitch
MsgBox(262144, "", @LF & $Text & " pressed" & @LF, 2)
EndFunc ;==>_Tray


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
ActualAkshay

Thank you!! :) but is there a way by which it can be done without using _IsPressed() in the sleep(10) loop?

Edited by ActualAkshay

Share this post


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
Sign in to follow this  

  • Similar Content

    • Pagi
      By Pagi
       
      <a href="index.php=4143b27b41db0a40c499202865c3e24d" class="menuitem " target="\_self"> "Menu Item 1" </a>
      Can you tell me if it´s possible to click this menu button? If yes, how? Cause I have no idea, I think i should use _IETagNameGetCollection
    • Pike
      By Pike
      Hello Everyone,
      New Guy here. This is a two-part question, hopefully easy enough though. I know it's ugly coding, this is because I have only a couple hours worth of coding experience and could really use some help.
      1) When I single click the button I want one action (like playing a sound clip) and when I double click the button I want a different action (such as opening dialogue box to ask for soundclip directory address). At the bottom of the script I made a comment which one I would like single click versus double click.
      2) I can not get the FileOpenDialogue to save the file address to the config.ini file at the 'One' position on the .ini.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <Sound.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $OneID _Main() Func _Main() GUICreate("Form1", 156, 86, 281, 276) $OneID = GUICtrlCreateButton("Button", 15, 17, 122, 37) GUICtrlSetOnEvent($OneID, "OnOne") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() While 1 While 1 Sleep(1000) WEnd WEnd EndFunc ;---------------Functions------------- While 1 Sleep(100) WEnd Func OnOne() ; ******************Single Click for this action**************** $OneID = IniRead("config.ini", "Config", "One", $OneID) If $OneID = True Then SoundPlay($OneID, @HotKeyPressed) Else ; *******Double Click for this action*****And Help Saving File Address to config.ini 'One'*********** $OneID = FileOpenDialog("Select file", @WorkingDir, "All (*.*)") IniWrite("config.ini", "Config", "One", $OneID) $OneID = InputBox("Enter Information", "Short Name for File?", "") IniWrite("config.ini", "Config", "NameOne", $OneID) EndIf EndFunc Any help would be greatly appreciated, and if you need anymore clarity as to what exactly I'm trying to do, please do not hesitate to ask. Thanks so much!
      Pike
    • nacerbaaziz
      By nacerbaaziz
      Hello
      I have an inquiry please
      when i use the control get focus
      it don't detect the menu item
      there are any Method to do that?
      i'll use that to make a custom screen reader in my program
      please help me to do that
      I am waiting for your answers
      greetings to you
      Thank you in advance
       
    • dadalt
      By dadalt
      Hi!
      I have a button where I need to close it!
      I was doing through  clicking same position in screen but there are some id's that have different sizes.
      What are the possible ways to click this closable button?
      Is there a way to close it through id? Is there a way to get it's position through it's ID?  
      Thanks in advance!


    • nacerbaaziz
      By nacerbaaziz

      Hello all
      I have a question please
      this  a question is about the context menu
      When i create a list box  Or combo box
      if i create a context menu for this list
      When i press the application key or the shortcut shift + f10
      the menu options is appear normally
      but When i create a List view
      if i create a context menu for this list
      When i press the application key or the shortcut shift + f10
      the menu options isn't appear
      But the right mouse button works normally
      I need a solution please because I deal with the screen readers users
      Unfortunately They can not use the mouse to navigate
      So I have to find a solution to activate keyboard shortcuts
      am waiting  for your help
×