Skrip Posted April 29, 2011 Share Posted April 29, 2011 (edited) Code Removed Okay, I am trying to make a minecraft server GUI. I am attempting to figure out how to run commands through the window, and cannot seem to get STDIN to work correctly. Anyone see the problem? Basically, the button gets clicked - server starts, clicked again - send stop command Edited April 29, 2011 by Skrip [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Info Posted April 29, 2011 Share Posted April 29, 2011 Can't really help you because I don't know what STDIN is but isn't there an official GUI version of a Minecraft server? Link to comment Share on other sites More sharing options...
jaberwacky Posted April 29, 2011 Share Posted April 29, 2011 This might be the problem: I stripped out the rest of the code to highlight the problem. If $sRunning = 0 Then $sRunning = 1 ElseIf $sRunning = 1 Then $sRunning = 1 ; should this be set to 0? EndIf Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Skrip Posted April 29, 2011 Author Share Posted April 29, 2011 Can't really help you because I don't know what STDIN is but isn't there an official GUI version of a Minecraft server?Yes, and I like my design better, just gotta get it workin!And no, that just says whether to start or stop it. That can go 0 after the button works. [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
BrewManNH Posted April 29, 2011 Share Posted April 29, 2011 (edited) This might be the problem: I stripped out the rest of the code to highlight the problem. If $sRunning = 0 Then $sRunning = 1 ElseIf $sRunning = 1 Then $sRunning = 1 ; should this be set to 0? EndIf Easier way would be to do it this way: $sRunning = Not $sRunning If you wanted to keep the value of $sRunning a numeral instead of a true/false you could also do the same thing this way. $sRunning = Number(Not $sRunning) Edit: Thought of a different method for using a number in place of true/false, after I posted Edited April 29, 2011 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jaberwacky Posted April 29, 2011 Share Posted April 29, 2011 I guess it would be easier but we're just trying to get the script to run right first. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Skrip Posted April 29, 2011 Author Share Posted April 29, 2011 I will change that for version one, thanks Brew - I forgot about that method. Also, does anyone know what the issue is with StdInWrite? [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Skrip Posted April 29, 2011 Author Share Posted April 29, 2011 Full code was now posted in OP. Anyone have any ideas? [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
BrewManNH Posted April 29, 2011 Share Posted April 29, 2011 Looking at your code, it looks like you're killing the java process before sending the stop command to it, there's nothing left for the StdInWrite to write to at that point. When you press restart, are you doing it before you've restarted the process? If not, there's nothing for StdInWrite to write to at that point either because it's not running. This is from just quickly scanning your code and I could be mistaken. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Skrip Posted April 29, 2011 Author Share Posted April 29, 2011 Looking at your code, it looks like you're killing the java process before sending the stop command to it, there's nothing left for the StdInWrite to write to at that point. When you press restart, are you doing it before you've restarted the process? If not, there's nothing for StdInWrite to write to at that point either because it's not running. This is from just quickly scanning your code and I could be mistaken. Look closer, ProcessClose is commented out ;~ ProcessClose("java.exe") [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
BrewManNH Posted April 29, 2011 Share Posted April 29, 2011 (edited) If you change these lines, what is the console output when you run the script?Global $sServer = Run(@ComSpec & " /k java -Xincgc -Xms768M -Xmx768M -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=4 -jar craftbukkit-0.0.1-SNAPSHOT.jar nogui", "C:\Users\" & @UserName & "\AppData\Roaming\.minecraft server\bin\", @SW_HIDE, BitOR($STDIN_CHILD, $STDERR_CHILD, $STDOUT_CHILD)) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sServer = ' & $sServer & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;The above console out put should be the PID of the process when you start Java with no error code showing ;~ And these lines $Result = StdinWrite($sServer, "stop" & @CRLF) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ; This should tell you how many characters are sent to the process, also with no error codesJust some basic error checking to see where you might be having the issue.I actually downloaded the bukkit server software to test this because it intrigued me. I could NOT get the StdInWrite to work with it no matter how I tried to start it. So, I figured out that the changes below should work for you.ElseIf $sRunning = 1 Then ControlSend("C:\Windows\system32\cmd.exe", "", "", "stop {ENTER}") ;~ ProcessClose("java.exe") ;~ StdinWrite($sServer, "stop" & @CRLF) $sRunning = 0 _GUICtrlStatusBar_SetText($StatusBar1, "Server Status: Not Running", 0) GUICtrlSetData($Button3, "Start")I've never used StdInWrite before, but it appears to not work with a Java console window, but ControlSend works great. Edited April 29, 2011 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Skrip Posted April 29, 2011 Author Share Posted April 29, 2011 If you change these lines, what is the console output when you run the script? Global $sServer = Run(@ComSpec & " /k java -Xincgc -Xms768M -Xmx768M -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=4 -jar craftbukkit-0.0.1-SNAPSHOT.jar nogui", "C:\Users\" & @UserName & "\AppData\Roaming\.minecraft server\bin\", @SW_HIDE, BitOR($STDIN_CHILD, $STDERR_CHILD, $STDOUT_CHILD)) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sServer = ' & $sServer & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;The above console out put should be the PID of the process when you start Java with no error code showing ;~ And these lines $Result = StdinWrite($sServer, "stop" & @CRLF) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Result = ' & $Result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ; This should tell you how many characters are sent to the process, also with no error codes Just some basic error checking to see where you might be having the issue. I actually downloaded the bukkit server software to test this because it intrigued me. I could NOT get the StdInWrite to work with it no matter how I tried to start it. So, I figured out that the changes below should work for you. ElseIf $sRunning = 1 Then ControlSend("C:\Windows\system32\cmd.exe", "", "", "stop {ENTER}") ;~ ProcessClose("java.exe") ;~ StdinWrite($sServer, "stop" & @CRLF) $sRunning = 0 _GUICtrlStatusBar_SetText($StatusBar1, "Server Status: Not Running", 0) GUICtrlSetData($Button3, "Start") I've never used StdInWrite before, but it appears to not work with a Java console window, but ControlSend works great. Ah ha! Thanks so much for your help, fixed the problem [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
BrewManNH Posted April 30, 2011 Share Posted April 30, 2011 Glad I could help, if you have any more issues, let us know and we'll try to help out. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
dumptruckman Posted May 8, 2011 Share Posted May 8, 2011 (edited) Code Removed Okay, I am trying to make a minecraft server GUI. I am attempting to figure out how to run commands through the window, and cannot seem to get STDIN to work correctly. Anyone see the problem? Basically, the button gets clicked - server starts, clicked again - send stop command Heh, I recently made a GUI for minecraft servers with autohotkey_l. From what I understand, the languages are pretty similar. I've decided to rewrite it in java to get cross-platform support (ended up here searching for how to send input to the console!). You're more than welcome to examine my code if you'd like for any ideas. source (unfortunately not well commented) Good luck! Edited May 8, 2011 by dumptruckman Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now