Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/22/2014 in all areas

  1. As said in the helpfile (Keyword reference > Dim / Global / Local / Const) : " To erase an array (maybe because it is a large global array and you want to free the memory), simply assign a single value to it: $aArray = 0 This will free the array and convert it back to the single value of 0. Declaring the same variable name again will erase all array values and reset the dimensions to the new definition."
    2 points
  2. nend

    Synology filestation UDF

    Hoi There all, This is my first UDF, It has not been completed and there are much improvements possible. This UDF only works for users of Synology NAS server Functions are: - _Synology_Filestation_Login - _Synology_Filestation_Logout - _Synology_Filestation_Get_Shares - _Synology_FileStation_Get_Dir - _Synology_Filestation_File_List This UDF is make use of the webapi. Webapi helpfile from synology (PDF) http://ukdl.synology.com/download/Document/DeveloperGuide/Synology_File_Station_API_Guide.pdf If there are users how wants to finished this UDF (or make improvements) Please be my quest. Global $o_Synology_HTTP ; #FUNCTION# ==================================================================================================================== ; Name...........: _Synology_Filestation_Login ; Description ...: Logs into filestation API. ; Syntax.........: _Synology_Filestation_Login($http_url, $username, $password, $raw) ; Parameters ....: $http_url - http URL for the Synology webinterface ; $username - Username for the user account ; $password - Password for the user account ; $raw - If true return string with raw API data ; Return values .: Success - Login taskid ; Failure - , Errorcode (read the API pdf for the error codes) ; Author ........: Dave Thijse ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _Synology_Filestation_Login($http_url, $username, $password, $raw = False) local $string_Array, $return_string $o_Synology_HTTP = ObjCreate("winhttp.winhttprequest.5.1") $return_string = _Post_Send($http_url & "/webapi/auth.cgi", "api=SYNO.API.Auth&version=3&method=login&account=" & $username & "&passwd=" & $password & "&session=FileStation&format=cookie") If $raw Then Return $return_string EndIf If StringInStr($return_string, '"error"') Then $string_Array = StringRegExp($return_string, '"code":(.*?)}', 3) Return SetError($string_Array[0]) Else $string_Array = StringRegExp($return_string, '"sid":"(.*?)"},"success"', 1, 1) If StringInStr($return_string, ":true") Then Return $string_Array[0] Else Return False EndIf EndIf EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Synology_Filestation_Logout ; Description ...: Logs out filestation API. ; Syntax.........: _Synology_Filestation_Logout($http_url, $raw) ; Parameters ....: $http_url - http URL for the Synology webinterface ; $raw - If true return string with raw API data ; Return values .: Success - return true ; Failure - , Errorcode (read the API pdf for the error codes) ; Author ........: Dave Thijse ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _Synology_Filestation_Logout($http_url, $raw = False) Local $return_string $return_string = _Post_send($http_url & "/webapi/auth.cgi", "api=SYNO.API.Auth&version=1&method=logout&session=Filestation") If $raw Then Return $return_string Else If StringInStr($return_string, '"error"') Then $string_Array = StringRegExp($return_string, '"code":(.*?)}', 3) Return SetError($string_Array[0]) Else Return True EndIf EndIf EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Synology_Filestation_Get_Shares ; Description ...: Gets all shares names ; Syntax.........:_Synology_Filestation_Get_Shares($http_url, $flag, $raw) ; Parameters ....: $http_url - http URL for the Synology webinterface ; $flag - 1 get names, 2 get fullpath ; $raw - If true return string with raw API data ; Return values .: Success - array with shares ; Failure - , Errorcode (read the API pdf for the error codes) ; Author ........: Dave Thijse ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _Synology_Filestation_Get_Shares($http_url, $flag = 1, $raw = False) Local $return_string, $string_Array $return_string = _Post_send($http_url & "/webapi/FileStation/file_share.cgi", "api=SYNO.FileStation.List&version=1&method=list_share&additional= real_path") If StringInStr($return_string, '"error"') Then If $raw Then Return $return_string Else $string_Array = StringRegExp($return_string, '"code":(.*?)}', 3) Return SetError($string_Array[0]) EndIf EndIf If $raw Then Return $return_string Else Switch $flag Case 1 $string_Array = StringRegExp($return_string, '"name":"(.*?)"', 3) Case 2 $string_Array = StringRegExp($return_string, '"real_path":"(.*?)"', 3) EndSwitch Return $string_Array EndIf EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Synology_FileStation_Get_Dir ; Description ...: Get directorie infomation ; Syntax.........:_Synology_FileStation_Get_Dir($http_url, $path, $raw) ; Parameters ....: $http_url - http URL for the Synology webinterface ; $path - share name ; $raw - If true return string with raw API data ; Return values .: Success - array 0 amount directories 1 amount files 2 total size ; Failure - , Errorcode (read the API pdf for the error codes) ; Author ........: Dave Thijse ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _Synology_FileStation_Get_Dir($http_url, $path, $raw = False) Local $return_string, $return_Array[3], $string_Array, $taskid, $return_raw $return_string = _Post_Send($http_url & "/webapi/FileStation/file_dirSize.cgi", "api=SYNO.FileStation.DirSize&version=1&method=start&path=" & _URIEncode($path)) If $raw Then $return_raw = $return_string EndIf If StringInStr($return_string, '"error"') Then If $raw = False Then $string_Array = StringRegExp($return_string, '"code":(.*?)}', 3) Return SetError($string_Array[0]) EndIf Else $string_Array = StringRegExp($return_string, '{"taskid":"(.*?)"},"success"', 1, 1) $taskid = $string_Array[0] While 1 $return_string = _Post_Send($http_url & "/webapi/FileStation/file_dirSize.cgi", "api=SYNO.FileStation.DirSize&version=1&method=status&taskid=" & $taskid) If StringInStr($return_string, '"error"') Then If $raw Then Return $return_raw = $return_raw & " " & $return_string EndIf $string_Array = StringRegExp($return_string, '"code":(.*?),"', 3) Return SetError($string_Array[0]) Else $string_Array = StringRegExp($return_string, '"finished":(.*?),"', 3) If $string_Array[0] = "true" Then If $raw = True Then $return_raw = $return_raw & $return_string Return $return_raw EndIf $string_Array = StringRegExp($return_string, '"num_dir":(.*?),"', 3) $return_Array[0] = Round($string_Array[0]) $string_Array = StringRegExp($return_string, '"num_file":(.*?),"', 3) $return_Array[1] = Round($string_Array[0]) $string_Array = StringRegExp($return_string, '"total_size":(.*?)},"', 3) $return_Array[2] = $string_Array[0] Return $return_Array EndIf EndIf Sleep(20) WEnd EndIf EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _Synology_Filestation_File_List ; Description ...: List files ; Syntax.........: _Synology_Filestation_File_List($http_url, $path, $pattern, $flag) ; Parameters ....: $http_url - http URL for the Synology webinterface ; $path - share name ; $pattern - Any glob syntax(? and *) if not set it's return all files ; $flag - 1 get names, 2 get fullpath ; Return values .: Success - array ; Failure - , Errorcode (read the API pdf for the error codes) ; Author ........: Dave Thijse ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _Synology_Filestation_File_List($http_url, $path, $pattern = 1, $flag = 1) Local $return_string, $string_Array, $taskid, $return_Array[1][1] $return_string = _Post_Send($http_url & "/webapi/FileStation/file_find.cgi", "api=SYNO.FileStation.Search&version=1&method=start&folder_path=" & _URIEncode($path) & "&pattern=" & $pattern) If StringInStr($return_string, '"error"') Then $string_Array = StringRegExp($return_string, '"code":(.*?),"', 3) Return SetError($string_Array[0]) Else $string_Array = StringRegExp($return_string, '{"taskid":"(.*?)"},"success"', 1, 1) $taskid = $string_Array[0] While 1 $return_string = _Post_Send($http_url & "/webapi/FileStation/file_find.cgi", "api=SYNO.FileStation.Search&version=1&method=list&taskid=" & $taskid & "&additional=real_path&limit=-1") If StringInStr($return_string, '"error"') Then $string_Array = StringRegExp($return_string, '"code":(.*?),"', 3) Return SetError($string_Array[0]) Else $string_Array = StringRegExp($return_string, '"finished":(.*?),"', 3) If $string_Array[0] = "true" Then Switch $flag Case 1 $path_array = StringRegExp($return_string, '"name":"(.*?)",', 3) Case 2 $path_array = StringRegExp($return_string, '"real_path":"(.*?)"', 3) EndSwitch Return $path_array EndIf EndIf Sleep(20) WEnd EndIf EndFunc ;------------------------------------------------------------------------------------------- Func _Post_Send($link, $sendstring) $o_Synology_HTTP.Open("POST", $link) $o_Synology_HTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $o_Synology_HTTP.Send($sendstring) Return $o_Synology_HTTP.ResponseText EndFunc Func _URIEncode($sData); Made by ProgAndy Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"") Local $nChar $sData="" For $i = 1 To $aData[0] $nChar = Asc($aData[$i]) Switch $nChar Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126 $sData &= $aData[$i] Case 32 $sData &= "+" Case Else $sData &= "%" & Hex($nChar,2) EndSwitch Next Return $sData EndFunc How to use 3x example #include <Array.au3> #include <Synology.au3> $username = "admin" $password = "*******" $http_url = "http://192.168.0.10:5000" _Synology_Filestation_Login($http_url, $username, $password) If @error Then ConsoleWrite("Error code = " & @error & @CRLF); see pdf voor error codes Else $path = "/homes"; begin with a share name _test1($path); get dir info _test2(); arraydisplay with all shares _test3($path); arraydisplay of all files _Synology_Filestation_Logout($http_url); logout If @error Then ConsoleWrite("Error code = " & @error & @CRLF) Else Exit EndIf EndIf Func _test1($path) local $dir_array $dir_array = _Synology_FileStation_Get_Dir($http_url, $path) If @error Then ConsoleWrite("Error code = " & @error & @CRLF); see pdf voor error codes Else ConsoleWrite("Directories = " & $dir_array[0] & @CRLF & "Files = " & $dir_array[1] & @CRLF & "Total size = " & ConvertSize($dir_array[2]) & @CRLF) EndIf EndFunc Func _test2() local $shares_array $shares_array = _Synology_Filestation_Get_Shares($http_url, 1); array with all shares If @error Then ConsoleWrite("Error code = " & @error & @CRLF); see pdf voor error codes Else _ArrayDisplay($shares_array) EndIf EndFunc Func _test3($path) Local $list_array $list_array = _Synology_Filestation_File_List($http_url, $path, "*.jpg", 2); filter = *.jpg If @error Then ConsoleWrite("Error code = " & @error & @CRLF); see pdf voor error codes Else _ArrayDisplay($list_array) EndIf EndFunc Func ConvertSize($inputSize, $outputPlaces = 2) Local $unitNames[5] = ["","K","M","G","T"] Local $bytes, $outputUnit $bytes = $inputSize * 1024 ^ 0 $outputUnit = Int(Log($bytes)/Log(1024)) If $outputUnit > 4 Then $outputUnit = 4 Return String(Round($bytes / 1024 ^ $outputUnit, $outputPlaces)) & " " & $unitNames[$outputUnit] & "B" EndFunc
    1 point
  3. Kernel Objects Information Sample output of Object Handles probing _ I've assembled a number of UDF's which use "undocumented" features of the O/S over the years. And this here would be the latest, and possibly the last (I hope?). The purpose of this UDF is to query kernel objects in the system. It's actually a pretty big UDF that ties together a lot of functionality, and hopefully makes it more accessible. With the UDF you can: Query a Kernel Object for 'hidden' information using its handle: Object Type and stats (_ObjectGetTypeInfoUD), Attributes and Access (_ObjectGetBasicInfoUD), Kernel Object Name (_ObjectGetNameUD), etc Query certain Kernel Event Objects for current states:Event, IoCompletion and Mutex ("Mutant") signal states (and more), Semaphore counts, Timer's remaining time, etc Get a list of opened File handles and filenames (there's already a few UDF's dedicated to that, though) Collect all the current handles held by the O/S and its processes, using specific filters, and get information on what the object is and its current state Kernel Objects Inspector script _ What's an Object you say? Whats a Kernel? Whats an NT? Gosh, maybe you shouldn't be here - go read Youtube. As Windows programmers, we make use of these Kernel Objects all the time... Object Types List Some of the most common System Objects: Token, Process, Thread, Event, Mutant (Mutex), Semaphore, Timer, File (includes NamedPipe and Mailslot), Key (Registry Key) Anytime you work with these objects, you are generating new objects at the kernel level. Luckily, the O/S allows above 16 million handles per process (see Pushing the Limits of Windows: Handles by Mark Russinovich), so this isn't a concern. However, if an individual process has in excess of 16K handles, there will be some trunacted values returned from the NT API call as it only returns 16-bit values for handles. See >this post where I try to describe this in better detail. However, this is no longer a problem with the latest update, which restores the upper bits of handles through a simple wraparound detection technique. There's more to say, but perhaps its best to show what functions are available. From the NTKernelObjectsInfo UDF Header: Querying time issues: Note that any call to query handles (_NTObjGetHandlesUD, _NTObjGetHandlesInfoEx) relies on a call to NtQuerySystemInformation, which gathers information on EVERY handle held by the system and it's processes. This can take a few seconds! Be patient. (Also, _NTObjBuildTypesIndexMap calls it indirectly) IMPORTANT: Be a little careful with looking for 'File' objects on Vista and Win7.. on XP there's already some safeguards which unfortunately prevent detecting certain objects. Newer versions of the O/S don't seem to have problems with threaded probing of File objects, but there may be some cases.. The Console output is still a bit noisy, but its good for analyzing where there's problems in reading handles, or analyzing "File" handles which can cause major problems, especially in the case of NamedPipes. Some example UDFs are included: NTSystemObjectsList: displays a list of System Object Types NTKernelObjectsCollectExample: A collection query at its simplest (see below for this example) NTKernelObjectsSelfExamine: creates a number of different Objects before listing everything NTKernelObjectsInspect: Inspect Kernel Objects with Filtering options from a GUI This GUI needs work! Notice that with the ArrayDisplay function, there is a 'Run User Func' option which will display any extra info retrieved for the object (see ExInfo column). NTKernelObjectsSpam: Creates a crapload of Kernel Objects. This is mostly useless, but its here to demonstrate how NTKernelObjectsInspect now is able to report correct handle values beyond 65,536 NTKernelObjectsCollectExample In this example I query only 2 processes for handles, and use exclusion criteria to remove "File" and "EtwRegistration" from the resultant list. ; =========================================================================================================== ; <NTKernelObjectsCollectExample.au3> ; ; Pretty barebones example of NTKernelObjectsInfo, showing the ease with which objects can be collected ; Uses multipe query types, multiple processes, and multiple Object Types with exclusion rules ; ; Author: Ascend4nt ; =========================================================================================================== #include "NTKernelObjectsInfo.au3" #include <Array.au3> ; -= FLAGS to Tweak Object Querying =- ; Force Win2000/XP Attribute skipping (must appear AFTER #include): ;$g_NTKO_bNamedPipeProtect = True ; Alternatively set own: ;$g_NTKO_sFileAttribSkipList = "0x0012019F|" ; Additionally, can force BadMask Skipping to OFF (not recommended): ;$g_NTKO_bSkipBadMasks = False ; Other queries available, although less often used: ; $NTOBJ_QUERYBY_PID (example: @AuotItPID), $NTOBJ_QUERYBY_OBJTYPE (ex: 28), and $NTOBJ_QUERYBY_HANDLE (actual object handle) $aRet = _NTObjGetHandlesInfoEx($NTOBJ_QUERYBY_PROCESSNAME, "firefox.exe|autoit3.exe", _ $NTOBJ_QUERYBY_OBJTYPENAME + $NTOBJ_QUERY_EXCLUDE, "File|EtwRegistration") ConsoleWrite("Errors: " & @error & ", @extended = " & @extended & @CRLF) _ArrayDisplay($aRet, "_NTObjGetHandlesInfoEx") Thanks for testing this out! Change History: NTKernelObjects.zip ~prev Downloads: 55
    1 point
  4. Glad I could help the helpfile could help
    1 point
  5. tommytx, Setting Opt("WinTitleMatchMode", 2) - (Match any substring in the title) would seem a good place to start experimenting. M23
    1 point
  6. Many professional notepads do not know how to. You're not going to write a book the size of several gigabytes?
    1 point
  7. Func _ArrayErase(ByRef $aRRAY) Local $aTemp[0] $aRRAY = $aTemp EndFunc ??
    1 point
  8. What might work on XP might not on later versions, for both IE and UAC prompts. I don't think the bosses here like discussing closing security prompts, or for that matter, detecting them, which is what UAC is. You could of course programmatically turn off UAC but that would require the script to be run under administrator rights. If it is some sort of tutorial, you could show images or even animated gifs, while using InetGet to do the actual downloads. If you carry on down the automating IE route, I suggest you post your code.
    1 point
  9. JWW

    FF.au3 (V0.6.0.1b-10)

    Does anyone have an updated FF.au3 with all of the changes/updates that have been provided to fix it? The ones I have found and changed: Thanks! Btw, I have attached mine with the above changes in case anyone wants to use it. Well, I don't see an option to attach, so here's a Dropbox link: https://www.dropbox.com/s/a82h566y3c3x2r3/FF.au3 John
    1 point
×
×
  • Create New...