bo8ster Posted January 7, 2009 Posted January 7, 2009 I have a 2003 Server box next to me which might help testing. What is the RegionServer? Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
Zedna Posted January 7, 2009 Posted January 7, 2009 Thanks for that Zedna, but using Au3Info.exe and hovering the cursor over the RegionServer window gives me the Title and Class, but produces no value for ClassNameNN. If I move the cursor off that window and onto the Desktop then I get Program Manager for the Title, and all the lower data, including ClassNameNN, gets populated (just as a check that Au3Info.exe was doing its stuff).Then try to use "" as ClassNameNN --> empty string Resources UDF ResourcesEx UDF AutoIt Forum Search
herewasplato Posted January 7, 2009 Posted January 7, 2009 ... 'sshhuuttddoowwnn'. Any idea what could cause that? ...Having more than one copy of the script running at a time will do that. If you have been testing this over and over - and there were old copies running - they all attempt to send info the the window that satisfies the WinWaitActive state.spelllllllcheck did not like sshhuuttddoowwnn [size="1"][font="Arial"].[u].[/u][/font][/size]
herewasplato Posted January 7, 2009 Posted January 7, 2009 Don't laugh too hard at the way this code looks.You would take out the part marked with;generates the windows to be closedYou should not have to maximize; but like I said, CMD windows are weird.expandcollapse popupAutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption("WinWaitDelay", 1) $TitleArray = StringSplit("RegionServer," & _ "MessagingServer," & _ "InventoryServer," & _ "AssetServer" & _ "GridServer," & _ "UserServer", ",") ;generates the windows to be closed For $i = 1 To $TitleArray[0] Run("cmd") WinWait("C:\WINDOWS\system32\cmd.exe") WinSetTitle("C:\WINDOWS\system32\cmd.exe", "", $TitleArray[$i]) Next ;adds a delay after each successful Win operation... AutoItSetOption("WinWaitDelay", 5000);in milliseconds ; ...so we can read the TrayTip lines below ;closes the windows For $i = 1 To $TitleArray[0] $handle = WinGetHandle($TitleArray[$i]) TrayTip("Closing " & $TitleArray[$i], _ "WinGetHandle returned " & $handle, 10) $var = WinActivate($handle) TrayTip("Closing " & $TitleArray[$i], _ "WinActivate returned " & $var, 10) $var = WinWaitActive($handle) TrayTip("Closing " & $TitleArray[$i], _ "WinWaitActive returned " & $var, 10) Send("exit") TrayTip("Closing " & $TitleArray[$i], _ "sent shutdown", 10) Sleep(500);in milliseconds Send("{ENTER}") TrayTip("Closing " & $TitleArray[$i], _ "sent ENTER", 10) $var = WinWaitClose($handle) TrayTip("Closing " & $TitleArray[$i], _ "WinWaitClose returned " & $var, 10) NextoÝ÷ Øw«z+b³¶¬^nè%w¬"Ù¢^jÈ®Ú+y§b&®¶sdWFôE6WD÷FöâgV÷CµvåFFÆTÖF6ÖöFRgV÷C²Â"¤WFôE6WD÷FöâgV÷CµvåvDFVÆgV÷C²Â ¢b33cµFFÆT'&Ò7G&æu7ÆBgV÷Cµ&Vvöå6W'fW"ÂgV÷C²fײð¢gV÷C´ÖW76væu6W'fW"ÂgV÷C²fײð¢gV÷C´çfVçF÷'6W'fW"ÂgV÷C²fײð¢gV÷C´76WE6W'fW"gV÷C²fײð¢gV÷C´w&E6W'fW"ÂgV÷C²fײð¢gV÷CµW6W%6W'fW"gV÷C²ÂgV÷C²ÂgV÷C² £¶vVæW&FW2FRvæF÷w2Fò&R6Æ÷6V@¤f÷"b33c¶ÒFòb33cµFFÆT'&³Ð¢'VâgV÷C¶6ÖBgV÷C²¢våvBgV÷C´3¢b3#µtäDõu2b3#·77FVÓ3"b3#¶6ÖBæWRgV÷C²¢vå6WEFFÆRgV÷C´3¢b3#µtäDõu2b3#·77FVÓ3"b3#¶6ÖBæWRgV÷C²ÂgV÷C²gV÷C²Âb33cµFFÆT'&²b33c¶Ò¤æW@ £¶6Æ÷6W2FRvæF÷w0¤f÷"b33c¶ÒFòb33cµFFÆT'&³Ð¢b33c¶æFÆRÒvävWDæFÆRb33cµFFÆT'&²b33c¶Ò¢vä7FfFRb33c¶æFÆR¢våvD7FfRb33c¶æFÆR¢6VæBgV÷C¶WBgV÷C²¢6ÆVWS¶âÖÆÆ6V6öæG0¢6VæBgV÷C·´TåDU'ÒgV÷C²¢våvD6Æ÷6Rb33c¶æFÆR¤æW [size="1"][font="Arial"].[u].[/u][/font][/size]
wibs Posted January 7, 2009 Author Posted January 7, 2009 (edited) I have a 2003 Server box next to me which might help testing. What is the RegionServer?Hi bo8ster,The background to this is OpenSim, the open-source version of Second Life, the 3D virtual world. To launch OpenSim you start 6 Servers, which are exe files, and they must be in the right sequence: UserServer, GridServer, AssetServer, InventoryServer, MessagingServer, then finally the Ring that Binds them All, the RegionServer. They must also be closed down in the precise reverse order, or corruption of the MySQL database may occur. Each Server opens a cmd window, and as well as status messages appearing in these windows, you can also enter commands. The command for shutting down a server, cleanly, is 'shutdown'. A regular cmd window will close down instantly with the command 'exit', but we cannot do that, as the server must finish any work it is doing at the time, save data to the database etc, before it closes, hence the 'shutdown' command, which does all this. We cannot close down a server until the previous one has shutdown first.Details of OpenSim are here: http://opensimulator.org/wiki/Main_PageMy tutorials on downloading and getting OpenSim up and running are here (if you are interested): http://chapter-and-metaverse.blogspot.com/Of course, what we are trying to achieve is a one-click solution to the problem of having to go into each cmd window, typing 'shutdown', waiting for the window to close, then doing the same in the other 5 cmd windows, a process that can take up to 10 minutes each time you need to close down your servers.As the regionserver is the one that does most of the work, it is usually only this one that we keep visible on the desktop on the dedicated servers we use (which can be Linux, or Windows Server 2003, or 2008, as you prefer, and I am a Windows user), the other servers are usually minimized to the taskbar.We already have a startup script (just using a windows batch file, which works fine), that launches the servers, but we could not find any batch commands to close the servers down correctly, and hence the reason for turning to AutoIt for a solution.Wibs Edited January 7, 2009 by wibs
wibs Posted January 7, 2009 Author Posted January 7, 2009 (edited) herewasplato, The script works! I just needed to make one edit and one change. On the first pass it closed the first 4 windows, then paused. This was due to a missing comma after AssetServer in the $TitleArray. I also added one extra {Enter} before the shutdown command, just to get the prompt back, as in some cases it may be in a wait mode. Final working script as follows: AutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption("WinWaitDelay", 1) $TitleArray = StringSplit("RegionServer," & _ "MessagingServer," & _ "InventoryServer," & _ "AssetServer," & _ "GridServer," & _ "UserServer", ",") For $i = 1 To $TitleArray[0] $handle = WinGetHandle($TitleArray[$i]) WinActivate($handle) WinWaitActive($handle) Send("{Enter}") Sleep(500);in milliseconds Send("shutdown") Sleep(500);in milliseconds Send("{ENTER}") WinWaitClose($handle) Next The main difference, apart from making it tidier by using a For loop (as opposed to a linear succession of commands), is the use of the WinWaitDelay and the WinGetHandle. Which of these do you think was the missing ingredient that finally solved the problem? Incidentally, you were also right about the cause of the 'sshhuuttddoowwnn', I noticed in the System Tray that there was a previous stalled script sitting there. Thank you very much Wibs Edited January 8, 2009 by wibs
wibs Posted January 8, 2009 Author Posted January 8, 2009 Now that the script works I shall now have a look at the error handling functions. What to do if a windows does not close, for any reason, or if a window is missing, etc. I am already thinking ahead to replacing my batch file for starting the servers with a compiled AutoIt script instead. I see there are at least two commands for starting an exe file, Run() and ShellExecute(). It was not immediately apparent in the help file which was the preferred command for launching an exe. Are there any known views on this? Wibs
bo8ster Posted January 8, 2009 Posted January 8, 2009 Thanks for the info wibs. Good to hear you got the script working. The WinKill and WinList functions might be good there. The help file has more. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
herewasplato Posted January 8, 2009 Posted January 8, 2009 ... WinWaitDelay and the WinGetHandle. Which of these do you think was the missing ingredient that finally solved the problem? ...The WinWaitDelay was just to make things run faster. [1ms instead of the default 250ms]. It was my attempt to crash my test script... but it would never crash. It made all of the windows and then closed them all. You tell us if WinGetHandle fixed things :-) Here is a version without WinGetHandle.AutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption("WinWaitDelay", 1) $TitleArray = StringSplit("RegionServer," & _ "MessagingServer," & _ "InventoryServer," & _ "AssetServer," & _ "GridServer," & _ "UserServer", ",") For $i = 1 To $TitleArray[0] WinActivate($TitleArray[$i]) WinWaitActive($TitleArray[$i]) Send("{Enter}") Sleep(500);in milliseconds Send("shutdown") Sleep(500);in milliseconds Send("{ENTER}") WinWaitClose($TitleArray[$i]) NextMy test code worked with and without WinGetHandle. If the version above does not work for you - then sending info to those particular CMD windows changes the window title somehow... and in a way that your eyes did not see/notice. Using WinGetHandle before sending "shutdown" solves that problem because the window's handle does not change. Funny thing about the missing comma - the test script happily created a CMD window and then changed the title to AssetServerGridServer by concatenating AssetServer and GridServer. I was too tired to notice. ... I am already thinking ahead to replacing my batch file for starting the servers with a compiled AutoIt script instead. ...Also, (just in case you did not know) you do not have to compile the code just to test it, you can run it from the SciTE editor for a quick test (assuming the server has AutoIt installed). Once you get all of the bugs out of your code or after you have pulled all of your hair out; whichever comes first, then you can compile it. Glad to have helped. ~MSP~ [size="1"][font="Arial"].[u].[/u][/font][/size]
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