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