Fixed. Apparently as of 0.75, the aos:// link includes the port. I adjusted for it, and added port column. I also fixed the insane one-space indentation.
Btw, this is for a portable installation (put it in your aos dir). Also, I use ahk_l, I'm not sure if it still works on basic.
#NoEnv
#SingleInstance, Force
URL := "http://www.ace-spades.com/play/"
SetTitleMatchMode, RegEx
AutoJoin := 0
Gui, Font, s16 Bold, Arial
Gui, Add, Text, x10 y0 h30 vTitle Center, Server List
Gui, Font, s8 Norm
SortColumns := [1,0,0,0,0,0]
Gui, Add, ListView, x10 y30 vServerList gListViewEvent, Index|Name|Players|Capacity|Ping|Server|Address|Port
Gui, Font, Bold
Gui, Add, Text, x10 w80 h20 vServerCount
Gui, Add, Button, w80 h20 vLocalServer gLocalServer, &Local Server
Gui, Add, Button, w80 h20 vRefreshList gRefreshList Default, &Refresh
Gui, +Resize +MinSize270x150
Gosub, RefreshList
Gui, Show, Center w600 h450
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, LocalServer, % "x" . (A_GuiWidth - 180) . " y" . (A_GuiHeight - 30)
GuiControl, Move, RefreshList, % "x" . (A_GuiWidth - 90) . " y" . (A_GuiHeight - 30)
WinSet, Redraw
Return
LocalServer:
Gui, Hide
Server := "aos://16777343:32887"
Name := "Local Server"
JoinServer(Server,Name)
Gui, Show
Return
ListViewEvent:
If (A_GuiEvent = "ColClick")
Gosub, SortColumns
If (A_GuiEvent != "DoubleClick")
Return
Gosub, SelectServer
Return
SelectServer:
Row := LV_GetNext()
LV_GetText(Server,Row,6) ;retrieve the server from the fourth column of the selected row
LV_GetText(Name,Row,2) ;retrieve the server name from the first column of the selected row
Gui, Hide
JoinServer(Server,Name)
Gui, Show
Return
SortColumns:
If SortColumns[A_EventInfo]
SortColumns[A_EventInfo] := (SortColumns[A_EventInfo] & 1) + 1 ;toggle sorting types between ascending and descending
Else
SortColumns[A_EventInfo] := (A_EventInfo = 3 || A_EventInfo = 4) ? 2 : 1 ;enable sorting for the column
For Index In SortColumns ;disable sorting on all other columns
{
If (Index != A_EventInfo)
SortColumns[Index] := 0
}
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)
RegExMatch(Output4, "aos\:\/\/(?<server>\d+)(?:\:(?<port>\d+))", output)
Server := outputserver
Port := outputport
Address := (Server & 0xFF) . "." . ((Server & 0xFF00) >> 8) . "." . ((Server & 0xFF0000) >> 16) . "." . ((Server & 0xFF000000) >> 24)
LV_Add("",A_Index,Output5,Output1,Output2,Output3,Output4,Address,Port)
}
;adjust column widths to suit their headers and contents
LV_ModifyCol(1,"AutoHdr Integer") ;index
LV_ModifyCol(2,"AutoHdr") ;server name
LV_ModifyCol(3,"AutoHdr Integer Desc") ;players
LV_ModifyCol(4,"AutoHdr Integer Desc") ;capacity
LV_ModifyCol(5,"AutoHdr Integer") ;ping
LV_ModifyCol(6,"AutoHdr") ;server
LV_ModifyCol(7,"AutoHdr") ;address
For Index, Value In SortColumns
{
If Value
{
LV_ModifyCol(Index,"Sort" . ((Value = 1) ? "" : "Desc"))
Break
}
}
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
JoinServer(Server,Name = "")
{
global AutoJoin
Loop
{
;open Ace of Spades
run, "%A_ScriptDir%\client.exe" "%Server%", %A_ScriptDir%, UseErrorLevel
If ErrorLevel
{
MsgBox, 16, Error, Could not open server "%Server%".
Return, 1
}
WinWait, Ace of Spades|ERROR ahk_class Ace of Spades|#32770,, 5
;check for connection errors
WinGetClass, WindowClass
If (WindowClass != "Ace of Spades") ;error dialogue
{
WinClose
If !AutoJoin
{
MsgBox, 22, Error, Could not connect to "%Name%": server is full or misconfigured.`n`nSelect "Try Again" to retry the connection`, or "Continue" to automaticially join.
IfMsgBox, Cancel
{
Gosub, StopAutoJoin
Break
}
IfMsgBox, Continue
{
AutoJoin := 1
ToolTip, Press Esc to stop automatic retrying.
Hotkey, Esc, StopAutoJoin, On
}
}
}
Else
{
Gosub, StopAutoJoin
If ErrorLevel ;window wait operation timed out
Return, 1
WinSetTitle, Ace of Spades ahk_class Ace of Spades,, Ace of Spades - %Name%
WinWaitClose
Break
}
}
Return, 0
StopAutoJoin:
AutoJoin := 0
ToolTip
Hotkey, Esc, StopAutoJoin, Off
Return
}
#If ListViewFocused()
ListViewFocused()
{
GuiControlGet, CurrentFocus, FocusV
Return, CurrentFocus = "ServerList" && LV_GetNext()
}
Enter::Gosub, SelectServer
#If