Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/06/2020 in all areas

  1. I've never done the RoR before. I used to connect from Laptop to Server2, then from Server2 to Server1, then disconnecting my Laptop connection to Server2 would leave Server1 with an active desktop. You could also try this
    2 points
  2. CoePSX

    Drawing script

    Hi I've been working on this script in the last few days, and although it's not so small, I believe it can serve a few coding examples and provide some fun. It's idea is simple: It reads an image, makes it b/w, and using the mouse it draws this image. I made this to draw images on handwrite messages in MSN, but it can be tested in Paint or any other image editor. The image processing is done by capturing the image, and using the GetBitmapBits API to get the pixels' colors. Based on the pixels color and the set sensitivity, it will be either black or white (the black part is the one that is going to be drawn). The drawing was a little bit harder to get working on big images. To make it look more like drawing than like printing, the script draws black areas using recursion. In big areas this would overflow the call stack, so I use an array as a custom stack. The random drawing pattern is my favorite. This is practically useless, but I have a lot of fun using this in MSN. But people don't believe I draw that good... drawingscript.au3 mae.bmp
    1 point
  3. I am going to answer this question because the primary objective is not related to game automation at all, there are many legitimate applications which can be automated in a Windows server. This was my go-to approach, sad to know that it no longer doesn't work, perhaps you can try an older version of the server if that is a possibility? The problem happens because there is no display attached to the machine after the RDP client disconnects, RoR solved this issue by simulation a display connection from the same machine itself. I looked for other virtual display solutions, perhaps a driver which could simulate a virtual screen, but I couldn't find any. Here is a stackoverflow thread I started for reference: https://stackoverflow.com/questions/43841450/uiautomation-wont-work-in-windows-server-vps-if-i-am-not-connected-via-rdp
    1 point
  4. Jos, I mean to cast no aspersions towards the Wrapper, nor the Stripper, although I have not used them extensively they appear useful. My target problem is much narrower, though still a pain point. Let me explain a little about my current projects. I have been using autoit to write Unix like utilities running under bash/WSL for windows. As you can imagine, using the input output streams is of primary significance. Therefore my programs don’t “work” without being compiled as such*. So I am typically developing jobs that run from the command line in a bash shell. Anyway, as you might imagine I get more than a few runtime errors; these typically have the incorrect line number in them. Note that I am NOT speaking about the related issue of @Scriptlinenumber being off; I am talking about the unstoppable (IFAIK) run time errors, such as array bounds etc. So this is what I wrote to get the correct line number at run time, even without preprocessing. I made a short video to illustrate: I have looked thru what both you and @mLipok have referenced, but I fail to find this exact functionality. Timeline: 0:02 Start the ErrMsgHack job in the background 0:16 Compile an example job using stdio 0:25 Run the example job, intentionally created with an array subscript error 0:31 After running a few seconds, job crashes with an autoit error, line number is thousands too high. 0:32 The background job kicks in and calculated the correct line no and changes the error pop up. 0:45 I use the new error line number to inspect the code in the source. It may not seem like a lot, but it certainly has saved me a lot of time. I gathered that other people also would benefit from it based on other discussions. But if this is already solved, I don’t wish to add any confusion. Thanks for your time. *If you were to tell me I am wrong about this, I would be elated!
    1 point
  5. You can test your expressions by running the StringRegExpGUI.au3. You can find it where you installed your AutoIt suite. Usually it will be C:\Program Files (x86)\AutoIt3\Examples\Helpfile\StringRegExpGUI.au3
    1 point
  6. me too. @trancexx soultions in my case is used translate the error message and to make logs from such cases, and have nothing to do with providing the correct line number. But you can catch the line number and redirect them to console using ConsoleWrite(). But the window will pop up in the end.... Maybe @trancexx have or may provide solution, to catch the text, redirect them to another output (already easy to do), and do not show this MsgBox at all (currently I do not know how to omnit displaying this specific window)
    1 point
  7. This is a continuation of Custom drawn TreeViews and ListViews. However, only with respect to listviews. The crucial difference between the new and the old code is that the new code is a complete UDF and therefore much easier to use. Because the UDF is about colors and fonts in listview items and subitems, it's only for listviews in Details or Report view. Main features The UDF supports the following main features. Colors and fonts: 1 Single items/subitems Back colors Fore colors Fonts and styles 2 Colors/fonts for entire columns 3 Alternating colors (entire listview) Alternating colors for rows, columns or both Both default and alternating color can be set Number of rows/columns between color change can be set 4 Custom default colors/font instead of standard default colors/font Custom default back and fore colors can be set for Normal listview items (instead of white and black) Selected listview items (instead of dark blue and white) Unfocused selected items (instead of button face and black) 5 Colors for selected listview items Back and fore colors for selected items when listview has focus Back and fore colors for selected items when listview has not focus Features 1, 2 and 3 cannot be mixed together. 4 and 5 can be mixed with the previous features. 5 extends the functionality of the previous features by adding colors to selected items. 5 cannot be used alone. Listviews: Multiple listviews Native and non-native listviews Native and non-native listview items The UDF can be used with existing listviews WM_NOTIFY message handlers: WM_NOTIFY message handlers can be used completely as usual The UDF can be used with existing WM_NOTIFY message handlers Colors and fonts for single listview items/subitems are stored in an array. The index in this array for a given listview item is stored in ItemParam. Except for this usage of ItemParam nothing in the UDF assumes that listviews or items/subitems are created in a certain way, or that any WM_NOTIFY handlers exists or are designed in a certain way. It should be easy to use the UDF with existing listviews with or without a WM_NOTIFY message handler or other message handlers. WM_NOTIFY message handlers Colors and fonts in listviews are implemented through custom draw notifications in the form of WM_NOTIFY messages. A WM_NOTIFY message handler is needed to implement colors/fonts. If a listview is included in a GUI and a little more than just very basic functionality is wanted, another WM_NOTIFY handler is soon needed to implement this functionality. To register a WM_NOTIFY handler you use the function GUIRegisterMsg. This function can register only one message handler at a time for the same message type. The result of code like this is that only WM_NOTIFY2 message handler is working: GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY1" ) ; Register WM_NOTIFY1 GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY2" ) ; Register WM_NOTIFY2 (unregisters WM_NOTIFY1) This makes it difficult to implement colors/fonts in a UDF, if you at the same time want to implement advanced functionality in your own code. A solution is to register the WM_NOTIFY message handler, that takes care of custom draw notifications, in a different way. This can be done by a technique called subclassing, which is implemented through the four functions SetWindowSubclass, GetWindowSubclass, RemoveWindowSubclass and DefSubclassProc (coded in WinAPIShellEx.au3). Subclassing Subclassing a window (or control) means to create a message handler for the window, that will receive messages to the window before the original message handler for the window. This section is information on the implementation of a WM_NOTIFY message handler through subclassing: The UDF The UDF is implemented in UDFs\ListViewColorsFonts.au3. This is a list of the most important functions copied from the UDF (around line 200): ; Initiating and exiting ; ---------------------- ; ListViewColorsFonts_Init ; ListViewColorsFonts_Exit ; ; Set colors/fonts for items/subitems ; ----------------------------------- ; ListViewColorsFonts_SetItemColors ; ListViewColorsFonts_SetItemFonts ; ListViewColorsFonts_SetItemColorsFonts ; ; Set colors/fonts for entire listview ; ------------------------------------ ; ListViewColorsFonts_SetColumnColorsFonts ; ListViewColorsFonts_SetAlternatingColors ; ListViewColorsFonts_SetDefaultColorsFonts ; ; Maintenance functions ; --------------------- ; ListViewColorsFonts_Redraw Some of the functions in the complete list in the file are not coded in this version. To use the UDF you first calls ListViewColorsFonts_Init which stores information about the listview and the parent window, and creates the subclass that takes care of the actual drawing of the colors and fonts. Then you call one or more of the ListViewColorsFonts_Set-functions to define the colors and fonts. Depending on the functions you might also need to call ListViewColorsFonts_Redraw. And that's all. Finally you can call ListViewColorsFonts_Exit to remove the subclass before the script exits. If you don't call ListViewColorsFonts_Exit it's called automatically by the UDF. This is the syntax for ListViewColorsFonts_Init and the information about $fColorsFonts flag also copied from ListViewColorsFonts.au3: ; ListViewColorsFonts_Init( $idListView, $fColorsFonts = 7, $iAddRows = 100, $bNative = False ) ; $idListView - Listview control ID or handle ; $fColorsFonts - Specifies options for usage of colors and fonts in the listview. Add required options together. ; 1: Back colors for items/subitems ; Can not be specified separately in this version ; 2: Fore colors for items/subitems ; Can not be specified separately in this version ; 4: Fonts and styles for items/subitems ; Can not be specified separately in this version ; 7: Back and fore colors, fonts and styles ; Flags 1/2/4 are combined in flag 7 in this version ; ; 8: Colors/fonts for entire columns ; ; 16: Alternating row colors (for entire listview) ; 32: Alternating column colors (for entire listview) ; ; 64: Custom default colors and font (for entire listview) ; Custom default back and fore colors can be set for ; - Normal listview items (instead of white and black) ; - Selected listview items (instead of dark blue and white) ; - Unfocused selected listview items (instead of button face and black) ; ; 128: Colors for selected items when listview has focus ; 256: Colors for selected items when listview has not focus The limitations with respect to flags 1, 2 and 4 in this version is only a matter of optimizations. It has nothing to do with features. Drawing of selected items is largely controlled by Windows. A lot of extra code is needed to implement custom colors for selected items through flags 128 and 256. For $fColorsFonts flag is further noted that: ; - Flags 1/2/4 can be combined in a total of seven different ways ; - Flags 1/2/4 (items/subitems), flag 8 (columns) and flags 16/32 (listview) cannot be combined ; - Flag 64 is used to replace the standard default colors/font by custom default colors/font ; Flag 64 can be used alone or in combination with flags 1-32 ; Custom default colors/font must be set before all other colors/fonts ; Flag 64 leads to some restrictions on the features for items/subitems (flags 1/2/4) ; - Flags 128/256 extends the functionality of flags 1-64 by adding colors to selected items ; Flags 128/256 cannot be used alone An array $aListViewColorsFontsInfo is used to store information about the listview, the parent window and the usage of colors/fonts in the listview. For flags 1/2/4 about single items/subitems another array $aListViewColorsFonts is used to store the colors and fonts for the items and subitems. The number of columns in this array depends on whether the flags 128/256 are set or not. The first 160 lines in the UDF contains information about these arrays. For flags 1/2/4 ItemParam field in the listview is used to store the zero based row index in $aListViewColorsFonts for a given listview item. For native listview items created with GUICtrlCreateListViewItem the existing value of ItemParam (control ID) is used as index in an intermediate array $aListViewColorsFonts_Index, and $aListViewColorsFonts_Index holds the index in $aListViewColorsFonts stored as index+1. For non-native listview items the index in $aListViewColorsFonts is stored in ItemParam as -index-20. For non-native listview items an existing value of ItemParam is overwritten. The best way to add colors and fonts to listviews is to put each listview in its own child window. The child window should not contain any other controls, and it should have the same size as the listview. However, this is not a requirement. See the UDF for documentation of the other functions. The implementation of the functions starts in line 230 and onwards. The UDF also contains a group of internal functions. Among other the subclass callback functions to draw the colors and fonts in response to NM_CUSTOMDRAW notifications from the listview. So far the UDF contains seven callback functions which starts around line 2100 and runs over the next 1300 lines nearly to the bottom of the file. The code This section is about some code details related partly to the subclass callback functions and partly to drawing of selected items. Subclass callback functions: Drawing of selected items: In the current version of the UDF the callback function that is implemented to draw single items/subitems ($fColorsFonts = 1/2/4) is the function that can handle all features ($fColorsFonts = 1+2+4 = 7). If only a part of the features is needed, it's possible to create smaller and faster functions, which only implements this part of the features. These functions (six functions in total) are postponed to next version. Features A few comments on the features. The main features in terms of colors and fonts are (a repeat of the list in top of post): 1 Single items/subitems 2 Colors/fonts for entire columns 3 Alternating colors (entire listview) 4 Custom default colors/font instead of standard default colors/font 5 Colors for selected listview items 1, 2 and 3 are features for different kind of elements in the listview and cannot be mixed together. 4 can be used either as an independent feature or mixed with 1, 2 or 3. 5 cannot be used as an independent feature but can only be used together with 1, 2, 3 or 4. 5 extends the functionality of these features by adding colors to selected items. When features 1, 4 and 5 are mixed together, it may look as shown in the following illustrations (screen dumps of examples 3.1 and 4.1 in folder \Examples\5) Selected items\). The first illustration shows how it looks when colors for single items/subitems are mixed with colors for selected items: In the upper picture rows 3-6 are provided with back and fore colors. All subitems in row 3 and 4. Only a few subitems in row 5 and 6. The rows are normal (unselected) rows. In the middle picture rows 2-7 are selected and the listview has focus. Rows 3-6 are also provided with back and fore colors for selected items. In the lower picture rows 2-7 are selected but the listview has not focus. Rows 3-6 are also provided with back and fore colors for selected but unfocused items. In the second illustration the standard default colors are replace with custom default colors. The standard default back and fore colors are: Normal (unselected) items: White and black Selected items in focused listview: Dark blue and white Selected items in unfocused listview: Button face and black These custom default colors are used in the illustration: Normal (unselected) items: Light green and brown Selected items in focused listview: Shiny green (chartreuse) and black Selected items in unfocused listview: Dark green and black Examples Two folders with examples is included in the zip below. The first folder is named Examples and contains examples about the usage of the functions in the UDF. The second folder is named UDF topics and contains examples related to the implementation of the UDF. It's about the use of the subclassing technique as a substitute for a WM_NOTIFY message handler. Particularly about the message flow and performance issues. These examples are addressed in next section. The Examples folder contains these subfolders and files: 0) UDF examples\ - The small examples from the documentation of the functions in the UDF 1) Items-subitems\ - Colors and fonts for single items/subitems 2) Entire columns\ - Colors and fonts for entire columns 3) Alternating colors\ - Alternating row/column colors in an entire listview 4) Custom defaults\ - Replace standard default colors/font with custom defaults 5) Selected items\ - Colors for selected items when listview has focus and has not focus 6) Help file examples\ - Shows how to add colors to a few examples from AutoIt Help file 7) Original examples\ - An implementation of the examples in the old thread with this UDF Listview templates\ - A collection of listview templates ready to add colors/fonts Features demo.au3 - A brief demonstration of all features No colors or fonts.au3 - Reference example All examples runs on Windows XP and later without any performance issues. Folder 1 - 5 demonstrates the five main color/font features listed in top of post. In most of the subfolders you can find a _Readme.txt file with a brief description of the examples. Multiple selections is enabled in most listviews. A few examples will not pass an Au3Check. In particular the examples in subfolder 1 and 2 and the examples in UDF topics folder (see next section) were used to test the subclassing technique as a substitute for a WM_NOTIFY message handler. More information about some of the examples: Examples\0) UDF examples\0) ListViewColorsFonts_Init\Example 1.au3: #include <GUIConstantsEx.au3> #include "..\..\..\UDFs\ListViewColorsFonts.au3" #include "..\..\..\UDFs\GuiListViewEx.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create GUI Local $hGui = GUICreate( "ListViewColorsFonts_Init\Example 1", 420, 200, -1, -1, $GUI_SS_DEFAULT_GUI-$WS_MINIMIZEBOX ) ; Create ListView Local $idListView = GUICtrlCreateListView( "", 10, 10, 400, 180, $GUI_SS_DEFAULT_LISTVIEW-$LVS_SINGLESEL, $WS_EX_CLIENTEDGE ) _GUICtrlListView_SetExtendedListViewStyle( $idListView, $LVS_EX_DOUBLEBUFFER+$LVS_EX_FULLROWSELECT ) Local $hListView = GUICtrlGetHandle( $idListView ) ; Reduces flicker ; Add columns to ListView _GUICtrlListView_AddColumn( $idListView, "Column 1", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 2", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 3", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 4", 94 ) ; Fill ListView Local $iItems = 100 For $i = 0 To $iItems - 1 GUICtrlCreateListViewItem( $i & "/Column 1|" & $i & "/Column 2|" & $i & "/Column 3|" & $i & "/Column 4", $idListView ) Next ; Perform initializations to add colors/fonts to single items/subitems ListViewColorsFonts_Init( $idListView, 7 ) ; $fColorsFonts = 7, ( $iAddRows = 100, $bNative = False ) ; Set a green back color for an entire item and a yellow back color for a single cell ListViewColorsFonts_SetItemColors( $idListView, 3, -1, 0xCCFFCC ) ; Green back color for entire item ListViewColorsFonts_SetItemColors( $idListView, 3, 2, 0xFFFFCC ) ; Yellow back color for cell 2 in item ; Force an update of local variables in drawing function ListViewColorsFonts_Redraw( $idListView ) ; Adjust height of GUI and ListView to fit ten rows Local $iLvHeight = _GUICtrlListView_GetHeightToFitRows( $hListView, 10 ) WinMove( $hGui, "", Default, Default, Default, WinGetPos( $hGui )[3] - WinGetClientSize( $hGui )[1] + $iLvHeight + 20 ) WinMove( $hListView, "", Default, Default, Default, $iLvHeight ) ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Delete color/font info for listview ListViewColorsFonts_Exit( $idListView ) GUIDelete() EndFunc UDF topics The examples in UDF topics folder is about the use of subclassing as a substitute for a WM_NOTIFY message handler. Particularly about the message flow and performance issues. These examples illustrates some of the issues, that was discussed in the Subclassing section above, with code. The UDF topics folder contains these subfolders: 1) Subclassing\ - Creating listviews in GUI or child windows? 2) Performance\ - How many listviews can you create in GUI? More information about the examples: Next version In The code section above is already mentioned a number of subclass callback functions which are postponed to next version. The purpose of these additional functions is merely to optimize the code in terms of speed. A number of ListViewColorsFonts_Get-functions to complement the corresponding ListViewColorsFonts_Set-functions are also deferred to next version. For single items/subitems ($fColorsFonts = 1/2/4) colors and fonts are stored in $aListViewColorsFonts array which again is stored in $aListViewColorsFontsInfo. The three functions ListViewColorsFonts_SetItemColors / SetItemFonts / SetItemColorsFonts are used to update $aListViewColorsFonts item by item or subitem by subitem. It would be much faster to update $aListViewColorsFonts directly. Two functions are needed to get a copy of the array from $aListViewColorsFontsInfo and store the array again after the updates. And there is also a need for a couple of examples to illustrate the technique. Examples to dynamically update colors and fonts are missing in this version. Perhaps there is also a need for a few functions to support dynamically updates. For non-native listviews created with _GUICtrlListView_Create it's not uncommon to use ItemParam to store a user defined value. If index in $aListViewColorsFonts is stored in ItemParam, it's no longer possible to use ItemParam for such purposes. A couple of functions to give the user an opportunity to still be able to store a user defined value would be nice. Several global variables are defined in this version. They will be removed in the next version except for a few variables which probably will need to be global in performance terms. If there will be reported any issues or problems in this version, they of course also need to be addressed. The next version should be ready in 2-3 months, and it should also be the final version. Zip file The zip is structured in this way Examples\ UDF topics\ UDFs\ ListViewColorsFonts.au3 GuiImageListEx.au3 GuiListViewEx.au3 NamedColors.au3 OtherColors.au3 NamedColors.au3 contains global constants of named colors copied from .NET Framework Colors Class. You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. (Set tab width = 2 in SciTE to line up comments by column.) ListViewColorsFonts.7z
    1 point
  8. Beege

    Explorer ListView UDF

    Here is a UDF I created to help me simplify creating MS Explorer-like ListViews.. It handles a lot of the overhead involved with working with them. Please let me know if theres something you don't understand or think I didnt explain well enough. Explaining things is always the hardest part for me. Example #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <File.au3> #include <ExpListView.au3> OnAutoItExitRegister('_Exit') Global $sRestore = @ScriptDir & '\Restore.ini' $hGUI = GUICreate("GUI", 849, 417) Global $hList1 = _ExpListView_Create($hGUI, 'c:\', 13, False, 29, 43, 385, 253) Global $hList2 = _ExpListView_Create($hGUI, 'My Computer', 28, False, 437, 43, 385, 253) ;This restores the columns to whatever they were the last time you exited the script. ;see exit function for saving views. If FileExists($sRestore) Then _ExpListView_ColumnViewsRestore($hList1, IniRead($sRestore, 'ListViews', 'List1', '')) _ExpListView_ColumnViewsRestore($hList2, IniRead($sRestore, 'ListViews', 'List2', '')) EndIf Global $sCurrentDirectory1 = GUICtrlCreateLabel("", 72, 12, 344, 26) Global $sCurrentDirectory2 = GUICtrlCreateLabel("", 477, 13, 344, 26) $setColunms1 = GUICtrlCreateButton("Set Columns", 138, 330, 67, 25, $WS_GROUP) $Checkbox1 = GUICtrlCreateCheckbox("Size", 138, 360, 79, 19) $Checkbox2 = GUICtrlCreateCheckbox("Modified", 234, 330, 79, 19) $Checkbox3 = GUICtrlCreateCheckbox("Attributes", 330, 330, 79, 19) $Checkbox4 = GUICtrlCreateCheckbox("Creation", 234, 360, 79, 19) $Checkbox5 = GUICtrlCreateCheckbox("Accessed", 330, 360, 79, 19) $Back1 = GUICtrlCreateButton("Back", 42, 312, 61, 25, $WS_GROUP) $Label1 = GUICtrlCreateLabel("Current:", 30, 12, 38, 17) $Label3 = GUICtrlCreateLabel("Current:", 435, 13, 38, 17) $Group1 = GUICtrlCreateGroup("Colunms", 126, 306, 289, 91) GUICtrlCreateGroup("", -99, -99, 1, 1) $ShowHidden1 = GUICtrlCreateButton("Hidden", 42, 342, 61, 25, $WS_GROUP) $input1 = GUICtrlCreateButton("Input", 42, 372, 61, 25, $WS_GROUP) $Group2 = GUICtrlCreateGroup("Colunms", 534, 306, 289, 91) GUICtrlCreateGroup("", -99, -99, 1, 1) $setColunms2 = GUICtrlCreateButton("Set Columns", 546, 330, 67, 25, $WS_GROUP) $Checkbox6 = GUICtrlCreateCheckbox("Size", 546, 360, 79, 19) $Checkbox7 = GUICtrlCreateCheckbox("Modified", 642, 330, 79, 19) $Checkbox8 = GUICtrlCreateCheckbox("Attributes", 738, 330, 79, 19) $Checkbox9 = GUICtrlCreateCheckbox("Creation", 642, 360, 79, 19) $Checkbox10 = GUICtrlCreateCheckbox("Accessed", 738, 360, 79, 19) $Back2 = GUICtrlCreateButton("Back", 450, 312, 61, 25, $WS_GROUP) $ShowHidden2 = GUICtrlCreateButton("Hidden", 450, 342, 61, 25, $WS_GROUP) $input2 = GUICtrlCreateButton("Input", 450, 372, 61, 25, $WS_GROUP) GUICtrlSetData($sCurrentDirectory1, _ExpListView_DirGetCurrent($hList1)) GUICtrlSetData($sCurrentDirectory2, _ExpListView_DirGetCurrent($hList2)) ;Here I set a function to update the Current Directory everytime the user changes directory by double clicking. ;This function is ONLY called on a double click event. Each Listview could have its own function if needed. _ExpListView_SetFunction($hList1, '_Call_Function') _ExpListView_SetFunction($hList2, '_Call_Function') GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Back1 _ExpListView_Back($hList1) GUICtrlSetData($sCurrentDirectory1, _ExpListView_DirGetCurrent($hList1)) Case $Back2 _ExpListView_Back($hList2) GUICtrlSetData($sCurrentDirectory2, _ExpListView_DirGetCurrent($hList2)) Case $setColunms1 Local $iColumn_Value = 0 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $iColumn_Value += 1 If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $iColumn_Value += 2 If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then $iColumn_Value += 4 If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then $iColumn_Value += 8 If GUICtrlRead($Checkbox5) = $GUI_CHECKED Then $iColumn_Value += 16 _ExpListView_SetColumns($hList1, $iColumn_Value) Case $setColunms2 Local $iColumn_Value = 0 If GUICtrlRead($Checkbox6) = $GUI_CHECKED Then $iColumn_Value += 1 If GUICtrlRead($Checkbox7) = $GUI_CHECKED Then $iColumn_Value += 2 If GUICtrlRead($Checkbox8) = $GUI_CHECKED Then $iColumn_Value += 4 If GUICtrlRead($Checkbox9) = $GUI_CHECKED Then $iColumn_Value += 8 If GUICtrlRead($Checkbox10) = $GUI_CHECKED Then $iColumn_Value += 16 _ExpListView_SetColumns($hList2, $iColumn_Value) Case $ShowHidden1 Local $flag = _ToggleHidden($hList1) _ExpListView_ShowHiddenFiles($hList1, $flag) _ExpListView_Refresh($hList1) Case $ShowHidden2 Local $flag = _ToggleHidden($hList2) _ExpListView_ShowHiddenFiles($hList2, $flag) _ExpListView_Refresh($hList2) Case $input1 Local $inputbox = InputBox('Directory Change', 'Enter the Directory to Navigate to:', '', ' M', Default, 130) _ExpListView_DirSetCurrent($hList1, $inputbox) GUICtrlSetData($sCurrentDirectory1, _ExpListView_DirGetCurrent($hList1)) Case $input2 Local $inputbox = InputBox('Directory Change', 'Enter the Directory to Navigate to:', '', ' M', Default, 130) _ExpListView_DirSetCurrent($hList2, $inputbox) GUICtrlSetData($sCurrentDirectory2, _ExpListView_DirGetCurrent($hList2)) EndSwitch WEnd ;hWnd is the only parameter needed for the call function you create. Func _Call_Function($hWnd) Switch $hWnd Case $hList1 GUICtrlSetData($sCurrentDirectory1, _ExpListView_DirGetCurrent($hWnd)) Case $hList2 GUICtrlSetData($sCurrentDirectory2, _ExpListView_DirGetCurrent($hWnd)) EndSwitch EndFunc ;==>_Call_Function Func _ToggleHidden($List) Static $bFlag1 = -1, $bFlag2 = -1 Switch $List Case $hList1 $bFlag1 *= -1 If $bFlag1 = -1 Then Return False Case $hList2 $bFlag2 *= -1 If $bFlag2 = -1 Then Return False EndSwitch Return True EndFunc ;==>_ToggleHidden ;Here we have a simple exit function that saves the column info so we can reload it at startup. Func _Exit() If Not FileExists($sRestore) Then _FileCreate($sRestore) IniWrite($sRestore, 'ListViews', 'List1', _ExpListView_ColumnViewsSave($hList1)) IniWrite($sRestore, 'ListViews', 'List2', _ExpListView_ColumnViewsSave($hList2)) EndFunc ;==>_Exit UDF #Region Header ; #INDEX# ======================================================================================================================= ; Title .........: ExpListView ; AutoIt Version : 3.3.5.0 ; Language ......: English ; Description ...: Functions for working with Explorer ListViews. ; Author(s) .....: Beege ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _ExpListView_Create ; _ExpListView_Back ; _ExpListView_DirGetCurrent ; _ExpListView_DirSetCurrent ; _ExpListView_SetColumns ; _ExpListView_SetFunction ; _ExpListView_ShowHiddenFiles ; _ExpListView_Refresh ; _ExpListView_ColumnViewsSave ; _ExpListView_ColumnViewsRestore ; =============================================================================================================================== #include-once #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <array.au3> GUIRegisterMsg($WM_NOTIFY, "EXPLORER_WM_NOTIFY") OnAutoItExitRegister('__EXIT') #EndRegion Header #Region Global Variables and Constants Global $Shell32 = DllOpen('shell32.dll') Global Const $FOLDER_ICON_INDEX = _GUIImageList_GetFileIconIndex(@SystemDir, 0, 1) Global $aListViews[1][7] = [[0, 'Current Dir', 'Dir History', 'Columns', 'Function', 'ColumnWidths', 'ShowHidden']] #cs $aListViews[0][0] = List Count [0][1-6] = Nothing $aListViews[$i][0] = hwnd [$i][1] = Current Directory [$i][2] = Directory History [$i][3] = Columns-Value :filesize = 1, modified = 2,Attributes = 4, Creation = 8, Accessed = 16 [$i][4] = Function to Call [$i][5] = Column Widths [$i][6] = Show Hidden Files Flag #ce #EndRegion Global Variables and Constants #Region Public Functions ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_Create ; Description ...: Create a ExpListView control ; Syntax.........: _ExpListView_Create($hWnd, $sStartDir, $iColumns, $bShowHidden = False, $iX = 1, $iY = 1, [, $iWidth = 150[, $iHeight = 150[, $iStyle = 0x0000000D[, $iExStyle = 0x00000000[, $fCoInit = False]]]]]) ; Parameters ....: $hWnd - Handle to parent or owner window ; $sStartDir - Directory to start ListView in ; $iColumns - This Flag value indicates which columns will be displayed. See Remarks ; $bShowHidden - This Flag value indicates weather hidden files will be displayed or not. ; $iX - Horizontal position of the control ; $iY - Vertical position of the control ; $iWidth - Control width ; $iHeight - Control height ; $iStyle - Control styles: See _GUICtrlListView_Create() for Styles ; $iExStyle - Extended control styles. See _GUICtrlListView_Create() for Extended Styles ; $fCoInit - Initializes the COM library for use by the calling thread. ; Return values .: Success - Handle to the ListView control ; Failure - 0 ; Author ........: Beege ; Remarks .......: The iColumns flag parameter can be a combination of the following values added together: ; 1 - File Size ; 2 - Last Modified ; 4 - Attributes ; 8 - Creation ; 16 - Last Accessed ; Ex: If you wanted to show columns File size, Attributes and Creation, Flag Value would be 1+4+8 = 13 ; Related .......: _GUICtrlListView_Create ; =============================================================================================================================== Func _ExpListView_Create($hWnd, $sStartDir, $iColumns, $bShowHidden = False, $iX = 1, $iY = 1, $iWidth = 150, $iHeight = 150, $iStyle = 0x0000000D, $iExStyle = 0x00000000, $fCoInit = False) Local $hListView = _GUICtrlListView_Create($hWnd, 'Name', $iX, $iY, $iWidth, $iHeight, $iStyle, $iExStyle, $fCoInit) If $hListView = 0 Then Return SetError(1, @extended, 0) _GUICtrlListView_SetImageList($hListView, _GUIImageList_GetSystemImageList(), 1) ReDim $aListViews[UBound($aListViews) + 1][UBound($aListViews, 2)] $aListViews[0][0] += 1 $aListViews[$aListViews[0][0]][0] = $hListView $aListViews[$aListViews[0][0]][1] = $sStartDir $aListViews[$aListViews[0][0]][5] = '50;50;50;50;50' $aListViews[$aListViews[0][0]][6] = $bShowHidden _ExpListView_SetColumns($hListView, $iColumns, False) _ChangeDir($aListViews[0][0], $sStartDir, False) Return $hListView EndFunc ;==>_ExpListView_Create ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_Back ; Description ...: Navigates ListView Back to previous Directorys ; Syntax.........: _ExpListView_Back($hWnd) ; Parameters ....: $hWnd - HWnd returned from _ExpListView_Create() ; Return values .: Success - 1 ; Failure - 0 and sets @ERROR: ; - 1 Invalid hWnd ; Author ........: Beege ; Remarks .......: Function returns a 2 and does not set error if the History Stack is Empty ; =============================================================================================================================== Func _ExpListView_Back($hWnd) Local $iArrayIndex = _GetIndex($hWnd) If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd Local $sPop = _HistoryPoP($iArrayIndex) If $sPop = -1 Then Return 2;History Stack is empty _ChangeDir($iArrayIndex, $sPop, False) Return 1 EndFunc ;==>_ExpListView_Back ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_DirGetCurrent ; Description ...: Gets ListView Current Directory ; Syntax.........: _ExpListView_DirGetCurrent($hWnd) ; Parameters ....: $hWnd - HWnd returned from _ExpListView_Create() ; Return values .: Success - Directory Name ; Failure - 0 and sets @ERROR: ; - 1 Invalid hWnd ; Author ........: Beege ; Remarks .......: - ; =============================================================================================================================== Func _ExpListView_DirGetCurrent($hWnd) Local $iArrayIndex = _GetIndex($hWnd) If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd Return $aListViews[$iArrayIndex][1] EndFunc ;==>_ExpListView_DirGetCurrent ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_DirSetCurrent ; Description ...: Sets ListView Current Directory ; Syntax.........: _ExpListView_DirSetCurrent($hWnd, $sDirectory) ; Parameters ....: $hWnd - HWnd returned from _ExpListView_Create() ; Return values .: Success - 1 ; Failure - 0 and sets @ERROR: ; - 1 Invalid hWnd ; Author ........: Beege ; Remarks .......: - ; =============================================================================================================================== Func _ExpListView_DirSetCurrent($hWnd, $sDirectory) Local $iArrayIndex = _GetIndex($hWnd) If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd If Not FileExists($sDirectory) Then Return SetError(2, @extended, 0) ;invalad Directory _ChangeDir($iArrayIndex, $sDirectory) Return 1 EndFunc ;==>_ExpListView_DirSetCurrent ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_SetColumns ; Description ...: Sets ListView Column Flag value indicating which columns to show. ; Syntax.........: _ExpListView_SetColumns($hWnd, $iColunms, $bRefresh = True) ; Parameters ....: $hWnd - HWnd returned from _ExpListView_Create() ; $iColumns - Column Flag Value. See Remarks ; $bRefresh - Flag indicating weather to refresh listview after setting columns ; Return values .: Success - 1 ; Failure - 0 and sets @ERROR: ; - 1 Invalid hWnd ; Author ........: Beege ; Remarks .......: The iColumns flag parameter can be a combination of the following values: ; 1 - File Size ; 2 - Last Modified ; 4 - Attributes ; 8 - Creation ; 16 - Last Accessed ; Ex: If you wanted to show columns File size, Attributes and Creation, Flag Value would be 1+4+8 = 13 ; =============================================================================================================================== Func _ExpListView_SetColumns($hWnd, $iColunms, $bRefresh = True) Local $iArrayIndex = _GetIndex($hWnd) If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd _SaveColunmWidths($iArrayIndex, $hWnd) $aListViews[$iArrayIndex][3] = $iColunms _SetColumnsWidths($iArrayIndex, $hWnd) If $bRefresh Then _ChangeDir($iArrayIndex, $aListViews[$iArrayIndex][1], False) Return 1 EndFunc ;==>_ExpListView_SetColumns ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_SetFunction ; Description ...: Sets a function to call after a Double-Click(Navigation) Event has happened. ; Syntax.........: _ExpListView_SetFunction($hWnd, $sFunction) ; Parameters ....: $hWnd - HWnd returned from _ExpListView_Create() ; $sFunction - Function to Call ; Return values .: Success - 1 ; Failure - 0 and sets @ERROR: ; - 1 Invalid hWnd ; Author ........: Beege ; Remarks .......: User function needs to have one parameter. That parameter is the Hwnd of the ListView that recived the Event. ; Ex: Func MyUserFunction($hWndListView) ; ... ; EndFunc ; =============================================================================================================================== Func _ExpListView_SetFunction($hWnd, $sFunction) Local $iArrayIndex = _GetIndex($hWnd) If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd $aListViews[$iArrayIndex][4] = $sFunction Return 1 EndFunc ;==>_ExpListView_SetFunction ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_ShowHiddenFiles ; Description ...: Sets Current ListView Directory ; Syntax.........: _ExpListView_ShowHiddenFiles($hWnd, $bShowHidden) ; Parameters ....: $hWnd - HWnd returned from _ExpListView_Create() ; $bShowHidden - This Flag value indicates weather hidden files will be displayed or not. True or False ; Return values .: Success - 1 ; Failure - 0 and sets @ERROR: ; - 1 Invalid hWnd ; - 2 Invalid Flag ; Author ........: Beege ; Remarks .......: ExpListViews are created with default showhidden flag being False ; =============================================================================================================================== Func _ExpListView_ShowHiddenFiles($hWnd, $bShowHidden) Local $iArrayIndex = _GetIndex($hWnd) If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd If $bShowHidden Or Not $bShowHidden Then $aListViews[$iArrayIndex][6] = $bShowHidden Return 1 EndIf Return SetError(2, @extended, 0);invalad Flag EndFunc ;==>_ExpListView_ShowHiddenFiles ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_Refresh ; Description ...: Refreshes ExpListView ; Syntax.........: _ExpListView_Refresh($hWnd) ; Parameters ....: $hWnd - HWnd returned from _ExpListView_Create() ; Return values .: Success - 1 ; Failure - 0 and sets @ERROR: ; - 1 Invalid hWnd ; Author ........: Beege ; Remarks .......: - ; =============================================================================================================================== Func _ExpListView_Refresh($hWnd) Local $iArrayIndex = _GetIndex($hWnd) If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd _ChangeDir($iArrayIndex, $aListViews[$iArrayIndex][1], False) EndFunc ;==>_ExpListView_Refresh ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_ColumnViewsSave ; Description ...: Gets string representing info about column widths and values ; Syntax.........: _ExpListView_ColumnViewsSave($hWnd) ; Parameters ....: $hWnd - HWnd returned from _ExpListView_Create() ; Return values .: Success - String ; Failure - 0 and sets @ERROR: ; - 1 Invalid hWnd ; Author ........: Beege ; Remarks .......: String is to be used with _ExpListView_ColumnViewsRestore() function. ; =============================================================================================================================== Func _ExpListView_ColumnViewsSave($hWnd) Local $iArrayIndex = _GetIndex($hWnd) If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd _SaveColunmWidths($iArrayIndex, $hWnd) Return ($aListViews[$iArrayIndex][3] & '|' & _GUICtrlListView_GetColumnWidth($hWnd, 0) & '|' & $aListViews[$iArrayIndex][5]) EndFunc ;==>_ExpListView_ColumnViewsSave ; #FUNCTION# ==================================================================================================================== ; Name...........: _ExpListView_ColumnViewsRestore ; Description ...: Restores ExpListViews Columns and Column Sizes ; Syntax.........: _ExpListView_ColumnViewsRestore($hWnd, $sColumnViews) ; Parameters ....: $hWnd - HWnd returned from _ExpListView_Create() ; $sColumnViews - String Returned from _ExpListView_ColumnViewsSave() ; Return values .: Success - String ; Failure - 0 and sets @ERROR: ; - 1 Invalid hWnd ; Author ........: Beege ; Remarks .......: - ; =============================================================================================================================== Func _ExpListView_ColumnViewsRestore($hWnd, $sColumnViews) Local $iArrayIndex = _GetIndex($hWnd) If $iArrayIndex = -1 Then Return SetError(1, @extended, 0);invald hWnd Local $aSplit = StringSplit($sColumnViews, '|') _GUICtrlListView_SetColumnWidth($hWnd, 0, $aSplit[2]) $aListViews[$iArrayIndex][5] = $aSplit[3] _SetColumnsWidths($iArrayIndex, $hWnd) _ExpListView_SetColumns($hWnd, $aSplit[1]) EndFunc ;==>_ExpListView_ColumnViewsRestore #EndRegion Public Functions #Region Internal Functions Func EXPLORER_WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Local $iCode = DllStructGetData($tNMHDR, "Code") If $iCode = $NM_DBLCLK Then ; Sent by a list-view control when the user double-clicks an item with the left mouse button Local $hWndFrom, $tInfo, $iArrayIndex $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $iArrayIndex = _GetIndex($hWndFrom) _GetChangeDir($iArrayIndex, DllStructGetData($tInfo, "Index")) If $aListViews[$iArrayIndex][4] <> '' Then Call($aListViews[$iArrayIndex][4], $hWndFrom) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>EXPLORER_WM_NOTIFY Func _SetColumnsWidths($iArrayIndex, $hWnd) Local $iColumnCount = _GUICtrlListView_GetColumnCount($hWnd) For $i = 1 To $iColumnCount _GUICtrlListView_DeleteColumn($hWnd, 1) Next Local $aColumnWidths = StringSplit($aListViews[$iArrayIndex][5], ';') If BitAND($aListViews[$iArrayIndex][3], 1) Then _GUICtrlListView_AddColumn($hWnd, 'Size', Int($aColumnWidths[1])) If BitAND($aListViews[$iArrayIndex][3], 2) Then _GUICtrlListView_AddColumn($hWnd, 'Modified', Int($aColumnWidths[2])) If BitAND($aListViews[$iArrayIndex][3], 4) Then _GUICtrlListView_AddColumn($hWnd, 'Attributes', Int($aColumnWidths[3])) If BitAND($aListViews[$iArrayIndex][3], 8) Then _GUICtrlListView_AddColumn($hWnd, 'Creation', Int($aColumnWidths[4])) If BitAND($aListViews[$iArrayIndex][3], 16) Then _GUICtrlListView_AddColumn($hWnd, 'Accessed', Int($aColumnWidths[5])) EndFunc ;==>_SetColumnsWidths Func _SaveColunmWidths($iArrayIndex, $hWnd) Local $i, $aColumnWidths, $iColunmValue = 1, $iColunmIndex = 1 $aColumnWidths = StringSplit($aListViews[$iArrayIndex][5], ';') For $i = 1 To 5 If BitAND($aListViews[$iArrayIndex][3], $iColunmValue) Then $aColumnWidths[$i] = _GUICtrlListView_GetColumnWidth($hWnd, $iColunmIndex) $iColunmIndex += 1 EndIf $iColunmValue += $iColunmValue Next $aListViews[$iArrayIndex][5] = _ArrayToString($aColumnWidths, ';', 1) EndFunc ;==>_SaveColunmWidths Func _GetIndex($hWnd) Local $i For $i = 1 To $aListViews[0][0] If $aListViews[$i][0] = $hWnd Then Return $i Next Return -1 EndFunc ;==>_GetIndex Func _ParentDirectory($iArrayIndex) Local $aDirSplit, $sChangeDir $aDirSplit = StringSplit($aListViews[$iArrayIndex][1], '\') If $aDirSplit[0] = 2 Then If $aDirSplit[2] = '' Then $sChangeDir = 'My Computer' Else $sChangeDir = $aDirSplit[1] & '\' EndIf Else For $i = 1 To $aDirSplit[0] - 1 $sChangeDir &= $aDirSplit[$i] & '\' Next $sChangeDir = StringTrimRight($sChangeDir, 1) EndIf _ChangeDir($iArrayIndex, $sChangeDir) EndFunc ;==>_ParentDirectory Func _GetChangeDir($iArrayIndex, $iListIndex) Local $sChangeDir, $sItemText = _GUICtrlListView_GetItemText($aListViews[$iArrayIndex][0], $iListIndex) Select Case $sItemText = '[..]' _ParentDirectory($iArrayIndex) Return Case $aListViews[$iArrayIndex][1] = 'My Computer' $sChangeDir = StringMid($sItemText, StringInStr($sItemText, '(') + 1, 2) & '\' Case Else If StringRight($aListViews[$iArrayIndex][1], 1) = '\' Then $sChangeDir = $aListViews[$iArrayIndex][1] & $sItemText Else $sChangeDir = $aListViews[$iArrayIndex][1] & '\' & $sItemText EndIf If StringInStr(FileGetAttrib($sChangeDir), 'D') = 0 Then Return EndSelect _ChangeDir($iArrayIndex, $sChangeDir) EndFunc ;==>_GetChangeDir Func _ChangeDir($iArrayIndex, $sDirectory, $bPushHistory = True) If $sDirectory = 'My Computer' Then If $bPushHistory Then _HistoryPush($iArrayIndex, $aListViews[$iArrayIndex][1]) _MyComputer($iArrayIndex) Return EndIf Local $aList, $sFile, $sAttributes, $iIcon, $iItem, $iSize, $aTime, $iColumnIndex = 1 _GUICtrlListView_DeleteAllItems($aListViews[$iArrayIndex][0]) $aList = _FileListToArray_mod($sDirectory) _GUICtrlListView_BeginUpdate($aListViews[$iArrayIndex][0]) _GUICtrlListView_AddItem($aListViews[$iArrayIndex][0], "[..]", $FOLDER_ICON_INDEX) If IsArray($aList) Then For $i = 1 To $aList[0] $sFile = $sDirectory & '\' & $aList[$i] $sAttributes = FileGetAttrib($sFile) If Not $aListViews[$iArrayIndex][6] Then;ShowHidden If StringInStr($sAttributes, 'H') > 0 Then ContinueLoop EndIf If StringInStr($sAttributes, 'D') > 0 Then $iIcon = $FOLDER_ICON_INDEX Else $iIcon = _GUIImageList_GetFileIconIndex($aList[$i]) EndIf $iItem = _GUICtrlListView_AddItem($aListViews[$iArrayIndex][0], $aList[$i], $iIcon) ; If BitAND($aListViews[$iArrayIndex][3], 1) Then ;size If $iIcon = $FOLDER_ICON_INDEX Then _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, 'DIR', $iColumnIndex) Else $iSize = FileGetSize($sFile) _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, _bytes($iSize), $iColumnIndex) EndIf $iColumnIndex += 1 EndIf If BitAND($aListViews[$iArrayIndex][3], 2) Then ;Modified $aTime = FileGetTime($sFile, 0) _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, $aTime[0] & '/' & $aTime[1] & '/' & $aTime[2] & ' ' & $aTime[3] & ':' & $aTime[4] & ':' & $aTime[5], $iColumnIndex) $iColumnIndex += 1 EndIf If BitAND($aListViews[$iArrayIndex][3], 4) Then ;Attributes _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, $sAttributes, $iColumnIndex) $iColumnIndex += 1 EndIf If BitAND($aListViews[$iArrayIndex][3], 8) Then;Creation $aTime = FileGetTime($sFile, 1) _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, $aTime[0] & '/' & $aTime[1] & '/' & $aTime[2] & ' ' & $aTime[3] & ':' & $aTime[4] & ':' & $aTime[5], $iColumnIndex) $iColumnIndex += 1 EndIf If BitAND($aListViews[$iArrayIndex][3], 16) Then;Accessed $aTime = FileGetTime($sFile, 2) _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $iItem, $aTime[0] & '/' & $aTime[1] & '/' & $aTime[2] & ' ' & $aTime[3] & ':' & $aTime[4] & ':' & $aTime[5], $iColumnIndex) $iColumnIndex += 1 EndIf $iColumnIndex = 1 Next EndIf _GUICtrlListView_EndUpdate($aListViews[$iArrayIndex][0]) If $bPushHistory Then _HistoryPush($iArrayIndex, $aListViews[$iArrayIndex][1]) $aListViews[$iArrayIndex][1] = $sDirectory EndFunc ;==>_ChangeDir Func _MyComputer($iArrayIndex) Local $drives, $attributes, $item, $Time, $iColunmIndex = 1 $aListViews[$iArrayIndex][1] = 'My Computer' _GUICtrlListView_DeleteAllItems($aListViews[$iArrayIndex][0]) $drives = DriveGetDrive("ALL") For $i = 1 To $drives[0] $item = _GUICtrlListView_AddItem($aListViews[$iArrayIndex][0], DriveGetLabel($drives[$i] & '\') & ' (' & StringUpper($drives[$i]) & ')', _GUIImageList_GetFileIconIndex($drives[$i] & '\')) If BitAND($aListViews[$iArrayIndex][3], 1) Then ;size _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $item, 'DIR', $iColunmIndex) $iColunmIndex += 1 EndIf If BitAND($aListViews[$iArrayIndex][3], 2) Then $iColunmIndex += 1;Modified If BitAND($aListViews[$iArrayIndex][3], 4) Then;Attributes $attributes = FileGetAttrib($drives[$i] & '\') _GUICtrlListView_AddSubItem($aListViews[$iArrayIndex][0], $item, $attributes, $iColunmIndex) EndIf $iColunmIndex = 1 Next EndFunc ;==>_MyComputer Func _HistoryPush($iArrayIndex, $sDir) $aListViews[$iArrayIndex][2] = $sDir & '|' & $aListViews[$iArrayIndex][2] EndFunc ;==>_HistoryPush Func _HistoryPoP($iArrayIndex) Local $aSplit = StringSplit($aListViews[$iArrayIndex][2], '|', 2) If $aSplit[0] = '' Then Return -1 Local $sReturn = $aSplit[0] _ArrayDelete($aSplit, 0) $aListViews[$iArrayIndex][2] = _ArrayToString($aSplit, '|') Return $sReturn EndFunc ;==>_HistoryPoP Func _FileListToArray_mod($sPath, $sFilter = "*", $iFlag = 0) Local $hSearch, $sFile, $sFileList, $sFolderList, $sDelim = "|" $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRegExp($sFilter, "[\\/:><\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") $hSearch = FileFindFirstFile($sPath & $sFilter) If @error Then Return SetError(4, 4, "") While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If @extended Then $sFolderList &= $sDelim & $sFile Else $sFileList &= $sDelim & $sFile EndIf WEnd FileClose($hSearch) $sFileList = $sFolderList & $sFileList If Not $sFileList Then Return SetError(4, 4, "") Return StringSplit(StringTrimLeft($sFileList, 1), "|") EndFunc ;==>_FileListToArray_mod Func _bytes($iBytes) Switch $iBytes Case 0 To 1023 Return $iBytes & " Bytes" Case 1024 To 1048575 Return Round($iBytes / 1024, 2) & " KB" Case 1048576 To 1073741823 Return Round($iBytes / 1048576, 2) & " MB" Case Else Return Round($iBytes / 1073741824, 2) & " GB" EndSwitch EndFunc ;==>_bytes Func __EXIT() DllClose($Shell32) EndFunc ;==>__EXIT ;Originally written by Prog@ndy Func _GUIImageList_GetSystemImageList($bLargeIcons = False) Local $SHGFI_USEFILEATTRIBUTES = 0x10, $SHGFI_SYSICONINDEX = 0x4000, $SHGFI_SMALLICON = 0x1;, $SHGFI_LARGEICON = 0x0;,$FILE_ATTRIBUTE_NORMAL = 0x80 Local $FileInfo = DllStructCreate("dword hIcon; int iIcon; DWORD dwAttributes; CHAR szDisplayName[255]; CHAR szTypeName[80];") Local $dwFlags = BitOR($SHGFI_USEFILEATTRIBUTES, $SHGFI_SYSICONINDEX) If Not ($bLargeIcons) Then $dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON) Local $hIml = _WinAPI_SHGetFileInfo(".txt", $FILE_ATTRIBUTE_NORMAL, DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), $dwFlags) Return $hIml EndFunc ;==>_GUIImageList_GetSystemImageList Func _GUIImageList_GetFileIconIndex($sFileSpec, $bLargeIcons = False, $bForceLoadFromDisk = False);modified Static $FileInfo = DllStructCreate("dword hIcon; int iIcon; DWORD dwAttributes; CHAR szDisplayName[255]; CHAR szTypeName[80];") Local $dwFlags = BitOR(0x4000, 0x1) If Not $bForceLoadFromDisk Then $dwFlags = BitOR($dwFlags, 0x10) DllCall($Shell32, "DWORD*", "SHGetFileInfo", "str", $sFileSpec, "DWORD", $FILE_ATTRIBUTE_NORMAL, "ptr", DllStructGetPtr($FileInfo), "UINT", DllStructGetSize($FileInfo), "UINT", $dwFlags) If @error Then Return SetError(1, 0, -1) Return DllStructGetData($FileInfo, "iIcon") EndFunc ;==>_GUIImageList_GetFileIconIndex Func _WinAPI_SHGetFileInfo($pszPath, $dwFileAttributes, $psfi, $cbFileInfo, $uFlags) Local $return = DllCall($Shell32, "DWORD*", "SHGetFileInfo", "str", $pszPath, "DWORD", $dwFileAttributes, "ptr", $psfi, "UINT", $cbFileInfo, "UINT", $uFlags) If @error Then Return SetError(@error, 0, 0) Return $return[0] EndFunc ;==>_WinAPI_SHGetFileInfo #EndRegion Internal Functions ExpListView.au3
    1 point
×
×
  • Create New...