Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/05/2015 in all areas

  1. Using the FTP FTPEx.au3 makes communicating with FTP a breeze. With great functions like _FTP_FileGet, _FTP_FilePut, and _FTP_DirPutContents, you can upload and download with ease. But what about the much needed ability to download a folder with a simple _FTP_DirGetContents function? Well I put together a function that will download a folder with ease... _FTP_DirGetContents Function: Func _FTP_DirGetContents($oConn, $opath, $olocal, $orec) If Not FileExists($olocal) Then DirCreate($olocal) If StringRight($opath, 1) <> "/" Then $opath &= "/" If $orec == 1 Then Local $ocurrent = _FTP_DirGetCurrent($oConn) _FTP_DirSetCurrent($oConn, $opath) Local $afolders = _FTP_ListToArray($oConn, 1) _FTP_DirSetCurrent($oConn, $ocurrent) For $o = 1 To $afolders[0] If $afolders[$o] == "." Or $afolders[$o] == ".." Then ContinueLoop If Not FileExists($olocal & "\" & $afolders[$o]) Then DirCreate($olocal & "\" & $afolders[$o]) _FTP_DirGetContents($oConn, $opath & $afolders[$o], $olocal & "\" & $afolders[$o], $orec) Next EndIf Local $hFTPFind Local $aFile = _FTP_FindFileFirst($oConn, $opath, $hFTPFind) While 1 _FTP_FileGet($oConn, $opath & $aFile[10], @ScriptDir & "\tmpdata\" & $aFile[10]) $aFile = _FTP_FindFileNext($hFTPFind) If @error Then ExitLoop WEnd _FTP_FindFileClose($hFTPFind) EndFunc Example Usage: #include <FTPEx.au3> If Not FileExist(@ScriptDir & "\ftptemp") Then DirCreate(@ScriptDir & "\ftptemp") $dir_local = @ScriptDir & "\ftptemp" $dir_remote = "/" Local $iOpen = _FTP_Open('MyFTP Control') Local $iConn = _FTP_Connect($iOpen, "YourFTPServer", "YourUsername", "YourPassword") _FTP_DirGetContents($iConn, $dir_remote, $dir_local, 1) _FTP_Close($iConn) _FTP_Close($iOpen) Function Call Explanation: _FTP_DirGetContents($oConn, $opath, $olocal, $orec) $oConn: session handle as returned by _FTP_Connect. $opath: The remote folder to download $olocal: The local folder to download to. $orec: set to 1 to download folder and subfolders. Set to 0 for non recursive. Enjoy
    1 point
  2. Hi This UDF is for anyone who - Object Orientated Programing ie properties and methods in autoIT - needs standards compliant JSON,, - JSON.parse (read) and JSON.stringify (to text ) - Now JSONPath - wants to use dot syntax in AutoIT like you would in Javascript - dosen't like AutoIt arrays - full javascript arrays and objects in AutoIT! - knows javascript or would like to learn autoIT or vice versa. - call javascript functions like EncodeURI - run any javascript from autoIT ! Tested IE8 - IE11. v7 JSON_OO v7.zip - IE free version. ( hey microsoft ditched IE now too!) .- No IE dependencies- Added arrayAdd and arrayDel- JSONPath! for searching.- Added Keys Function - to list properties of a JSON object.- Secure JSON parse- Native Pure JS implementaion not a port.Credits to Douglas Crockford's for JSON2 code and stefan.goessner for JSONPath code. (see example file). v4 - json_oo_v4.zip. - use v7 (v4 may not work because of windows updates on dec-2014. ). v4 uses IEs JSON , so no ported external librariesv4 also includes a Non - IE version of JSON no include files but no stringify and uses javascript EVal (not secure). use v7.eg valid JSON '{ "hello" : "world" }' invalid "{ 'hello' : 'world' }"v4 does not have JSONPath , arrayAdd, arrayDel or keys (properties) methods - use v7 - enjoy ...the brakes come off Autoit . This is the smallest OO extensions for AutoIT Object Oriented JSON --- using JSON to Build Objects in Native AutoIT -- Using JSON to create objects $oJSON = _OO_JSON_Init ( ) $jsObj = $oJSON.parse('{ "hello": "world" }') $jsObj.hello;-> world $oJSON.stringify( $jsObj );-> {"hello":"world"} $jsObj.stringify();-> {"hello":"world"} ARRAYS - goodbye Auto it arrays hooray The real magic in this script is that it lets you access JSON array items by index number through dot syntax without the need for a for-each loop. eg you can go $obj.arr.item(n) It does this by making javascript objects syntax friendly to Autoit. . Also you can go $obj.arr.item("property").and $obj.arr.property & Also $obj.arr.length (see below) -- Using JSON to create one dimentional array $sJSON=[ "h1", "h2", "h3" ] $oResult.length= 3 $oResult.item(0);-> h1 -- Using JSON to create 2 dimentional array; $sJSON=[[1,2],[3,4],[5,6]] $oResult.length= 3 $oResult.item(0);-> $oResult.item(0).stringify();-> [1,2] $oResult.item(2).item(1);-> 6 $oResult.item(2).length;-> 2 -- Using JSON to create an object array $sJSON= [ { "card":"ace" }, {"card":"king" }] $oResult.length= 2 $oResult.item(0).card;-> ace -- Using JSON to create key values $sJSON= { "name":"Jon" , "surname":"who" } $oResult.item("surname");-> who $oResult.surname ;-> who Many other benefits such as building objects using JSON text just like you would in JavaScript Basic OO - Properties and methods -- Add properties to objects in AutoIT $jsObj.propAdd("myProp", "'x'") $jsObj.myProp ;-> x $jsObj.propAdd("myProp", '{ "hello": "world" }') $jsObj.myProp.hello ;-> world -- User Defined methods - using javascript -CASE SENSITIVE $jsObj.methAdd("myMethod", " Function('y','return y*5') " ) $jsObj.myMethod(5) ;-> 25 Some people have problems on 64 bit autoIT windows with the script control...here is the work around.. '?do=embed' frameborder='0' data-embedContent>> You will most likely have the script control ..but here it is.. http://www.microsoft.com/en-us/download/details.aspx?id=1949 --- using JSON to Build Objects in Native AutoIT -- Using JSON to create objects $oJSON = _OO_JSON_Init ( ) $jsObj = $oJSON.parse('{ "hello": "world" }') -- Accessing Items $jsObj.hello;-> world $jsObj.item("hello");-> world -- Using Any Object to create objects $jsObj.stringify();-> {"hello":"world"} $jsObj = $jsObj.parse('{ "goodbye": "world" }') $jsObj.goodbye;-> world -- Read JSON from a file (PC only) - untested $var = _OO_JSON_Read_File("jsondata.txt") $obj = $oJSON.parse($var) > BASIC OO (Object Oriented) programming in Auto it -- Compound Syntax $oJSON.parse( '{ "hello":"world" }' ).hello;-> world -- assigning propeprties $jsObj.parse ( '{ "goodbye": "world" }') $jsObj.goodbye ;-> world $jsObj.goodbye = "hello" $jsObj.goodbye;-> hello > OO Adding Methods and Properties in Auto it -- Add properties to objects in AutoIT $jsObj.propAdd("myProp", "'x'") $jsObj.myProp ;-> x $jsObj.propAdd("myProp", '{ "hello": "world" }') $jsObj.myProp.hello ;-> world -- User Defined methods - using javascript -CASE SENSITIVE $jsObj.methAdd("myMethod", " Function('y','return y*5') " ) $jsObj.myMethod(5) ;-> 25 > Querying Objects $jsObj = $oJSON.parse('{ "hello": "world" , "Goodbye" : "World" } ') $jsObj.type($jsObj) ->object $jsObj.isArray() ->False -- List object properties or "keys" $jsObj.keys($jsObj).stringify() ->["hello","Goodbye"] -- Querying Objects $jsObj = $jsObj.parse({ "hello" : "world" , "myarray" : [ "item0", 2 , { "jon" : "who"} ] }) > JSON path - always returns an array of matches $jsObj.jsonPath( "$.*").stringify() -> ["world",["item0",2,{"jon":"who"}]] $jsObj.jsonPath( "$..hello").stringify() -> ["world"] $jsObj.jsonPath( "$..myarray").stringify() ->[["item0",2,{"jon":"who"}]] $jsObj.jsonPath( "$..myarray[?(@.jon)]").stringify() ->[{"jon":"who"}] $jsObj.jsonPath( "$..myarray[?(@.jon)]").item(0).stringify() ->{"jon":"who"} > Basic Arrays using JSON -- Querying Arrays $jsObj.myarray.stringify() ->["item0",2,{"jon":"who"}] $jsObj.type($jsObj.myarray) ->object $jsObj.myarray.isArray() ->True $jsObj.myarray.length ->3 $jsObj.type($jsObj.myarray.item(0)) ->string $jsObj.type($jsObj.myarray.item(1)) ->number $jsObj.type($jsObj.myarray.item(2)) ->object > Modifying Arrays using OO -- Empty array; $jsObj = $oJSON.parse('[]') $jsObj.stringify() ->[] $jsObj.isArray( ) ->True -- Add items; $jsObj.arrayAdd( 0, "test0") $jsObj.arrayAdd( 1, "test1") $jsObj2 = $oJSON.parse( '{ "hello" : "world" }') $jsObj.arrayAdd( 2, $jsObj2) $jsObj.stringify() ->["test0","test1",{"hello":"world"}] -- Delete items; $jsObj.arrayDel( 0) $jsObj.stringify() ->["test1",{"hello":"world"}] -- Using JSON to create one dimentional array $sJSON=[ "h1", "h2", "h3" ] $oResult.length= 3 $oResult.item(0);-> h1 -- Using JSON to create 2 dimentional array; $sJSON=[[1,2],[3,4],[5,6]] $oResult.length= 3 $oResult.item(0);-> $oResult.item(0).stringify();-> [1,2] $oResult.item(2).item(1);-> 6 $oResult.item(2).length;-> 2 -- Using JSON to create an object array $sJSON= [ { "card":"ace" }, {"card":"king" }] $oResult.length= 2 $oResult.item(0).card;-> ace -- Using JSON to create key values $sJSON= { "name":"Jon" , "surname":"who" } $oResult.item("surname");-> who $oResult.surname ;-> who > Working with OO Objects -- assigning JSON objects in AutoIT $jsObj = $oJSON.parse( '{ "hello" : "world" }') $jsObj2 = $oJSON.parse( '{}' ) $jsObj2 = $jsObj $jsObj.hello;-> world $jsObj2.hello;-> world -- Assign an JSON object to a property $jsObj = $oJSON.parse( '{ "hello" : "world" }') $jsObj.hello ;-> world $jsObj2.propAdd("myProp") $jsObj2.myProp = $jsObj $jsObj2.myProp ;-> $jsObj2.myProp.stringify() ;-> {"hello":"world"} $jsObj2.myProp.hello ;-> world -- Using Existing JS Objects , Object must exist in the scripting object (not IE) $oJSON2 =$jsObj.objGet('JSON') ; objGet is javascript eval $oResult = $oJSON2.parse('{ "hello":"world" }') $oResult.hello;-> world > Using Javascript functions extending UDF -- Calling javascript standard functions $jsObj.jsFunAdd( "encodeURI") $jsObj.encodeURI( 'te st' );-> te%20st $jsObj.protoAdd("encodeURI", " function (s) { return encodeURI(s); } " $jsObj.encodeURI( 'te st' );-> te%20st -- Calling javascript literal methods $str_obj = $jsObj.toObj("my string") $str_obj.jsMethAdd( "charAt") $str_obj.charAt( 0 );-> m $jsObj.toObj('\"my string').charAt(0) ;-> \ $str_obj.jsFunAdd( "charAt") $str_obj.charAt( 0 );-> m $jsObj.jsMethAdd("toFixed" ) $jsObj.toObj(5.56789).toFixed(2) ;-> 5.57 $jsObj.jsMethAdd("concat" , 3 ) $jsObj.toObj('hello').concat( ' world', ' again ', ' and again ' ) ;-> hello world again and again $jsObj.dot("\""'my string", "charAt(0)" );-> \ > depreciated syntax -- depreciated syntax - previous UDFs $jsObj = _JS_obj_create ( '{ "hello": "world" }') ; invalid "{ 'hello':'world'}" $jsObj.hello ;-> world $jsObj.objToString();-> {"hello":"world"} $jsObj.strToObject ( '{ "goodbye": "world" }') $jsObj.goodbye ;-> world -- Close IE explorer.exe instance - not required anymore _OO_JSON_Quit ( ) -- Objects still usable after _OO_JSON_Quit closes $jsObj.goodbye ;-> world Example script output; see example file ; enjoy
    1 point
  3. Hey guys, i wrote a small TVmaze.com API UDF for my TV-Show-Manager program. You can get any tv-show info you like with this UDF. Everything like tv-schedule, series info, cast list, episode list etc. including image links can be downloaded and will be returned in arrays. The API is way faster than for example tvrage.com. In case anyone ever needs it: Simple Example: #include "TVMazeAPI_UDF.au3" #include <Array.au3> ;===========TV Schedule for next 2 days========== $TV_Schedule=_GetTVSchedule() _ArrayDisplay($TV_Schedule,"TV Schedule") ;===============Search for a show================ $SearchResults=_SearchShow("person of interest") If @error then Exit _ArrayDisplay($SearchResults,"Searchresults") ;===============Get show info/details============ $ShowID=$SearchResults[0][1];Show id is taken from the searchresults first result $ShowInfo = _GetShowInfo($ShowID) _ArrayDisplay($ShowInfo,"Show Info") ;=============Get the cast of a show============= $Cast=_GetCast($ShowID) _ArrayDisplay($Cast,"Cast") ;============Get all Episodes of a Show========== $AllEpisodes = _GetShowEpisodes($ShowID) _ArrayDisplay($AllEpisodes,"All Episodes") ;========Filter Episodes by selected season====== $FilteredBySeason2 = _FilterBySeason($AllEpisodes, "2") _ArrayDisplay($FilteredBySeason2,"Filtered by episodes of season 2") ;====Get only last and next episode of a show==== $LastAndNextEpisode = _GetShowEpisodes($ShowID, 0, @TempDir, 0, 1) _ArrayDisplay($LastAndNextEpisode,"Last and Next Episodes only") Example usage(image): Updated 30.12.2015: - Bug fix TVMazeAPI_UDF.zip
    1 point
  4. When you compile the script to an exe, you'd need to use the "#AutoIt3Wrapper_Change2CUI=y" directive in your script.
    1 point
  5. I found these functions on MSDN which control various aspects of monitors such as brightness, contrast, color temperature, etc. This works on my monitors on Windows7 x64. Your mileage may vary. Doesn't work on anything lower than Windows Vista. Not all monitors are supported. Requires the latest AutoIt3 beta. [10-17-2013] -- The VCPs described in the MCCS standard are now wrapped up into Monitor Configuration Wrapper.au3. BE CAREFUL WITH THESE! I made this UDF without any real understanding of why. I do not foresee myself using these, but I put them out here in case someone else does. These functions are all untested. I leave it up to you to decide if the functions that you want to use have been implemented correctly. If you bork your monitor, then go out and buy yourself something really nice. Here are the required au3 files: Monitor Configuration.zip previous: 52 The list of files in the UDF: Monitor Configuration Wrapper.au3 -- This wraps up the MCCS standard into a UDF. Deprecates Low Level.au3. Beware. Example High Level.au3 -- Run this example for a simple monitor configuration dashboard. Monitor Configuration High Level.au3 Monitor Configuration Low Level.au3 -- Deprecated. Monitor Configuration Constants.au3 Monitor Configuration.au3 -- Internal, do not use. What's that? You want to turn off your monitor programmatically? #include "Monitor Configuration Wrapper.au3" Global Const $physical_monitor = GetPhysicalMonitorsFromHMonitor(_WinAPI_EnumDisplayMonitors()[1][0]) PowerMode($physical_monitor, $POWER_OFF)
    1 point
  6. Do you even know what a script is?
    1 point
×
×
  • Create New...