Sign in to follow this  
Followers 0
ActualAkshay

Different Tray menus for left and right mouse click

3 posts in this topic

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



#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

#3 ·  Posted (edited)

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  
Followers 0

  • Similar Content

    • OtenMoten
      By OtenMoten
      Hello dear community,
       
      definitely I need external help now. I've did all 'ControlClick() - Tutorials' and read a lot of topics about interaction betweend AutoIT and external programs.
      The most of them are about "Clicking a button ...". In my case it's different because I need to click a specific element within the program.
       
      The 'program' what I am talking about is called Mendeley. It's library software for documents administration.
       
      In the attachements in picture '1.jpg' you can see the red marked Help element. 
      In the picture '2.jpg' you see the context menu of the Help element. This is what I'm trying to do with the ControlClick() function.
       
      Following I represent my code which not worked for me:
      #include <MsgBoxConstants.au3> Opt("WinTitleMatchMode", 2) $hWnd = WinGetHandle("Mendeley Desktop", "") MsgBox($MB_SYSTEMMODAL, "handle check", $hWnd) ControlClick($hWnd, "Mendeley Desktop", "Help") The MsgBox tells me the number of the handle of the Mendeley window. It's not 0 so for me it means the window is recognized correctly.
       
      When I'm execute the script the Help element is not clicked.
      Any suggestions for me?
       
      Kind regards
      OtenMoten


    • WoodGrain
      By WoodGrain
      Hi All,
      I'm using UseTraySetIcon("shell32.dll", xx) to set my tray icon to a specific icon while running, is there a way I can specify this icon when I compile my script into an exe so my exe icon is the same?
      Thanks!
    • 9252Survive
      By 9252Survive
      Hello Guys, 
      Is there a way to have Auto it Exe messages/line number when you hover over the tray icon just at it shows when you run Au3.?
      For an example, if I the script has paused due to WinWait or Sleep I could hover over the icon and it shows the line where it's at. Is there a way to achieve the same with the compiled exe? 
      Many thanks for the help! 
       
    • nacerbaaziz
      By nacerbaaziz
      hello guys
      how are you؟
      I hope to be fine.
      I have a question  please
      how do I get the menu item that was pressed without that contains a variable؟
      For example I have a menu  of Favorites and I want the script recognizes the existing path in the pressed item
      i'll repeat to tell the item does not contain a variable
      Is there any solution
      if you want to explain more I could write an example of what I want.
      Greetings to all,
      thanks in advance
    • boy233
      By boy233
      I need to click on the text "Batch submission" but I can not!
      <div class="batchmenu2" onclick="Go('/lot/')" style="background-color: rgb(255, 255, 255);"> <span class="iconep">l</span> <div class="menu"> <b>Batch submission</b> <br> Bulk messages via file </div> </div> How could I do it?
      How can I click the specific OnClick?