右击托盘图标

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: 右击托盘图标

Re: 右击托盘图标

by zcw1030 » 10 Jun 2020, 08:22

tmplinshi wrote:
10 Jun 2020, 07:44
你好,

你需要调用 TrayIcon_Button 这个函数, 而不是去修改它.

Code: Select all

#Include TrayIcon.ahk ; 或者完整路径 D:\Desktop\TrayIcon.ahk

TrayIcon_Button("Shadowsocks.exe", "R")
点击弹出的右键菜单可参考这个脚本:
https://github.com/tmplinshi/RegSsHotkey/blob/master/Lib/RegisterShadowsocksHotkey.ahk
谢谢!

Re: 右击托盘图标

by tmplinshi » 10 Jun 2020, 07:44

你好,

你需要调用 TrayIcon_Button 这个函数, 而不是去修改它.

Code: Select all

#Include TrayIcon.ahk ; 或者完整路径 D:\Desktop\TrayIcon.ahk

TrayIcon_Button("Shadowsocks.exe", "R")
点击弹出的右键菜单可参考这个脚本:
https://github.com/tmplinshi/RegSsHotkey/blob/master/Lib/RegisterShadowsocksHotkey.ahk

Re: 右击托盘图标

by zcw1030 » 10 Jun 2020, 05:38

BoBo wrote:
10 Jun 2020, 05:34
As @tmplinshi (the author of these functions) is a moderator of this forum section (and therefore should speak your native language), I'd guess he'll be able to give you some advice on this. Good luck :thumbup:
thanks

Re: 右击托盘图标

by BoBo » 10 Jun 2020, 05:34

As @tmplinshi (the author of these functions) is a moderator of this forum section (and therefore should speak your native language), I'd guess he'll be able to give you some advice on this. Good luck :thumbup:

Re: 右击托盘图标

by zcw1030 » 10 Jun 2020, 05:28

BoBo wrote:
10 Jun 2020, 04:03
https gist.github.com /tmplinshi/83c52a9dffe65c105803d026ca1a07da Broken Link for safety
HTH
您好,这样改了一下,但是会报错,不知哪里有误。

Code: Select all

; Function .....: TrayIcon_Button
; Description ..: Simulate mouse button click on a tray icon.
; Parameters ...: sExeName - Executable Process Name of tray icon.
; ..............: sButton  - Mouse button to simulate (L, M, R).
; ..............: bDouble  - True to double click, false to single click.
; ..............: nIdx     - Index of tray icon to click if more than one match.
; ----------------------------------------------------------------------------------------------------------------------
TrayIcon_Button(Shadowsocks, sButton:="R", bDouble:=False, nIdx:=1)
{
    d := A_DetectHiddenWindows
    DetectHiddenWindows, On
    WM_MOUSEMOVE      = 0x0200
    WM_LBUTTONDOWN    = 0x0201
    WM_LBUTTONUP      = 0x0202
    WM_LBUTTONDBLCLK  = 0x0203
    WM_RBUTTONDOWN    = 0x0204
    WM_RBUTTONUP      = 0x0205
    WM_RBUTTONDBLCLK  = 0x0206
    WM_MBUTTONDOWN    = 0x0207
    WM_MBUTTONUP      = 0x0208
    WM_MBUTTONDBLCLK  = 0x0209
    sButton := "R"
    oIcons  := TrayIcon_GetInfo(Shadowsocks)
    If ( bDouble )
        PostMessage, oIcons[nIdx].msgid, oIcons[nIdx].uid, %sButton%DBLCLK,, % "ahk_id " oIcons[nIdx].hwnd
    Else
    {
        PostMessage, oIcons[nIdx].msgid, oIcons[nIdx].uid, %sButton%DOWN,, % "ahk_id " oIcons[nIdx].hwnd
        PostMessage, oIcons[nIdx].msgid, oIcons[nIdx].uid, %sButton%UP,, % "ahk_id " oIcons[nIdx].hwnd
    }
    DetectHiddenWindows, %d%
    Return

Re: 右击托盘图标

by BoBo » 10 Jun 2020, 04:03

右击托盘图标

by zcw1030 » 10 Jun 2020, 03:52

大家好,不知能否用ahk实现右击托盘图标的动作,就是鼠标右击截图中的图标,谢谢。
Attachments
Snipaste_2020-06-10_13-10-06.png
Snipaste_2020-06-10_13-10-06.png (30.81 KiB) Viewed 69727 times

Top