Jump to content

Search the Community

Showing results for tags 'curl'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 19 results

  1. Hi, I'm failing to send Curl post command using AutoIT, basically I believe that the reason is having '!' special character in URL I would be glad for help ; Construct JSON data Local $jsonData = '{"exit_status": ' & $exitStatus & ', "plugin_output": "' & $pluginOutput & '"}' ; Send CURL command Local $curlCommand = 'curl -X POST -k -H "Content-type: application/json" -H "Accept: application/json" --data "' & $jsonData & '" "https://<URL>/v1/actions/process-check-result?service=.com!passive.setEnv_check"'
  2. I built my own libcurl for AutoIt based on BinaryCall UDF. libcurl - the multiprotocol file transfer library The Features: Pure AutoIt script, no DLLs needed.Build with SSL/TLS and zlib support (without libidn, libiconv, libssh2).Full easy-interface and partial multi-interface support.Data can read from or write to autoit variables or files.Smaller code size (compare to most libcurl DLL).The version information of this build: Curl Version: libcurl/7.42.1SSL Version: mbedTLS/1.3.10Libz Version: 1.2.8Protocols: ftp,ftps,http,httpsHere are the helper functions (not include in libcurl library). Curl_DataWriteCallback()Curl_DataReadCallback()Curl_FileWriteCallback()Curl_FileReadCallback()Curl_Data_Put()Curl_Data_Get()Curl_Data_Cleanup()See the example script for detail usage. Curl.zip
  3. Alright, I may be an idiot. Three years ago, I wrote a program that pushed component information to a secure site via their API. I went back to add some attributes and (here's the idiot part) ended up losing the source code and my modified code does not quite work. I have the compiled version that works minus the new attributes, so I know that their system has not changed. I stripped the larger program down from 3,000 lines to the part that is broken, but I am stumped. This was one of my first scripts, so it heavily leverages examples and isn't as pretty as I'd like it to be. Be gentle. The program / script creates a new records as expected, but for some reason, I cannot access information in the response, which I need for a later step. I use Charles, a web debugging proxy tool so I can see the request and the response and both are as expected. Also, when I write to log file, the JSON reply is exactly what I expect and need, but when I try to do anything with the http body, it seems to be blank. Here is the script minus the URL and token: #include <Array.au3> #include <Curl.au3> #include <MsgBoxConstants.au3> #include <json.au3>  ; this was added as an alternate way to read the data Global $WM_serial_number = "WM20745001" Global $wm_component_status_id = "10" Global $wm_manufacturer ="Multi-Tech" Global $wm_model = "MTR-LAT1-B07" Global $cellular_carrier_id = "3" Global $iccid_esn = "89010303300012345678" Global $ip_address = "192.168.2.11" Global $NewIDNumber     Local $Curl = Curl_Easy_Init()     Local $Html = $Curl ; any number as identify     Local $Header = $Curl + 1 ; any number as identify     Local $HtmlFile = "cURL_Request.html"     Local $File = FileOpen($HtmlFile, 2 + 16)     Local $Slist = Curl_Slist_Append(0, "content-type: multipart/form-data; boundary=---011000010111000001101001")     $Slist = Curl_Slist_Append($Slist, "authorization: Token token=" & $Token)     Curl_Easy_Setopt($Curl, $CURLOPT_PROXY, "127.0.0.1") ; needed to use Charles web debugging proxy     Curl_Easy_Setopt($Curl, $CURLOPT_PROXYPORT, 8888) ; needed to use Charles     Curl_Easy_Setopt($Curl, $CURLOPT_HTTPHEADER, $Slist) ;     Curl_Easy_Setopt($Curl, $CURLOPT_URL, $Server & "wireless_module" & "s")     Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0)     Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, 30)     Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $Html)     Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_FileWriteCallback())     Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $File)     Local $HttpPost = ""     Local $LastItem = ""         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[serial_number]", $CURLFORM_COPYCONTENTS, $WM_serial_number, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[component_status_id]", $CURLFORM_COPYCONTENTS, $wm_component_status_id, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[manufacturer]", $CURLFORM_COPYCONTENTS, $wm_manufacturer, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[model]", $CURLFORM_COPYCONTENTS, $wm_model, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[cellular_carrier_id]", $CURLFORM_COPYCONTENTS, $cellular_carrier_id, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[iccid_esn]", $CURLFORM_COPYCONTENTS, $iccid_esn, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[ip_address]", $CURLFORM_COPYCONTENTS, $ip_address, $CURLFORM_END)         ; submit         Curl_Easy_Setopt($Curl, $CURLOPT_HTTPPOST, $HttpPost)         Local $Code = Curl_Easy_Perform($Curl)         If $Code = $CURLE_OK Then         ConsoleWrite("Content Type: " & Curl_Easy_GetInfo($Curl, $CURLINFO_CONTENT_TYPE) & @LF)         ConsoleWrite("Download Size: " & Curl_Easy_GetInfo($Curl, $CURLINFO_SIZE_DOWNLOAD) & @LF)         MsgBox(0, 'Html', BinaryToString(Curl_Data_Get($Html))) ; this is something I threw in for debugging, expecting to see SOMETHING. Returns nothing         MsgBox(0, 'Header', BinaryToString(Curl_Data_Get($Header))) ; this is something I threw in for debugging, expecting to see SOMETHING. Returns nothing         Local $response = Curl_Easy_GetInfo($Curl, $CURLINFO_RESPONSE_CODE)             If $response = "409" Then $response = "Failed due to a conflict."             If $response = "200" Then $response = "Was NOT created."             If $response = "201" Then $response = "Was created."             ; read the ID that was assigned and store it         $NewIDNumber = StringRight(StringLeft(BinaryToString(Curl_Data_Get($Html)), 10), 4) ; this DID work, but now it doesn't. An old compiled version still works ;~         Global $JsonObject = json_decode($Html); another debugging attempt. Did not use json functions previously and the program worked without it. ;~         Global $NewIDNumber = json_get($JsonObject, '.id')         ConsoleWrite(@CRLF &'! id:' & $NewIDNumber & @CRLF & @CRLF)    ; debugging feedback         MsgBox(0, $response, $wm_serial_number & " new ID = " & $NewIDNumber); debugging feedback         If $Code <> $CURLE_OK Then ConsoleWrite(Curl_Easy_StrError($Code) & @LF)             Local $Data = BinaryToString(Curl_Data_Get($Curl))             Curl_Easy_Cleanup($Curl)             Curl_Data_Cleanup($Curl)             Curl_Data_Cleanup($Header)             Curl_Data_Cleanup($Html)             Curl_FormFree($HttpPost)             Curl_slist_free_all($Slist)             curl_easy_reset($Curl)             FileClose($File)             ConsoleWrite(@LF)         EndIf  This is the captured request (minus the host and token) POST /api/v2/wireless_modules HTTP/1.1 Host: api. Accept: */* authorization: Token token= Content-Length: 942 Expect: 100-continue content-type: multipart/form-data; boundary=---011000010111000001101001; boundary=------------------------9adb0d87c7ea5061 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[serial_number]" WM20745001 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[component_status_id]" 10 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[manufacturer]" Multi-Tech --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[model]" MTR-LAT1-B07 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[cellular_carrier_id]" 3 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[iccid_esn]" 89010303300012345678 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[ip_address]" 192.168.2.11 --------------------------9adb0d87c7ea5061-- and the captured response HTTP/1.1 201 Created Date: Sun, 04 Apr 2021 00:12:18 GMT Server: Apache Cache-Control: max-age=0, private, must-revalidate Access-Control-Allow-Origin: not-allowed Vary: Accept-Encoding Access-Control-Max-Age: 1728000 X-XSS-Protection: 1; mode=block X-Request-Id: 71cfcf36-6020-48a6-a822-d2b393a27b69 Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: PUT, OPTIONS, GET, POST ETag: W/"25d97fe8a9387cb4b9029a9e62b0bfa2" X-Frame-Options: SAMEORIGIN, SAMEORIGIN X-Runtime: 0.344005 X-Content-Type-Options: nosniff Access-Control-Request-Method: * X-Powered-By: Phusion Passenger 5.2.1 Strict-Transport-Security: max-age=63072000; includeSubDomains; preload Location: /wireless_modules/3195 Status: 201 Created Connection: close Transfer-Encoding: chunked Content-Type: application/json; charset=utf-8 X-Charles-Received-Continue: HTTP/1.1 100 Continue {"id":3195,"model":"MTR-LAT1-B07","serial_number":"WM20745001","manufacturer":"Multi-Tech","mfg_date":null,"iccid_esn":"89010303300012345678","ip_address":"192.168.2.11","purchase_order":null,"supplier":null,"cellular_carrier_id":3,"component_status_id":10,"component_status":{"id":10,"name":"Hold","description":"Available- Held for specific use"},"custom_attributes":[{"name":"Deactivated","type":"Boolean","value":false},{"name":"Port 3001","type":"Boolean","value":false}],"comments":[]} Also attached is the log file. I need to read the id value. Clearly, it is arriving back to cURL, since it is being written out to the log, but I cannot seem to get to it within the code. It is established that I may be an idiot, but this idiot has wasted days in non-billable hours trying to figure out what should be a simple glitch. Help??? cURL_Request.html
  4. Ciao, This example reproduces the problem I encounter when sending a post request to an echo server. Instead of being sent as text utf8, the data is transmitted base64 encoded. Example: - json String: '{"firstName":"Jonathan","lastName":"Freeman","loginCount":4,"active": "yes","text":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel volutpat nunc. Maecenas id tempus mi. Morbi ipsum enim, ultricies ac augue sit amet, ullamcorper finibus ex. Vestibulum vel posuere nibh, nec faucibus eros. Nam malesuada non lacus a suscipit. Nulla rhoncus tempus mi quis placerat. Curabitur commodo tincidunt justo quis sollicitudin."}' - server response: "data:application/octet-stream;base64,AAAAALgE6QNYAIAAAgAAANQCAAAAAAAAWF8AAAAAAAD0VQAAAAAAAD9APQAAAAAAAwAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAABBAAAAAAABRUAAAAmIZwcAbRt8/LMa9UAAAAAAAAAAGFzIGlkIHRlbXB1cyBtaS4gTW9yYmkgaXBzdW0gZW5pbSwgdWx0cmljaWVzIGFjIGF1Z3VlIHNpdCBhbWV0LCB1bGxhbWNvcnBlciBmaW5pYnVzIGV4LiBWZXN0aWJ1bHVtIHZlbCBwb3N1ZXJlIG5pYmgsIG5lYyBmYXVjaWJ1cyBlcm9zLiBOYW0gbWFsZXN1YWRhIG5vbiBsYWN1cyBhIHN1c2NpcGl0LiBOdWxsYSByaG9uY3VzIHRlbXB1cyBtaSBxdWlzIHBsYWNlcmF0LiBDdXJhYml0dXIgY29tbW9kbyB0aW5jaWR1bnQganVzdG8gcXVpcyBzb2xsaWNpdHVkaW4uIn0=" How can I go about transmitting data in text format utf8? Thanks in advance for the help. In the zip file: - CurlJsonPost.au3: this script - Curl.au3: UDF by Ward (thank you!) - data.json: json srting for command line test Note: using Curl.exe with json string saved in a file (utf8 encoded) named data.json, works perfectly To try with the command line tool: - save data.json in curl\bin directory - open cmd.exe and cd to curl\bin directory - Enter the following command: curl -H "Content-Type: application/json" --data @data.json https://httpbin.org/post #Include "Curl.au3" Global $_cURL_OutputBuffer Local $sJson = '{"firstName":"Jonathan","lastName":"Freeman","loginCount":4,"active": "yes","text":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel volutpat nunc. Maecenas id tempus mi. Morbi ipsum enim, ultricies ac augue sit amet, ullamcorper finibus ex. Vestibulum vel posuere nibh, nec faucibus eros. Nam malesuada non lacus a suscipit. Nulla rhoncus tempus mi quis placerat. Curabitur commodo tincidunt justo quis sollicitudin."}' Local $iRetCode, $sServerResponse ConsoleWrite("=== Json post test ===" & @LF) ConsoleWrite(StringFormat("Retcode: %s - %s", $iRetCode, Curl_Easy_strerror($iRetCode)) & @LF) ConsoleWrite("Data returned from server" & @LF & @LF) $sServerResponse = JsonPost_Test($sJson, $iRetCode) ConsoleWrite($sServerResponse & @LF) Func JsonPost_Test($sJson, ByRef $iRetCode) ; Init Easy Curl Interface e set url (echo service) Local $oCurl = Curl_Easy_Init() curl_easy_setopt($oCurl, $CURLOPT_URL, "https://httpbin.org/post") ; Set content type header Local $headers = curl_slist_append(0, "Content-Type: application/json") curl_easy_setopt($oCurl, $CURLOPT_HTTPHEADER, $headers) ; Post fields & size curl_easy_setopt($oCurl, $CURLOPT_POSTFIELDS, $sJson) curl_easy_setopt($oCurl, $CURLOPT_POSTFIELDSIZE, StringLen($sJson)) ; Set callbac function to get server response back (see global var $_cURL_OutputBuffer) $hWriteFunc = DllCallbackRegister("WriteFunc_CallBack", "uint:cdecl", "ptr;uint;uint;ptr") curl_easy_setopt($oCurl, $CURLOPT_WRITEFUNCTION, DllCallbackGetPtr($hWriteFunc)) ; Ignore ssl certificates check curl_easy_setopt($oCurl, $CURLOPT_SSL_VERIFYPEER, 0) curl_easy_setopt($oCurl, $CURLOPT_SSL_VERIFYHOST, 0) ; Execute the post request $iRetCode = curl_easy_perform($oCurl) ; Set return trasfer & clear output buffer global var Local $sReturnTransfer = $_cURL_OutputBuffer $_cURL_OutputBuffer = "" Return SetError(0, 0, $sReturnTransfer) EndFunc Func WriteFunc_CallBack($ptr,$nSize,$nMemb,$pStream) Local $vData = DllStructCreate ("byte[" & $nSize*$nMemb & "]",$ptr) $_cURL_OutputBuffer &= BinaryToString(DllStructGetData($vData,1)) Return $nSize*$nMemb EndFunc curlJsonPost.zip
  5. Hello friends, i have a working curl command that show informations about my account on binance.com, but_it dont work with autoit code without curl.exe. I want to do it without curl, because the whole process much Slower_ with StdoutRead (I want get the response in variable.) My Curl command in Autoit: This 2 are works, but_ i would like to do it without curl.exe $apikey="XYZ" sCommand = @ScriptDir & '\curl.exe -k -H "X-MBX-APIKEY: ' & $apikey & '" -X GET "https://api.binance.com/api/v3/account?' & $request the same in .bat file curl.exe -k -H "X-MBX-APIKEY: XYZ" -X GET "https://api.binance.com/api/v3/account?timestamp=1514917812000&signature=85bdee77e53cd521e1d5229fbfb459d53799c42b3fa4596d73f1520fad5f965a" (I use curl with -k option which allows curl to make insecure connections, because there is problem with the sites certificate, (cURL error 60)) I tried many variations, this is the latest... I cant get the same response. curl $error message (I changed ): {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} autoit version $error message (Response code:400): Mandatory parameter 'timestamp' was not sent, was empty/null, or malformed. $request = $query & '&signature=' & $signature $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "https://api.binance.com/api/v3/account", False) $oHTTP.SetRequestHeader("X-MBX-APIKEY", $apikey) $oHTTP.Send($request) $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status If $oStatusCode <> 200 then MsgBox(4096, "Response code", $oStatusCode) EndIf thanks
  6. Some time ago I needed a way to uploade images to imgur, from one of my programs, and took a look at there API. Don't know if anyone can/would use it, but here is my code #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #INDEX# ======================================================================================================================= ; Title .........: IMGUR Curl udf ; AutoIt Version : 1.0 ; Description ...: Uploads files to imgur using curl, and returns imgur url, deletion key, imgsize ect. in an array ; Author(s) .....: Rex ; =============================================================================================================================== #include-once #include <curl.au3> ; By Ward #include <JSON.au3> ; by Ward ; #FUNCTION# ==================================================================================================================== ; Name...........: _Imgur ; Description ...: Allows the user to uploade images to Imgur, or delete an already uploaded image using the images DeleteHash ; Syntax.........: _Imgur($AuthKey, True/False, $vData) ; Parameters ....: $AuthKey - API key from Imgur ; $bImg_Up - If true an image uploade is expected, if False a DeleteHas is expected ; $vData - The image to uploade, or the DeleteHash that was returned from Imgur at Image uploade ; Return values .: Success - An Array containing: ID, Datetime, type, animated, width, height, size, deletehash and url ; Failur - Sets @Error to 1 if no AuthKey is provided ; Failur - Sets @Error to 2 if $bImg_Up = True but no Image data is provided ; Failur - Sets @Error to 3 if $bImg_Up = True but $vData isn't Binary ; Failur - Sets @Error to 4 if $bImg_Up = False but no DeleteHash is provided ; Failur - Sets @Error to 5 if the API returns 400 -> Bad Request ; Failur - Sets @Error to 6 if the API returns 403 -> Permission Denied ; Failur - Sets @Error to 7 if the API returns 413 -> Data to large ; Failur - Sets @Error to 8 if the API returns 415 -> Unsupported data ; Failur - Sets @Error to 9 if Curl returns no Curl ; Failur - Sets @Error to 10 and returns Curl error msg if Curl fails ; Failur - Sets @Error to 11 If StringRegExp failed on the header (no array) ; Author ........: Rex ; Modified.......: ; Remarks .......: Needs Curl, Json And BinaryCall by Ward - Base64Encode By Ward and _EPOCH_Decrypt by Trancexx ; Is includede in the UDF is self ; Related .......: ; Link ..........: ; Example .......: $dFile = FileOpenDialog('Open', @ScriptDir, 'Image Files (*.jpg;*.jpeg;*.png;*.bmp;*.gif)', 1) ; Browse image ; $hData = FileOpen($dFile, 16) ; Open as binary ; $dData = FileRead($hData) ; Read the data ; FileClose($hData) ; Close the FileHandle ; $aData = _Imgur('APIKEY', True, $dData) ; Uploade the Image ; ; $aDelete = _Imgur('APIKEY', False, 'DELETEHASH') ; ; =============================================================================================================================== Func _Imgur($sAuthKey, $bImg_Up = True, $vData = '') ; Performe some error checking Select Case $sAuthKey = '' ; If no authkey is provided Return SetError(1, 0, -1) ; We set error to 1 Case $vData = '' And $bImg_Up = True ; If no image data is sendt Return SetError(2, 0, -1) ; We sent error to 2 Case $vData <> '' And $bImg_Up = True And IsBinary($vData) = 0 ; If $vData isn't binary Return SetError(3, 0, -1) ; We sent error to 3 Case $vData = '' And $bImg_Up = False ; If no deleta hash was send Return SetError(4, 0, -1) ; We sent error to 4 EndSelect Local $aResult[9] ; Return array Local $ProgressCallback = DllCallbackGetPtr(DllCallbackRegister("ShowProgress", "int:cdecl", "ptr;uint64;uint64;uint64;uint64")) Local $Curl = Curl_Easy_Init() If Not $Curl Then Return SetError(9, 0, -1) Local $sHtml = $Curl Local $sHeader = $Curl + 1 ; any number as identify Local $sList = Curl_Slist_Append(0, "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:34.0) Gecko/20100101 Firefox/34.0") $sList = Curl_Slist_Append($sList, 'Referer: http://imgur.com/') $sList = Curl_Slist_Append($sList, 'Type: Base64') $sList = Curl_Slist_Append($sList, "Authorization: client-ID " & $sAuthKey) Curl_Easy_Setopt($Curl, $CURLOPT_HTTPHEADER, $sList) ; If $bImg_Up is true we uploads the image If $bImg_Up = True Then $dImage = _Base64Encode($vData) ; Convert the image to Base64 Curl_Easy_Setopt($Curl, $CURLOPT_URL, "https://api.imgur.com/3/upload/") ; If we wants to uploade an image Curl_Easy_Setopt($Curl, $CURLOPT_POST, 1) Curl_Easy_Setopt($Curl, $CURLOPT_COPYPOSTFIELDS, $dImage) Else ; If no img we expect a delete Curl_Easy_Setopt($Curl, $CURLOPT_URL, "https://api.imgur.com/3/image/" & $vData) ; If we wants to delete an image Curl_Easy_Setopt($Curl, $CURLOPT_CUSTOMREQUEST, 'DELETE') ; When we deletes an image EndIf ; Get header Curl_Easy_Setopt($Curl, $CURLOPT_HEADERFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERDATA, $sHeader) Curl_Easy_Setopt($Curl, $CURLOPT_FOLLOWLOCATION, 1) ; Checks use this to see the respons from server, and get img url/delete hash ect. Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $sHtml) Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, 30) Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0) Curl_Easy_Setopt($Curl, $CURLOPT_NOPROGRESS, 0) Curl_Easy_Setopt($Curl, $CURLOPT_XFERINFOFUNCTION, $ProgressCallback) Local $Code = Curl_Easy_Perform($Curl) If $Code <> $CURLE_OK Then Return SetError(10, 0, Curl_Easy_StrError($Code)) EndIf ;ConsoleWrite(@CRLF & 'HEADER: ' & BinaryToString(Curl_Data_Get($sHeader)) & @CRLF) ;ConsoleWrite(@CRLF & 'HTML RAW: ' & BinaryToString(Curl_Data_Get($sHtml)) & @CRLF) ; Check what the header returns $aHeader = StringRegExp(BinaryToString(Curl_Data_Get($sHeader)), 'HTTP/1.1 (400|403|413|415|200)', 1) If IsArray($aHeader) Then Select Case $aHeader[0] = 400 ; If 403 then Permission Denied Return SetError(5, 0, -1) Case $aHeader[0] = 403 ; If 403 then Permission Denied Return SetError(6, 0, -1) Case $aHeader[0] = 413 ; If 413 then the data is to large Return SetError(7, 0, -1) Case $aHeader[0] = 415 ; If 415 then the data is unsupported Return SetError(8, 0, -1) Case $aHeader[0] = 200 ; If 200 uploade/delete was a sucess ; Decode the json returned from imgur Local $sJson = Json_Decode(BinaryToString(Curl_Data_Get($sHtml))) ; If deleting an image we only needs to return Sucess - IMGUR returns Sucess If $bImg_Up = False Then ReDim $aResult[1] ; Slim down the array $aResult[0] = 'Success' Return $aResult EndIf ; If an image was uploaded then we need to return some data to the user $aResult[0] = Json_Get($sJson, '["data"]["id"]') ; Imgur image id ; Date time the image was uploaded, it's returned in unix timestamp, so we converts it to regular time stamp $aResult[1] = _EPOCH_Decrypt(Json_Get($sJson, '["data"]["datetime"]')) ; Type of uploaded image $aResult[2] = Json_Get($sJson, '["data"]["type"]') ; Was the image animated $aResult[3] = Json_Get($sJson, '["data"]["animated"]') ; Width of the image $aResult[4] = Json_Get($sJson, '["data"]["width"]') ; Height of the image $aResult[5] = Json_Get($sJson, '["data"]["height"]') ; Size of the image $aResult[6] = Json_Get($sJson, '["data"]["size"]') ; Delete hash of the image $aResult[7] = Json_Get($sJson, '["data"]["deletehash"]') ; Image link $aResult[8] = Json_Get($sJson, '["data"]["link"]') Curl_Easy_Cleanup($Curl) Curl_Data_Cleanup($Curl) Curl_Slist_Free_All($sList) Return $aResult EndSelect Else ; If the Regexp failed Return SetError(11, 1, -1) EndIf EndFunc ;==>_Imgur Func ShowProgress($Ptr, $dltotal, $dlnow, $ultotal, $ulnow) ProgressSet(Int($ulnow / $ultotal * 100), '% Sendt = ' & Int($ulnow / $ultotal * 100)) Return 0 EndFunc ;==>ShowProgress ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: _EPOCH_Decrypt ; Description ...: Converts Epoch Time to human time ; Syntax ........: _EPOCH_Decrypt(TIMESTAMP) ; Return values .: Convertede timestamp ; Author ........: Trancexx ; Modified ......: ; Remarks .......: ; =============================================================================================================================== Func _EPOCH_Decrypt($iEpochTime) ; By trancexx forum thread: https://www.autoitscript.com/forum/topic/83667-epoch-time/ Local $iDayToAdd = Int($iEpochTime / 86400) Local $iTimeVal = Mod($iEpochTime, 86400) If $iTimeVal < 0 Then $iDayToAdd -= 1 $iTimeVal += 86400 EndIf Local $i_wFactor = Int((573371.75 + $iDayToAdd) / 36524.25) Local $i_xFactor = Int($i_wFactor / 4) Local $i_bFactor = 2442113 + $iDayToAdd + $i_wFactor - $i_xFactor Local $i_cFactor = Int(($i_bFactor - 122.1) / 365.25) Local $i_dFactor = Int(365.25 * $i_cFactor) Local $i_eFactor = Int(($i_bFactor - $i_dFactor) / 30.6001) Local $aDatePart[3] $aDatePart[2] = $i_bFactor - $i_dFactor - Int(30.6001 * $i_eFactor) $aDatePart[1] = $i_eFactor - 1 - 12 * ($i_eFactor - 2 > 11) $aDatePart[0] = $i_cFactor - 4716 + ($aDatePart[1] < 3) Local $aTimePart[3] $aTimePart[0] = Int($iTimeVal / 3600) $iTimeVal = Mod($iTimeVal, 3600) $aTimePart[1] = Int($iTimeVal / 60) $aTimePart[2] = Mod($iTimeVal, 60) Return StringFormat("%.2d/%.2d/%.2d %.2d:%.2d:%.2d", $aDatePart[0], $aDatePart[1], $aDatePart[2], $aTimePart[0], $aTimePart[1], $aTimePart[2]) EndFunc ;==>_EPOCH_Decrypt ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: _Base64Encode ; Description ...: Encodes data into Base64 ; Syntax ........: _Base64Encode(Data, Linebreak) ; Return values .: Base64 Encodede string ; Author ........: Ward ; Modified ......: ; Remarks .......: ; =============================================================================================================================== Func _Base64Encode($Data, $LineBreak = 76) ; By Ward Local $Opcode = '0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737' $Opcode &= '475767778797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB633C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1' $Opcode &= 'E8040FB63383E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E8060FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F' $Opcode &= '90276100FB6730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC04750C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E' $Opcode &= '5BC9C21000' Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) $Data = Binary($Data) Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") DllStructSetData($Input, 1, $Data) $LineBreak = Floor($LineBreak / 4) * 4 Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3) $OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4 Local $Ouput = DllStructCreate("char[" & $OputputSize & "]") DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($Input), _ "int", BinaryLen($Data), _ "ptr", DllStructGetPtr($Ouput), _ "uint", $LineBreak) Return DllStructGetData($Ouput, 1) EndFunc ;==>_Base64Encode I have added Wards curl, json and BinaryCall to the att. zip file. Cheers /Rex Includes.zip
  7. Hi everyone its been loooong since I posted here I have been trying to convert this curl executable parameters into autoit using the winhttp com object; curl -F data_file=@my_audio_file.mp3 -F model=en-US "https://api.speechmatics.com/v1.0/user/41049/jobs/?auth_token=MmQ5MTk4jdsgjhgghstOGU5YS00OWFhLWghdgjshgdhbshj017###" any ideas guys PS: I am excited to post here after a looong time
  8. Hi All i am currently trying to add a function to my project that can send SMS, i have gone with Twilio for the sms service that use a REST API. I have never worked with an API before, and could use some help. I can get my function working with using cURL.exe and copy past command from the website with the following code. And thats great unfortunately i am have issue with character like æøå when sending a SMS appears like a box or ?. this does not happen if i do it from the website so it looks like a Unicode issue in curl.exe. I have done some searching on the forum and understand that i should be able to implement this curl command with the WinHTTP UDF from @trancexx so i don't need a third part exe and it might fix my charater issue. Unfortunately i really don't understand how i am to change curl commands to the WinHTTP and i was hoping some good maybe give me an example i could learn from. Thanks in advanced i have removed the AuthToken number from the script. _SendSMS("00000000","SomeOne","SMS body info") Func _SendSMS($SendTo,$SendFrom,$Msgtxt) $AccountSID = "ACbb765b3180d5938229eff8b8f63ed1bc" $AuthToken = "Auth Token number" $Data = '"https://api.twilio.com/2010-04-01/Accounts/'&$AccountSID&'/Messages.json"'& _ '-X POST \ --data-urlencode "To=+45'&$SendTo&'" \ --data-urlencode "From='&$SendFrom&'" \ --data-urlencode "Body='&$Msgtxt&'" \ -u '&$AccountSID&':'&$AuthToken&'' ShellExecute(@ScriptDir&"\curl.exe","-k "&$Data) ;~ curl 'https://api.twilio.com/2010-04-01/Accounts/ACbb765b3180d5938229eff8b8f63ed1bc/Messages.json' -X POST \ ;~ --data-urlencode 'To=+4500000000' \ ;~ --data-urlencode 'From=Reception' \ ;~ --data-urlencode 'Body=Test Body' \ ;~ -u ACbb765b3180d5938229eff8b8f63ed1bc:[AuthToken] EndFunc
  9. What's the best way to receive file from a desktop app? app.exe will execute a cmd with "au3file.exe /path/of/the/file.xml" and the au3file.exe will get and delete that. Or else? THE MOST IMPORTANT PART OF THE QUESTION And best way to transfer file to a desktop app? au3file.exe do a $_POST request and the app.exe MUST HAVE a local HTTP server that can receive $_POST, but it looks heavy 'cause the app must have a server such XAMPP. au3file.exe execute a cmd with "app.exe /path/of/the/file.xml" and the app.exe will now get that file and delete. Or else?
  10. Like Request for node.js or Requests for python, Request UDF is a powerful and easy-to-use HTTP client for AutoIt. It is based on my Curl.au3 and Json.au3 (not included). The Features: Request target can be a string (single url), an array (urls), an object (single url + options or url array + options), an object array (urls + different options), or a json string (decode to array or object automatically), etc.Easy to setup post data, cookies, agent, refer, timeout, proxy, etc.Easy to setup the default options before a series of requests.Use BinaryToString() to decode the returned data according to content type automatically. Use curl multi interface by default. It means all requests will transfer simultaneously and won't block the GUI event.Use callback function to recieve the data and information for every url before main function finished.Supports https and ftp protocols.Example: #Include "Json.au3" #Include "Curl.au3" #Include "Request.au3" RequestDefault('{refer: "http://www.autoitscript.com", agent: "AutoIt/Request", callback: "MyCallback"}') Local $Data = Request("http://httpbin.org/get") ConsoleWrite($Data & @LF) Request('["http://www.google.com", "http://wikipedia.org"]') Request('{url: "http://www.google.com", agent: "AutoIt/Request"}') Request('{url: ["http://www.google.com", "http://wikipedia.org"], agent: "AutoIt/Request"}') Local $Array[] = ["http://www.google.com", "http://wikipedia.org"] Request($Array) Request("http://httpbin.org/post", "key=Post%20can%20be%20the%20raw%20data") Request("http://httpbin.org/post", '{key: "Post can be a json object string"}') Request('{url: "http://httpbin.org/post", post:{key: "Post can be set as second paramemtr or \"post\" option"}}') Local $Obj Json_Put($Obj, ".key", "Post can be an object") Local $Json = Request("http://httpbin.org/post", $Obj) Func MyCallback($Obj) Local $Data = Json_ObjGet($Obj, "Data") Local $EffectiveUrl = Json_ObjGet($Obj, "EffectiveUrl") ConsoleWrite("Callback: " & $EffectiveUrl & " download size: " & StringLen($Data) & @LF) EndFunc More examples are in the archive. Request.zip
  11. Hi all: I have a small problem with Curl syntax to send a POST to a CouchDB database. I want send this: -H Content-type: application/json -X POST http://127.0.0.1:5984/test -d {"title": "pencil"} but this code does not work: $code ='curl.exe -H Content-type: application/json -X POST http://127.0.0.1:5984/test -d {"title": "pencil"}' Run(@ComSpec & " /k " & $code,"",@SW_HIDE) but to work I have to format the line like this: $code = 'curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:5984/test" -d "{\"title\":\"pencil\"}"' Run(@ComSpec & " /k " & $code,"",@SW_HIDE) my question is whether this is the most correct way to write the correct code using the additional signs " and \ or is there some other more elegant way to do the same. Thank's
  12. AutoIt Radio Player Last : v0.0.0.8 Tested only on W7X64 Changelog : ==========> AutoIt Radio Player v0.0.0.8.zip <========== Personal Message : This is my first script posted. Any comment are welcome. Give me your best web radio i will try add them ! Install/Use : Add a station : Unsolved problem : When the coverGUI go outside the monitor and comeback inside, a part of current cover disapear : I have no idea how fix that TODO : Make coverGUI mouse resizable (while script running) : any idea are welcome Crop some pixel of cover : any idea are welcome Related Posts/Bin : ArrayMultiColSort MouseWheelDelta Sample1 MouseWheelDelta Sample2 ContextMenu Fix ReduceMemory MemGlobalAllocFromBinary Curl.au3 (AutoIt binary code) Main Code : ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7;All Warning ;-w 5 = local var declared but not used : Removed for Curl.au3 ;-d = as Opt("MustDeclareVars", 1) : Removed for Bass.au3 #AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w- 4 -w 6 -w- 7 #Region ;==> #include #include <Array.au3>;_ArrayAdd #include <GuiButton.au3>;_GUICtrlButton_SetImage() #include <GuiMenu.au3>;$MNS_MODELESS #include <GUIConstants.au3>;$WS_POPUP #include <GDIplus.au3>;_GDIPlus_BitmapCreateFromStream() #include <Memory.au3>;$GMEM_MOVEABLE #include <String.au3>;_StringBetween() #include <AutoIt Radio Player\include\Bass.au3>;_BASS_ChannelPlay() #include <AutoIt Radio Player\include\BassConstants.au3>;$BASS_CONFIG_NET_PLAYLIST #include <AutoIt Radio Player\include\Curl.au3>;Curl_Data_Get() #EndRegion ;==> #include #Region ;==> Func for Bass.au3 Local $MusicHandle Func _Audio_play($MusicHandle) _BASS_ChannelPlay($MusicHandle, 1) EndFunc Func _Audio_stop($MusicHandle) _BASS_ChannelStop($MusicHandle) EndFunc Func _Audio_init_stop($MusicHandle) _BASS_StreamFree($MusicHandle) _BASS_Free() EndFunc Func _Audio_init_start() If _BASS_STARTUP(@ScriptDir & "\AutoIt Radio Player\include\bass.dll") Then If _BASS_Init(0, -1, 44100, 0) Then If _BASS_SetConfig($BASS_CONFIG_NET_PLAYLIST, 1) = 0 Then SetError(3) EndIf Else SetError(2) EndIf Else SetError(@error) EndIf EndFunc Func _Set_volume($volume) _BASS_SetConfig($BASS_CONFIG_GVOL_STREAM, $volume * 100) EndFunc Func _Set_url($file) If FileExists($file) Then $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0) Else $MusicHandle = _BASS_StreamCreateURL($file, 0, 1) EndIf If @error Then Return SetError(1) EndIf Return $MusicHandle EndFunc #EndRegion ;==> Func for Bass.au3 Global Const $SC_DRAGMOVE = 0xF012;Global #Region ;==> Func from AutoIt Forum ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayMultiColSort ; Description ...: Sort 2D arrays on several columns ; Syntax.........: _ArrayMultiColSort(ByRef $aArray, $aSortData[, $iStart = 0[, $iEnd = 0]]) ; Parameters ....: $aArray - The 2D array to be sorted ; $aSortData - 2D array holding details of the sort format ; Format: [Column to be sorted, Sort order] ; Sort order can be either numeric (0/1 = ascending/descending) or a ordered string of items ; Any elements not matched in string are left unsorted after all sorted elements ; $iStart - Element of array at which sort starts (default = 0) ; $iEnd - Element of array at which sort endd (default = 0 - converted to end of array) ; Requirement(s).: v3.3.8.1 or higher ; Return values .: Success: No error ; Failure: @error set as follows ; @error = 1 with @extended set as follows (all refer to $sIn_Date): ; 1 = Array to be sorted not 2D ; 2 = Sort data array not 2D ; 3 = More data rows in $aSortData than columns in $aArray ; 4 = Start beyond end of array ; 5 = Start beyond End ; @error = 2 with @extended set as follows: ; 1 = Invalid string parameter in $aSortData ; 2 = Invalid sort direction parameter in $aSortData ; Author ........: Melba23 ; Remarks .......: Columns can be sorted in any order ; Example .......; Yes ; =============================================================================================================================== Func _ArrayMultiColSort(ByRef $aArray, $aSortData, $iStart = 0, $iEnd = 0) ; Errorchecking ; 2D array to be sorted If UBound($aArray, 2) = 0 Then Return SetError(1, 1, "") EndIf ; 2D sort data If UBound($aSortData, 2) <> 2 Then Return SetError(1, 2, "") EndIf If UBound($aSortData) > UBound($aArray) Then Return SetError(1, 3) EndIf ; Start element If $iStart < 0 Then $iStart = 0 EndIf If $iStart >= UBound($aArray) - 1 Then Return SetError(1, 4, "") EndIf ; End element If $iEnd <= 0 Or $iEnd >= UBound($aArray) - 1 Then $iEnd = UBound($aArray) - 1 EndIf ; Sanity check If $iEnd <= $iStart Then Return SetError(1, 5, "") EndIf Local $iCurrCol, $iChunk_Start, $iMatchCol ; Sort first column __AMCS_SortChunk($aArray, $aSortData, 0, $aSortData[0][0], $iStart, $iEnd) If @error Then Return SetError(2, @extended, "") EndIf ; Now sort within other columns For $iSortData_Row = 1 To UBound($aSortData) - 1 ; Determine column to sort $iCurrCol = $aSortData[$iSortData_Row][0] ; Create arrays to hold data from previous columns Local $aBaseValue[$iSortData_Row] ; Set base values For $i = 0 To $iSortData_Row - 1 $aBaseValue[$i] = $aArray[$iStart][$aSortData[$i][0]] Next ; Set start of this chunk $iChunk_Start = $iStart ; Now work down through array For $iRow = $iStart + 1 To $iEnd ; Match each column For $k = 0 To $iSortData_Row - 1 $iMatchCol = $aSortData[$k][0] ; See if value in each has changed If $aArray[$iRow][$iMatchCol] <> $aBaseValue[$k] Then ; If so and row has advanced If $iChunk_Start < $iRow - 1 Then ; Sort this chunk __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf ; Set new base value $aBaseValue[$k] = $aArray[$iRow][$iMatchCol] ; Set new chunk start $iChunk_Start = $iRow EndIf Next Next ; Sort final section If $iChunk_Start < $iRow - 1 Then __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf Next EndFunc ;==>_ArrayMultiColSort ; #FUNCTION# ==================================================================================================================== ; Name...........: __AMCS_SortChunk ; Description ...: Sorts array section ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func __AMCS_SortChunk(ByRef $aArray, $aSortData, $iRow, $iColumn, $iChunkStart, $iChunkEnd) Local $aSortOrder ; Set default sort direction Local $iSortDirn = 1 ; Need to prefix elements? If IsString($aSortData[$iRow][1]) Then ; Split elements $aSortOrder = StringSplit($aSortData[$iRow][1], ",") If @error Then Return SetError(1, 1, "") EndIf ; Add prefix to each element For $i = $iChunkStart To $iChunkEnd For $j = 1 To $aSortOrder[0] If $aArray[$i][$iColumn] = $aSortOrder[$j] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] ExitLoop EndIf Next ; Deal with anything that does not match If $j > $aSortOrder[0] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] EndIf Next Else Switch $aSortData[$iRow][1] Case 0, 1 ; Set required sort direction if no list If $aSortData[$iRow][1] Then $iSortDirn = -1 Else $iSortDirn = 1 EndIf Case Else Return SetError(1, 2, "") EndSwitch EndIf ; Sort the chunk Local $iSubMax = UBound($aArray, 2) - 1 __ArrayQuickSort2D($aArray, $iSortDirn, $iChunkStart, $iChunkEnd, $iColumn, $iSubMax) ; Remove any prefixes If IsString($aSortData[$iRow][1]) Then For $i = $iChunkStart To $iChunkEnd $aArray[$i][$iColumn] = StringTrimLeft($aArray[$i][$iColumn], 3) Next EndIf EndFunc ;==>__AMCS_SortChunk Func _ReduceMemory() Local $aReturn = DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1) If @error = 1 Then Return SetError(1, 0, 0) EndIf Return $aReturn[0] EndFunc ;==>_ReduceMemory ; #FUNCTION# ==================================================================================================================== ; Name...........: _GDIPlus_ImageLoadFromHGlobal ; Description ...: Creates an Image object based on movable HGlobal memory block ; Syntax.........: _GDIPlus_ImageLoadFromHGlobal($hGlobal) ; Parameters ....: $hGlobal - Handle of a movable HGlobal memory block ; Return values .: Success - Pointer to a new Image object ; Failure - 0 and either: ; |@error and @extended are set if DllCall failed: ; | -@error = 1 if could not create IStream ; | -@error = 2 if DLLCall to create image failed ; |$GDIP_STATUS contains a non zero value specifying the error code ; Author ........: ProgAndy ; Modified.......: ; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources. ; The HGLOBAL will be owned by the image and freed automatically when the image is disposed. ; Related .......: _GDIPlus_ImageLoadFromStream, _GDIPlus_ImageDispose ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _GDIPlus_ImageLoadFromHGlobal($hGlobal) Local $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $hGlobal, "bool", True, "ptr*", 0) If @error Or $aResult[0] <> 0 Or $aResult[3] = 0 Then Return SetError(1, @error, 0) Local $hImage = DllCall($__g_hGDIPDll, "uint", "GdipLoadImageFromStream", "ptr", $aResult[3], "int*", 0) Local $error = @error Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr") Local $aCall = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $aResult[3], "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) If $error Then Return SetError(2, $error, 0) If $hImage[2] = 0 Then Return SetError(3, 0, $hImage[2]) Return $hImage[2] EndFunc ;==>_GDIPlus_ImageLoadFromHGlobal ; #FUNCTION# ==================================================================================================================== ; Name...........: _MemGlobalAllocFromBinary ; Description ...: Greates a movable HGLOBAL memory block from binary data ; Syntax.........: _MemGlobalAllocFromBinary($bBinary) ; Parameters ....: $bBinary - Binary data ; Return values .: Success - Handle of a new movable HGLOBAL ; Failure - 0 and set @error: ; |1 - no data ; |2 - could not allocate memory ; |3 - could not set data to memory ; Author ........: ProgAndy ; Modified.......: ; Remarks .......: ; Related .......: _MemGlobalAlloc, _MemGlobalFree, _MemGlobalLock ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _MemGlobalAllocFromBinary(Const $bBinary) Local $iLen = BinaryLen($bBinary) If $iLen = 0 Then Return SetError(1, 0, 0) Local $hMem = _MemGlobalAlloc($iLen, $GMEM_MOVEABLE) If @error Or Not $hMem Then Return SetError(2, 0, 0) DllStructSetData(DllStructCreate("byte[" & $iLen & "]", _MemGlobalLock($hMem)), 1, $bBinary) If @error Then _MemGlobalUnlock($hMem) _MemGlobalFree($hMem) Return SetError(3, 0, 0) EndIf _MemGlobalUnlock($hMem) Return $hMem EndFunc ;==>_MemGlobalAllocFromBinary #EndRegion ;==> Func from AutoIt Forum ;INI Location Local $Config_INI = "AutoIt Radio Player\Config.ini" Local $Save_INI = "AutoIt Radio Player\Save.ini" ;Get $aRadio and $aLabel <===========================================That part need improve Local $aINISections = IniReadSectionNames($Config_INI) Local $aRadio[0][8] Local $aLabel[0][11] For $i = 1 To UBound($aINISections) - 1 If $aINISections[$i] <> "GUI" Then ;For $aRadio Local $SoundLink = "", $CoverLink = "", $CoverLinkStart = "", $CoverLinkEnd = "", $CoverLinkBetweenNum = "", $CoverLinkBefore = "", $Default = 0 ;For $aLabel Local $CurrentArtistLink = "", $CurrentArtistStart = "", $CurrentArtistEnd = "", $CurrentArtistBetweenNum = 0, $CurrentArtistSplit = "", $CurrentArtistNumSplit = "" Local $CurrentAlbumLink = "", $CurrentAlbumStart = "", $CurrentAlbumEnd = "", $CurrentAlbumBetweenNum = 0, $CurrentAlbumSplit = "", $CurrentAlbumNumSplit = "" Local $CurrentTitleLink = "", $CurrentTitleStart = "", $CurrentTitleEnd = "", $CurrentTitleBetweenNum = 0, $CurrentTitleSplit = "", $CurrentTitleNumSplit = "" Local $NextArtistLink = "", $NextArtistStart = "", $NextArtistEnd = "", $NextArtistBetweenNum = 0, $NextArtistSplit = "", $NextArtistNumSplit = "" Local $NextAlbumLink = "", $NextAlbumStart = "", $NextAlbumEnd = "", $NextAlbumBetweenNum = 0, $NextAlbumSplit = "", $NextAlbumNumSplit = "" Local $NextTitleLink = "", $NextTitleStart = "", $NextTitleEnd = "", $NextTitleBetweenNum = 0, $NextTitleSplit = "", $NextTitleNumSplit = "" Local $ListenersCountLink = "", $ListenersCountStart = "", $ListenersCountEnd = "", $ListenersCountBetweenNum = 0, $ListenersCountSplit = "", $ListenersCountNumSplit = "" Local $controlID1 = "", $controlID2 = "" Local $Sec = IniReadSection($Config_INI, $aINISections[$i]) For $y = 1 To UBound($Sec) - 1 Assign($Sec[$y][0], $Sec[$y][1]) Next ;$aRadio _ArrayAdd($aRadio, $aINISections[$i] & "|" & $SoundLink & "|" & $CoverLink & "|" & $CoverLinkStart & "|" & $CoverLinkEnd & "|" & $CoverLinkBetweenNum & "|" & $CoverLinkBefore & "|" & $Default) ;$aLabel _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Current" & "|" & "Artist" & "|" & $CurrentArtistLink & "|" & $CurrentArtistStart & "|" & $CurrentArtistEnd & "|" & $CurrentArtistBetweenNum & "|" & $CurrentArtistSplit & "|" & $CurrentArtistNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Current" & "|" & "Album" & "|" & $CurrentAlbumLink & "|" & $CurrentAlbumStart & "|" & $CurrentAlbumEnd & "|" & $CurrentAlbumBetweenNum & "|" & $CurrentAlbumSplit & "|" & $CurrentAlbumNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Current" & "|" & "Title" & "|" & $CurrentTitleLink & "|" & $CurrentTitleStart & "|" & $CurrentTitleEnd & "|" & $CurrentTitleBetweenNum & "|" & $CurrentTitleSplit & "|" & $CurrentTitleNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Next" & "|" & "Artist" & "|" & $NextArtistLink & "|" & $NextArtistStart & "|" & $NextArtistEnd & "|" & $NextArtistBetweenNum & "|" & $NextArtistSplit & "|" & $NextArtistNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Next" & "|" & "Album" & "|" & $NextAlbumLink & "|" & $NextAlbumStart & "|" & $NextAlbumEnd & "|" & $NextAlbumBetweenNum & "|" & $NextAlbumSplit & "|" & $NextAlbumNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Next" & "|" & "Title" & "|" & $NextTitleLink & "|" & $NextTitleStart & "|" & $NextTitleEnd & "|" & $NextTitleBetweenNum & "|" & $NextTitleSplit & "|" & $NextTitleNumSplit & "|" & $controlID1 & "|" & $controlID2) _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Listeners" & "|" & "Count" & "|" & $ListenersCountLink & "|" & $ListenersCountStart & "|" & $ListenersCountEnd & "|" & $ListenersCountBetweenNum & "|" & $ListenersCountSplit & "|" & $ListenersCountNumSplit & "|" & $controlID1 & "|" & $controlID2) EndIf Next Global $aRadio_Sort[][] = [[0, 0], [1, 0]] _ArrayMultiColSort($aRadio, $aRadio_Sort) Local $aLabel2[0][11] For $i = 0 To UBound($aLabel) - 1 If $aLabel[$i][3] <> "" Then Local $fill = $aLabel[$i][0] For $y = 1 To UBound($aLabel, 2) - 1 $fill = $fill & "|" & $aLabel[$i][$y] Next _ArrayAdd($aLabel2, $fill) EndIf Next $aLabel = $aLabel2 ;_ArrayDisplay($aRadio) ;_ArrayDisplay($aLabel) ;Init/Opt Opt("GUIOnEventMode", 1) _Audio_init_start() _GDIPlus_Startup() ;Icon Local $IcoFile = @ScriptDir & "\AutoIt Radio Player\img\icon.ico" Local $IcoNumber = -1 TraySetIcon($IcoFile, $IcoNumber) ;Get Default Station Local $def_selected = 0 For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][0] = IniRead($Save_INI, @ComputerName, "Default_Radio", "default") Then $def_selected = 1 $aRadio[$r][7] = 1 EndIf Next If $def_selected = 0 Then $aRadio[0][7] = 1 EndIf ;ConsoleWrite("Start" & @CRLF) ;Get $Radio_Name, $Radio_SoundLink, $Radio_CoverLink, $Radio_CoverLink_Start, $Radio_CoverLink_End, $Radio_CoverLink_BetweenNum, $Radio_CoverLink_Before Local $Radio_Name, $Radio_SoundLink, $Radio_CoverLink Local $Radio_CoverLink_Start, $Radio_CoverLink_End, $Radio_CoverLink_BetweenNum, $Radio_CoverLink_Before For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][7] = 1 Then $Radio_Name = $aRadio[$r][0] $Radio_SoundLink = $aRadio[$r][1] $Radio_CoverLink = $aRadio[$r][2] $Radio_CoverLink_Start = $aRadio[$r][3] $Radio_CoverLink_End = $aRadio[$r][4] $Radio_CoverLink_BetweenNum = $aRadio[$r][5] $Radio_CoverLink_Before = $aRadio[$r][6] EndIf Next ;Declare Local $PlayerGUI, $CoverGUI;GUI Local $PlayPause, $Close;Button Local $Play = 1;PlayStatus ($Play = 1 = Autoplay) Local $Volume_Label, $VolumePercent, $Previous_VolumePercent;Volume Local $Previous_Cover_Read;PreviousRead Local $BASS_ErrorGetCode ;$Config_INI\GUI Local $CoverSize = IniRead($Config_INI, "GUI", "CoverSize", 150) Local $PlayerBorder = IniRead($Config_INI, "GUI", "PlayerBorder", 10) ;ConsoleWrite("Build GUI" & @CRLF) ;Build GUI _Build_PlayerGUI() _Build_CoverGUI() ;ConsoleWrite("Show GUI" & @CRLF) GUISetState(@SW_SHOW, $PlayerGUI) If $Radio_CoverLink <> "" Then GUISetState(@SW_SHOW, $CoverGUI) EndIf _Set_volume(0) ;GetPlayerDATA() - GetCoverDATA() - Start Sound GetPlayerDATA();Start Sound too with resume on disconnect AdlibRegister("GetPlayerDATA", 8000) If $Radio_CoverLink <> "" Then GetCoverDATA() AdlibRegister("GetCoverDATA", 8000) EndIf ;ConsoleWrite("GUIRegisterMsg" & @CRLF) GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL");for set volume GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN");for drag gui #Region ;==> Internal Func Func _Build_CoverGUI() ;ConsoleWrite("Build CoverGUI" & @CRLF) If $Radio_CoverLink <> "" Then $CoverGUI = GUICreate("AutoIt Radio Cover", _;Title $CoverSize, _ ;X $CoverSize, _ ;Y IniRead($Save_INI, @ComputerName, "Cover_X", -1), _;Left IniRead($Save_INI, @ComputerName, "Cover_Y", -1), _;Top $WS_POPUP, $WS_EX_TOPMOST);Style GUISetBkColor(0x000000, $CoverGUI);Black BkColor GUISetIcon($IcoFile, $IcoNumber, $CoverGUI) Else $CoverGUI = "" EndIf EndFunc ;==>_Build_CoverGUI Func _Build_PlayerGUI() ;ConsoleWrite("Build PlayerGUI" & @CRLF) ;Clean previous stored ControlID For $r = 0 To UBound($aLabel) - 1 $aLabel[$r][9] = "" $aLabel[$r][10] = "" Next ;$LabelCount Local $LabelCount = 0 For $r = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$r][0] Then $LabelCount = $LabelCount + 1 EndIf Next ;$LabelY If $LabelCount * 13 + $PlayerBorder * 2 < 50 Then Local $LabelY = 10 * 3 Else $LabelY = $LabelCount * 13 EndIf ;$PlayerGUI $PlayerGUI = GUICreate("AutoIt Radio Player", _ $PlayerBorder + 260 + 50 + 10 + $PlayerBorder * 2, _;X $PlayerBorder + $LabelY + $PlayerBorder, _;Y IniRead($Save_INI, @ComputerName, "Title_X", -1), _;Left IniRead($Save_INI, @ComputerName, "Title_Y", -1), _;Top $WS_POPUP, $WS_EX_TOPMOST);Style GUISetBkColor(0x000000, $PlayerGUI);Black BkColor GUISetIcon($IcoFile, $IcoNumber, $PlayerGUI) ;$Contextmenu Local $ContextMenu = GUICtrlCreateContextMenu(-1) Local $hCM = GUICtrlGetHandle($ContextMenu) _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS)) Local $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu) GUICtrlSetOnEvent($ContextMenu_Item1, "ContextMenu_ChangeRadio") GUICtrlCreateMenuItem("", $ContextMenu);Add separator For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][7] = 0 Then GUICtrlCreateMenuItem($aRadio[$r][0], $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") EndIf Next ;GUICtrlCreateLabel $LabelCount = 0 Local $Previous_Type = "" For $r = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$r][0] Then If $Previous_Type <> $aLabel[$r][1] Then $Previous_Type = $aLabel[$r][1] $aLabel[$r][10] = GUICtrlCreateLabel($aLabel[$r][1], $PlayerBorder, 13 * $LabelCount + $PlayerBorder, 50, 13, $SS_CENTERIMAGE) GUICtrlSetColor($aLabel[$r][10], 0xFFFFFF);White TextColor GUICtrlSetOnEvent($aLabel[$r][10], "_WM_LBUTTONDOWN") $ContextMenu = GUICtrlCreateContextMenu($aLabel[$r][10]) $hCM = GUICtrlGetHandle($ContextMenu) _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS)) $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") GUICtrlCreateMenuItem("", $ContextMenu);Add separator For $r2 = 0 To UBound($aRadio) - 1 If $aRadio[$r2][7] = 0 Then GUICtrlCreateMenuItem($aRadio[$r2][0], $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") EndIf Next EndIf $aLabel[$r][9] = GUICtrlCreateLabel("", $PlayerBorder + 50, 13 * $LabelCount + $PlayerBorder, 260, 13, $SS_CENTERIMAGE) $LabelCount = $LabelCount + 1 GUICtrlSetColor($aLabel[$r][9], 0xFFFFFF);White TextColor GUICtrlSetOnEvent($aLabel[$r][9], "_WM_LBUTTONDOWN") $ContextMenu = GUICtrlCreateContextMenu($aLabel[$r][9]) $hCM = GUICtrlGetHandle($ContextMenu) _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS)) $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") GUICtrlCreateMenuItem("", $ContextMenu);Add separator For $r2 = 0 To UBound($aRadio) - 1 If $aRadio[$r2][7] = 0 Then GUICtrlCreateMenuItem($aRadio[$r2][0], $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") EndIf Next EndIf Next ;GUICtrlCreateLabel Volume $Volume_Label = GUICtrlCreateLabel("0", $PlayerBorder, $PlayerBorder, 260 + 50, $LabelY, "") GUICtrlSetColor($Volume_Label, 0xFFFFFF);White TextColor GUICtrlSetOnEvent($Volume_Label, "_WM_LBUTTONDOWN") GUICtrlSetState($Volume_Label, $GUI_HIDE) ;$Volume_Label Contextmenu $ContextMenu = GUICtrlCreateContextMenu($Volume_Label) $hCM = GUICtrlGetHandle($ContextMenu) _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS)) $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") GUICtrlCreateMenuItem("", $ContextMenu);Add separator For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][7] = 0 Then Local $Item = GUICtrlCreateMenuItem($aRadio[$r][0], $ContextMenu) GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio") EndIf Next ;$Close $Close = GUICtrlCreateButton("Close", _ $PlayerBorder * 2 + 260 + 50, _;Left $PlayerBorder, _;Top 10, _;X 10, _;Y $BS_BITMAP);Style _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Close.bmp") GUICtrlSetOnEvent($Close, "_Close") GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "_Close") ;$PlayPause $PlayPause = GUICtrlCreateButton("Play/Pause", _ $PlayerBorder * 2 + 260 + 50, _;Left $PlayerBorder + 10 + 10, _;Top 10, _;X 10, _;Y $BS_BITMAP);Style _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\Stop.bmp") GUICtrlSetOnEvent($PlayPause, "_PlayPause") EndFunc ;==>_Build_PlayerGUI Func _Close() _Audio_init_stop($MusicHandle) _GDIPlus_Shutdown() Exit EndFunc ;==>_Close Func _PlayPause() ;Change $Play If $Play = 1 Then $Play = 0 Else $Play = 1 EndIf Local $Msg = GUIGetCursorInfo($PlayerGUI) ;Change Button Image If $Play = 1 Then If $Msg[4] = $PlayPause Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopp.bmp");Mouse Pressed Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopo.bmp");Mouse Over EndIf Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stop.bmp");Nothing EndIf Else If $Msg[4] = $PlayPause Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playp.bmp");Mouse Pressed Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playo.bmp");Mouse Over EndIf Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\play.bmp");Nothing EndIf EndIf ;Play Sound If $Play = 0 Then _Audio_stop($MusicHandle) Else $MusicHandle = _Set_url($Radio_SoundLink) _Audio_play($MusicHandle) EndIf EndFunc ;==>_PlayPause Func _RemoveVolumeLabel() AdlibUnRegister("_RemoveVolumeLabel") ;Show Others Label For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$i][0] Then GUICtrlSetState($aLabel[$i][9], $GUI_SHOW) EndIf Next Local $Previous_Type = "" For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$i][0] Then If $Previous_Type <> $aLabel[$i][1] Then $Previous_Type = $aLabel[$i][1] GUICtrlSetState($aLabel[$i][10], $GUI_SHOW) EndIf GUICtrlSetState($aLabel[$i][9], $GUI_SHOW) EndIf Next ;Hide Volume Label GUICtrlSetState($Volume_Label, $GUI_HIDE) EndFunc ;==>_RemoveVolumeLabel Func _Save_Change_Volume() AdlibUnRegister("_Save_Change_Volume") _Set_volume($VolumePercent);Set IniWrite($Save_INI, @ComputerName, "Volume", $VolumePercent);Save EndFunc ;==>_Save_Change_Volume Func _WM_LBUTTONDOWN() ;Move GUI If WinActive("AutoIt Radio Cover") Then _SendMessage($CoverGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) Else _SendMessage($PlayerGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndIf ;Save GUI pos Local $Player_pos = WinGetPos("AutoIt Radio Player") Local $Cover_pos = WinGetPos("AutoIt Radio Cover") IniWrite($Save_INI, @ComputerName, "Title_X", $Player_pos[0]) IniWrite($Save_INI, @ComputerName, "Title_Y", $Player_pos[1]) If $Radio_CoverLink <> "" Then IniWrite($Save_INI, @ComputerName, "Cover_X", $Cover_pos[0]) IniWrite($Save_INI, @ComputerName, "Cover_Y", $Cover_pos[1]) EndIf EndFunc ;==>_WM_LBUTTONDOWN Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) AdlibUnRegister("_RemoveVolumeLabel") If GUICtrlGetState($Volume_Label) <> 80 Then ;Show $Volume_Label GUICtrlSetState($Volume_Label, $GUI_SHOW) ;Hide Others Label Local $Previous_Type = "" For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$r][0] Then If $Previous_Type <> $aLabel[$i][1] Then $Previous_Type = $aLabel[$i][1] GUICtrlSetState($aLabel[$i][10], $GUI_HIDE) EndIf GUICtrlSetState($aLabel[$i][9], $GUI_HIDE) EndIf Next EndIf ;Change $VolumePercent Local $WheelDelta = BitShift($wParam, 16) / 120 $VolumePercent = $VolumePercent + 4 * $WheelDelta If $WheelDelta > 0 Then If $VolumePercent > 100 Then $VolumePercent = 100 Else If $VolumePercent < 0 Then $VolumePercent = 0 EndIf If $Previous_VolumePercent <> $VolumePercent Then $Previous_VolumePercent = $VolumePercent GUICtrlSetData($Volume_Label, $VolumePercent) EndIf ;Change\Save Sound AdlibRegister("_Save_Change_Volume", 50) ;Hide $Volume_Label in 3s AdlibRegister("_RemoveVolumeLabel", 3000) Return $GUI_RUNDEFMSG EndFunc ;==>_WM_MOUSEWHEEL Func ContextMenu_ChangeRadio() $Previous_Cover_Read = "" Local $NewRadioName = GUICtrlRead(@GUI_CtrlId, 1) ;Maybe the next radio have no cover so delete it If $Radio_CoverLink <> "" Then GUIDelete($CoverGUI) AdlibUnRegister("GetCoverDATA") EndIf ;Maybe the $PlayerGUI need resize so delete it GUIDelete($PlayerGUI) AdlibUnRegister("GetPlayerDATA") _Audio_stop($MusicHandle) ;Remove Default Radio Tag For $r = 0 To UBound($aRadio) - 1 $aRadio[$r][7] = 0 Next ;Set $NewRadioName to Default For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][0] = $NewRadioName Then $aRadio[$r][7] = 1 IniWrite($Save_INI, @ComputerName, "Default_Radio", $aRadio[$r][0]) EndIf Next ;Get $Radio_Name, $Radio_SoundLink, $Radio_CoverLink, $Radio_CoverLink_Start, $Radio_CoverLink_End, $Radio_CoverLink_BetweenNum, $Radio_CoverLink_Before For $r = 0 To UBound($aRadio) - 1 If $aRadio[$r][7] = 1 Then $Radio_Name = $aRadio[$r][0] $Radio_SoundLink = $aRadio[$r][1] $Radio_CoverLink = $aRadio[$r][2] $Radio_CoverLink_Start = $aRadio[$r][3] $Radio_CoverLink_End = $aRadio[$r][4] $Radio_CoverLink_BetweenNum = $aRadio[$r][5] $Radio_CoverLink_Before = $aRadio[$r][6] EndIf Next ;ConsoleWrite("Build GUI" & @CRLF) ;Build GUI _Build_PlayerGUI() _Build_CoverGUI() ;ConsoleWrite("Show GUI" & @CRLF) GUISetState(@SW_SHOW, $PlayerGUI) If $Radio_CoverLink <> "" Then GUISetState(@SW_SHOW, $CoverGUI) EndIf ;GetPlayerDATA() - GetCoverDATA() GetPlayerDATA() AdlibRegister("GetPlayerDATA", 8000) If $Radio_CoverLink <> "" Then GetCoverDATA() AdlibRegister("GetCoverDATA", 8000) EndIf EndFunc ;==>ContextMenu_ChangeRadio Func UseCurl($Link, $Timeout, $binary = 0, $write = 0, $file = "") Local $Error = "" Local $Data = "" Local $Curl = Curl_Easy_Init() If Not $Curl Then Return If $write = 0 Then ;Read Mode ; How to get html or header data? ; 1. Set $CURLOPT_WRITEFUNCTION and $CURLOPT_HEADERFUNCTION to Curl_DataWriteCallback() ; 2. Set $CURLOPT_WRITEDATA or $CURLOPT_HEADERDATA to any number as identify ; 3. Use Curl_Data_Get() to read the returned data in binary format ; 4. Use Curl_Data_Cleanup() to remove the data Local $Html = $Curl ; any number as identify Local $Header = $Curl + 1 ; any number as identify Curl_Easy_Setopt($Curl, $CURLOPT_URL, $Link) Curl_Easy_Setopt($Curl, $CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A') Curl_Easy_Setopt($Curl, $CURLOPT_FOLLOWLOCATION, 1) Curl_Easy_Setopt($Curl, $CURLOPT_ACCEPT_ENCODING, "") Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $Html) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_HEADERDATA, $Header) Curl_Easy_Setopt($Curl, $CURLOPT_COOKIE, "tool=curl; script=autoit; fun=yes;") Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, $Timeout) Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0) Local $Code = Curl_Easy_Perform($Curl) If $Code = $CURLE_OK Then ;ConsoleWrite("Content Type: " & Curl_Easy_GetInfo($Curl, $CURLINFO_CONTENT_TYPE) & @LF) ;ConsoleWrite("Download Size: " & Curl_Easy_GetInfo($Curl, $CURLINFO_SIZE_DOWNLOAD) & @LF) $Data = BinaryToString(Curl_Data_Get($Html)) $Error = "" ;MsgBox(0, 'Header', BinaryToString(Curl_Data_Get($Header))) ;MsgBox(0, 'Html', BinaryToString(Curl_Data_Get($Html))) Else ;ConsoleWrite(Curl_Easy_StrError($Code) & @LF) $Data = "" $Error = Curl_Easy_StrError($Code) EndIf Curl_Easy_Cleanup($Curl) Curl_Data_Cleanup($Header) Curl_Data_Cleanup($Html) Else ;Write Mode EndIf Local $aray[2] = [$Data,$Error] return $aray EndFunc Func GetCoverDATA() ;ConsoleWrite("GetCoverDATA (Start)" & @CRLF) ;Get $RealCoverLink If $Radio_CoverLink_Start = "" Then ;ConsoleWrite("$RealCoverLink = $Radio_CoverLink" & @CRLF) Local $RealCoverLink = $Radio_CoverLink Else ;ConsoleWrite("$RealCoverLink <> $Radio_CoverLink" & @CRLF) ;UseCurl($Link, $Timeout, $binary = 0, $write = 0, $file = "") Local $aray = UseCurl($Radio_CoverLink, 5) Local $Data = $aray[0] Local $Error = $aray[1] If $Error <> "" then ;ConsoleWrite("$Error = " & $Error & @CRLF) EndIf Local $Between = _StringBetween($Data, $Radio_CoverLink_Start, $Radio_CoverLink_End) If @error <> 0 Then $Between = "" Else $Between = $Between[$Radio_CoverLink_BetweenNum] EndIf $RealCoverLink = $Radio_CoverLink_Before & $Between $RealCoverLink = StringReplace($RealCoverLink, " ","%20") EndIf ;ConsoleWrite("$RealCoverLink = " & $RealCoverLink & @CRLF) ;UseCurl($Link, $Timeout, $binary = 0, $write = 0, $file = "") Local $Cover_Read = UseCurl($RealCoverLink, 5, 1) $Cover_Read = $Cover_Read[0] If $Cover_Read <> $Previous_Cover_Read and $Cover_Read <> "" Then $Previous_Cover_Read = $Cover_Read Local $hMem = _MemGlobalAllocFromBinary($Cover_Read) Local $hImage = _GDIPlus_ImageLoadFromHGlobal($hMem) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($CoverGUI) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $CoverSize, $CoverSize) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hImage) EndIf ;ConsoleWrite("GetCoverDATA (End)" & @CRLF) EndFunc ;==>GetCoverDATA() Func GetPlayerDATA() _ReduceMemory() ;ConsoleWrite("GetPlayerDATA (Start)" & @CRLF) ;Assign Local $Previous_Data, $Previous_DataLink For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$i][0] Then If $Previous_DataLink <> $aLabel[$i][3] Then Local $aray = UseCurl($aLabel[$i][3], 5) Local $Data = $aray[0] Local $Error = $aray[1] $Previous_Data = $Data $Previous_DataLink = $aLabel[$i][3] Else $Data = $Previous_Data $Previous_DataLink = $aLabel[$i][3] EndIf Local $Between = _StringBetween($Data, $aLabel[$i][4], $aLabel[$i][5]) If @error <> 0 Then $Between = "" Else If Not ($aLabel[$i][6] > Ubound($Between)-1) Then $Between = $Between[$aLabel[$i][6]] Else $Between = "" EndIf EndIf If $aLabel[$i][7] <> "" Then Local $Split = StringSplit($Between, $aLabel[$i][7], 1) If $Split[0] < $aLabel[$i][8] Then Local $Info = "" Else $Info = $Split[$aLabel[$i][8]] EndIf Else $Info = $Between EndIf If $Data = "" Then $Info = $Error EndIf $Info = StringReplace($Info, "â·", "·") $Info = StringReplace($Info, "apos;", "'") Assign($aLabel[$i][1] & $aLabel[$i][2], $Info) EndIf Next If _BASS_ChannelIsActive($MusicHandle) <> 1 and $Play = 1 Then _Audio_stop($MusicHandle) ;ConsoleWrite("Start playing sound" & @CRLF) $Play = 1 $MusicHandle = _Set_url($Radio_SoundLink) _Audio_play($MusicHandle) ;ConsoleWrite("Set Volume" & @CRLF) $VolumePercent = IniRead($Save_INI, @ComputerName, "Volume", 4) $Previous_VolumePercent = $VolumePercent _Set_volume($VolumePercent) EndIf ;Update Ctrl For $i = 0 To UBound($aLabel) - 1 If $Radio_Name = $aLabel[$i][0] Then If Eval($aLabel[$i][1] & $aLabel[$i][2]) <> GUICtrlRead($aLabel[$i][9]) Then GUICtrlSetData($aLabel[$i][9], Eval($aLabel[$i][1] & $aLabel[$i][2])) EndIf EndIf Next ;ConsoleWrite("GetPlayerDATA (End)" & @CRLF) EndFunc ;==>GetPlayerDATA() #EndRegion ;==> Internal Func While 1 Local $Msg = GUIGetCursorInfo($PlayerGUI) If $Msg[4] = $Close Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Closep.bmp");MousePressed Else _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Closeo.bmp");MouseOver EndIf Else _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Close.bmp");Nothing EndIf If $Play = 1 Then If $Msg[4] = $PlayPause Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopp.bmp");MousePressed Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopo.bmp");MouseOver EndIf Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stop.bmp");Nothing EndIf Else If $Msg[4] = $PlayPause Then If $Msg[2] = 1 Then _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playp.bmp");MousePressed Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playo.bmp");MouseOver EndIf Else _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\play.bmp");Nothing EndIf EndIf Sleep(100) WEnd ;1075 v0.0.0.8 30/04/2016 01:55
  13. Mp3SearchEngine v2.0.0.6 May be some of you know Songr . This script do the same job, it can find more mp3 files but is not as fast as Songr. Sites used are music search engine Websites designed for LEGAL entertainment purposes only. Thanks to Brett Francis, Prog@ndy and Eukalyptus for >Bass Udf, trancex for >WinHttp Udf and the AutoIt Community for his help. Changes of v1.0.8.5 Three websites replaced cause they are dead or use now js. All search engines updated ( not without difficulties for audiodump) I use RAGrid.dll for the first listview (more fast and stable, but with some inconvenients to manage the no-edit of cells) Input queries are saved ( the twenty latest) I use now an mp3 pre-Load management before playing and a double progressbar for visualize pre-load and play, where you can click for directly go play in the loaded part. Most includes needed are embedded and all external files are embedded in script with >BinaryToAu3Kompressor . Multi downloads available with embedded downloader.exe Changes of v1.0.8.8 Search on audiodump and myfreemp3 fixed. New buttons. Added Gui Menu. Titles are no more editable. New "About" with >TaskDialog (Thanks Prog@andy) Query button permit now to check / uncheck all checkboxes And some few fixes and cleaning. Really more stable now. Changes of v1.0.9.2 Dilandau is replaced by mp3chief and mp3ili by mp3clan Search on mp3juices, baseofmp3 and soundcloud fixed. Soso now provide m4a (aac) instead of mp3 ( m4a can be played by MSE) Added possibility to encode automaticaly to mp3, aac or ogg ( at the end of download) using bassenc.dll and command line tools : lame, faac and oggenc. Changes of v1.0.9.3 mp3skull fixed mp3chief fixed myfreemp3 fixed mp3clan changed to tusmp3 mp3juices changed to emp3world baseofmp3 changed to imp3 and some minor improvements. Version 2.0.0.6 Most previous websites used are dead or have changed the way to get links, so instead of try to repair the previous version, i have created a complete new version. The main tendency is the simplification : Only one website : audiodump (Up to 500 results by request) Script use now the little pearl created by Ward : curl.au3 It permit to create tasks (get source and get multi mp3) in asynchronous mode. So now, no need to use several executables and no more gui who do not respond in case of connection problems. Script use Bass.dll X86 loaded in memory for play songs. Result is light and fast, but don't abuse of audiodump servers who are not beasts of race. Warning : For avoid errors with curl.au3, you'll need to comment the line 63 : ;~ #Include <BinaryCall.au3> @AutoItX64 not supported and only tested on Win7X64 and Win8.1X64. As your browser, use Ctrl+w for remove the current Tab.(if there is no search or download running from it) And also Ctrl+q for set/remove Gridlines. Events are displayed to the bottom of the Gui. Version 2.0.1.1 Added a Paste Button. Querry list is now correctly saved. Querry Combo is now sorted in alphabetical order After a 'No match', the next search will use the previous empty listview. Bug when removing tabs is corrected. Added string correction for the request that, in the previous version, was not always able to return a correct result. A big thanks to Ward for his great UDF, and Nina my favorite tester, (who between us is also my third daughter), for his precious advices . previous downloads : 1703 As there is no more script downloads count, source and executable are available in the downloads section Enjoy ! July 2017 Project Discontinued due to website changes
  14. I will add the splunk remote export and then combine them if there is interest (think i might be the only security guy here). this will return the XML reports from paloalto for the hashes in the list. hashlist should be relative to the script, as well the reports will be written to the scriptdir. ;curl test #include<file.au3> local $aHashes $curldir = "C:\Users\curluser\Desktop\CURL\" ; with trailing backslash $sApiKey = "This is where the API Key Goes" _FileReadToArray("hashlist.csv" , $aHashes , 0) ; This is a list of SHA-256, one per line. As mine was exported from Splunk the first row is the table name.... For $i = 1 to ubound($aHashes) - 1 ; ...so its skipped here by starting on 1 instead of 0 $iPid = run($curldir & "curl -k -F hash=" & $aHashes[$i] & " -F format=xml -F apikey=" & $sApiKey & " https://wildfire.paloaltonetworks.com/publicapi/get/report", "", @SW_HIDE , $stdout_child) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd filewrite($aHashes[$i] & ".xml" , $sOutput) next
  15. i have used this and love it but cant seem to figure out a way to actually download a image or webpage etc locally, it will show in console no problem https://www.autoitscript.com/forum/topic/137456-curl-udf-a-udf-for-transferring-data-with-url-syntax/ anyone have any ideas or did i miss it in one of the examples?
  16. Version 2.0.1.1

    2,592 downloads

    Search and Get mp3 from Internet : Topic If UAC enabled, Run it as Administrator for the first execution.
  17. Hi all, Because i wanted to download and read remote files through proxy servers and if needed use advanced authentication methods (e.g. NTLM), i made some useful functions that utilize standalone wget or curl executables (included). http://publictoolsrepo.sourceforge.net/apps/wget-curl.zip - i was unable to attach it #include <Array.au3> #include 'udf_wget_curl.au3' ; gui examples ; =============================================================================================================================== ; a simple input window Dim $sVALUE = __gui_create_input_dialog('this is the title of the window', 'this is the text shown on the window', 'name', '', False, -1, -1, False, FileRead('randomtext.txt'), 'a optional default value') ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sVALUE = ' & $sVALUE & @CRLF) ;### Debug Console ; a simple input window with the screen dimmed and the field is passworded Dim $sVALUE = __gui_create_input_dialog('another nice popup', 'this one shows the screen dimmed and the size of the window is relative to the text length' & @CRLF & 'this one shows the screen dimmed and the size of the window is relative to the text length', 'password? :)', '', True, -1, -1, True) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sVALUE = ' & $sVALUE & @CRLF) ;### Debug Console ; a simple combo window Dim $sVALUE = __gui_create_combo_dialog('the title', 'the text', 'choose your food', '', False, -1, -1, False, '', 'Pizza|Burger|Raw Code', '') ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sVALUE = ' & $sVALUE & @CRLF) ;### Debug Console ; a auth window :) Dim $aRESULT = __gui_create_auth_dialog('this looks legit', 'your data is safe with me ;)', 0, True, False, False) _ArrayDisplay($aRESULT) ; a progress window example Dim $aPROGRESS = __gui_progress_create('text displayed', 10, -1, 10, 'this footnote text is optional!') Sleep(1000) __gui_progress_set_bar_amount($aPROGRESS, 20, 'test updated :)') Sleep(1000) __gui_progress_set_bar_amount($aPROGRESS, 40, 'test updated :) and another') Sleep(1000) __gui_progress_set_bar_amount($aPROGRESS, 60, 'test updated :) and another and another') Sleep(1000) __gui_progress_set_bar_amount($aPROGRESS, 80, 'test updated :) and another and another and another') Sleep(1000) __gui_progress_destroy($aPROGRESS) ; wget-curl examples ; =============================================================================================================================== ; download a file with progess __wget_download_start('http://ipv4.download.thinkbroadband.com/10MB.zip', @ScriptDir, 'randomtext.txt', 'a file for you') ; read a remote file :) Dim $sFILE = __wget_read_remote_file('http://publictoolsrepo.sourceforge.net/apps/randomtext.txt') ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sFILE = ' & $sFILE & @CRLF) ;### Debug ConsoleAs a bonus i also included some of my GUI functions that are used by it. Most functions are written and designed using a modular approach so they should be easily implementable. The following dependencies are also included and i would like to credit the authors. GIFAnimation - trancexx ResourcesEx - Zedna (original) guinness (current) _StringSize - Melba23
  18. Hi, I have created / registered a twitter app and have generated customer keys and access token, but unable to understand how to use it. I have assumed that using the access token it would be possible to login into twitter without using the necessary web-browser based auth - This is presently being provided by sean's twitter udf. The reason is that I am working on a cli based application and is being used for automation purposes. I also wanted to know 1: Whether it would be possible to use curl udf to connect to twitter (oAuth) without using a username/password. All I need is your guidance on this in the right direction. Regards Deltarocked.
  19. I'm using to upload a file to a server. After the upload the server returns a URL to that file. My program needs to give that URL to the user. libcURL is working fine and the upload is successful, and the HTML response needed is output to scite's console. I need the information put into the console to be stored in a variable, though, and I can't figure it out. I think I need to use stdout or stdread to do this. I have used these before when using a run() command but this library is using a dll (and is much cleaner than my previous version which used run commands). How do I record the output buffer of a DLL? (or whatever stdout is called). This attachment is what I'm testing it with, just open "playground.au3" and run it. It should spit a bunch of information to the console. The top listing of variables is all from curl_getdata(), the part with brackets and arrows is from my web server. I need the second part to be put into a variable. PS: The cURL process ID is stored as $__hcurl_process seangriffin's manages to accomplish this, it looks like the key is to use "DllCallbackRegister". I'm trying to plug this in to smartee's UDF but the two UDF's look like completely different languages. I don't think I will be able to figure this out on my own, but I'm going to keep trying. EDIT: You need to move the DLL's to the same folder as playground.au3, and edit "libcURL.au3" and change the #include to quotes instead of brackets. I packed it wrong.
×
×
  • Create New...