如何在C#中按顺序运行自动热键代码?

时间:2019-05-20 12:01:50

标签: c# autohotkey

我在c#中使用autohotkey.dll。

我想按顺序运行每个步骤,但是

例如我有以下代码和

达到睡眠状态5000时需要等待5秒

但不等5秒,只需执行Messagebox.show对话框即可。

我如何运行每个步骤?

感谢帮助

string scriptContent = @"
WinActivate, chrome
sleep, 5000
"
CoCOMServer ahkThread = new CoCOMServer();
ahkThread.ahktextdll(scriptContent);
MessageBox.Show("hello");

1 个答案:

答案 0 :(得分:0)

等待ahk脚本退出:

string scriptContent = @"
WinActivate, chrome
sleep, 5000
"
CoCOMServer ahkThread = new CoCOMServer();
ahkThread.ahktextdll(scriptContent);

while (ahkThread.ahkReady() != 0) // will check evey 100 millisecond if the script still runs
    Thread.Sleep(100); 

MessageBox.Show("hello");
相关问题