;===================================================================== ; NNTP News Reader ; Initial Release: January 20, 2013 ; Updated: March 01, 2017 ; Version: 1.00 ; Author: ripdad ; ;------------------ ; Tested Versions: ; 3.3.8.1 ; 3.3.12.0 ; 3.3.14.0 ; 3.3.15.0 ;------------------ ; ; Link: http://en.wikipedia.org/wiki/Network_News_Transfer_Protocol ; ; List of free news servers: http://www.freeusenetnews.com/ ;===================================================================== ; #include 'array.au3' Opt('TrayAutoPause', 0) Opt('GUICloseOnESC', 0) Opt('MustDeclareVars', 1) Opt('GUIResizeMode', 0x0322) Opt('GUIDataSeparatorChar', '¦'); <- change to broken pipe, because pipe is used in received data Opt('TCPTimeout', 990); <- earlier versions of autoit have issues if set higher ; Local $sTitle = 'NNTP News Reader v1.00' ; If Not TCPStartup() Then Exit MsgBox(8240, $sTitle, 'Error: TCPStartup' & @TAB, 15) EndIf ; ;[ini] Local $sPathIni = @ScriptDir & '\NNTP.ini' If Not FileExists($sPathIni) Then _IniConfig() EndIf ; ;[server config] Local $NNTP_NewsServer = IniRead($sPathIni, 'News_Servers', 'lastserver', 'news.aioe.org'); <- fail default Local $NNTP_ServerIP = TCPNameToIP($NNTP_NewsServer) If @error Then MsgBox(8240, $sTitle, 'Cannot obtain IP for: ' & $NNTP_NewsServer & @TAB, 15) EndIf Local $NNTP_ServerPort = '119' Local $NNTP_Socket = 0 ; ;[vars] Local Const $GUI_ENABLE = 64, $GUI_DISABLE = 128 Local $sFontFace = 'Verdana', $nFontSize = '12' Local $nArticle = 0, $nColumn = -1 Local $aLV[1][1] ; ;[gui] Local $ID_GUI = GUICreate($sTitle, 720, 430, Default, Default, 0x00CF0000) GUISetFont(8.5, Default, Default, 'microsoft sans serif') Local $ID_GP1 = GUICtrlCreateGroup('', 10, 0, 700, 40) Local $ID_GRP = GUICtrlCreateCombo('', 15, 12, 200, 150) Local $ID_ACT = GUICtrlCreateCombo('', 220, 12, 55, 150) Local $ID_CON = GUICtrlCreateCombo('', 280, 12, 160, 150) Local $ID_FNT = GUICtrlCreateCombo('', 445, 12, 70, 20) Local $ID_FTS = GUICtrlCreateCombo('', 518, 12, 50, 20) Local $ID_IND = GUICtrlCreateLabel('IND', 572, 13, 30, 18, 0x1201) Local $ID_PB1 = GUICtrlCreateProgress(602, 13, 100, 9, 0x01) Local $ID_PB2 = GUICtrlCreateProgress(602, 22, 100, 9, 0x01) Local $ID_LTV = GUICtrlCreateListView('Subject¦Poster¦Date¦Size¦Article#', 10, 45, 700, 180) Local $ID_NFO = GUICtrlCreateLabel('Ready', 10, 230, 700, 20, 0x1201) Local $OBJ_SE = ObjCreate('Shell.Explorer') Local $ID_OBJ = GUICtrlCreateObj($OBJ_SE, 10, 255, 700, 160) GUICtrlSetBkColor($ID_PB1, 0xFFFFFF) GUICtrlSetBkColor($ID_PB2, 0xFFFFFF) GUICtrlSetColor($ID_PB1, 0x00AA00) GUICtrlSetColor($ID_PB2, 0xBB0000) GUICtrlSetData($ID_GRP, 'Select News Group¦' & _GetNewsGroups(), 'Select News Group') GUICtrlSetData($ID_ACT, '100¦300¦500¦1000¦2000¦5000¦10000¦15000¦20000¦25000', '100') GUICtrlSetData($ID_FNT, 'Arial¦Courier¦Georgia¦Tahoma¦Verdana', 'Verdana') GUICtrlSetData($ID_FTS, '12¦14¦16¦18¦20', '12') GUICtrlSetData($ID_CON, _GetNewsServers(), $NNTP_NewsServer) GUICtrlSetResizing($ID_OBJ, 0x0066); $GUI_DOCKBORDERS GUICtrlSetResizing($ID_NFO, 0x0226); $GUI_DOCKMENUBAR+$GUI_DOCKLEFT+$GUI_DOCKRIGHT GUICtrlSetResizing($ID_LTV, 0x0226) GUICtrlSetTip($ID_GRP, 'Select a News Group') GUICtrlSetTip($ID_ACT, 'Articles to Get') GUICtrlSetTip($ID_CON, 'News Server') GUICtrlSetTip($ID_FNT, 'Font Face') GUICtrlSetTip($ID_FTS, 'Font Size') GUICtrlSetTip($ID_IND, 'Progress and Timeout Indicators') GUICtrlSetTip($ID_PB1, 'Progress') GUICtrlSetTip($ID_PB2, 'Timeout') LV_SetColumnWidth($ID_LTV, '550|170|120|60|60') GUICtrlSendMsg($ID_LTV, 0x1036, 0, 0x14230); <- lv tip on-hover, trancexx _IE_Write_HTML($sTitle) GUISetState(@SW_SHOW, $ID_GUI) GUICtrlSetState($ID_LTV, 256) GUIRegisterMsg(0x004E, '_WM_NOTIFY') GUIRegisterMsg(0x0024, '_WM_GETMINMAXINFO') OnAutoItExitRegister('Exit_App') ; While 1 Switch GUIGetMsg() Case -3 Exit Case $ID_FNT, $ID_FTS _Set_Font() Case $ID_CON _NNTP_Init() GUICtrlSetData($ID_NFO, 'Ready') Case $ID_GRP _DLG_Config() GUICtrlSetData($ID_NFO, 'Ready') Case Else EndSwitch Select Case $nArticle _NNTP_ReadArticle() $nArticle = 0 Case $nColumn > -1 LV_SortColumn($nColumn) $nColumn = -1 Case Else EndSelect WEnd ; Func _DLG_Config() GUICtrlSetState($ID_ACT, 128) GUICtrlSetState($ID_GRP, 128) GUICtrlSetState($ID_CON, 128) GUICtrlSetState($ID_FNT, 128) GUICtrlSetState($ID_FTS, 128) GUICtrlSetState($ID_LTV, 256) _NNTP_Group() GUICtrlSetState($ID_ACT, 64) GUICtrlSetState($ID_GRP, 64) GUICtrlSetState($ID_CON, 64) GUICtrlSetState($ID_FNT, 64) GUICtrlSetState($ID_FTS, 64) GUICtrlSetState($ID_LTV, 256) EndFunc ; Func _NNTP_Init() _IE_Write_HTML($sTitle) Local $xServer = GUICtrlRead($ID_CON) Local $xIP = TCPNameToIP($xServer) If @error Then _IE_Write_HTML('Cannot obtain IP for: ' & $xServer) Return EndIf ; $NNTP_NewsServer = $xServer $NNTP_ServerIP = $xIP ; Local $sData = _NNTP_COMMAND('CONNECT', 1) If @error Then _IE_Write_HTML('Cannot Connect to: ' & $xServer) Return EndIf _NNTP_COMMAND('MODE READER', 1) If @error Then Return $sData &= _NNTP_COMMAND('HELP') _NNTP_COMMAND('QUIT', 1) _IE_Write_HTML($sData) IniWrite($sPathIni, 'News_Servers', 'lastserver', $NNTP_NewsServer) EndFunc ; Func _IE_Write_HTML($str) $str = StringReplace($str, '<', '<') $str = StringReplace($str, '>', '>') $str = StringReplace($str, @CRLF & @CRLF, '{HEADER}', 1) $str = StringReplace($str, @CRLF, '
') Local $a = StringSplit($str, '
', 1) Local $string, $body = 0, $quoted = 0, $response = 0 $str = '' ; For $i = 1 To $a[0] $string = StringStripWS($a[$i], 3) If Not StringExists($string) Then $string = '  ' EndIf ; If $body Then If StringRegExp($string, '(?i)(https?:.*(\.gif|\.jpg|\.jpeg|\.png))') Then $str &= StringRegExpReplace($string, '(?i)(https?:.*(\.gif|\.jpg|\.jpeg|\.png))', '

' & @CRLF) EndIf ; If StringLeft($string, 4) = '>' Then; quoted If $response Then $str &= '
' & @CRLF $response = 0 EndIf ; If $quoted Then $str &= $string & '
' & @CRLF Else $str &= '' & $string & '
' & @CRLF $quoted = 1 EndIf Else; response If $quoted Then $str &= '

' & @CRLF $quoted = 0 EndIf ; If $response Then $str &= $string & '
' & @CRLF Else $str &= '' & $string & '
' & @CRLF $response = 1 EndIf EndIf Else; header If StringInStr($string, '{HEADER}') Then $str &= StringReplace($string, '{HEADER}', '


', 1) & @CRLF & @CRLF $body = 1 Else $str &= $string & '
' & @CRLF EndIf EndIf Next ; Local $sHTML = '' & @CRLF $sHTML &= '' & @CRLF $sHTML &= $str & @CRLF & '' & @CRLF ;================================ $OBJ_SE.Navigate('about:blank') $OBJ_SE.Document.Write($sHTML) $OBJ_SE.Document.Close() ControlFocus($sTitle, '', '[CLASSNN:Internet Explorer_Server1]') EndFunc ; Func _NNTP_ReadArticle() Local $sGroup = _NNTP_GET_GROUP() If @error Then Return ; Select Case $nArticle $nArticle = StringTrimRight(GUICtrlRead(GUICtrlRead($ID_LTV)), 1) $nArticle = StringRegExpReplace($nArticle, '.*¦', '') If Not StringIsDigit($nArticle) Then Return Case Else _IE_Write_HTML('Article ID Not Found') Return '' EndSelect ; _IE_Write_HTML($sTitle) ; _NNTP_CONNECT() If @error Then Return _NNTP_COMMAND('GROUP ' & $sGroup, 1) If @error Then Return Local $sData = _NNTP_COMMAND('ARTICLE ' & $nArticle) If @error Then Return _NNTP_COMMAND('QUIT', 1) ; Local $sPattern = '(?i)(format=)|(charset=)|(reply-type=)|(Cancel-Lock:)|(Content-Type:)|(Face:)|(Importance:)|' $sPattern &= '(Injection-Date:)|(Injection-Info:)|(Mime-Version:)|(Organization:)|(Priority:)|(References:)|' $sPattern &= '(Transfer-Encoding:)|(X-Accept-Language:)|(X-Antivirus:)|(X-Antivirus-Status:)|(X-Comment-To:)|' $sPattern &= '(X-Debug:)|(X-MimeOLE:)|(X-No-Archive:)|(X-No-Trolls:)|(X-Notice:)|(X-Postfilter:)|(X-Received:)|(X-Trace:)' ; ; separate header and body Local $sHead = StringLeft($sData, StringInStr($sData, @CRLF & @CRLF) + 3) Local $sBody = StringTrimLeft($sData, StringInStr($sData, @CRLF & @CRLF) + 3) ; $sHead = _Header_FixUp($sHead) $sBody = _Body_FixUp($sBody) ; ; process header Local $a = StringSplit($sHead, @CRLF, 1) Local $s, $sArticle = '' ; For $i = 1 To $a[0] $s = StringStripWS($a[$i], 7) If StringExists($s) Then; filter unwanted or unnecessary lines in header Select Case StringRegExp(StringLeft($s, 1), '[\W]') Case StringRegExp($s, $sPattern) Case Else $sArticle &= $s & @CRLF EndSelect EndIf Next $sArticle &= @CRLF & @CRLF & $sBody; rejoin header and body _IE_Write_HTML($sArticle) GUICtrlSetData($ID_NFO, 'Ready') EndFunc ; Func _Header_FixUp($sHeader) ; fix line wraps after comma $sHeader = StringReplace($sHeader, ',' & @CRLF, ',') ; fix line wraps after semi-colon $sHeader = StringReplace($sHeader, ';' & @CRLF, ';') ; fix tabs $sHeader = StringReplace($sHeader, @TAB, ' ') ; ; fix line wraps Local $a = StringSplit($sHeader, @CRLF, 1) Local $t = '' $sHeader = '' ; For $i = 1 To $a[0] $sHeader &= StringStripWS($a[$i], 7) If $i < $a[0] Then $t = $a[$i + 1] If StringExists($t) Then If StringRegExp($t, '(\w.*?:\s)') Then $sHeader &= @CRLF Else $sHeader &= ' ' & $t & @CRLF $i += 1 EndIf EndIf Else $sHeader &= @CRLF EndIf Next Return $sHeader EndFunc ; Func _Body_FixUp($sBody) ; remove beginning and ending whitespace $sBody = StringStripWS($sBody, 3) ; remove usenet termination $sBody = StringTrimRight($sBody, 1) ; fix google formatting, if exist $sBody = StringReplace($sBody, '=20', ' ') $sBody = StringReplace($sBody, '=92', "'") $sBody = StringReplace($sBody, '=3D', '=') $sBody = StringReplace($sBody, '=' & @CRLF, '') ; ; wrap unquoted lines Local $a = StringSplit($sBody, @CRLF, 1) Local $sLine $sBody = '' ; For $i = 1 To $a[0] $sLine = StringStripWS($a[$i], 7) If StringExists($sLine) Then If Not StringMatch(StringLeft($sLine, 1), '>|', '') Then $sLine = StringRegExpReplace($sLine, '(.{90}\s)', '\1' & @CRLF) $sLine = StringReplace($sLine, @CRLF & ' ', @CRLF) $sLine = StringStripWS($sLine, 3) EndIf $sBody &= $sLine & @CRLF Else $sBody &= @CRLF EndIf Next Return $sBody EndFunc ; Func _NNTP_Group() Local $sGroup = _NNTP_GET_GROUP() If @error Then Return ; GUICtrlSetData($ID_LTV, 'Subject Items: 0') GUICtrlSendMsg($ID_LTV, 0x1009, 0, 0) ; _IE_Write_HTML($sTitle) ; _NNTP_CONNECT() If @error Then Return Local $sData = _NNTP_COMMAND('GROUP ' & $sGroup, 1) If @error Then Return ; ;$sRtn = group string (space delimited) ;====================================== ;1 = server code (211) ;2 = estimated number of articles in group. ;3 = first article number in the group. ;4 = last article number in the group. ;5 = selected group. ; Local $a = StringSplit($sData, ' ') $a[1] = Number($a[1]) ; If ($a[0] <> 5) Or ($a[1] <> 211) Then _NNTP_COMMAND('QUIT', 1) _IE_Write_HTML($sData) Return EndIf ; $a[2] = Number($a[2]) $a[4] = Number($a[4]) ; If $a[2] = 0 Then _IE_Write_HTML('No Articles Found') Return EndIf ; Local $NumberArticles = Number(GUICtrlRead($ID_ACT)) If $NumberArticles > $a[2] Then $NumberArticles = $a[2] EndIf Local $sRange = ($a[4] - $NumberArticles) & '-' & $a[4] ; $sData = _NNTP_COMMAND('XOVER ' & $sRange);<-- get article list within provided range If @error Then Return _NNTP_COMMAND('QUIT', 1) If @error Then Return ; GUICtrlSetData($ID_NFO, 'Please Wait...') ; $sData = StringTrimLeft($sData, StringInStr($sData, @CRLF) + 1) $sData = StringTrimRight($sData, 5); trim EOF ; Local $aHeaders = StringSplit($sData, @CRLF, 1) ; ;$aHeaders (tab delimited) ;============================ ;1 = article number ;2 = subject line ;3 = poster/sender ;4 = NNTP-Posting-Date ;5 = Message-ID ;6 = References ;7 = Bytes ;8 = Lines ;9 = Xref ; $sData = '' Local $nItem, $n = 0 Local $aTemp, $nHeaders = $aHeaders[0] Local $a2D[$nHeaders + 1][6] = [[$nHeaders, '']] Local $nLastArticle = IniRead($sPathIni, $NNTP_NewsServer, $sGroup, 0) ; For $i = 1 To $nHeaders $aTemp = StringSplit($aHeaders[$i], @TAB) If ($aTemp[0] = 9) And StringIsDigit($aTemp[1]) Then $n += 1 ; ; String Fixups $a2D[$n][1] = StringStripWS($aTemp[2], 7) & '¦'; subject $a2D[$n][2] = StringStripWS(StringReplace($aTemp[3], '"', ''), 7) & '¦'; poster $a2D[$n][3] = StringRegExpReplace($aTemp[4], '.*?(\d{1,2}.\w{3}.\d{4}.\d{2}\:\d{2}\:\d{2}).*', '\1') & '¦'; date $a2D[$n][4] = GetByteFormat($aTemp[7]) & '¦'; size $a2D[$n][5] = $aTemp[1]; article number ; If StringLen(StringRegExpReplace($a2D[$n][3], '(\s.*)', '')) = 1 Then $a2D[$n][3] = '0' & $a2D[$n][3] EndIf ; $nItem = GUICtrlCreateListViewItem(' ', $ID_LTV) GUICtrlSetData($nItem, $a2D[$n][1] & $a2D[$n][2] & $a2D[$n][3] & $a2D[$n][4] & $a2D[$n][5]) ; ; Highlight last article number from previous session If ($a2D[$n][5] = $nLastArticle) Then GUICtrlSetBkColor($nItem, 0xFFCCCC) ElseIf StringLeft($a2D[$n][1], 3) <> 'Re:' Then GUICtrlSetBkColor($nItem, 0xD0FFD0) EndIf EndIf GUICtrlSetData($ID_PB1, ($i / $nHeaders) * 100) Next ; ; Write current article number to ini IniWrite($sPathIni, $NNTP_NewsServer, $sGroup, $a2D[$a2D[0][0]][5]) ; GUICtrlSetData($ID_LTV, 'Subject Items: ' & $n) GUICtrlSetData($ID_PB1, 0) $aHeaders = 0 $sData = 0 $aLV = $a2D $a2D = 0 EndFunc ; Func _NNTP_CONNECT() For $i = 1 To 4 If $i > 3 Then _IE_Write_HTML('Cannot Connect to: ' & $NNTP_NewsServer) GUICtrlSetData($ID_NFO, 'Ready') Return SetError(-1) EndIf _NNTP_COMMAND('CONNECT', 1) If @error Then GUICtrlSetData($ID_NFO, '> Retry: ' & $i) Sleep(2000) Else ExitLoop EndIf Next _NNTP_COMMAND('MODE READER', 1) If @error Then Return SetError(-2) EndFunc ; Func _NNTP_COMMAND($sCommand, $response_expected = 0, $strPost = 0) GUICtrlSetData($ID_NFO, '[ ' & $sCommand & ' ]') Sleep(10) ; Select; Connection Handler Case $sCommand = 'CONNECT' $NNTP_Socket = TCPConnect($NNTP_ServerIP, $NNTP_ServerPort) If @error Or $NNTP_Socket < 1 Then _WSAGetLastErrorEx() Return SetError(-1) EndIf Case Else If $sCommand = 'POST' And $strPost Then TCPSend($NNTP_Socket, $strPost) Else TCPSend($NNTP_Socket, $sCommand & @CRLF) EndIf ; If @error Then _WSAGetLastErrorEx() TCPCloseSocket($NNTP_Socket) _IE_Write_HTML('Error sending command: ' & $sCommand) Return SetError(-1) EndIf EndSelect ; Local $timeout = 0, $nError = 0, $sError = 0, $SocketError = 0, $sData = '' Local $sReceive, $lines = 0, $progress = 0, $IsTerminated = 0 ; Do $sReceive = TCPRecv($NNTP_Socket, 16384, 1) If @error Then _WSAGetLastErrorEx() $SocketError = 1 ExitLoop EndIf ; If StringLeft($sReceive, 2) = '0x' Then $sReceive = BinaryToString($sReceive) StringReplace($sReceive, @CRLF, '') $lines += @extended $sData &= $sReceive ; Select; Response Handler Case $lines = 1; server responses are one-liners. $nError = StringLeft($sData, 3); check for server errors. If $nError >= 400 Then; error codes range from 400 to 503. $sError = $sData; <-- copy msg to trigger an error. ExitLoop ElseIf $response_expected Then; server responses are not terminated. If StringLen($sData) > 5 Then; server codes are 3 digits followed by a message. $IsTerminated = 1; <-- manually terminate the response. ExitLoop EndIf EndIf Case StringRegExp(StringRight($sData, 20), '.*(\r\n\.\r\n)'); test data for terminator (EOF). $IsTerminated = 1; <-- server terminated. ExitLoop Case Else EndSelect ; $progress += 0.5 If $progress > 100 Then $progress = 0; reset EndIf GUICtrlSetData($ID_PB1, $progress) GUICtrlSetData($ID_PB2, 0) $timeout = 0 Else $timeout += 0.3 GUICtrlSetData($ID_PB2, $timeout) EndIf ; Sleep(10) Until $timeout > 100 ; GUICtrlSetData($ID_PB1, 0) GUICtrlSetData($ID_PB2, 0) ; Select; Data Handler Case $SocketError _IE_Write_HTML('Server Disconnected') Case $sError If StringMatch($sCommand, '.') Then Return; escape POST from server _IE_Write_HTML(StringStripWS($sError, 7)); display error from server If StringMatch($nError, '423|430') Then; specific server error Return SetError(-2) EndIf Case $IsTerminated If StringMatch($sCommand, 'QUIT') Then TCPCloseSocket($NNTP_Socket) EndIf Return $sData Case $timeout > 100 _IE_Write_HTML('Connection Timed Out') Case Else _IE_Write_HTML('No Data Received') EndSelect ; TCPCloseSocket($NNTP_Socket) Return SetError(-1) EndFunc ; Func _NNTP_GET_GROUP() Local $str = GUICtrlRead($ID_GRP) If $str <> 'Select News Group' Then If StringExists($str) Then Return $str EndIf _IE_Write_HTML('Please Select a Valid "News Group"') Return SetError(-1) EndFunc ; Func Exit_App() GUIRegisterMsg(0x004E, '') GUIRegisterMsg(0x0024, '') GUICtrlDelete($ID_OBJ) GUIDelete($ID_GUI) TCPShutdown() Exit EndFunc ; Func _GetNewsServers() Local $a = IniReadSection($sPathIni, 'News_Servers') If Not IsArray($a) Then Return '' Local $str = '' For $i = 2 To $a[0][0] $str &= '¦' & $a[$i][1] Next Return StringTrimLeft($str, 1) EndFunc ; Func _GetNewsGroups() Local $a = IniReadSection($sPathIni, 'News_Groups') If Not IsArray($a) Then Return '' Local $str = '' For $i = 1 To $a[0][0] $str &= '¦' & $a[$i][1] Next Return StringTrimLeft($str, 1) EndFunc ; Func _Set_Font() $sFontFace = GUICtrlRead($ID_FNT) $nFontSize = GUICtrlRead($ID_FTS) GUICtrlSetState($ID_LTV, 256) EndFunc ; ; simple version Func StringExists($s, $n = 30) Return StringLen(StringStripWS(StringLeft($s, $n), 8)) EndFunc ; ; simple version Func GetByteFormat($n_b) Local $a_ab = StringSplit('B|KB|MB|GB|TB', '|') ; For $i = 1 To $a_ab[0]; "bytes" in -> div -> abrv -> out If ($n_b < 1024) Then Return Round($n_b, 1) & ' ' & $a_ab[$i] $n_b /= 1024 Next EndFunc ; ; simple version Func StringMatch($s, $c, $d = '|') $s = StringLower($s) $c = StringLower($c) Local $a = StringSplit($c, $d, 1) ; For $i = 1 To $a[0] If ($s == $a[$i]) Then Return $i Next EndFunc ; Func GetRandomString() Local $objSTL = ObjCreate('Scriptlet.TypeLib') Return StringRegExpReplace($objSTL.Guid, '[\W]', '') EndFunc ; Func LV_SortColumn(ByRef $nColumn) If StringMatch($nColumn, '2|3') Then Return GUICtrlSetData($ID_NFO, 'Please Wait...') GUICtrlSendMsg($ID_LTV, 0x1009, 0, 0) Local $sItem ; For $i = 1 To $aLV[0][0] $aLV[$i][0] = $aLV[$i][$nColumn + 1] & $aLV[$i][5] Next _ArraySort($aLV, 0, 1) ; For $i = 1 To $aLV[0][0] If StringExists($aLV[$i][1]) Then $sItem = GUICtrlCreateListViewItem(' ', $ID_LTV) GUICtrlSetData($sItem, $aLV[$i][1] & $aLV[$i][2] & $aLV[$i][3] & $aLV[$i][4] & $aLV[$i][5]) EndIf GUICtrlSetData($ID_PB1, ($i / $aLV[0][0]) * 100) Next GUICtrlSetData($ID_NFO, 'Ready') GUICtrlSetData($ID_PB1, 0) EndFunc ; ; simple version Func LV_SetColumnWidth(ByRef $IDLV, $sWidth) Local $a = StringSplit($sWidth, '|') ; For $i = 1 To $a[0] GUICtrlSendMsg($IDLV, 0x101E, $i - 1, Number($a[$i])) Next EndFunc ; Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tStruct = DllStructCreate('hwnd hWndFrom;uint_ptr IDFrom;int Code;int Item;int SubItem', $lParam) ; If @error = 0 Then Switch DllStructGetData($tStruct, 'Code') Case -3; $NM_DBLCLK $nArticle = 1 Case -108; $LVN_COLUMNCLICK $nColumn = DllStructGetData($tStruct, 'SubItem') EndSwitch EndIf Return 'GUI_RUNDEFMSG' EndFunc ; Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tagMaxinfo = DllStructCreate('int;int;int;int;int;int;int;int;int;int', $lParam) DllStructSetData($tagMaxinfo, 7, 725); min-width DllStructSetData($tagMaxinfo, 8, 435); min-height Return 'GUI_RUNDEFMSG' EndFunc ; ;============================================================= ; WSAGetLastError: Windows Sockets Error Codes ; http://msdn.microsoft.com/en-us/library/ms740668.aspx ; ; FormatMessage: ; http://msdn.microsoft.com/en-us/library/ms679351.aspx ;============================================================= Func _WSAGetLastErrorEx($m = 0) Local $a = DllCall('ws2_32.dll', 'int', 'WSAGetLastError') If @error Or Not IsArray($a) Then Return SetError(-1, 0, -1) If ($m = 0) And ($a[0] < 6) Then Return 0 $a = DllCall('kernel32.dll', 'int', 'FormatMessage', 'int', 0x00001000, 'ptr', 0, 'int', $a[0], 'int', 0, 'str', 0, 'int', 2048, 'ptr', 0) If @error Or Not IsArray($a) Then Return SetError(-2, 0, -2) _IE_Write_HTML('[Error:' & $a[3] & '] ' & StringStripWS($a[5], 7)) If $m Then Return $a[3] Return SetError(-3, 0, -3) EndFunc ; Func _IniConfig() Local $hFile = FileOpen($sPathIni, 2) If $hFile = -1 Then Exit MsgBox(8240, $sTitle, 'Error: Cannot Open Ini File' & @TAB, 15) EndIf ; Local $str = '' $str &= '[News_Servers]' & @CRLF $str &= 'lastserver=news.aioe.org' & @CRLF; <-last server that was used $str &= '1=news.aioe.org' & @CRLF; <-primary, >1mbs $str &= '2=nntp.aioe.org' & @CRLF; <-secondary, >1mbs $str &= '3=freenews.netfront.net' & @CRLF; >1mbs $str &= '4=news.mixmin.net' & @CRLF; ~50kbs $str &= @CRLF $str &= '[News_Groups]' & @CRLF $str &= '1=alt.comp.os.windows-10' & @CRLF $str &= '2=alt.comp.os.windows-8' & @CRLF $str &= '3=alt.windows7.general' & @CRLF $str &= '4=microsoft.public.windowsxp.general' & @CRLF $str &= '5=alt.msdos.batch.nt' & @CRLF $str &= '6=comp.os.linux.misc' & @CRLF $str &= '7=alt.os.linux.mint' & @CRLF $str &= '8=alt.html' & @CRLF $str &= @CRLF FileWrite($hFile, $str) FileClose($hFile) EndFunc ;