Jump to content

wierd issue using send ("{ENTER}") with a CMD window


rikka
 Share

Go to solution Solved by Danp2,

Recommended Posts

So, starting from the beginning. I have a minecraft spigot server on windows 10 (running on my own raw iron with an i7 10700 and 32GB DDR4 if that info is helpful) and im attempting to make a script that will run from task scheduler to stop the server using the /stop command from its console, wich saves all the worlds rather than just resetting the machine every night with task scheduler directly.

I'm running into a wierd issue with sending enter to the console window (witch is the CMD window generated by the following .bat script)
half the time I try to use send ("{ENTER}") from autoIT, it just puts the console window in fullscreen as if I had pressed ALT+ENTER. 

IDK if its any help to know, but im also running the box headless in my homelab rack and interface with it exclusively through windows remote desktop.



the following is the .bat script that makes the console window and starts the server

title PatrickServer

java -DIReallyKnowWhatIAmDoingISwear -Xmx30G -Xms30G -jar spigot-1.19.4.jar

msg PATRICK watchdog  tripped, restart timer initiated

timeout 10

shutdown -r -t 0




and here is the autoIT code im trying to use

#include <MsgBoxConstants.au3>
;check if the server window is open
If WinExists("PatrickServer") Then
;if server window is open, select it as active
WinActivate("PatrickServer")


sleep (1000)
;now, give the players online a 5 minute warning, a 30 second warning, and a 5 second countdown to the restart
Send("say Server will be restarting in 5 minutes!")
Send("{Enter}")
;comment out the sleep 270000 and uncomment sleep 1000 to make testing speedier
;sleep (1000)
sleep (2700000)

;30 second warning
Send("say Server will be restarting in 30 Seconds!")
Send("{Enter}")
sleep (25000)

;5 second countdown
send ("say Server will be restarting in 5 seconds")
Send("{Enter}")
sleep (1000)

send ("say Server will be restarting in 4 seconds")
Send("{Enter}")
sleep (1000)

send ("say Server will be restarting in 3 seconds")
Send("{Enter}")
sleep (1000)

send ("say Server will be restarting in 2 seconds")
Send("{Enter}")
sleep (1000)

send ("say Server will be restarting in 1 seconds")
Send("{Enter}")
sleep (1000)

send ("SERVER RESTARTING")
Send("{Enter}")
sleep (1000)

;stop the server
Send("stop")
Send("{Enter}")


else
;else, if the window isnt found, let (totally) the greatest sysadmin of all time know that they did a poopy stink
msgbox ( $MB_OK, "restart failed", "the system has attempted to restart by using /stop in MCS and failed!" )
EndIf

Link to comment
Share on other sites

27 minutes ago, Danp2 said:

Try adding $SEND_RAW to your send statements, like this --

Send("say Server will be restarting in 5 minutes!", $SEND_RAW)

P.S. Please read the forum rules to be sure that you don't violate them.

this solution worked perfectly
its worthy of note for future readers that you need to include AutoItConstants.au3 for it to do so

Link to comment
Share on other sites

On 12/19/2023 at 10:41 PM, Danp2 said:

Try adding $SEND_RAW to your send statements, like this --

Send("say Server will be restarting in 5 minutes!", $SEND_RAW)

P.S. Please read the forum rules to be sure that you don't violate them.

I'd like to mention the possibility to add the "!" as "{!}" to the send string: This way the option to send special chars in the string is still available.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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...