Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Autohotkey 如何仅在AHK中执行第一个命令后执行下一个命令?_Autohotkey - Fatal编程技术网

Autohotkey 如何仅在AHK中执行第一个命令后执行下一个命令?

Autohotkey 如何仅在AHK中执行第一个命令后执行下一个命令?,autohotkey,Autohotkey,我有自动热键脚本 目前我的AHK脚本一直在运行。它等待用户输入 如果用户按11,则执行操作。 如果用户按12,则执行其他操作 当前AHK脚本 1:: Input Key, L1 if Key=1 { Run C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\Users\username\Desktop\new.ps1 ; How can I make this command run o

我有自动热键脚本

目前我的AHK脚本一直在运行。它等待用户输入

如果用户按11,则执行操作。
如果用户按12,则执行其他操作

当前AHK脚本

1::
Input Key, L1

if Key=1
    {
    Run C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\Users\username\Desktop\new.ps1
    ; How can I make this command run only after above script has finished executing?
}
使用


与Run不同,RunWait将等待目标关闭或退出,此时ErrorLevel将设置为程序的退出代码(作为带符号的32位整数)。有些程序即使仍在运行,也会立即返回;这些程序会产生另一个进程。

您可以创建热字符串,而不是像1::然后输入键这样的热键:

:*:11::
RunWait xyz
Return

:*:12::
RunWait, abc
Return

我发现我们可以使用这个命令运行PS脚本
运行C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe-文件C:\Users\myuser\Desktop\new.ps1
现在我只需要在PS脚本完成执行后运行下一个命令的帮助。谢谢,不要运行C:\Windows\System32…我应该使用
Runwait C:\Windows\System32…
?罗伯特,我不能做
:*:1::Runwait xyz return
:*:11::Runwait,abc return
对吗?或者我可以吗?我试过了,它只执行第一个条件。一旦你达到第一个条件“1”,第一个热字符串就会执行。我经常做的是让每段代码在末尾都有一个唯一的“\”,因此:*:1\::和:*:11\::和:*:12\::等等。。我没有使用#Hotstring EndChars来定义结束字符,而是使用基于语言的各种“结束”字符(英语、德语、荷兰语、法语、Python、AHK、HTML等),这样“r=”是“Reagrds”,r\”是“Met vriendelijke groet”,“r/”=“Mit Freundlichen Grüssen”,“r[”是“Return”如果我使用
:*:1\:
我需要按
1
和``正确?我想你想写1\,但是\被倒计时消耗掉了。除非你使用计时器。按1等待几毫秒(例如300),如果没有按其他数字,执行1,否则执行1n。