小编Mát*_*rga的帖子

C#检测关闭应用程序

我正在尝试创建一个任务栏替换,我希望每个正在运行的应用程序都有一个按钮.

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)

这是我到目前为止,它为每个正在运行的应用程序创建一个按钮.我需要检测其中一个应用程序是否关闭,因此我可以删除与其对应的按钮.如果您认为有更好的方法,请告诉我.

c#

1
推荐指数
1
解决办法
1542
查看次数

从python中的异步函数修改全局变量

我正在使用 discord.py 在 Python 中制作一个 Discord 机器人。我想从异步线程设置/修改全局变量。

message = ""

@bot.command()
async def test(ctx, msg):
    message = msg
Run Code Online (Sandbox Code Playgroud)

然而这行不通。我怎样才能做到这一点?

python asynchronous python-3.x discord.py

1
推荐指数
1
解决办法
2949
查看次数

标签 统计

asynchronous ×1

c# ×1

discord.py ×1

python ×1

python-3.x ×1