Jump to content

uteotw

Active Members
  • Posts

    28
  • Joined

  • Last visited

uteotw's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Most excellent, I needed something like this for a long time. Thanks a lot. Now, I've found a small problem with it when I loop through folders very quickly my script (compiled or not) would "randomly" hang! I tracked it down to this UDF and I've just made a couple tweaks to make it more reliable: - added Local declaration to 3 variables, which is necessary when using Opt("MustDeclareVars", 1) in your scripts - added ProcessWaitClose, not sure if it's really necessary but it doesn't hurt - used DllOpen / DllClose Func _FileListTreeToArray($pFolder, $tPath = 0, $tType = "", $tSort = "N") Local $wCheck = StringSplit(StringLeft($pFolder, 3), ":" ) ; <<< my tweak ... declared $wCheck If $wCheck[0] <> 2 and StringLeft($pFolder, 1) <> "\" then $pFolder = @WorkingDir & "\" & $pFolder If $wCheck[0] <> 2 and StringLeft($pFolder, 1) = "\" then $pFolder = @WorkingDir & $pFolder If StringRight($pFolder, 1) = "\" then $pFolder = StringTrimRight($pFolder, 1) If Not FileExists($pFolder) then Return Seterror(0, 0, 0) if $tPath > 1 OR $tPath < 0 then return Seterror(1, 0, 0) Local $wSort = StringReplace($tSort, "-", "") ; <<< my tweak ... declared $wSort If StringLen($wSort) <> 1 or $wSort <> "N" and $wSort <> "S" and $wSort <> "E" and $wSort <> "D" and $wSort <> "G" and _ $wSort <> "" then return Seterror(1, 0, 0) If Stringreplace(Stringreplace(Stringreplace( Stringreplace(Stringreplace(Stringreplace($tType, "-", ""), "H", ""), "S", _ ""), "A", ""), "R", ""), "D", "") <> "" then return Seterror(1,0,0) local $uArray, $iStdout, $sTemp, $placeholder If $tType = "" Then $iStdout = Run(@comspec & ' /C cd ..\..\..\..\.. & dir "' & $pFolder & '" /A /B /O:' & $tSort & ' /S', @workingdir, _ @SW_HIDE, 6) Else $iStdout = Run(@comspec & ' /C cd ..\..\..\..\.. & dir "' & $pFolder & '" /A:' & $tType & ' /B /O:' & $tSort & ' /S', _ @workingdir, @SW_HIDE, 6) EndIF Local $line ; <<< my tweak ... declared $line While 1 $line = StdoutRead($iStdout) If @error Then ExitLoop If $line <> "" then $sTemp &= $line Wend ProcessWaitClose($iStdout) ; <<<< my tweak ... might be necessary in case of sub-processed? For $i = 0 To StringLen($sTemp) $placeholder &= " " Next Local $dll = DllOpen("user32.dll") ; <<<< my tweak ... dllopen $sTemp = DllCall($dll, "long", "OemToChar", "str", $sTemp, "str", $placeholder) DllClose($dll) ; <<<< my tweak ... dllclose If Not Isarray($sTemp) or $sTemp[0] < 1 then return Seterror(2,1,0) $sTemp = $sTemp[2] $sTemp = StringReplace($sTemp, @crlf, @lf) $sTemp = StringReplace($sTemp, @cr, @lf) If StringRight($sTemp, 1) = @lf then $sTemp = StringTrimRight($sTemp, 1) If StringLeft($sTemp, 1) = @lf then $sTemp = StringTrimLeft($sTemp, 1) If Not StringInStr($sTemp, @lf) then If $sTemp = "" then local $return[1] = [0] Else local $return[2] = [1, $sTemp] EndIf Else local $return = StringSplit($sTemp, @lf) EndIF if not isarray($return) then Return Seterror(2,2,0) EndIF If $tPath = 1 Then For $dArray = 1 To $return[0] Step 1 $return[$dArray] = StringReplace($return[$dArray], $pFolder & "\", "") Next EndIf return Seterror(0,0,$return) EndFunc ;==>_FileReadTreeInArray Now, my scripts don't hang anymore
  2. This is birlliant stuff. I just want to report a minor issue: $tagSYSTEMTIME already exists in StructureConstants.au3 , which is included in Date.au3 for example. So this causes a conflict when including Date.au3 in a script. Global Const : WinINetConstants.au3(29,136) : ERROR: $tagSYSTEMTIME previously declared as a 'Const'
  3. Hi I have a fresh Win2008 x64 install. I then start a couple file explorer and internet explorer windows. I then run the example script for ObjCreate: $oShell = ObjCreate("shell.application") ; Get the Windows Shell Object $oShellWindows=$oShell.windows ; Get the collection of open shell Windows if Isobj($oShellWindows) then $string="" ; String for displaying purposes for $Window in $oShellWindows ; Count all existing shell windows $String = $String & $window.LocationName & @CRLF next Msgbox(0,"Shell Windows","You have the following shell windows:" & @CRLF & @CRLF & $String); endif Result, only the file explorer windows are listed. The internet explorer windows are ignored. The weird thing is that I have another Win2008 machine for which it works perfectly, the example scripts lists any IE windows running. That 2nd machine has a couple more features installed, a IIS running compared to my fresh Win2008 install. Does anyone know why IE is ignored by $oShellWindows=$oShell.windows on a fresh Win2008 install? Thanks
  4. D'oh! forgot to change it to just "While 1" Yep, actually I was looking into "C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files\Content.IE5" So far I had tried on a WinXP x86 and x64, both with IE6. I've just tried it on a 3rd machine (Win2008 x64 - IE7) with which I don't browse much and your script worked fine. In the cache folder Windows explorer show 909 files in total, of which 367 are JPGs. When I tried my script returned: $iTotalLoops: 978 << 69 more loops than expected and this is explained by what you said "keep in mind that these cache entries enumerations will also list more than actual cache files" $iTotalEmpy: 0 << good $iJPG: 367 << as expected $iNotJPG: 611 I've tried on a 4th machine (XP x86 - IE6) with which I do a lot of browsing and again your example scripts exits before going through all the files and my script returned: $iTotalLoops: 24773 $iTotalEmpy: 7889 $iJPG: 4580 $iNotJPG: 12304 In the end, I don't know what it is, IE cache becoming corrupt over time or after a certain size? All I can say is that may be you could try to have more files in your cache. I usually set the cache size to 200MB. Anyways, I can work around it and still get the info I'm looking for. Thanks again for the UDF.
  5. @ Ultima Things seems to be moving along nicely and I appriciate all the hard work. I used the example: _WinINet_FindFirstUrlCacheEntry.au3, and I was surprised to see it stop after just returning 2 files. It seems that $avCacheEntryInfo = _WinINet_FindNextUrlCacheEntry($hCacheEntry) doesn't always an return an Array so in your example it exists the main loop. The thing is that my IE cache contains 12 folders, 2922 files which seems to be spread pretty equally across the 12 folders. And there is a total of 254 JPGs. I modified your example script to count a few things: ;#include <WinINet.au3> #include "WinINet.au3" Global $hWinINetDll = DllOpen("wininet.dll") Global $iPtr, $iLength, $avCacheEntry = _WinINet_FindFirstUrlCacheEntry() Global $hCacheEntry = $avCacheEntry[0] Global $avCacheEntryInfo = $avCacheEntry[1] $avCacheEntry = 0 Local $sExtension = "jpg" Local $iJPG = 0 Local $iNotJPG = 0 Local $iNotArray = 0 Local $iNotArrayTotal = 0 Local $iTotalLoops = 0 While Not @error $iTotalLoops = $iTotalLoops + 1 If IsArray($avCacheEntryInfo) Then If StringLower(StringRight($avCacheEntryInfo[2], StringLen($sExtension))) = StringLower($sExtension) Then $iJPG = $iJPG + 1 Else $iNotJPG = $iNotJPG + 1 EndIf EndIf $avCacheEntryInfo = _WinINet_FindNextUrlCacheEntry($hCacheEntry) If NOT IsArray($avCacheEntryInfo) Then $iNotArray = $iNotArray + 1 ElseIf $iNotArray > 0 Then ConsoleWrite("$iNotArray: " & $iNotArray & @CRLF) $iNotArrayTotal = $iNotArrayTotal + $iNotArray $iNotArray = 0 EndIf If $iNotArray = 2000 Then ; after 2000 I don't expect any more results ConsoleWrite("$iNotArray: " & $iNotArray & @CRLF) ExitLoop EndIf WEnd _WinINet_FindCloseUrlCache($hCacheEntry) DllClose($hWinINetDll) $iTotalLoops = $iTotalLoops - $iNotArray + 1 ConsoleWrite("----------" & @CRLF) ConsoleWrite("$iTotalLoops: " & $iTotalLoops & @CRLF) ConsoleWrite("$iTotalEmpy: " & $iNotArrayTotal & @CRLF) ConsoleWrite("$iJPG: " & $iJPG & @CRLF) ConsoleWrite("$iNotJPG: " & $iNotJPG & @CRLF) ConsoleWrite("----------" & @CRLF) In the end this is the result: $iTotalLoops: 1565 << expected : 2922 $iTotalEmpy: 791 $iJPG: 151 << expected : 254 $iNotJPG: 623 I'm not sure if this is a problem in _WinINet_FindNextUrlCacheEntry(), or a problem with my cache (I'll clean it up and will try again), or may be me who don't understand everything yet.
  6. What if there is not eject button? I use a Mac Mini as my HD MediaPlayer on my HUGE LCD TV. It used run WinXP and now it runs a stripped down version of Win2008, because I wanted to use a homebrewed Apple Remoter Driver, but I would certainly not run Vista ever). Anyhow, when not using MediaPortal there is no direct interface to eject the CD other than right-clicking on the CD Drive in Windows Explorer. I like that implementation and I'm going to try it. Even if unhandy it still is a good job. For a first script, or at least a first posted script it looks pretty well written and thought out. Now if it were truly unhandy and/or useless, then it could almost be considered as Art, which I defined as something that has no other purpose than itself. But it's an all different matter.
  7. _WinINet_DllStructReadArray(), I could I have missed it!!? I must have been blind when reading the list of functions. Thanks for the _WinINet_FindFirstUrlCacheEntry() update and no rush for the rest.
  8. Wonderful. I actually needed the "cache" functions. Update: I've just tried to use the "cache" functions and I'm not too sure what to do. I get _WinINet_FindFirstUrlCacheGroup and _WinINet_GetUrlCacheGroupAttribute to work, but I'm not sure what to do with the result from _WinINet_GetUrlCacheGroupAttribute because what ever attribute I use it returns the same array. #include <array.au3> #include <WinINet.au3> Opt("MustDeclareVars", 1) Opt("TrayIconDebug", 1) DllOpen("wininet.dll") Local $search = _WinINet_FindFirstUrlCacheGroup(0) ConsoleWrite(@error & @CRLF) _ArrayDisplay($search, "$search") Local $attribute = _WinINet_GetUrlCacheGroupAttribute($search[1], $CACHEGROUP_ATTRIBUTE_GROUPNAME) ConsoleWrite(@error & @CRLF) _ArrayDisplay($attribute, "$attribute") FYI, I'm on WinXP64, don't think it should make a difference and there a files under my current user IE cache. I guess I'll have to wait for some examples.
  9. It is possible for webpages http://www.autoitscript.com/forum/index.php?showtopic=59960 But I never got around doing it 100% in AutoIt. Lack of time and skills.
  10. Hi I've been dealing with bigger arrays recently, and I need to remove duplicates elements from these arrays. I wasn't satisfied with the simple,crappy and slow compare/delete routine I wrote. So after searching the forums I found several good UDFs but the one from nitro322 and SmOke_N in this post http://www.autoitscript.com/forum/index.php?showtopic=7821 had the best performance. So I decided take it and modify. ;================================================================== ; Function Name: _ArrayRemoveDuplicates() ; ; Description : Removes duplicate elements from an Array ; Parameter(s) : $avArray ; $iBase ; $iCaseSense ; $sDelimter ; Requirement(s) : None ; Return Value(s): On Success - Returns 1 and the cleaned up Array is set ; On Failure - Returns an -1 and sets @Error ; @Error=1 $avArray is not an array ; @Error=2 $iBase is different from 1 or 2 ; @Error=3 $iCaseSense is different from 0 or 1 ; Author : uteotw, but ALL the credits go to nitro322 and SmOke_N, see link below ; Note(s) : None ; Link ; http://www.autoitscript.com/forum/index.php?showtopic=7821 ; Example ; Yes ;================================================================== Func _ArrayRemoveDuplicates(ByRef $avArray, $iBase = 0, $iCaseSense = 0, $sDelimter = "") Local $sHold If Not IsArray($avArray) Then SetError(1) Return -1 EndIf If Not ($iBase = 0 Or $iBase = 1) Then SetError(2) Return -1 EndIf If $iBase = 1 AND $avArray[0] = 0 Then SetError(0) Return 0 EndIf If Not ($iCaseSense = 0 Or $iCaseSense = 1) Then SetError(3) Return -1 EndIf If $sDelimter = "" Then $sDelimter = Chr(01) & Chr(01) EndIf If $iBase = 0 Then For $i = $iBase To UBound($avArray) - 1 If Not StringInStr($sDelimter & $sHold, $sDelimter & $avArray[$i] & $sDelimter, $iCaseSense) Then $sHold &= $avArray[$i] & $sDelimter EndIf Next $avNewArray = StringSplit(StringTrimRight($sHold, StringLen($sDelimter)), $sDelimter, 1) ReDim $avArray[$avNewArray[0]] For $i = 1 to $avNewArray[0] $avArray[$i-1] = $avNewArray[$i] Next ElseIf $iBase = 1 Then For $i= $iBase To UBound($avArray) - 1 If Not StringInStr($sDelimter & $sHold, $sDelimter & $avArray[$i] & $sDelimter, $iCaseSense) Then $sHold &= $avArray[$i] & $sDelimter EndIf Next $avArray = StringSplit(StringTrimRight($sHold, StringLen($sDelimter)), $sDelimter, 1) EndIf Return 1 EndFuncoÝ÷ Øw«yªÞ²{¦¦W¬jëh×6#include<Array.au3> ; Example # 1 : using Base 0 array Dim $avArray[10] $avArray[0] = "JPM" $avArray[1] = "STRING1" $avArray[2] = "Jon" $avArray[3] = "Larry" $avArray[4] = "Jeremy" $avArray[5] = "Valik" $avArray[6] = "String1" ; this element will be deleted from the updated array $avArray[7] = "String2" $avArray[8] = "JdeB" $avArray[9] = "STRING2" ; this element will be deleted from the updated array _ArrayDisplay($avArray, "Example # 1 : Before") _ArrayRemoveDuplicates($avArray) _ArrayDisplay($avArray, "Example # 1 : After") ; Example # 2 : Base 1 array Dim $avArray[11] $avArray[0] = 10 $avArray[1] = "JPM" $avArray[2] = "String1" $avArray[3] = "Jon" $avArray[4] = "Split/Split" $avArray[5] = "Jeremy" $avArray[6] = "Valik" $avArray[7] = "String1" ; this element will be deleted from the updated array $avArray[8] = "String2" $avArray[9] = "JdeB" $avArray[10] = "STRING2" ; this element will be deleted from the updated array _ArrayDisplay($avArray, "Example # 2 : Before") _ArrayRemoveDuplicates($avArray, 1) _ArrayDisplay($avArray, "Example # 2 : After") ; Example # 3 : Base 1 array and Case Sensitive Dim $avArray[11] $avArray[0] = 10 $avArray[1] = "JPM" $avArray[2] = "String1" $avArray[3] = "Jon" $avArray[4] = "Split/Split" $avArray[5] = "Jeremy" $avArray[6] = "Valik" $avArray[7] = "String1" ; this element will be deleted from the updated array $avArray[8] = "String2" $avArray[9] = "JdeB" $avArray[10] = "STRING2" ; this element will NOT be deleted from the updated array _ArrayDisplay($avArray, "Example # 3 : Before") _ArrayRemoveDuplicates($avArray, 1, 1) _ArrayDisplay($avArray, "Example # 3 : After") ; Example # 4 : Base 1 array, Case Sensitive and using "/" as Delimiter Dim $avArray[11] $avArray[0] = 10 $avArray[1] = "JPM" $avArray[2] = "String1" $avArray[3] = "Jon" $avArray[4] = "Split/Split" ; this element will become 2 elements in the updated array $avArray[5] = "Jeremy" $avArray[6] = "Valik" $avArray[7] = "String1" ; this element will be deleted from the updated array $avArray[8] = "String2" $avArray[9] = "JdeB" $avArray[10] = "STRING2" ; this element will NOT be deleted from the updated array _ArrayDisplay($avArray, "Example # 4 : Before") _ArrayRemoveDuplicates($avArray, 1, 1, "/") _ArrayDisplay($avArray, "Example # 4 : After") Hope this will useful. uteotw _ArrayRemoveDuplicates.au3 ArrayRemoveDuplicates.au3
  11. True, but does the XML DOM Wrapper try to access that url when processing xmlns attribute? By the way, I'm not the one owning the system generating the XML. I've just found out that if it were <soap:FolderResponse xmlns="http://microsoft.com/workbench/store"> then Local $sNodes = _XMLSelectNodes('//soap:Envelope/soap:Body/soap:FolderResponse/*') would work So, how can I declare before that not all the nodes use the "soap" name space?
  12. Hi AutoIt and XML gurus I'm trying to process the return envelope from a SOAP request. <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <FolderResponse xmlns="http://microsoft.com/workbench/store"> <FolderResult> <Documents Count="3"> <Document DocumentID="1" /> <Document DocumentID="2" /> <Document DocumentID="3" /> </Documents> </FolderResult> </FolderResponse> </soap:Body> </soap:Envelope> I'm trying to access all "DocumentID". But _XMLSelectNodes() can't process past <FolderResponse xmlns="http://microsoft.com/workbench/store"> Here is my AutoIt code: #Include <Array.au3> #Include <_XMLDomWrapper.au3> Local $sFile = "C:\XMLFile1.xml" If FileExists($sFile) Then Local $ret = _XMLFileOpen ($sFile, 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"') Local $sNodes = _XMLSelectNodes('//soap:Envelope/soap:Body/FolderResponse[@xmlns="http://microsoft.com/workbench/store"]/*') _ArrayDisplay($sNodes, "$sNodes") EndIf Then it works fine. Why is _XMLSelectNodes() failing on [@xmlns="http://microsoft.com/workbench/store"] ? Is it something wrong in my syntax? or is it somthing that the XML DOM Wrapper can't do? Thanks uteotw
  13. Bump ... truly sorry about that ... I'll let it die if nobody is able to help.
  14. Hi I'm very impressed with new GDIPlus management and SreenCapture management UDFs. I'm looking for a way, save a whole page browsed in IE as an image. Using _ScreenCapture_CaptureWnd() only captures what is drawn on the window, so if the page is longer than the IE window not everything will be saved in the image. After a bit of search around the web I've found this page http://www.codeproject.com/KB/IP/htmlimagecapture.aspx explaining that MSHTML has a IHTMLElementRender interface which include a DrawToDC() function http://msdn2.microsoft.com/en-us/library/a...273(VS.85).aspx Update: Another page gives another example which seems better as it handles opacity http://www.nathanm.com/ihtmlelementrender-opacity I tried to understand how to use MSHTML within AutoIt and looked around the fourms http://www.autoitscript.com/forum/index.ph...2&hl=mshtml http://www.autoitscript.com/forum/index.ph...2&hl=mshtml But I'm not that good and my attempts fail miserably. 1. Could some just show how to MSHTML interface/function after creating $oIE object 2 I guess it would be neat to add this as a new function in IE.au3 or ScreenCapture.au3 Thanks uteotw
  15. Neat script, I remember trying it a while back, and I just gave shot at the updated version but it fails. I've completly deleted my previous install of AutoIt and I've just installed AutoIt 3.2.10.0 and the latest SciTE. I ran the your script... Calvin and Hobbes and Dilbert comics got downloaded to @HomeDrive But then the script failed on line 291 DailyComics.au3 (291) : ==> Subscript used with non-Array variable.: Return $ImageLink[0]
×
×
  • Create New...