Jump to content

Check if process is using CPU; if not, close it. Any way to do this?


kr580
 Share

Recommended Posts

My script is below, it runs a few different map rendering programs for my small Minecraft server. It all runs fine except the last one, Tectonicus, doesn't close itself (cmd window or javatect.exe process) when it's finished; you have to manually exit it. This is a fault of the jar file itself, not cmd, java or AutoIt. Exit and Cls don't do anything in the command line. Since the window/process doesn't close the RunWait command won't continue to the last group of orders. The rendering duration varies so I can't really use just a Run command paired with Sleep+WinKill or something and I would like it to tell the players that the rendering (and lag) is complete the moment it finishes... if possible.

Does anyone have a smart idea of how to have AutoIt tell when the rendering is complete and close the window once it's done rendering? Is there a way to check if a process is actively using computer resources (CPU/RAM)?

Note: Paths are all correct, just edited a bit. Also, javatect.exe is just a renamed copy of java.exe. It works the same as java.exe, I was just trying to differentiate it from the other 1 or 2 java.exe processes I always have running. Didn't want to close them all.

Any help is greatly appreciated! Thanks - Kevin

WinExists("Minecraft Server")
WinActivate("Minecraft Server")
Sleep ( 1000 )
Send("say Map rendering started.")
Send("{Enter}")
Sleep ( 1000 )
Send("save-all")
Send("{Enter}")
Sleep ( 1000 )


DirCopy ( "C:\Users\~~~\Desktop\MC\world", "C:\Users\~~~\Desktop\MCBackup\worldbackup", 1 )
Sleep ( 5000 )

RunWait(@comspec & " /C title Minecraft Biome Extractor|java -jar C:\Users\~~~\Desktop\MCBackup\MinecraftBiomeExtractor.jar -nogui C:\Users\~~~\Desktop\MCBackup\worldbackup", "C:\Users\~~~\Desktop\MCBackup")
RunWait(@comspec & " /C title MCMap 1.3|mcmap1.3 -skylight -west -file C:\Users\~~~\Desktop\MCWeb\3dmap\%DATE:~4,2%-%DATE:~7,2%-%DATE:~-4%_%time:~0,2%;%time:~3,2%;%time:~6,2%_PST.png -noise 0 -colors C:\Users\~~~\Desktop\MCBackup\defaultcolors.txt -biome -biomecolors C:\Users\~~~\Desktop\MCBackup\worldbackup\biomes C:\Users\~~~\Desktop\MCBackup\worldbackup", "C:\Users\~~~\Desktop\MCBackup")
RunWait(@comspec & " /C title PixelMap 0.86|PixelMap0.86 -w C:\Users\~~~\Desktop\MCBackup\worldbackup -f C:\Users\~~~\Desktop\MCWeb\2dmap\%DATE:~4,2%-%DATE:~7,2%-%DATE:~-4%_%time:~0,2%;%time:~3,2%;%time:~6,2%_PST.png -r 90 --silent --no-gui", "C:\Users\~~~\Desktop\MCBackup")
RunWait(@comspec & " /C title Tectonicus 2.05|""C:\Program Files\Java\jre6\bin\javatect.exe"" -jar Tectonicus2.05.jar config=layerConfig.xml", "C:\Users\~~~\Desktop\MCBackup")


WinExists("Minecraft Server")
WinActivate("Minecraft Server")
Sleep ( 1000 )
Send("say Map rendering complete.")
Send("{Enter}")
Link to comment
Share on other sites

Oh nice, Tectonicus is no longer dead. If I ever play Minecraft again I'll have to update it.

Anyway, it was asked that I review this thread in case it was game automation related. Lucky for you I have used Tectonicus and know what it is. This is not bot related.

As for your specific problem, it should be trivial to solve. First question, though, is this a bug in Tectonicus? It certainly sounds like it. I used to drive Tectonicus with a BAT file and I had to use a PAUSE statement to keep it from automatically closing. If it's a bug then report it and hopefully it will get fixed. Otherwise you can read and parse the stdout text to see when it's done.

Link to comment
Share on other sites

Because I was curious I just dropped the latest version of Tectonicus into place an ran it. It ran fine. It did not hang on completion. I ran it from a batch file on a 64-bit system with the 64-bit Java runtime installed (and I confirmed that it used the 64-bit version). Maybe you are exhausting the Java memory pool because you are using 32-bit or something? I also observed that the last thing Tectonicus prints is "Finished" which is rather convenient for my second suggestion. My suggestion, though, is not necessary. You have some sort of issue with Tectonicus on your system. I suggest resolving that rather than attempting crude work-arounds. Tectonicus works fine on my system.

Here's the very simple batch file I use for the world I just rendered:

@Echo OFF
java -jar Tectonicus.jar config=ConfigOcean.xml
PAUSE
Edited by Valik
Extra words are extra.
Link to comment
Share on other sites

Thanks for the reply. It's good to see it SHOULD close, but it might add to the frustration that it doesn't close for me. As far as I know I have everything on 64-bit for this process. And as I've also said, I've run plenty of JAR files and other programs with batch and none of them have this problem, it's only Tectonicus for me.

Any clue on where I would start to look for the problem that won't allow it to close? I'm good at following instructions on how to make this stuff work, I just don't have much knowledge of HOW it all works so I'm a bit lost at this point. I'm also brand spankin new to AutoIt, having used it all of two days, so I might need some help figuring out that stdout text method.

This still leaves the window open when it finishes. I don't know how to get any simpler of a command line than that and I'm out of ideas. :D It doesn't appear that there's any options that would make a difference in the config file.

@Echo OFF
java -jar Tectonicus.jar config=layerConfig.xml

Thanks again for the reply - Kevin

Edited by kr580
Link to comment
Share on other sites

Make sure you have the latest version of Java, the 64-bit version of Java (if you have a 64-bit system) and the latest version of Tectonicus. Yes, Java is 2 separate downloads and by default most people have the 32-bit version. You have to explicitly install the 64-bit version. It's unlikely that you have it.

Link to comment
Share on other sites

I'm pretty sure I had 64-bit on but I just removed all the Java I had installed and reinstalled the Java SE 7u1 JRE 64-bit and it didn't fix the not-closing problem at all. I used the JDK one too for good measure and no go.

Mysterious. :D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...