1

我想将其转换为 Powershell,但我不太确定如何转换。重要的部分是为托盘菜单项创建一个处理程序。

NotifyIcon trayIcon;
ContextMenuStrip trayMenu;
trayMenu = new ContextMenuStrip();
trayMenu.Items.Add("Login", ContextMenuStripItemImages).Click += new EventHandler(Login_Click); //Create a new item in the context menu strip and link its Click event with Login_Click
trayIcon = new NotifyIcon();
trayIcon.ContextMenuStrip = trayMenu; //Set the ContextMenuStrip of trayIcon to trayMenu
}

private void Login_Click(object sender, EventArgs e)
{
    //Do something when Login is clicked
}

提前感谢您的帮助!

4

1 回答 1

1

像这样:

trayMenu.Items.Add("Login", ContextMenuStripItemImages).add_Click({... script here ...})

发件人用$this和 e (EventArgs)表示$_

于 2013-06-26T14:04:50.070 回答