Thalez Posted July 9, 2020 Share Posted July 9, 2020 *Repost in honor of the forum rules* The issue: I wrote a script, that uses ControlSend() for stopping the server and sometimes announce the next server restart, through the console. So far everything works fine, except that when I leave the remote desktop connection to my server, then the strings are not case-sensitive anymore and / for example becomes 7. For the commands, that does not matter too much, as it send 7 instead of / and in the console you can run commands without slash, so I just removed those.As for the messages though: NEXT SERVER RESTART AT 06:30 CESTbecomes next server restart at 06.30 cest I searched a lot about this particular issue, but have found no solution so far. I am kinda like an advanced beginner, I have some roots in scripting/programming, but I never followed that path enough, to become advanced in it. Recently I found AutoIt and fell in love with its simplicity and that it just works for simple things, which it does for me. (almost ;D) Any tiny bit could help me create this reliable script, which I would want to post somewhere for fellow people around the world, so that they can use this for themselves. Thanks for any help in advance and here is my script: Pls dont judge my beginner skills 😅 expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: Thalez Script Function: Automatically restart a Server on a Daily basis. (every 8 hours) #ce ---------------------------------------------------------------------------- ; Live Variables Global $IsServerRestarting = False Global $RestartAdCounter = 0 ; Variables for customizing the script <-------- ; Server Console Window Global $ConsoleWindowName = "DnDnS Server" ; It is required that you have this set correct ; Misc Global $RestartAdText = "NEXT SERVER RESTART AT" ; Restart Advertisements Global $RestartAdToggle = True ; Turn the restard advertisements on or off Global $RestartAdInterval = 20 ; Minutes | How often you want to advertise the next restart Global $TimeFormat = "CEST" ; The current time format ; Turn a restart scheduler on or off (Potentially breaks the restart advertisements) Global $Restarter1 = True Global $Restarter2 = True Global $Restarter3 = True ;Restarter 1 Global $Restarter1TimeH = '06' ; Hour/24 Global $Restarter1TimeM = '25' ; Minute (MINUS 5) ;Restarter 2 Global $Restarter2TimeH = '14' ; Hour/24 Global $Restarter2TimeM = '25' ; Minute (MINUS 5) ;Restarter 3 Global $Restarter3TimeH = '22' ; Hour/24 Global $Restarter3TimeM = '25' ; Minute (MINUS 5) ; Variables for customizing the script <-------- ;Confirm Initiation ControlFocus($ConsoleWindowName, "", "") ControlSend($ConsoleWindowName, "", "", "say AUTO-RESTART SCRIPT LOADED") ControlSend($ConsoleWindowName, "", "", "{ENTER}") ; Running Script While 1 ; A scheduled announcement for the next restart (Has to be rewritten, depending on the restart schedulers, that are turned on) If $RestartAdCounter = $RestartAdInterval * 4 and $IsServerRestarting = False Then $RestartAdCounter = 0 ; Next Restarter 1 If @HOUR >= 23 or @HOUR < 7 Then AnnounceRestart("06", "30") EndIf ; Next Restarter 2 If @HOUR >= 7 and @HOUR < 15 Then AnnounceRestart("14", "30") EndIf ; Next Restarter 3 If @HOUR >= 15 and @HOUR < 23 Then AnnounceRestart("22", "30") EndIf EndIf ; Actual Server Restart 1 If $RestartAdToggle = True and $Restarter1 = True and @HOUR = $Restarter1TimeH and @MIN = $Restarter1TimeM and $IsServerRestarting = False Then $IsServerRestarting = True RestartServer() EndIf ; Actual Server Restart 2 If $RestartAdToggle = True and $Restarter2 = True and @HOUR = $Restarter2TimeH and @MIN = $Restarter2TimeM and $IsServerRestarting = False Then $IsServerRestarting = True RestartServer() EndIf ; Actual Server Restart 3 If $RestartAdToggle = True and $Restarter3 = True and @HOUR = $Restarter3TimeH and @MIN = $Restarter3TimeM and $IsServerRestarting = False Then $IsServerRestarting = True RestartServer() EndIf $RestartAdCounter += 1 Sleep(15000) ; Update interval = 15 seconds WEnd ;Functions ; /stop the server after 5 minutes, with announcements Func RestartServer() ControlFocus($ConsoleWindowName, "", "") ControlSend($ConsoleWindowName, "", "", "say SERVER RESTART IN 5 MINUTES") ControlSend($ConsoleWindowName, "", "", "{ENTER}") Sleep(180000) ControlSend($ConsoleWindowName, "", "", "say SERVER RESTART IN 2 MINUTES") ControlSend($ConsoleWindowName, "", "", "{ENTER}") Sleep(60000) ControlSend($ConsoleWindowName, "", "", "say SERVER RESTART IN 1 MINUTE") ControlSend($ConsoleWindowName, "", "", "{ENTER}") Sleep(30000) ControlSend($ConsoleWindowName, "", "", "say SERVER RESTART IN 30 SECONDS") ControlSend($ConsoleWindowName, "", "", "{ENTER}") Sleep(20000) ControlSend($ConsoleWindowName, "", "", "say SERVER RESTART IN 10 SECONDS") ControlSend($ConsoleWindowName, "", "", "{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "say 9..{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "say 8..{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "say 7..{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "say 6..{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "say 5..{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "say 4..{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "say 3..{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "say 2..{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "say 1..{ENTER}") Sleep(1000) ControlSend($ConsoleWindowName, "", "", "stop{ENTER}") ResetIsServerRestarting() EndFunc Func ResetIsServerRestarting() ; After 5 minutes delay Sleep(300000) $IsServerRestarting = False EndFunc ; Announce the next restart, with Hour and Minute input Func AnnounceRestart($H, $M) ControlFocus($ConsoleWindowName, "", "") ControlSend($ConsoleWindowName, "", "", "say ") ControlSend($ConsoleWindowName, "", "", $RestartAdText) ControlSend($ConsoleWindowName, "", "", " ") ControlSend($ConsoleWindowName, "", "", $H) ControlSend($ConsoleWindowName, "", "", ":") ControlSend($ConsoleWindowName, "", "", $M) ControlSend($ConsoleWindowName, "", "", " ") ControlSend($ConsoleWindowName, "", "", $TimeFormat) ControlSend($ConsoleWindowName, "", "", "{ENTER}") EndFunc ; Just a function to put in, whenever you want to test something Func TestFunc() ControlFocus($ConsoleWindowName, "", "") ControlSend($ConsoleWindowName, "", "", "say test{ENTER}") EndFunc Link to comment Share on other sites More sharing options...
Musashi Posted July 9, 2020 Share Posted July 9, 2020 (edited) The request and the script are almost completely identical to your already locked thread : https://www.autoitscript.com/forum/topic/203314-controlsend-issue-with-minecraft-server-console-locked/ The only difference is, that you omitted the term Minecraft. 1 hour ago, Thalez said: *Repost in honor of the forum rules* With this repost, the forum rules are hardly honoured, but rather ridiculed . Edited July 9, 2020 by Musashi typo "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 9, 2020 Moderators Share Posted July 9, 2020 Thalez, I see you did not read those rules to which you were linked very carefully - you missed the part that says: "Do not repost the same question if the previous thread has been locked - particularly if you merely reword the question to get around one of the prohibitions listed above" Do NOT start another thread on this - our patience has limits. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts