Jump to content

StdinWrite / StdoutRead help needed


Recommended Posts

What I am attempting to do is use AutoIt to read and write to the minecraft (bukkit) console

The console itself comes up as a cmd window when you start the jar with a .bat file. So far I have been able to read FROM StdoutRead, but I have had less success writing TO the console and getting any kind of response. Here is the server, example .bat file, and the following script:

#include <GuiEdit.au3>

OnAutoItExitRegister("close")
hotkeyset("{ENTER}","enter")

$GUI = GUICreate("MC Console Wrapper", 514, 251, 192, 124)
$Edit = GUICtrlCreateEdit("", 8, 8, 497, 209, 2101312)
$Input = GUICtrlCreateInput("", 8, 224, 497, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$temp = FileFindFirstFile("*.bat")
$server = run(FileFindNextFile($TEMP),@WorkingDir,default,0x7)
ConsoleWrite($server&@CRLF)

While 1
$temp = ""
$temp = StderrRead($server)
if @extended > 2 then
GUICtrlSetData($Edit,guictrlread($Edit)&@CRLF&$temp)
_GUICtrlEdit_Scroll($Edit, 7)
EndIf
$temp = StdoutRead($server)
if @extended > 2 then
GUICtrlSetData($Edit,guictrlread($Edit)&@CRLF&$temp)
_GUICtrlEdit_Scroll($Edit, 7)
EndIf

$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit

EndSwitch
WEnd

func enter()
if WinActive($gui) Then
If guictrlread($Input) <> "" Then
StdinWrite($server,guictrlread($Input))
consolewrite(@error&@CRLF)
GUICtrlSetData($Input,"")
EndIf
Else
hotkeyset("{ENTER}")
send("{enter}")
hotkeyset("{ENTER}","enter")
EndIf
EndFunc

func close()
Do
ProcessClose("java.exe")
until ProcessExists("java.exe") = 0
EndFunc

Any help would be appreciated :P

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Yes

This is going to be a tool for server admins, so they can write custom macros in autoit for their minecraft server. For instance, instead of typing a set commands (say, /time set 1000, /spawn set, /restart), you could type a custom command (like /blarky) and have autoit type the set of commands. I also plan to add detecting if someone is SPAMMING CAPS and react if i can get this to work

Because it runs the server locally, it is only useful for people HOSTING a server. This doesn't give anyone an unfair advantage, or let anyone do anythign they're not supposed to do, it only helps the people who own the server do what they can do already

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

  • Moderators

corgano,

This thread was reported as "automation of a game server" - which is clearly forbidden by the rules. As a non-gamer myself I am leaving it to Valik to make a final decision on its legality - but until he does, I am locking the thread. Please accept my apologies if he subsequently gives you the OK. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Okay, seriously, a batch file? You are clinically retarded, right? Otherwise I can't possibly fathom a reason you need a batch file when you're using AutoIt. Especially when that's almost certainly your problem. Or your server jar is broken.

Anyway, I downloaded the official Minecraft server jar and put the code below in the same directory. It correctly starts the server and displays the GUI (I intentionally left off the nogui flag). After 5 seconds it writes "help" to the server which works as you can see in the GUI when it suddenly dumps the help text.

Local $pid = Run("java -Xmx1024M -Xms1024M -jar minecraft_server.jar", "", @SW_SHOW, 0x7)
Sleep(5000)
StdinWrite($pid, "help")

You're on your own for the rest. I'm on the fence on this thread but I'd prefer to keep it locked. Especially since I think your real issue is rather stupid.

A batch file? Meh.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...