Jump to content

dphuc23

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by dphuc23

  1. Thanks. It worked perfectly. Also, I tried my code (below) but It doesn't seem to work very well 😅😅 Func Wait() Do ConsoleWrite("Connection no exists" & @CRLF) Until _WinAPI_IsInternetConnected() = True EndFunc
  2. It will exit the For loop. I want the loop to stop and continue running after the network connection is back
  3. Hi all Is had a problem when using For loop. I want to stop the For loop when Internet connection is lost but it still execute. Here is my code. Is there anything wrong? #include <Constants.au3> #include <WinAPIDiag.au3> For $i = 1000 To 1 Step -1 If _WinAPI_IsInternetConnected() Then ConsoleWrite($i & @CRLF) Sleep(1000) ; The variable $i will decrease by 1 unit every second Else ConsoleWrite("Connection no exists" & @CRLF) Sleep(1000) EndIf Next
  4. Hello, I'm newbie in AutoIT. I'm trying to get the date and time from a web service which returns the current local time for a given timezone as either plain-text or JSON. Here is the website: http://worldtimeapi.org/api/timezone/Asia/Bangkok JSON: {"abbreviation":"+07","client_ip":"183.81.120.244","datetime":"2021-07-23T14:00:22.225651+07:00","day_of_week":5,"day_of_year":204,"dst":false,"dst_from":null,"dst_offset":0,"dst_until":null,"raw_offset":25200,"timezone":"Asia/Bangkok","unixtime":1627023622,"utc_datetime":"2021-07-23T07:00:22.225651+00:00","utc_offset":"+07:00","week_number":29} Here is what I found Local $String = BinaryToString(INetRead ("http://worldtimeapi.org/api/timezone/Asia/Bangkok",1)) $Obj = Json_Decode($String) $datetime = functionOfMyDreams($Obj, "" ,"datetime") ConsoleWrite($datetime) Func functionOfMyDreams($decodedObject, $targetObject, $targetKeyInObject) $value = Json_Get($decodedObject, '["' & $targetObject & '"]["' & $targetKeyInObject & '"]') return $value EndFunc ;==>functionOfMyDreams The UDF: https://www.autoitscript.com/forum/topic/104150-json-udf-library-fully-rfc4627-compliant/
×
×
  • Create New...