Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/21/2015 in all areas

  1. Melba23

    Forum behaviour

    A recent thread degenerated into personal abuse because some members posted rather sarcasticly in response to the initial question and the OP then responded with rather more venom than was probably warranted. Can I take this opportunity to remind people that we try to run a civilised and polite forum and we would appreciate it if you could act accordingly. If you do not have a sensible comment to make in response to a question, please refrain from posting at all. And, as is explained in the Forum rules, if you do get flamed just report the offending post to the moderating team so that we can deal with it. Certainly do not expect us to take sides if you engage in a flame war - all participants will be treated as equally guilty. Basically, please help us keep the forum running in the way the majority of members would like to see. Thanks in advance for your cooperation. M23
    6 points
  2. TheSaint

    Wiki Challenge Part 2

    I would go further, and say, that they should be able to look at the code, and have a reasonable degree of understanding, without having to go elsewhere. Having to go elsewhere, could be a deterrent for some. Especially if you are looking for simplicity, which is indeed one of AutoIt's excellent selling points. Remember we are talking about three basic kinds of interested people ... though there are many variants. [1] Complete beginner with no experience. [2] A beginner with a little experience, who has possibly failed with or been disappointed with other languages. [3] A beginner who has experience with other languages. P.S. We are indeed limited in this endeavor, by what the budding programmer would conceive as complex and or outside their comfort zone. Ideally, the ones judging this challenge, should be a bunch of beginners, the targeted audience. Most of us here, are not really subjective enough, because we have too much understanding and knowledge. It may seem an easy challenge to some some, but I think not.
    2 points
  3. UEZ

    Wiki Challenge Part 2

    Well, what is complicated and what not, what is a good example for a beginner what not is not easy to answer because it depends on the individual's talent for coding. Example: #include <MsgBoxConstants.au3> Global Const $iTimeout = 30 MsgBox($MB_APPLMODAL, "AutoIt Lesson 1", "Hello world!", $iTimeout) This is a very easy example but is it a good example? For me, a beginner should be able to analyze the code and try to understand using the help file and searching the AutoIt forums. All these examples should be easy to understand if you spend some time for analyzing which should be prerequisite if you want to learn. Br, UEZ
    2 points
  4. 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
  5. Hi! Today I want to show you my current AutoIt project: The ISN AutoIt Studio. The ISN AutoIt Studio is a complete IDE made with AutoIt, for AutoIt! It includes a GUI designer, a code editor (with syntax highlighting, auto complete & intelisense), a file viewer, a backup system, trophies and a lot more features!! Here are some screenshots: Here some higlights: -> easy to create/manage/public your AutoIt-projects! ->integrated GUI-Editor (ISN Form Studio 2) ->integrated - file & projectmanager ->auto backupfunction for your Projects ->extendable with plugins! ->available in several languages ->trophies ->Syntax highlighting /Autocomplete / Intelisense ->Dynamic Script ->detailed overview of the project (total working hours, total size...) And much more!!! -> -> Click here to download ISN AutoIt Studio <- <- Here is the link to the german autoit forum where I posted ISN AutoIt Studio the first time: http://autoit.de/index.php?page=Thread&threadID=29742&pageNo=1 For more information visit my Homepage: https://www.isnetwork.at So….have fun with ISN AutoIt Studio! PS: Sorry for my bad English! ^^
    1 point
  6. I have NOT debugged or ran the code I'm about to provide, I'm merely providing the logic and hope it runs out of the box for you. You can do the leg work and debug. This script takes 2 command lines, url and words pattern for regex Compile this script (name it something like myInetGetSource.au3 and compile). #include <INet.au3> #NoTrayIcon ; there are a minimum of 2 switches ; 1: url ; 2: word to find, each command line after would be a word to find If Not ($CmdLine[0] = 2) Then Exit 0 If StringRegExp(_INetGetSource($cmdline[1]), $CmdLine[2]) Then Exit 1 Exit 0 ; nothing found From here you can manipulate your main script... something like: #include <Array.au3> #include <ProcessConstants.au3> #include <WinAPIProc.au3> #include <WinAPISys.au3> Global $gsFile = "c:\servers.txt" Global $gsGetSourceExe = "name of exe here"; Global $giMaxRun = 5 ; how many exe's to run at a time ; splitting up the file into lines Global $gaURLs = StringSplit(StringStripCR(FileRead($gsFile)), @LF) ; putting words to find in an array Global $gaWords[2] = ["word1", "word2"] ; create regexp to capture words Global $gsFind = "(?si)" For $words = 2 To $CmdLine[0] $gsFind &= "\Q" & $gaWords[$words] & "\E|" Next $gsFind = StringTrimRight($gsFind, 1) ; randomize array _ArrayShuffle($gaURLs, 1) Global $gaData[UBound($gaURLs)][4]; [n][0] = url, [n][1] = pid, [n][2] = process handle, [n][3] = exit code Global $iCount, $iLoop ; launch and monitor For $i = 1 To UBound($gaURLs) - 1 Step $giMaxRun $iCount = 0 For $j = 0 To $giMaxRun - 1 If ($i + $j) > (UBound($gaURLs) - 1) Then ExitLoop $gaData[$i + $j][0] = $gaURLs[$i + $j] $gaData[$i + $j][1] = _myRunToCmdLine($gsGetSourceExe, $gaURLs[$i + $j], $gsFind) $gaData[$i + $j][2] = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION, 0, $gaData[$i + $j][1]) $iCount += 1 Next ; wait for them to be done ; now we could do a real monitor and it would speed it up even more ; but I don't have the patience to write it $iLoop = $iCount While $iCount For $j = 0 To $iLoop - 1 If Not StringLen($gaData[$i + $j][2]) Then If Not ProcessExists($gaData[$i + $j][1]) Then $gaData[$i + $j][3] = Int(_WinAPI_GetExitCodeProcess($gaData[$i + $j][2])) _WinAPI_CloseHandle($gaData[$i + $j][2]) $iCount -= 1 EndIf EndIf Next Sleep(10) ; sanity sleep WEnd Next ; $gaData array now holds all your data ; it will show url in [n][0] and the exit code in [n][3] ; if exit code is 1, then the word(s) was/were found _ArrayDisplay($gaData) Func _myRunToCmdLine($sExe, $sURL, $sPattern) If StringInStr($sExe, " ", 1, 1) Then $sExe = '"' & StringReplace($sExe, '"', '""', 0, 1) & '"' EndIf If StringInStr($sURL, " ", 1, 1) Then $sURL = '"' & $sURL & '"' EndIf If StringInStr($sPattern, " ", 1, 1) Then $sPattern = '"' & StringReplace($sPattern, '"', '""', 0, 1) & '"' EndIf Return Run($sExe & " " & $sURL & " " & $sPattern) EndFunc Good luck.
    1 point
  7. I don't want to install any font. But I was curious about what you did so I added following lines to avoid font installing: #include <WinAPIGdi.au3> _WinAPI_AddFontResourceEx('..\Black-and-Knight.ttf', $FR_PRIVATE) _WinAPI_AddFontResourceEx('..\ChaosandPain-CnP.ttf', $FR_PRIVATE) _WinAPI_AddFontResourceEx('..\TheDeadAreComing.ttf', $FR_PRIVATE) _WinAPI_AddFontResourceEx('..\vtks encount(e)r.ttf', $FR_PRIVATE) Nice looking intro. Br, UEZ
    1 point
  8. water

    Excel (general questions)

    What are the return codes and values of @error and @extended after calling _Excel_BookClose and _Excel_Close?
    1 point
  9. water

    Excel (general questions)

    Was Excel already running when you started the script?
    1 point
  10. water

    Excel (general questions)

    You need to widen the column when "####" is being shown. Use: so widen all columns in the used range.
    1 point
  11. water

    Excel (general questions)

    All functions of the latest Excel UDF start with _Excel_ (note the second underscore). User _Excel_BookOpen to open and import the CSV file to Excel.
    1 point
  12. First param of _Excel_Open is $visible Check out _Excel_RangeWrite to write arrays-
    1 point
  13. I would suggest to use IE.au3 library it is more flexible than chrome for learning. With that (IE) you can navigate onto webpage, read the contents of HTML and then parse the images on the website
    1 point
  14. If you check other processes which exist on your computer- You will be surprised that hundreds of them exist on the computers of users and 90% of them are listenning to something. This should'nt affect the processor power much.
    1 point
  15. czardas

    Wiki Challenge Part 2

    I would like to comment that some of the points raised by mLipok and BrewManNH are really quite trivial to fix.
    1 point
  16. JohnOne

    Wiki Challenge Part 2

    Example 4 is good, but if I were a beginner (and I can remember them days) it would overwhelm me, and once again I have a bit of trouble seeing what the automation aspect of it is. I like Example 5, it demonstrates automation well and is relatively simple to understand, not going to nitpick about comments or naming conventions on any of them. So it's between Example 5 and Example 6 for me. I read the comments about it requiteing an English version of windows, I'm not sure why that is, but I'm sure tons of examples in the help file would also require it, and since it's written and commented in English, I would expect a user looking into coding would understand that. Also maybe there is a way to make it independant of language. I cast my vote to Example 6.
    1 point
  17. TheSaint

    Wiki Challenge Part 2

    @BrewManNH - I think you are being a tad picky there. We are supposed to be judging the code, not really the comments, Comments are subjective, and perhaps couched in a certain way for a beginner. In any case, they can easily be amended. Send, is one of AutoIt's great selling points, and really, if the User is going to be doing other things while doing a quick example, then what is the point? I would also add, that we are talking visual in the first instance. You have to entice the budding programmer with what they read first, so that they even bother to install AutoIt and run the example. If they look at the code, and think something is Cool, and that they would like to do or be able to do that, then you have achieved your goal. P.S. In reality, one should be able to remove all the comments, and the example should have a good chance at standing on it's own legs and being understandable from a beginner's perspective.
    1 point
  18. You should really look into how create your own context menu entry.
    1 point
  19. Why dont you make it already executed, sitting in the tray and listening for the event?
    1 point
  20. czardas

    Wiki Challenge Part 2

    I don't see any problem with people discussing the entries. This is also meant to be a learning experience.
    1 point
  21. Try this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $iWidth = 600 $iHeight = 400 $hGui = GUICreate("", $iWidth, $iHeight, -1, -1) Create_GRID($iWidth, $iHeight) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Create_GRID($iWidth, $iHeight, $iGrid_w = 20, $iGrid_h = 20, $iColorW = 0x00000, $iColorH = 0x00000) Local $x, $y GUICtrlCreateGraphic(0, 0, $iWidth, $iHeight) For $x = 0 To $iWidth / $iGrid_w GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $x * $iGrid_w, 0) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $iColorW) GUICtrlSetGraphic(-1, $GUI_GR_LINE, $x * $iGrid_w, $iHeight) Next For $y = 0 To $iHeight / $iGrid_h GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $y * $iGrid_h) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $iColorH) GUICtrlSetGraphic(-1, $GUI_GR_LINE, $iWidth, $y * $iGrid_h) Next EndFunc Br, UEZ
    1 point
×
×
  • Create New...