WAIT! There's no "auto-connect" option
I tried with something like this
#NoEnv
URL := "http://ace-spades.com/play/"
SetTitleMatchMode, RegEx
Gui, Font, s16 Bold, Arial
Gui, Add, Text, x10 y0 h30 vTitle Center, Server List
Gui, Font, s8 Norm
Gui, Add, ListView, x10 y30 vServerList gSelectServer, Name|Players|Ping|Address
Gui, Font, Bold
Gui, Add, Text, x10 w80 h20 vServerCount
Gui, Add, Button, w80 h20 vRefreshList gRefreshList Default, Refresh
Gui, +Resize +MinSize200x150
Gosub, RefreshList
Gosub, GuiSize
Gui, Show, w490 h350
Return
GuiEscape:
GuiClose:
ExitApp
GuiSize:
GuiControl, Move, Title, % "w" . (A_GuiWidth - 20)
GuiControl, Move, ServerList, % "w" . (A_GuiWidth - 20) . " h" . (A_GuiHeight - 70)
GuiControl, Move, ServerCount, % "y" . (A_GuiHeight - 30)
GuiControl, Move, RefreshList, % "x" . (A_GuiWidth - 90) . " y" . (A_GuiHeight - 30)
WinSet, Redraw
Return
SelectServer:
If (A_GuiEvent != "DoubleClick")
Return
Row := LV_GetNext()
LV_GetText(Address,Row,4) ;retrieve the address from the fourth column of the selected row
Gui, Hide
Run %A_ScriptDir%\AoS.ahk
Loop
{
;open Ace of Spades
Run, %Address%,, UseErrorLevel
If ErrorLevel
MsgBox, 16, Error, Could not open address "%Address%".
WinWait, Ace of Spades|ERROR ahk_class Ace of Spades|#32770
;check for connection errors
WinGetClass, WindowClass
If (WindowClass != "Ace of Spades") ;error dialogue
{
WinClose
LV_GetText(ServerName,Row,1) ;retrieve the server name from the first column of the selected row
[color=red] MsgBox, 26,, Could not connect to "%ServerName%": server is full or misconfigured.`nPress 'Continue' to auto-join.[/color]
IfMsgBox, Cancel
Break
[color=red]IfMsgBox, Continue
{
Loop
{
Run %Address%
WinWait, Ace of Spades|ERROR ahk_class Ace of Spades|#32770,, 3
WinGetTitle, T
If T = ERROR
WinClose
Else break 2
}[/color]
}
}
Else If !ErrorLevel ;operation did not time out
WinWaitClose
}
Gui, Show
Return
RefreshList:
;request the server selection page
Try
{
WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("GET",URL) ;open request
WebRequest.Send() ;send request
ServerPage := WebRequest.ResponseText ;retrieve response
WebRequest := "" ;free request
}
Catch Error
{
WebRequest := "" ;free request
If (Error.Extra = "Send")
MsgBox, 16, Error, Could not request server list.
Else If (Error.Extra = "ResponseText")
MsgBox, 16, Error, Could not retrieve server list.
ServerPage := ""
}
RegExMatch(ServerPage,"iS)<div\b[^<]*<a\b[^>]*>[^<]*?([\d\.]+)",Output), Version := (Output1 = "") ? "Unknown Version" : ("Version " . Output1) ;find the current version
;retrieve the server list
ServerPage := SubStr(ServerPage,InStr(ServerPage,"<pre>") + 5) ;remove everything before the server list
ServerPage := SubStr(ServerPage,1,InStr(ServerPage,"</pre>") - 1) ;remove everything after the server list
StringReplace, ServerPage, ServerPage, `r,, All ;remove carriage returns
ServerPage := Trim(ServerPage,"`n") ;trim off leading and trailing newlines
ServerPage := SubStr(ServerPage,InStr(ServerPage,"`n") + 1) ;remove the header row
GuiControl, -Redraw, ServerList ;prevent redrawing of the ListView
LV_Delete() ;remove all listview entries
;populate the ListView
Loop, Parse, ServerPage, `n
{
RegExMatch(A_LoopField,"S)\s*(\d+\s*/\s*\d+)\s*(\d+)\s*[^>]*>\s*[^""]*""([^""]+)[^>]*>([^<]+)",Output)
LV_Add("Auto",Output4,Output1,Output2,Output3)
}
;adjust column widths to suit their headers and contents
LV_ModifyCol(1,"AutoHdr")
LV_ModifyCol(2,"AutoHdr Integer")
LV_ModifyCol(3,"AutoHdr Integer")
LV_ModifyCol(4,"AutoHdr")
GuiControl, +Redraw, ServerList ;allow the ListView to be redrawn
GuiControl,, ServerCount, % LV_GetCount() . " servers." ;update the server count
Gui, Show,, Ace of Spades (%Version%) Servers
Return
But for some reason the script hits the MsgBox line and there's no MsgBox...
053: if (WindowClass != "Ace of Spades")
055: WinClose (0.13)
056: LV_GetText(ServerName,Row,1)
057: MsgBox,26,,Could not connect to "%ServerName%": server is full or misconfigured.
Press 'Continue' to auto-join. (18.33)
Press [F5] to refresh.
Could you please add an Auto-join option?