Jump to content

How can my script only work sometimes?


Recommended Posts

Hello!

Im new to autoit. I have been trying to make a small script for saving and backing up a small minecraft server im hosting. I've tried making this Work for several days now, without luck. The thing is, i have more or less made a working script now. But sometimes the script only does some of the Things its supposed to, and other times it runs the Whole thing without issue. I have no idea what the cause of this is, since nothing is changing on my server.

 

My code is as follows:

#RequireAdmin

Global $variabel = 0


While 1
   if WinExists("C:\Windows\system32\cmd.exe") Then
   WinClose("C:\Windows\system32\cmd.exe")
EndIf
   Sleep(2000)
   Run("F:\FTB\ServerStart.bat")
   Sleep(180000)
   While $variabel < 7
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is saving, please standby..")
   Send("{ENTER}")
   Sleep(1000)
   Send("save-off")
   Send("{ENTER}")
   Sleep(1000)
   Send("save-all")
   Send("{ENTER}")
   Sleep(5000)
   Run("F:\FTB\ServerBackup.bat")
   Sleep(20000)
   Send("save-on")
   Send("{ENTER}")
   Sleep(500)
   Send("say Done saving..")
   Send("{ENTER}")
   $variabel += 1
   Sleep(900000)
   WEnd
   If $variabel = 7 Then
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 15 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(300000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 10 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(300000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 5 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 4 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 3 minutes. Please log out before that time")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 2 minutes. Please log out now")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say Server is restarting in 1 minutes. Please log out now")
   Send("{ENTER}")
   Sleep(60000)
   WinActivate("C:\Windows\system32\cmd.exe")
   Send("say RESTARTING NOW!")
   Send("{ENTER}")
   Sleep(5000)
   Send("save-off")
   Send("{ENTER}")
   Sleep(5000)
   Send("save-all")
   Send("{ENTER}")
   Sleep(10000)
   Send("stop")
   Send("{ENTER}")
   Sleep(10000)
   Send("{ENTER}")
   Sleep(1000)
   Run("F:\FTB\ServerBackup.bat")
   Sleep(10000)
   EndIf
WEnd

 

It is a shitty code i know. The reason im caling Winactivate on each input, is because i thought that might the cause of my problems. But it seems i doesnt.

 

Im basically trying to start my server from the script, then save an backup a few times, and then end it with restarting server by closing it. Its run through console, hence the use of "Send" commands.

 

I've tried solving this by myself without luck, and now i hope for someone to enligthen me, as im sure the fault lies between my chair and my keyboard.

 

Hope to hear from you, Cheers.

Edited by Melba23
Added code tags
Link to comment
Share on other sites

I'm not sure this is against the forum rules. He just does a backup of a game server.
Let's see what the Mods say.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Skoven,

let's see what a Moderator says. I've reported this thread and I'm sure soon a Mod will post his opinion :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The problem is your winactivate and send - you shouldnt use them.

As i can see you are only starting cmd commands . For example Runwait or Run:

RunWait(@comspec & " /c say RESTARTING NOW! ",@sw_hide)

Link to comment
Share on other sites

  • Developers

I'll let it go for the moment but please make sure we stay without the scope of our forum rules!

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

@Jos So, is it a Green Signal?

​Not sure which part of my post was unclear to you, but you are slowly getting on my nerves with your posting style lately, so please back off and only post in a thread when you have actually something substantial to contribute. This is a statement and does not require response in this thread and when you want to discuss anything you can do it in PM with me.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

The problem is your winactivate and send - you shouldnt use them.

As i can see you are only starting cmd commands . For example Runwait or Run:

RunWait(@comspec & " /c say RESTARTING NOW! ",@sw_hide)

​I'll admit i don't know what you are talking about. As i just said, i've just started using autoit, and as such the programming language is still very foreign to me.

 

Problem is, the minecraft server runs as a command console, therefore im forced to "Send" the commands to the console, because the minecraft server runs within. I'm not sure if that helped anything or not.

 

Appreciate the help though.

Link to comment
Share on other sites

I concur with Water. It is not so easy to view this as game automation.

I'll let it go for the moment but please make sure we stay without the scope of our forum rules!

Jos

​so what about this???

FORUM RULES:

  • Launching, automation or script interaction with games or game servers, regardless of the game.
Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

​​so what about this???

FORUM RULES:

  • Launching, automation or script interaction with games or game servers, regardless of the game.

​Ah! Not game automation, but interaction with a game server. I don't know enough about the subject, but I fail to see any game-play advantage gained by a backup script. Strictly speaking you are right though.

Edited by czardas
Link to comment
Share on other sites

All right, it seems people find it more entertaining punching rules, than helping in here, event though everyone knows im just trying to communicate with a command promt. Will an admin please delete this thread..

Edited by Skoven
Link to comment
Share on other sites

  • Moderators

232showtime,

When a Mod has already said only a few posts above yours that the thread is legal, why on earth do you feel the need to jump in and start the discussion all over again?

Skoven,

As you may have noticed, gaming is a very touchy subject here and some wannabee-Mods get all excited about any hint of  it.  You have both active Mods saying that the thread is permissible so, given that this one is now so polluted, I suggest you start a new one and link to this one to show that the question is allowed. I will lock this one to prevent any more silliness.

BEWARE: anyone who starts off questioning the legality of the new thread is going to get very short shrift indeed.

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

  • Developers

​so what about this???

FORUM RULES:

  • Launching, automation or script interaction with games or game servers, regardless of the game.

​Sending me a PM saying you sorry for " quoting me" and "Just asking"  doesn't mean much since you did more than that. You are actually questioning me!

I will be the first one to admit that I make mistakes on a regular basis, but in case anyone feels that has happened it would be nice when a nice constructive PM is send on that in stead of a reply like this.

Next time I am questioned like this, that member will get a short vacation from these forum as I seriously don't think anybody of the team has to account for these type of decisions to you or anybody else other than the other teammembers.

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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