Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/21/2024 in all areas

  1. 1 point
  2. I have merged the update into my version of AutoItTools.lua, and looked a the changes made and will be in the next Beta version upload soon. tnx
    1 point
  3. 1 point
  4. Here my take on it : #include <Constants.au3> #include <String.au3> Local $Hex_To_String[] = [ _ '2020202057202d44435736433659414550564b4a' & @CRLF, _ Chr(255) & '2020202020202020202020205635434a43344434' & @CR, _ '123 DEAD 678 BEEF', _ '343138334949313439373534200202020202020' & Chr(32), _ "v5abcw76-mnbvvf"] Local $sResult For $i = 0 To UBound($Hex_To_String) - 1 $sResult = Example_1($Hex_To_String[$i]) If @error Then ContinueLoop MsgBox($MB_OK, "Invalid input on", $Hex_To_String[$i]) ConsoleWrite($sResult & @CRLF) ;MsgBox($MB_OK, "Example_1", $sResult) Next Func Example_1($sSerial) $sSerial = StringRegExpReplace($sSerial, "([\h\v\xFF])", "") ; remove all unwanted characters If StringLen($sSerial) > 20 And StringIsXDigit($sSerial) Then If Mod(StringLen($sSerial), 2) Then Return SetError(1) $sSerial = StringRegExpReplace(_HexToString($sSerial), "([\x20\xFF])", "") EndIf Return $sSerial EndFunc ;==>Example_1
    1 point
  5. j0kky

    Currently used DNS

    Hi folks, Last morning I needed to know programmatically which were my DNS(s) for the current connection, and I searched for an API which fitted my needs... I just tried dnsqueryconfig, which shows the DNS(s) used, if you have manually selected them in the past. The API is little tricky (or maybe I'm little rusty), so I decided to write a small UDF function to avoid a waste of time in the future... here you are. ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_DnsQueryConfig ; Description ...: Retrieves the currently used DNS servers, if they were selected by user ; Syntax.........: _WinAPI_DnsQueryConfig() ; Return values .: On success it returns an array with the list of currently used DNS servers ; ; On failure it returns 0 and sets @error to non zero (these values are useful only for debugging reasons): ; |1 - DllCall error ; |2 - Generic error, DNS could be generated automatically ; Author ........: j0kky ; Modified ......: 1.0.0 14/11/2018 ; Link ..........: https://docs.microsoft.com/en-us/windows/desktop/api/windns/nf-windns-dnsqueryconfig ; =============================================================================================================================== Func _WinAPI_DnsQueryConfig() Local Const $DnsConfigDnsServerList = 6 Local $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", Null, "dword*", 0) If @error Then Return SetError(1, 0, 0) if $aRet[6] <= 4 Then Return SetError(2, 0, 0) Local $tagBuffer = "" For $i = 1 To ($aRet[6] / 4) $tagBuffer &= "dword;" Next Local $tBuffer = DllStructCreate($tagBuffer) $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", DllStructGetPtr($tBuffer), "dword*", $aRet[6]) Local $aDNS[($aRet[6] / 4) - 1] For $i = 2 to (UBound($aDNS) + 1) $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "dword", DllStructGetData($tBuffer, $i)) if @error Then Return SetError(1, 0, 0) $aDNS[$i - 2] = $aRet[0] Next Return SetError(0, 0, $aDNS) EndFunc
    1 point
  6. for more complex urls, you can use something like this regex : Local $aUrl[9] = ["http://server:12345/path/blabla", _ "http://server.com:1234/path?query_string#fragment_id", _ "ftp://user:password@server:1234/path", _ "ftp://user@server:1234/path", _ "http://www.server.com", _ "www.server.com/path", _ "server.com", _ "http://user@server.com:1234/path?query_string#fragment_id", _ "user@server.com:1234" ] Local $sPattern = "^(?i)(?:(?:[a-z]+):\/\/)?" & _ ; Protocol "(?:(?:(?:[^@:]+))" & _ ; Username "(?::(?:[^@]+))?@)?" & _ ; Password "([^\/:]+)" & _ ; Host "(?::(?:\d+))?" & _ ; Port "(?:\/(?:[^?]+)?)?" & _ ; Path "(?:\?\N+)?" ; Query For $i = 0 To UBound($aUrl) - 1 $aHost = StringRegExp($aUrl[$i], $sPattern, 1) ConsoleWrite($aHost[0] & @TAB & $aUrl[$i] & @CRLF) Next https://regex101.com/r/yB3dO1/1
    1 point
×
×
  • Create New...