Detect if script tray icon is middle clicked Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
ntepa
Posts: 426
Joined: 19 Oct 2022, 20:52

Detect if script tray icon is middle clicked

Post by ntepa » 01 Apr 2023, 05:12

When I middle click the tray icon, lParam is the same as LButton. Why does it detect MButton as LButton?
Is this the same for anyone else?

Code: Select all

#Requires AutoHotkey v2.0
Persistent

OnMessage 0x404, AHK_NOTIFYICON
AHK_NOTIFYICON(wParam, lParam, msg, hwnd) {
    switch lParam {
    case 0x202: ; WM_LBUTTONUP
        MsgBox "left clicked tray icon"

    case 0x205: ; WM_RBUTTONUP
        MsgBox "right clicked tray icon"

    case 0x208: ; WM_MBUTTONUP
        MsgBox "middle clicked tray icon"
    }
}
Last edited by ntepa on 01 Apr 2023, 06:20, edited 1 time in total.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Detect if script tray icon is middle clicked

Post by swagfag » 01 Apr 2023, 06:04

not for me, it says MsgBox "middle clicked tray icon"
maybe u have some other ahk scripts running

ntepa
Posts: 426
Joined: 19 Oct 2022, 20:52

Re: Detect if script tray icon is middle clicked

Post by ntepa » 01 Apr 2023, 06:20

This shows "mbutton" when I middle click:

Code: Select all

g := Gui()
g.Show("w100 h100")

OnMessage 0x208, WM_MBUTTONUP
WM_MBUTTONUP(wparam, lparam, msg, hwnd) {
    MsgBox "mbutton"
}
I didn't remap MButton. There's no other scripts running. KeyHistory shows MButton was pressed.
I'm using Windows 11.

iPhilip
Posts: 814
Joined: 02 Oct 2013, 12:21

Re: Detect if script tray icon is middle clicked

Post by iPhilip » 01 Apr 2023, 12:30

@ntepa, I can confirm @swagfag's results. You might take a look at your mouse settings.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Detect if script tray icon is middle clicked

Post by swagfag » 01 Apr 2023, 12:35

or maybe its something specific to win11. im on 10


iPhilip
Posts: 814
Joined: 02 Oct 2013, 12:21

Re: Detect if script tray icon is middle clicked

Post by iPhilip » 04 Apr 2023, 09:50

Wow! Thank you for letting us know about the bug.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

Post Reply

Return to “Ask for Help (v2)”