Jump to content

Systray: Leftclick -> some action, Rightclick -> menu


rudi
 Share

Recommended Posts

Hello,

I want to write an autoit3 script that wil be controlled only by it's systray icon. Playing arround with all the

TRAY* fuctions, I fail to do the following:

1.) a left mouse click on the script's tray icon shall NOT open the menu of the systray, but trigger some action done by the script itself.

2.) a right mouse click shall open the systray's menu with 2 entries:

2.1.) open a window to type in some input

2.2.) exit the script.

The main part of the script is done: Scan the clipboard for a pattern (StringRegExp, great feature :) ), do some calculations and finally open the calculated URL in a new browser window.

I just desperately :D fail "binding" my actions to left/right clicking the systray icon.

Who can point me into the right direction :D , please?

Thank you, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Do you already have the options in the tray that appear when you right click?

Anyways, look at TraySetOnEvent in the help file. I think t has what you want.

For creating and using tray menu and items, the help file provides a good example:

#Include <Constants.au3>
#NoTrayIcon

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.

$settingsitem   = TrayCreateMenu("Settings") ; Create menu and first item
$displayitem    = TrayCreateItem("Display", $settingsitem) ; add item to the Settings item
$printeritem    = TrayCreateItem("Printer", $settingsitem) ; add item to the Settings item
TrayCreateItem("")
$aboutitem      = TrayCreateItem("About") ; Add an item to menu
TrayCreateItem("")
$exititem       = TrayCreateItem("Exit") ; add an item to menu

TraySetState()

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $aboutitem ; If About is pressed
            Msgbox(64,"about:","AutoIt3-Tray-sample")
        Case $msg = $exititem ; If Exit is pressed
            ExitLoop
    EndSelect
WEnd

Exit
Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

Hello BALA,

thanks for your reply.

Do you already have the options in the tray that appear when you right click?

Anyways, look at TraySetOnEvent in the help file. I think t has what you want.

Well, almost: I altered the help example script lots of times.

Let me take smaller steps:

Left Click on the systray always opens the menu. How to make the left click on the systray icon to ONLY trigger some action within my script?

I found traygetmsg() and tried to work with it like this:

#Include <Constants.au3>
Opt("TrayAutoPause", 0)  ; don't PAUSE script, if systray icon is clicked
Opt("TrayIconDebug", 1)  ; tooltip shows current script code line


[snip]

While 1
$msg = 0
$msg = TrayGetMsg()
    Select
        Case $msg = $TRAY_EVENT_PRIMARYUP
            MsgBox(64, "Systray", "PiMouseUp",2)
        Case $msg = $TRAY_EVENT_PRIMARYDOWN
            MsgBox(64, "Systray", "PiMouseDown",2)
        case $msg = $TRAY_EVENT_PRIMARYDOUBLE
            MsgBox(64, "Systray", "PiMouseDouble",2)
            
        Case $msg = $TRAY_EVENT_SECONDARYDOWN
            MsgBox(64, "Systray", "SecMouseDown",2)
        Case $msg = $TRAY_EVENT_SECONDARYUP
            MsgBox(64, "Systray", "SecMouseUp",2)
        Case $msg = $TRAY_EVENT_SECONDARYDOUBLE
            MsgBox(64, "Systray", "SecMouseDouble",2)
    EndSelect
WEnd

When I start this script, on left clicks always the systray menu opens.

A left click presens PriLeftDown, PriLeftUp

a left doubleclick presents PriLeftDown, PriLeftUp,PriLeftDouble,PriLeftUp

same for right (double) clicks

But on a left mouse click, I DO NOT want the menu to pop up.

Propably I miss something very basic here... :">

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Hello,

I now found how to get *ONE* action upon a left mouse click upon the systray icon:

#Include <Constants.au3>

Opt("trayautopause", 0)  ; no PAUSE if tray icon is clicked.
Opt("TrayMenuMode", 1)  ; Default tray menu items (Script Paused/Exit) will not be shown.

TraySetToolTip("Left Klick to open TID #'s found in Clipboard")
While 1
    $msg = 0
    $msg = TrayGetMsg()
    Select
        Case $msg = $TRAY_EVENT_PRIMARYUP
            ClipScan()
        Case $msg = $TRAY_EVENT_SECONDARYUP
            ; <<<<  here shall the systray *MENU* appear to do some selections. >>>>>
            MsgBox(64, "TIDjumper", "Closeing TID Jumper (place more help info here later on)", 2)
            Exit
    EndSelect
WEnd

Any suggestions how to make a right mouse click to open the systray menu?

Or perhaps to open some box LIKE a systray menu at the typical location left bottom corner = click coordinates?

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...