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

    • WoodGrain
      By WoodGrain
      Hi guys,
       
      I've written a script that will move my mouse to a location on the screen whenever my remote access software becomes active, the problem I have is that as soon as the remote access software becomes active it appears to capture the mouse and keyboard so nothing happens when I use MouseMove().
       
      Is there any way around this?
       
      Thanks!
    • Dalex
      By Dalex
      It has been a while since I last installed and used Autoit, I just installed the latest version along with Scite.  For some reason, I do not have the option to create new .au3 files when right clicking. I have tried rebooting, and running the installation as administrator as mentioned in other threads. no joy...
       
      OS = Windows 10 Enterprise version 1806
       
      Thanks in advance!

    • badcoder123
      By badcoder123
      Hey, all.  
      I've been looking for a way to change cursor colour but not the cursor itself. I've been looking for a couple hours now and can't find anything.  I also don't even know where to start, if anyone has any tips or examples please comment them.
      Thanks
    • nooneclose
      By nooneclose
      Hello again, I am in phase two of my help bot. I cannot figure out how to properly code Autoit to click on a webpage button using the I.E UDF. I want to click on the button that I have attached as an image. This button does not have a name but it has an ID. Here is the HTML code for this button that I found using chromes developer inspector.
      HTML Code: 
      <img role="button" tabindex="-1" id="toolactions_INSERT-tbb_image" src="nav_icon_insertkey.gif" alt="New Work Order CTRL+ALT+I" draggable="false"> Here is the code that I have so far:
      ;******************************************************************************* ; Opens IE and fill out a New Workorder ;******************************************************************************* ; Start IE at the ** Tracking Application in ****** $oIE = _IECreate("https:I_am_Bound_by_my_company_to_not_reveal_this_webpage") ; Wait for a browser page load to complete _IELoadWait($oIE) Sleep(6000) ; Store the field names where the important data will be sent Local $nWorkOrderB = _IEGetObjById($oIE, "toolactions_INSERT-tbb_image") _IEAction($nWorkOrderB, "click")  I want my program to click on the button that looks like a piece of paper with a blue # 
      (For those wondering, I am allowed to send images just not the URL.) 
      As always any help would be appreciated. 

    • 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
×