我想将此转换为Powershell,但我不太确定如何。重要的是为trayMenu项创建一个处理程序。
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
}
提前感谢您的帮助!
答案 0 :(得分:1)
像这样:
trayMenu.Items.Add("Login", ContextMenuStripItemImages).add_Click({... script here ...})
发件人用$this
和e(EventArgs)代表$_
。