Leaderboard
Popular Content
Showing content with the highest reputation on 06/27/2016 in all areas
-
Not sure this is helpful to someone other than me ... #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> Local $hGui = GUICreate("IP Address Control Enable/Disable Example", 400, 300) Local $hIPAddress1 = _GUICtrlIpAddress_Create($hGui, 10, 10) Local $hIPAddress2 = _GUICtrlIpAddress_Create($hGui, 10, 40) Local $hIPAddress3 = _GUICtrlIpAddress_Create($hGui, 10, 70) _GUICtrlIpAddress_Set($hIPAddress1, "192.168.1.10") _GUICtrlIpAddress_Set($hIPAddress2, "255.255.255.0") _GUICtrlIpAddress_Set($hIPAddress3, "192.168.1.1") _GUICtrlIpAddress_Disable($hIPAddress1, 1) _GUICtrlIpAddress_Disable($hIPAddress2, 7) ; 4 + 2 + 1 _GUICtrlIpAddress_Disable($hIPAddress3, 0xf) ; 8 + 4 + 2 + 1 GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlIpAddress_Disable ; Description ...: Disable (grays-out) the specified fields of an IP Address control ; Syntax ........: _GUICtrlIpAddress_Disable($hWnd[, $iFields = 0]) ; Parameters ....: $hWnd - Handle to the control ; $iFields - Fields to enable/disable. Can be a combination of the following : ; 0 : Enable all fields ; 1 : Disable the first field ; 2 : Disable the second field ; 4 : Disable the third field ; 8 : Disable the fourth field ; Return values .: On success1 - 1 ; On failure - 0 and set @error to non zero value ; Author ........: jguinch ; =============================================================================================================================== Func _GUICtrlIpAddress_Disable($hWnd, $iFields = 0) Local $aFields[4], $n = 0, $hEdit If Not IsInt($iFields) Or $iFields < 0 Or $iFields > 15 Then Return SetError(3, 0, 0) Local $hWindow = _WinAPI_GetAncestor($hWnd) If @error Then Return SetError(1, 0, 0) If Not $hWindow Or Not WinExists($hWnd) Then Return SetError(2, 0, 0) Local $aFields = _WinAPI_EnumChildWindows ($hWnd, False) If @error Or $aFields[0][0] <> 4 Then Return SetError(1, 0, 0) If $iFields = 0xf Then Return ControlDisable($hWindow, "", $hWnd) Local $iRet = ControlEnable($hWindow, "", $hWnd) For $i = 0 to 3 $iRet *= ( BitAND($iFields, 2 ^ $i) ? ControlDisable($hWindow, "", $aFields[4 - $i][0]) : ControlEnable($hWindow, "", $aFields[4 - $i][0]) ) Next Return $iRet EndFunc1 point
-
What seems to be the problem? Your script sets an image to every column in the _AddSubItem lines, if that's not what you wanted, then you need to remove the parameter that does that. Also, you're adding images to the image list AFTER you're trying to use them, you need to create and load the imagelist prior to creating the listview items that will be using it.1 point
-
Comboku, The Interrupting a running function tutorial in the Wiki shows how you can do this. M231 point
-
dmob, The final parameter of the WM_LBUTTONDOWN message needs to be coded to determine the offset within the control where the action is to occur - some Googling shows that the formula is as follows: x = DTP_Width - 10 y = DTP_Height / 2 Param = x + ( y * 0x00010000 ) It works in the original snippet as the "open" button is to the left of the visible control and so the 1 pixel is over the button - within a ListView that is unlikely to be the case and so we have to define the X-coordinate required, which is not hard as we set the width of the control when we draw it (experimentation shows that we can apparently ignore the Y-coordinate): _SendMessage($hTemp_Edit, 0x0201, 1, $aEdit_Pos[2] - 10) ; WM_LBUTTONDOWN Try changing the _GUIListViewEx_SetEditStatus lines in the example I posted above to this: _GUIListViewEx_SetEditStatus($iLV_Index, "0", 3) ; No dropdown _GUIListViewEx_SetEditStatus($iLV_Index, "1", 3, "#") ; Dropdown with default date _GUIListViewEx_SetEditStatus($iLV_Index, "2", 3, "2000/01/01#") ; Dropdown with defined date and run it with this version of the UDF: The syntax is pretty easy - a trailing "#" in $vParam1 forces the DTP to open on edit. Does that meet your requirements? M231 point
-
_FFPrefSet("network.proxy.http_port", Int($aResult[$iIndex]))1 point
-
Try: _FFPrefSet("network.proxy.http_port", Int($test))1 point
-
All of these scripts were written by me but use methods seen by others. With so many different versions of FileListToArray in the wild I think its nice to see why certain methods work better than others. -Added results from Sm0ke_N and randallc which forced rearrangement, also note some versions are faster with smaller amounts of files but slower with larger amounts -Much like college football, the rankings mean very little. Sometimes you will only want a small amount of code to find everything, sometimes you will include randallc's bigass code if you need the search to be very specific (Of course i'm biased toward #1 because I wrote it and it is very small code) Test #1: 2090 files / 253 folders @ 6.9 GB (*.*) Test #2: 102,084 files / 8824 folders @ 205 GB (*.*) Test #3: 102,084 files / 8824 folders @ 205 GB (*.mp3, 6720 found) Test #4: 102,084 files / 8824 folders @ 205 GB (*.mp3 + *.exe, 9704 found) #7 - Array based w/ Redimensioning Test #1: 1.9365s Test #2: DNF #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.8.1 Author: WeaponX Script Function: Recursive file search (array based) Notes: Redim causes big speed decrease, moreso than StringSplit #ce ---------------------------------------------------------------------------- #include <array.au3> $timestamp = TimerInit() $Array = RecursiveFileSearch("D:\") MsgBox(0, "", (TimerDiff($timestamp) / 1000) & " seconds") ;1.9365s / 2090 files ;_ArrayDisplay($Array) Func RecursiveFileSearch($startDir, $depth = 0) If $depth = 0 Then Global $RFSarray[1] $search = FileFindFirstFile($startDir & "\*.*") If @error Then Return ;Search through all files and folders in directory While 1 $next = FileFindNextFile($search) If @error Then ExitLoop ;If folder, recurse If StringInStr(FileGetAttrib($startDir & "\" & $next), "D") Then RecursiveFileSearch($startDir & "\" & $next, $depth + 1) Else ;Increase size of array ReDim $RFSarray[$RFSarray[0] + 1] ;Store filename in array $RFSarray[$RFSarray[0]] = $startDir & "\" & $next ;Increment file count $RFSarray[0] += 1 EndIf WEnd FileClose($search) If $depth = 0 Then Return $RFSarray EndFunc ;==>RecursiveFileSearch Redim causes slowdown #6 - Array based using FileSystemObject Test #1: 0.8403s Test #2: 47.508s #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.8.1 Author: WeaponX (source: http://www.microsoft.com/technet/scriptcen...4/hey1020.mspx) Script Function: Recursive file search using FileSystemObject (array based) Notes: -Slowest #ce ---------------------------------------------------------------------------- #include <array.au3> $timestamp = TimerInit() $Array = _AdvancedFileListToArray("D:\temp") MsgBox(0, "", (TimerDiff($timestamp) / 1000) & " seconds") ;0.8403s / 2090 files _ArrayDisplay($Array) Func _AdvancedFileListToArray($sPath, $rootFolder = '') ;Run once If Not IsDeclared("objFSO") Then Global $objFSO = ObjCreate("Scripting.FileSystemObject") $AFLTfilecount = DirGetSize($sPath, 1) Global $objArray[$AFLTfilecount[1] + 1] $rootFolder = $objFSO.GetFolder($sPath) ;Store all files in root folder first For $objFile In $rootFolder.Files $objArray[$objArray[0] + 1] = $sPath & "\" & $objFile.Name $objArray[0] += 1 Next EndIf ;Loop through all subfolders in root folder For $Subfolder In $rootFolder.SubFolders $objFolder = $objFSO.GetFolder($Subfolder.Path) ;Loop through all files in folder For $objFile In $objFolder.Files $objArray[$objArray[0] + 1] = $Subfolder.Path & "\" & $objFile.Name $objArray[0] += 1 Next _AdvancedFileListToArray($sPath, $Subfolder) Next Return $objArray EndFunc ;==>_AdvancedFileListToArray -Object communication slowness -EDIT: Fixed incorrect file count #5 - String based Test #1: 0.0902s <- LOWEST Test #2: 33.6384s #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.8.1 Author: WeaponX Script Function: Recursive file search (string based) Notes: -Fastest thus far #ce ---------------------------------------------------------------------------- #include <array.au3> $timestamp = TimerInit() $Array = RecursiveFileSearch("D:\temp") MsgBox(0, "", (TimerDiff($timestamp) / 1000) & " seconds") ;0.0902s / 2090 files _ArrayDisplay($Array) Func RecursiveFileSearch($startDir, $depth = 0) If $depth = 0 Then Global $RFSstring = "" $search = FileFindFirstFile($startDir & "\*.*") If @error Then Return ;Search through all files and folders in directory While 1 $next = FileFindNextFile($search) If @error Then ExitLoop ;If folder, recurse If StringInStr(FileGetAttrib($startDir & "\" & $next), "D") Then RecursiveFileSearch($startDir & "\" & $next, $depth + 1) Else ;Append filename to master string $RFSstring &= $startDir & "\" & $next & "*" EndIf WEnd FileClose($search) If $depth = 0 Then Return StringSplit(StringTrimRight($RFSstring, 1), "*") EndFunc ;==>RecursiveFileSearch -Fastest in test 1 #4 - String based w/ Helper function Test #1: 0.1797s Test #2: 8.5200s Test #3: 8.5601s #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.8.1 Author: WeaponX Script Function: Recursive file search with helper function (string based) Notes: -StringSplit is faster than ReDim #ce ---------------------------------------------------------------------------- #include <array.au3> $timestamp = TimerInit() $Array = FileListToArrayX("D:\temp") MsgBox(0, "", (TimerDiff($timestamp) / 1000) & " seconds") ;0.1797s / 2090 files _ArrayDisplay($Array) Func FileListToArrayX($FLTAXstartDir) Local $FLTAXstring = "" ;Retrieve array of all folders $folderArray = RecursiveFolderSearch($FLTAXstartDir) ;Loop through all folders For $X = 1 To $folderArray[0] $search = FileFindFirstFile($folderArray[$X] & "\*.*") If @error Then ContinueLoop ;Search through all files and folders in directory While 1 $next = FileFindNextFile($search) If @error Then ExitLoop ;Skip folders, append to strin of all filenames If Not StringInStr(FileGetAttrib($folderArray[$X] & "\" & $next), "D") Then $FLTAXstring &= $folderArray[$X] & "\" & $next & "*" WEnd FileClose($search) Next ;Split string into array and return it Return StringSplit(StringTrimRight($FLTAXstring, 1), "*") EndFunc ;==>FileListToArrayX Func RecursiveFolderSearch($startDir, $depth = 0) If $depth = 0 Then Global $RFSstring = $startDir & "*" $search = FileFindFirstFile($startDir & "\*.*") If @error Then Return ;Search through all files and folders in directory While 1 $next = FileFindNextFile($search) If @error Then ExitLoop ;If folder, recurse If StringInStr(FileGetAttrib($startDir & "\" & $next), "D") Then ;Append foldername to string $RFSstring &= $startDir & "\" & $next & "*" ;Recurse RecursiveFolderSearch($startDir & "\" & $next, $depth + 1) EndIf WEnd FileClose($search) If $depth = 0 Then Return StringSplit(StringTrimRight($RFSstring, 1), "*") EndFunc ;==>RecursiveFolderSearch -Similar to randallc's method with helper function http://www.autoitscript.com/forum/index.php?showtopic=49396 -Helper function not really helpful since you still have to run FileGetAttrib against every single file #3 - String based w/ Helper functions (randallc) Updated times using _FileListToArrayFaster1d Test #1: 0.0936s Test #2: 4.3418s <- LOWEST Test #3: 5.1980s Test #4: 6.1400s Average: 3.9434s http://www.autoitscript.com/forum/index.php?showtopic=49396 #2 - Command line based (dir) (Sm0ke_N) Test #1: 0.2496s Test #2: 11.1895s Test #3: 1.6623s <- LOWEST Test #4: 2.3218s <- LOWEST Average: 3.8558s http://www.autoitscript.com/forum/index.ph...t=0&start=0# #1 - Array based Test #1: 0.1063s Test #2: 5.1020s Test #3: 5.5785s Test #4: 5.5986s Average: 4.0964s #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: WeaponX Updated: 2/21/08 Script Function: Recursive file search 2/21/08 - Added pattern for folder matching, flag for return type 1/24/08 - Recursion is now optional Parameters: RFSstartdir: Path to starting folder RFSFilepattern: RegEx pattern to match "\.(mp3)" - Find all mp3 files - case sensitive (by default) "(?i)\.(mp3)" - Find all mp3 files - case insensitive "(?-i)\.(mp3|txt)" - Find all mp3 and txt files - case sensitive RFSFolderpattern: "(Music|Movies)" - Only match folders named Music or Movies - case sensitive (by default) "(?i)(Music|Movies)" - Only match folders named Music or Movies - case insensitive "(?!(Music|Movies)\:)\b.+" - Match folders NOT named Music or Movies - case sensitive (by default) RFSFlag: Specifies what is returned in the array 0 - Files and folders 1 - Files only 2 - Folders only RFSrecurse: TRUE = Recursive, FALSE = Non-recursive RFSdepth: Internal use only #ce ---------------------------------------------------------------------------- Func RecursiveFileSearch($RFSstartDir, $RFSFilepattern = ".", $RFSFolderpattern = ".", $RFSFlag = 0, $RFSrecurse = True, $RFSdepth = 0) ;Ensure starting folder has a trailing slash If StringRight($RFSstartDir, 1) <> "\" Then $RFSstartDir &= "\" If $RFSdepth = 0 Then ;Get count of all files in subfolders for initial array definition $RFSfilecount = DirGetSize($RFSstartDir, 1) ;File count + folder count (will be resized when the function returns) Global $RFSarray[$RFSfilecount[1] + $RFSfilecount[2] + 1] EndIf $RFSsearch = FileFindFirstFile($RFSstartDir & "*.*") If @error Then Return ;Search through all files and folders in directory While 1 $RFSnext = FileFindNextFile($RFSsearch) If @error Then ExitLoop ;If folder and recurse flag is set and regex matches If StringInStr(FileGetAttrib($RFSstartDir & $RFSnext), "D") Then If $RFSrecurse And StringRegExp($RFSnext, $RFSFolderpattern, 0) Then RecursiveFileSearch($RFSstartDir & $RFSnext, $RFSFilepattern, $RFSFolderpattern, $RFSFlag, $RFSrecurse, $RFSdepth + 1) If $RFSFlag <> 1 Then ;Append folder name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf EndIf ElseIf StringRegExp($RFSnext, $RFSFilepattern, 0) And $RFSFlag <> 2 Then ;Append file name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf WEnd FileClose($RFSsearch) If $RFSdepth = 0 Then ReDim $RFSarray[$RFSarray[0] + 1] Return $RFSarray EndIf EndFunc ;==>RecursiveFileSearch -Same as #5 but uses an array instead of returning StringSplit() -Fastest in test 2 -EDIT: Fixed incorrect file count -EDIT: Code updated 2/21/08, removed autoit tags Conclusions -Redim is very very slow, when using huge amounts of files. #7 never even finished Test #2 after waiting about 3 minutes. The memory usage in the task manager was slowly growing at a rate of 2mb / sec -Ubound is slower than storing the number of elements in index zero -FileSystemObject is very slow but I don't think it has to do with AutoIt -StringRegExp is quite fast1 point