Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/29/2013 in all areas

  1. For those who enjoy using ListViews and wish to export the data to a XML file, then this function is for you. Thanks to >Mat for the optimised XML format. This is an example of the output for a ListView with 2 rows and 2 columns. <?xml version="1.0" encoding="UTF-8" ?> <listview rows="2" cols="2"> <item> <column01>Row 1: Col 1</column01> <column02>Row 1: Col 2</column02> </item> <item> <column01>Row 2: Col 1</column01> <column02>Row 2: Col 2</column02> </item> </listview> Function without an array: #include <Constants.au3> #include <GUIListView.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListView_SaveXML ; Description ...: Exports a listview to a XML file. ; Syntax ........: _GUICtrlListView_SaveXML($hListView, $sFilePath[, $fDetails = Default]) ; Parameters ....: $hListView - Control ID/Handle to the control ; $sFilePath - Filepath to save the XML data string to. ; $fDetails - [optional] Print the number of columns & rows. Default is True. ; Return values .: Success - True ; Failure - False and sets @error to non-zero. ; Author ........: guinness ; Remarks .......: GUICtrlListView.au3 should be included. ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListView_SaveXML($hListView, $sFilePath, $fDetails = Default) Local Const $iColumnCount = _GUICtrlListView_GetColumnCount($hListView) - 1 Local Const $iItemCount = _GUICtrlListView_GetItemCount($hListView) - 1 Local $sDetails = '' If $fDetails Or $fDetails = Default Then $sDetails = ' rows="' & $iItemCount & '" cols="' & $iColumnCount & '"' EndIf Local $sXMLHeader = '<?xml version="1.0" encoding="UTF-8" ?>' & @CRLF & '<listview' & $sDetails & '>' & @CRLF $sDetails = '' Local $aColumns[$iColumnCount + 1], $aColumnText = 0 ; ListView Columns For $i = 0 To $iColumnCount $aColumnText = _GUICtrlListView_GetColumn($hListView, $i) $aColumns[$i] = StringStripWS(StringLower($aColumnText[5]), $STR_STRIPALL) Next Local $sReturn = '' For $i = 0 To $iItemCount ; ListView Items. $sReturn &= @TAB & '<item>' & @CRLF For $j = 0 To $iColumnCount $sReturn &= @TAB & @TAB & '<' & $aColumns[$j] & '>' & _GUICtrlListView_GetItemText($hListView, $i, $j) & '</' & $aColumns[$j] & '>' & @CRLF Next $sReturn &= @TAB & '</item>' & @CRLF Next $sReturn &= '</listview>' & @CRLF $sReturn = $sXMLHeader & $sReturn Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(1, 0, False) EndIf FileWrite($hFileOpen, $sReturn) FileClose($hFileOpen) Return True EndFunc ;==>_GUICtrlListView_SaveXML Function with an array: - It uses another function called >_GUICtrlListView_CreateArray() #include <Constants.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListView_SaveXMLEx ; Description ...: Exports a listview to a XML file. ; Syntax ........: _GUICtrlListView_SaveXMLEx(Const Byref $aArray, $sFilePath[, $fDetails = Default[, $sDelimiter = '|']]) ; Parameters ....: $aArray - [in/out and const] A 2-dimensional array returned by _GUICtrlListView_CreateArray. ; $sFilePath - Filepath to save the XML data string to. ; $fDetails - [optional] Print the number of columns & rows. Default is True. ; $sDelimiter - [optional] Delimiter used as the _GUICtrlListView_CreateArray delimiter parameter. Default is '|'. ; Return values .: Success - True ; Failure - False and sets @error to non-zero. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListView_SaveXMLEx(ByRef Const $aArray, $sFilePath, $fDetails = Default, $sDelimiter = '|') If $sDelimiter = Default Then $sDelimiter = '|' EndIf Local $sDetails = '' If $fDetails Or $fDetails = Default Then $sDetails = ' rows="' & $aArray[0][0] & '" cols="' & $aArray[0][1] & '"' EndIf Local $sXMLHeader = '<?xml version="1.0" encoding="UTF-8" ?>' & @CRLF & '<listview' & $sDetails & '>' & @CRLF $sDetails = '' Local $aColumns = StringSplit($aArray[0][2], $sDelimiter) ; ListView Columns For $i = 1 To $aColumns[0] $aColumns[$i] = StringStripWS(StringLower($aColumns[$i]), $STR_STRIPALL) Next Local Const $iColumnCount = $aArray[0][1] - 1 Local $iColumnIndex = 0, $sReturn = '' For $i = 1 To $aArray[0][0] ; ListView Items. $sReturn &= @TAB & '<item>' & @CRLF For $j = 0 To $iColumnCount $iColumnIndex = $j + 1 $sReturn &= @TAB & @TAB & '<' & $aColumns[$iColumnIndex] & '>' & $aArray[$i][$j] & '</' & $aColumns[$iColumnIndex] & '>' & @CRLF Next $sReturn &= @TAB & '</item>' & @CRLF Next $sReturn &= '</listview>' & @CRLF $sReturn = $sXMLHeader & $sReturn Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(1, 0, False) EndIf FileWrite($hFileOpen, $sReturn) FileClose($hFileOpen) Return True EndFunc ;==>_GUICtrlListView_SaveXMLEx Download the ZIP file to obtain all exporting UDFs as well as an example of usage. ListView Export.zip Other Examples for exporting ListView data are: >_GUICtrlListView_SaveCSV(), >_GUICtrlListView_SaveHTML() & >_GUICtrlListView_SaveTxt()
    1 point
  2. Rickname, I would not use the SortCallBack but use a WM_NOTIFY handler to look for the $LVN_COLUMNCLICK message. Then you can very easily get the column clicked from the $tagNMLISTVIEW struct and action a _GUICtrlListView_SimpleSort on the column you wish to sort in its place. If all that sounds like Chinese then look at the _GUICtrlListView_Create example in the Help file and see if that helps. If not, then feel free to come back and ask again. M23
    1 point
  3. Melba23

    Façade Key Sender

    DatMCEyeBall, Your 2 threads so far have been Malware and this Game-related script. Before you post for a third time, please read the Forum rules (there is also a link at bottom right of each page) because if I have to moderate you a third time, sanctions will follow. M23 P.S. And you really do need to learn about arrays and loops - then I will not have to scroll through so much garbage to find out what you are doing. P.P.S. And if you wonder why your next post does not appear - you are on Moderator preview until you prove that you can be trusted.
    1 point
  4. I Love the Term "error checking"
    1 point
  5. DatMCEyeBall posted a thread with this title a few minutes ago. It has been deleted as it was a good example of malware - taking screenshots and popping up random panels and MsgBoxes on another PC screen after being installed as a service. It was also appallingly badly written which meant that the script was so long that it was impossible to edit the post - thus I deleted the whole thread and have put this in its place so that there is some record of its existence. DatMCEyeBall, Do not post scripts like that again or you will be sanctioned. And learn about arrays and loops. M23
    1 point
  6. dqdegvzman, you're telling us what you want, not what you have tried on your own. This is not a forum where we spoon feed code to you, this is a forum where we assist when you run into an issue with a script you are writing. I would suggest beginning with the help file, see if you can download the file using InetGet or some other means. Then, once you have this down, move along to the silent install.
    1 point
  7. Melba23

    How to lockscreen

    olo, Look in the Help file for Send - or in the online documentation. When you have a Help file as detailed as that which is provided for AutoIt, then it pays to use it. M23
    1 point
  8. Melba23

    How to lockscreen

    olo, "Win + L" is the standard "lockscreen" command for Windows - all that command does is to Send it. M23
    1 point
  9. Xenobiologist

    How to lockscreen

    Send('#l')
    1 point
  10. @Rickname #How can we benefit from your udf ? sry bcause I dont know what is virtualisation >.< Sure no problem. I'm have been answered this question on updated post. Please look on Simple and Complex Implementation sub topic on main post. But if you want basic description of what is virtualization here on our dictionary. File Virtualization Windows Registry Registry virtualization on this UDF different from Virtual Registry provide by Microsoft. Sorry to not to take on account for person who doesn't know for What is Virtualization because in the first when post this topic I tough people who reading this topic are they who search virtualization solution in AutoIt3. If you are new then gladly welcome.
    1 point
  11. jchd

    Comparison of two files

    Apologies to update myself. I ran a simpler version which is as close as fastest than I believe an SQLite implementation can be. Results from a run over a set of 15 XML files totalling 2 696 614 lines and 81518277 bytes, details below. D:\somepath>wc *.xml Lines Words Bytes 500 597 15195 F2008-08rpleb.xml 4077 4870 124056 F2008-09pckbx.xml 114008 135374 3441076 F2008-10dykxv.xml 161906 192098 4905017 F2008-11oowcq.xml 180883 214616 5481306 F2008-12wrnvy.xml 140594 166830 4261162 F2009-01wtiyu.xml 152628 181129 4603496 F2009-02baozh.xml 198300 234930 5993839 F2009-03mfbbb.xml 199248 235940 6011069 F2009-04vykln.xml 215067 255011 6497965 F2009-05fphdx.xml 204878 242848 6198099 F2009-06ndtvq.xml 93342 110597 2828989 F2009-07hqnms.xml 180302 213717 5445789 F2009-08pgriq.xml 221067 262122 6674143 F2009-09phjch.xml 205817 244028 6222960 F2009-10jqmsg.xml 227406 269189 6872148 F2009-11sclnn.xml 196591 232751 5941968 F2009-12lgzkm.xml 2696614 3196647 81518277 total 6 011 069 F2009-04vykln.xml 5 941 968 F2009-12lgzkm.xml 15 195 F2008-08rpleb.xml 6 222 960 F2009-10jqmsg.xml 124 056 F2008-09pckbx.xml 6 674 143 F2009-09phjch.xml 3 441 076 F2008-10dykxv.xml 5 445 789 F2009-08pgriq.xml 4 905 017 F2008-11oowcq.xml 2 828 989 F2009-07hqnms.xml 5 481 306 F2008-12wrnvy.xml 6 198 099 F2009-06ndtvq.xml 4 261 162 F2009-01wtiyu.xml 6 497 965 F2009-05fphdx.xml 4 603 496 F2009-02baozh.xml 5 993 839 F2009-03mfbbb.xml 6 872 148 F2009-11sclnn.xml 157 815 F2009-03mfbbb.xml.uniq 178 632 F2009-12lgzkm.xml.uniq 158 642 F2009-04vykln.xml.uniq 124 052 F2009-01wtiyu.xml.uniq 169 914 F2009-05fphdx.xml.uniq 166 560 F2008-12wrnvy.xml.uniq 167 236 F2009-06ndtvq.xml.uniq 150 090 F2008-11oowcq.xml.uniq 75 764 F2009-07hqnms.xml.uniq 108 093 F2008-10dykxv.xml.uniq 151 001 F2009-08pgriq.xml.uniq 5 886 F2008-09pckbx.xml.uniq 181 401 F2009-09phjch.xml.uniq 846 F2008-08rpleb.xml.uniq 176 872 F2009-10jqmsg.xml.uniq 119 988 F2009-02baozh.xml.uniq 188 160 F2009-11sclnn.xml.uniq In this set, there are a very large number or dupplicate lines both within the same file and among files. This version makes no atempt to delete dupplicate lines during insert, but instead extracts, at the output stage, those lines which have no copy elsewhere. That turned out to make insertion about twice as fast (compared to the previous version using an insertion trigger) but only slowed down output a little (thanks to good indexing choice). This also demonstrates that you can have duplicate primary keys and ignore the row being inserted if it already exists in the DB. >Exit code: 0 Time: 1241.077 I challenge making it significantly faster by using only vanilla AutoIt-provided resources/UDFs, specially when run over a large set of large files as the one examplified above. I cheated in making the index use a (faster) binary compare (not a case-insensitive one), but Note that the code is rather simple, straitforward and naturally copes with as many files as needed. #include <SQLite.au3> #include <SQLite.Dll.au3> #include <Array.au3> Main() ; removes every occurence of exact same (with respect to case, see below) text line found elsewhere in a group of text files Func Main() ; init SQLite _SQLite_Startup() ; create a :memory: DB Local $hDB = _SQLite_Open() ; create a single table, with an index on text ; doing so will minimize the number of comparisons, and those compares are fast low-level code ; ; WARNING: this will work as intended, for ASCII or Unicode, with respect to case ; lower ASCII compares *-without-* respect to case can still be done efficiently by using COLLATE NOCASE ; universal Unicode compares without respect to case need a bit more complex setup (but can still be called efficient) _SQLite_Exec($hDB, "CREATE TABLE Strings (String CHAR, Source INTEGER, PRIMARY KEY (String, Source) ON CONFLICT IGNORE);") ; get the list of input files (may process any number of files in the same run) Local $dir = "your input path" Local $files = _FileListToArray(@ScriptDir & "\", '*.inputtxt', 1) If @error Then Return ; process input files Local $txtstr For $i = 1 to $files[0] ConsoleWrite("Processing file " & $dir & $files[$i] & @LF) _FileReadToArray($dir & $files[$i], $txtstr) ; process input lines _SQLite_Exec($hDB, "begin;") If Not @error Then For $j = 1 To $txtstr[0] _SQLite_Exec($hDB, "insert into Strings (Source, String) values (" & $i & "," & _SQLite_Escape($txtstr[$j]) & ");") Next EndIf _SQLite_Exec($hDB, "commit;") Next ; store remaining data in output files Local $nrows, $ncols ConsoleWrite("Creating output files" & @LF) For $i = 1 to $files[0] ; select relevant strings left _SQLite_GetTable($hDB, "select String from Strings X where " & _ "Source = " & $i & " and " & _ "not exists (select 1 from Strings Y where Y.String = X.String and Y.Source != X.Source);", _ $txtstr, $nrows, $ncols) ; write to input filename + extra extension .uniq _FileWriteFromArray($dir & $files[$i] & '.uniq', $txtstr, 2) Next EndFunc
    1 point
×
×
  • Create New...