0

I have a function that starts some files and then change their names to their ids:

    Global $PID2 = Run("java " & $chosen & ' -jar "spigot-1.6.2-R0.1.jar"', "E:\Spill\Alle spill\Minecraft\Bungee Servers\Hub", $Hide)
    WinWaitActive("C:\Windows\system32\java.exe")
    WinSetTitle("C:\Windows\system32\java.exe","",$PID2)
    Global $PID3 =Run("java " & $chosen & ' -jar "spigot-1.6.2-R0.1.jar"', "E:\Spill\Alle spill\Minecraft\Bungee Servers\Survival", $Hide)
    WinWaitActive("C:\Windows\system32\java.exe")
    WinSetTitle("C:\Windows\system32\java.exe","",$PID3)
    Global $PID4 =Run("java " & $chosen & ' -jar "spigot-1.6.2-R0.1.jar"', "E:\Spill\Alle spill\Minecraft\Bungee Servers\KnarWorld", $Hide)
    WinWaitActive("C:\Windows\system32\java.exe")
    WinSetTitle("C:\Windows\system32\java.exe","",$PID4)
    Global $PID5 =Run("java " & $chosen & ' -jar "spigot-1.6.2-R0.1.jar"', "E:\Spill\Alle spill\Minecraft\Bungee Servers\Plotworld", $Hide)
    WinWaitActive("C:\Windows\system32\java.exe")
    WinSetTitle("C:\Windows\system32\java.exe","",$PID5)
    Global $PID1 =Run("java " & $chosen & ' -jar "BungeeCord.jar"', 'E:\Spill\Alle spill\Minecraft\bungee', $Hide)
    WinWaitActive("C:\Windows\system32\java.exe")
    WinSetTitle("C:\Windows\system32\java.exe","",$PID1)

I also have a function to stop the files:

WinActivate($PID1)
Send("end {ENTER}")
WinActivate($PID2)
Send("stop{ENTER}")
WinActivate($PID3)
Send("stop{ENTER}")
WinActivate($PID4)
Send("stop{ENTER}")
WinActivate($PID5)
Send("stop{ENTER}")

The problem is on the second function that instead of finding the ids and sending the wanted commands one by one, it starts spamming in whatever window is active. How can I make it run once and stop, but still work if I trigger it again? The whole code: http://pastebin.com/U8XBk4HE

4

2 回答 2

1

对于这类任务,有两个功能:

  • SendKeepActive(...)使 AutoIt尝试在 Send() 的每个模拟击键之间重置活动窗口
  • ControlSend(...)将击键发送到特定窗口,而不管它是否处于活动状态。
于 2013-07-29T08:33:13.027 回答
0

也许你应该放一个WinWaitActive让它等待:

WinActivate($PID1)
WinWaitActive($PID1)
Send("end {ENTER}")
于 2013-07-26T16:57:15.703 回答