我正在尝试创建一个任务栏替换,我希望每个正在运行的应用程序都有一个按钮.
public void AddBtn(string name) {
Button newButton = new Button();
this.Controls.Add(newButton);
newButton.Location = new Point(count * 75, Screen.PrimaryScreen.Bounds.Height - 25);
newButton.Text = name;
newButton.Name = count.ToString();
newButton.BringToFront();
count++;
}
private void GetRunning()
{
Process[] processes = Process.GetProcesses();
foreach (Process process in Process.GetProcesses().Where(p => !string.IsNullOrEmpty(p.MainWindowTitle)).ToList())
AddBtn(process.ProcessName);
}
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止,它为每个正在运行的应用程序创建一个按钮.我需要检测其中一个应用程序是否关闭,因此我可以删除与其对应的按钮.如果您认为有更好的方法,请告诉我.
我正在使用 discord.py 在 Python 中制作一个 Discord 机器人。我想从异步线程设置/修改全局变量。
message = ""
@bot.command()
async def test(ctx, msg):
message = msg
Run Code Online (Sandbox Code Playgroud)
然而这行不通。我怎样才能做到这一点?