royliaoz 发表于 2011-7-6 00:04:12

TrayItemSetOnEvent 能传递函数的参数吗?

TrayItemSetOnEvent 能传递函数的参数吗?
找了论坛,没发现有同学讨论过这个问题,
请问能实现吗?谢谢各位老师

easefull 发表于 2011-7-6 01:52:42

用全局变量吧

forestchi 发表于 2011-7-6 11:21:28

本帖最后由 forestchi 于 2011-7-6 11:22 编辑

#NoTrayIcon

Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)        ; Default tray menu items (Script Paused/Exit) will not be shown.
Global $nMsg;全局变量
TraySetClick(16)        ; Only secondary mouse button will show the tray menu.

$infoitem = TrayCreateItem("Info")
$nMsg="新值"
TrayItemSetOnEvent(-1,"ShowInfo")

TrayCreateItem("")

$exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitScript")

TraySetState()

While 1
        Sleep(10)        ; Idle loop
WEnd

Exit


; Functions
Func ShowInfo()
       ;Msgbox(0,"Info","Tray OnEvent Demo")
       MsgBox(0,"",$nMsg)
EndFunc


Func ExitScript()
        Exit
EndFunc

happytc 发表于 2011-7-6 13:41:43

au3好些函数不能传递参数的设计非常不好!
用全局变量使得可移植性变得很差
页: [1]
查看完整版本: TrayItemSetOnEvent 能传递函数的参数吗?