
gius
Active Members-
Posts
57 -
Joined
-
Last visited
Everything posted by gius
-
Wakillon, I tested with my PC, with screen resolution 1280 x 1024 and it works great, congratulations for the work! The best setting for my PC is 960x540 with 7 fps, since it is the best setting, it is possible to launch the executable and start recording without having the gui (I set the setting based on 960x540 and 7 fps)? thanks
-
guinness, It is this the result I was looking for. It is easy to modify, I have already changed ;ConsoleWrite($sFileList & @CRLF) FileWrite(@ScriptDir & "\result.txt",$sFileList) your explanations in the code they are very clear, is really a great work thanks again
-
guinness, Your code works very well and it's really fast, thanks for everything
-
I have just started studying AutoIt, it is difficult for me to understand how to do it. guinness, I put your added $listing &= $path & $file & "[" FileGetTime($path & $file, $FT_MODIFIED, 1) & "]|" with all the code #include <String.au3> #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> global $listing $directory = @DesktopDir list($directory, 0) time() Func list($path = "", $counter = 0) $counter = 0 $path &= '\' Local $list_files = '', $file, $demand_file = FileFindFirstFile($path & '*') If $demand_file = -1 Then Return '' While 1 $file = FileFindNextFile($demand_file) If @error Then ExitLoop If @extended Then If $counter >= 10 Then ContinueLoop list($path & $file, $counter + 1 ) Else $listing &= $path & $file & "[" FileGetTime($path & $file, $FT_MODIFIED, 1) & "]|" EndIf WEnd FileClose($demand_file) EndFunc func time() $listing = StringTrimRight($listing, 1) $listing = _StringExplode($listing, "|", 0) _ArraySort($listing) _FileCreate(@ScriptDir & "\result.txt") _FileWriteFromArray(@ScriptDir & "\result.txt",$listing) endfunc but it does not work, it gives me this error: ==> Error in expression.: $listing &= $path & $file & "[" FileGetTime($path & $file, $FT_MODIFIED, 1) & "]|" $listing &= ^ ERROR I have done something wrong? How I can add $ FT_CREATED and the date format 03.14.2015 [17:10:46]? thanks
-
The code is this: #include <String.au3> #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> global $listing $directory = @DesktopDir list($directory, 0) time() Func list($path = "", $counter = 0) $counter = 0 $path &= '\' Local $list_files = '', $file, $demand_file = FileFindFirstFile($path & '*') If $demand_file = -1 Then Return '' While 1 $file = FileFindNextFile($demand_file) If @error Then ExitLoop If @extended Then If $counter >= 10 Then ContinueLoop list($path & $file, $counter + 1 ) Else $listing &= $path & $file & "|" EndIf WEnd FileClose($demand_file) EndFunc func time() $listing = StringTrimRight($listing, 1) $listing = _StringExplode($listing, "|", 0) _ArraySort($listing) ;_ArrayDisplay($listing, "File") _FileCreate(@ScriptDir & "\result.txt") _FileWriteFromArray(@ScriptDir & "\result.txt",$listing) endfunc I have a little changed. I wish to file result.txt _FileWriteFromArray (ScriptDir & "\ Result.txt", listing $) there is also an indication the file creation date and the last modification of the file, with the format for example: 14.03.2015 [17:10:46] I've added this but does not work $listing = FileGetTime($sFile, $FT_MODIFIED) $listing = FileGetTime($sFile, $FT_CREATED) where I am wrong? thanks
-
Guinnes, Maybe I was wrong to use the _FileListToArrayRec I would like to have in the list the file creation date and the last modification of the file, with the format, for example: 14.03.2015 [17:10:46] can anyone help me? thanks
-
yes Realm, I am confused, it is FileGetTime() but do not know how to add this code $aTime_Mod = FileGetTime($sFile, $FT_MODIFIED) $aTime_Created = FileGetTime($sFile, $FT_CREATED) $aResult[$i][1] = $aTime_Mod[0] & "/" & $aTime_Mod[1] & "/" & $aTime_Mod[2] & " [" & $aTime_Mod[3] & ":" & $aTime_Mod[4] & ":" & $aTime_Mod[5] & "]" $aResult[$i][2] = $aTime_Created[0] & "/" & $aTime_Created[1] & "/" & $aTime_Created[2] & " [" & $aTime_Created[3] & ":" & $aTime_Created[4] & ":" & $aTime_Created[5] & "]" in the first code. Anyone can help me? Thanks
-
Hello everyone, In this topic '?do=embed' frameborder='0' data-embedContent>> I found a code (Belini member) that searches files in a very fast #include <String.au3> #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> global $listing $directory = @DesktopDir list($directory, 0) time() Func list($path = "", $counter = 0) $counter = 0 $path &= '\' Local $list_files = '', $file, $demand_file = FileFindFirstFile($path & '*') If $demand_file = -1 Then Return '' While 1 $file = FileFindNextFile($demand_file) If @error Then ExitLoop If @extended Then If $counter >= 10 Then ContinueLoop list($path & $file, $counter + 1 ) Else $listing &= $path & $file & "|" EndIf WEnd FileClose($demand_file) EndFunc func time() $listing = StringTrimRight($listing, 1) $listing = _StringExplode($listing, "|", 0) _ArraySort($listing) ;_ArrayDisplay($listing, "File") _FileCreate(@ScriptDir & "\result.txt") _FileWriteFromArray(@ScriptDir & "\result.txt",$listing) endfunc I can not understand the function where add FileSetTime $FT_CREATED $FT_ACCESSED $aTime_Mod = FileGetTime($sFile, $FT_MODIFIED) $aTime_Created = FileGetTime($sFile, $FT_CREATED) $aResult[$i][1] = $aTime_Mod[0] & "/" & $aTime_Mod[1] & "/" & $aTime_Mod[2] & " [" & $aTime_Mod[3] & ":" & $aTime_Mod[4] & ":" & $aTime_Mod[5] & "]" $aResult[$i][2] = $aTime_Created[0] & "/" & $aTime_Created[1] & "/" & $aTime_Created[2] & " [" & $aTime_Created[3] & ":" & $aTime_Created[4] & ":" & $aTime_Created[5] & "]" I think that the right function is $list_files maybe within FOR - NEXT? thanks
-
ZIP UDF for read file .docx .xlsx .pptx
gius replied to gius's topic in AutoIt General Help and Support
Thanks Orbs for the reply. I used your advice to update the code: #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstants.au3> #include <GUIlistview.au3> #include <FontConstants.au3> #include <WinAPI.au3> Global $Zip = FileCopy("Full_Path.docx", "Full_Path.zip") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Global $listView Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 Local $obj = ObjCreate("xd2txcom.Xdoc2txt.1") Local $sFilter = "*.txt;*.pdf;*.doc;*.xls;*.docx;*.xlsx" ; Create a string with the correct format for multiple filters Local $word = GUICtrlCreateInput("", 464, 24, 129, 37) $Form1 = GUICreate(" ", 623, 438, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) GUISetFont(18, 600, 0, "MS Sans Serif") ; Set the font for all controls in one call $Label1 = GUICtrlCreateLabel("Search:", 16, 24, 422, 41) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $input = GUICtrlCreateInput("", 364, 24, 129, 37) ; $input is the ControlID of the input control GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $input ; When {ENTER} pressed in input $word = GUICtrlRead($input) ; Read the content of the input GUIDelete($Form1) ; Delete GUI SplashTextOn("", "...", 200, 200, -1, -1, 4, "", 24) ExitLoop EndSwitch WEnd For $k = 0 To UBound($folders) - 1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], "*" & $sFilter, 1, 1, 0, 2) ; list files If Not @error Then For $i = 1 To $aFiles[0] ; loop through files Switch _FileGetExt($aFiles[$i]) Case '.pdf','.doc','.xls','.ppt','.docx','.xlsx','.pptx' $content = $obj.ExtractText($aFiles[$i], False) Case Else $content = FileRead($aFiles[$i]) EndSwitch ; the following regex captures the full lines containing $word $res = StringRegExp($content, '(?im)(.*\b\Q' & $word & '\E\b.*)\R?', 3) ; if $word must be a lone word ; $res = StringRegExp($content, '(?im)(.*\Q' & $word & '\E.*)\R?', 3) ; if $word can be part of another word If IsArray($res) Then $aResult[$n][0] = $aFiles[$i] ; file path For $j = 0 To UBound($res) - 1 $aResult[$n + $j][1] = $res[$j] ; lines Next $n += $j EndIf Next EndIf Next ReDim $aResult[$n][2] aGUI($aResult) SplashOff() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func aGUI($array, $title = "") Local $gui, $i, $findStrPos, _ $itemText, $replacedText, _ $leftStr ;$gui = GUICreate($title, 1024, 768, 192, 124) $gui = GUICreate($title, 800, 640, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) $Label1 = GUICtrlCreateLabel("", 100, 0, 400, 35, $SS_CENTER) GUICtrlSetFont(-1, 16, 400, 4, 'Comic Sans Ms') $listView = _GUICtrlListView_Create($gui, "file", 20, 35, @DesktopWidth - 20, @DesktopHeight - 120, BitOR($LVS_REPORT, $LVS_SINGLESEL)) $hFont1 = _WinAPI_CreateFont(25, 6, 0, 0, $FW_MEDIUM, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $DEFAULT_PITCH, 'Tahoma') ; <<<<<<<<<<<<<<<< make our own font using WinAPI _WinAPI_SetFont($listView, $hFont1, True) ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Here we set the font for the $listview items $header = HWnd(_GUICtrlListView_GetHeader($listView)) ; <<<<<<<<<<<<<<<< Here we get the header handle _WinAPI_SetFont($header, $hFont1, True) ; <<<<<<<<<<<<<<<<<<< Here we set the header font _GUICtrlListView_SetExtendedListViewStyle($listView, $LVS_EX_GRIDLINES) _GUICtrlListView_AddColumn($listView, "Text") _GUICtrlListView_AddColumn($listView, "") _GUICtrlListView_AddArray($listView, $array) For $i = 0 To UBound($array) - 1 Step 1 $itemText = _GUICtrlListView_GetItemText($listView, $i) If $itemText <> "" Then $findStrPos = StringInStr($itemText, "\", 0, -1) $leftStr = StringLeft($itemText, $findStrPos) $replacedText = StringReplace($itemText, $leftStr, "") _GUICtrlListView_SetItemText($listView, $i, $replacedText) EndIf Next _GUICtrlListView_SetColumnWidth($listView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($listView, 1, $LVSCW_AUTOSIZE_USEHEADER) GUISetState(@SW_SHOW) EndFunc ;==>aGUI Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, _ $sIndices, $sData, $sAdata, $file, $splitFile $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $listView Switch $iCode Case $NM_DBLCLK $sIndices = _GUICtrlListView_GetSelectedIndices($listView) $sData = _GUICtrlListView_GetItemText($listView, $sIndices) $sAdata = _ArraySearch($aResult, $sData, Default, Default, Default, 3) $file = _ArrayToString($aResult, Default, $sAdata, 0, Default) $splitFile = StringSplit($file, "|") ShellExecute($splitFile[1]) EndSwitch EndSwitch EndFunc ;==>WM_NOTIFY Func _FileGetExt($sTarget) Return StringTrimLeft($sTarget, StringInStr($sTarget, '.', 0, -1)) EndFunc with your line Case 'pdf','doc','xls','ppt','docx','xlsx','pptx' the program would close I have changed with Case '.pdf','.doc','.xls','.ppt','.docx','.xlsx','.pptx' and it works, but does not find any file .docx .xlsx .pptx I was wrong again? thanks -
I think it is important even read the "phrase" or "word" in that line or string exists, for every line that exists in a file For those who have many files it is important to read the "thought" where is located the "phrase" to search. But it's my idea... Thanks
-
llewxam, A really good work it possible to even add the opportunity to see the string or line where it was found the "phrase"? Maybe with a button that opens an array in columns? thanks
-
ZIP UDF for read file .docx .xlsx .pptx
gius replied to gius's topic in AutoIt General Help and Support
Thanks Orbs for your reply, my code is incomplete: #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstants.au3> #include <GUIlistview.au3> #include <FontConstants.au3> #include <WinAPI.au3> Global $Zip = FileCopy("Full_Path.docx", "Full_Path.zip") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Global $listView Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 Local $obj = ObjCreate("xd2txcom.Xdoc2txt.1") Local $sFilter = "*.doc;*.txt;*.pdf;*xls" ; Create a string with the correct format for multiple filters Local $word = GUICtrlCreateInput("", 464, 24, 129, 37) $Form1 = GUICreate(" ", 623, 438, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) GUISetFont(18, 600, 0, "MS Sans Serif") ; Set the font for all controls in one call $Label1 = GUICtrlCreateLabel("Search:", 16, 24, 422, 41) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $input = GUICtrlCreateInput("", 364, 24, 129, 37) ; $input is the ControlID of the input control GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $input ; When {ENTER} pressed in input $word = GUICtrlRead($input) ; Read the content of the input GUIDelete($Form1) ; Delete GUI SplashTextOn("", "...", 200, 200, -1, -1, 4, "", 24) ExitLoop EndSwitch WEnd For $k = 0 To UBound($folders) - 1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], "*" & $sFilter, 1, 1, 0, 2) ; list files If Not @error Then For $i = 1 To $aFiles[0] ; loop through files If StringRight($aFiles[$i],4) = '.doc' Then $content = $obj.ExtractText($aFiles[$i], False) Else $content = FileRead($aFiles[$i]) EndIf ; the following regex captures the full lines containing $word $res = StringRegExp($content, '(?im)(.*\b\Q' & $word & '\E\b.*)\R?', 3) ; if $word must be a lone word ; $res = StringRegExp($content, '(?im)(.*\Q' & $word & '\E.*)\R?', 3) ; if $word can be part of another word If IsArray($res) Then $aResult[$n][0] = $aFiles[$i] ; file path For $j = 0 To UBound($res) - 1 $aResult[$n + $j][1] = $res[$j] ; lines Next $n += $j EndIf Next EndIf Next ReDim $aResult[$n][2] aGUI($aResult) SplashOff() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func aGUI($array, $title = "") Local $gui, $i, $findStrPos, _ $itemText, $replacedText, _ $leftStr ;$gui = GUICreate($title, 1024, 768, 192, 124) $gui = GUICreate($title, 800, 640, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) $Label1 = GUICtrlCreateLabel("", 100, 0, 400, 35, $SS_CENTER) GUICtrlSetFont(-1, 16, 400, 4, 'Comic Sans Ms') $listView = _GUICtrlListView_Create($gui, "file", 20, 35, @DesktopWidth - 20, @DesktopHeight - 120, BitOR($LVS_REPORT, $LVS_SINGLESEL)) $hFont1 = _WinAPI_CreateFont(25, 6, 0, 0, $FW_MEDIUM, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $DEFAULT_PITCH, 'Tahoma') ; <<<<<<<<<<<<<<<< make our own font using WinAPI _WinAPI_SetFont($listView, $hFont1, True) ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Here we set the font for the $listview items $header = HWnd(_GUICtrlListView_GetHeader($listView)) ; <<<<<<<<<<<<<<<< Here we get the header handle _WinAPI_SetFont($header, $hFont1, True) ; <<<<<<<<<<<<<<<<<<< Here we set the header font _GUICtrlListView_SetExtendedListViewStyle($listView, $LVS_EX_GRIDLINES) _GUICtrlListView_AddColumn($listView, "Text") _GUICtrlListView_AddColumn($listView, "") _GUICtrlListView_AddArray($listView, $array) For $i = 0 To UBound($array) - 1 Step 1 $itemText = _GUICtrlListView_GetItemText($listView, $i) If $itemText <> "" Then $findStrPos = StringInStr($itemText, "\", 0, -1) $leftStr = StringLeft($itemText, $findStrPos) $replacedText = StringReplace($itemText, $leftStr, "") _GUICtrlListView_SetItemText($listView, $i, $replacedText) EndIf Next _GUICtrlListView_SetColumnWidth($listView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($listView, 1, $LVSCW_AUTOSIZE_USEHEADER) GUISetState(@SW_SHOW) EndFunc ;==>aGUI Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, _ $sIndices, $sData, $sAdata, $file, $splitFile $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $listView Switch $iCode Case $NM_DBLCLK $sIndices = _GUICtrlListView_GetSelectedIndices($listView) $sData = _GUICtrlListView_GetItemText($listView, $sIndices) $sAdata = _ArraySearch($aResult, $sData, Default, Default, Default, 3) $file = _ArrayToString($aResult, Default, $sAdata, 0, Default) $splitFile = StringSplit($file, "|") ShellExecute($splitFile[1]) EndSwitch EndSwitch EndFunc ;==>WM_NOTIFY I only added #include "_Zip.au3" FileCopy ("Full_Path.docx", "Full_Path.zip") but I do not know how to add $aRet = _Zip_SearchInFile("Full_Path.zip", "Text_To_Find") You could help me to complete my code? thank you -
ZIP UDF for read file .docx .xlsx .pptx
gius replied to gius's topic in AutoIt General Help and Support
Thanks Orbs and TheSaint for the reply, the code the beginning topic already opens .doc .txt .pdf, can anyone help me to run my code also with .docx .xlsx .pptx .odt file? thank you -
Hello everyone Can anyone help me to use the ZIP UDF to open and read text in files .docx .xlsx .pptx with this code? #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstants.au3> #include <GUIlistview.au3> #include <FontConstants.au3> #include <WinAPI.au3> Global $Zip = FileCopy("Full_Path.docx", "Full_Path.zip") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Global $listView Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 Local $obj = ObjCreate("xd2txcom.Xdoc2txt.1") Local $sFilter = "*.doc;*.txt;*.pdf;*xls" ; Create a string with the correct format for multiple filters Local $word = GUICtrlCreateInput("", 464, 24, 129, 37) $Form1 = GUICreate(" ", 623, 438, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) GUISetFont(18, 600, 0, "MS Sans Serif") ; Set the font for all controls in one call $Label1 = GUICtrlCreateLabel("Search:", 16, 24, 422, 41) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $input = GUICtrlCreateInput("", 364, 24, 129, 37) ; $input is the ControlID of the input control GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $input ; When {ENTER} pressed in input $word = GUICtrlRead($input) ; Read the content of the input GUIDelete($Form1) ; Delete GUI SplashTextOn("", "...", 200, 200, -1, -1, 4, "", 24) ExitLoop EndSwitch WEnd For $k = 0 To UBound($folders) - 1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], "*" & $sFilter, 1, 1, 0, 2) ; list files If Not @error Then For $i = 1 To $aFiles[0] ; loop through files If StringRight($aFiles[$i],4) = '.doc' Then $content = $obj.ExtractText($aFiles[$i], False) Else $content = FileRead($aFiles[$i]) EndIf ; the following regex captures the full lines containing $word $res = StringRegExp($content, '(?im)(.*\b\Q' & $word & '\E\b.*)\R?', 3) ; if $word must be a lone word ; $res = StringRegExp($content, '(?im)(.*\Q' & $word & '\E.*)\R?', 3) ; if $word can be part of another word If IsArray($res) Then $aResult[$n][0] = $aFiles[$i] ; file path For $j = 0 To UBound($res) - 1 $aResult[$n + $j][1] = $res[$j] ; lines Next $n += $j EndIf Next EndIf Next ReDim $aResult[$n][2] aGUI($aResult) SplashOff() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func aGUI($array, $title = "") Local $gui, $i, $findStrPos, _ $itemText, $replacedText, _ $leftStr ;$gui = GUICreate($title, 1024, 768, 192, 124) $gui = GUICreate($title, 800, 640, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) $Label1 = GUICtrlCreateLabel("", 100, 0, 400, 35, $SS_CENTER) GUICtrlSetFont(-1, 16, 400, 4, 'Comic Sans Ms') $listView = _GUICtrlListView_Create($gui, "file", 20, 35, @DesktopWidth - 20, @DesktopHeight - 120, BitOR($LVS_REPORT, $LVS_SINGLESEL)) $hFont1 = _WinAPI_CreateFont(25, 6, 0, 0, $FW_MEDIUM, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $DEFAULT_PITCH, 'Tahoma') ; <<<<<<<<<<<<<<<< make our own font using WinAPI _WinAPI_SetFont($listView, $hFont1, True) ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Here we set the font for the $listview items $header = HWnd(_GUICtrlListView_GetHeader($listView)) ; <<<<<<<<<<<<<<<< Here we get the header handle _WinAPI_SetFont($header, $hFont1, True) ; <<<<<<<<<<<<<<<<<<< Here we set the header font _GUICtrlListView_SetExtendedListViewStyle($listView, $LVS_EX_GRIDLINES) _GUICtrlListView_AddColumn($listView, "Text") _GUICtrlListView_AddColumn($listView, "") _GUICtrlListView_AddArray($listView, $array) For $i = 0 To UBound($array) - 1 Step 1 $itemText = _GUICtrlListView_GetItemText($listView, $i) If $itemText <> "" Then $findStrPos = StringInStr($itemText, "\", 0, -1) $leftStr = StringLeft($itemText, $findStrPos) $replacedText = StringReplace($itemText, $leftStr, "") _GUICtrlListView_SetItemText($listView, $i, $replacedText) EndIf Next _GUICtrlListView_SetColumnWidth($listView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($listView, 1, $LVSCW_AUTOSIZE_USEHEADER) GUISetState(@SW_SHOW) EndFunc ;==>aGUI Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, _ $sIndices, $sData, $sAdata, $file, $splitFile $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $listView Switch $iCode Case $NM_DBLCLK $sIndices = _GUICtrlListView_GetSelectedIndices($listView) $sData = _GUICtrlListView_GetItemText($listView, $sIndices) $sAdata = _ArraySearch($aResult, $sData, Default, Default, Default, 3) $file = _ArrayToString($aResult, Default, $sAdata, 0, Default) $splitFile = StringSplit($file, "|") ShellExecute($splitFile[1]) EndSwitch EndSwitch EndFunc ;==>WM_NOTIFY thanks
-
Melba23, this is my code #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstants.au3> #include <GUIlistview.au3> #include <FontConstants.au3> #include <WinAPI.au3> Global $Zip = FileCopy("Full_Path.docx", "Full_Path.zip") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Global $listView Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 Local $obj = ObjCreate("xd2txcom.Xdoc2txt.1") Local $sFilter = "*.doc;*.txt;*.pdf;*xls" ; Create a string with the correct format for multiple filters Local $word = GUICtrlCreateInput("", 464, 24, 129, 37) $Form1 = GUICreate(" ", 623, 438, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) GUISetFont(18, 600, 0, "MS Sans Serif") ; Set the font for all controls in one call $Label1 = GUICtrlCreateLabel("Search:", 16, 24, 422, 41) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $input = GUICtrlCreateInput("", 364, 24, 129, 37) ; $input is the ControlID of the input control GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $input ; When {ENTER} pressed in input $word = GUICtrlRead($input) ; Read the content of the input GUIDelete($Form1) ; Delete GUI SplashTextOn("", "...", 200, 200, -1, -1, 4, "", 24) ExitLoop EndSwitch WEnd For $k = 0 To UBound($folders) - 1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], "*" & $sFilter, 1, 1, 0, 2) ; list files If Not @error Then For $i = 1 To $aFiles[0] ; loop through files If StringRight($aFiles[$i],4) = '.doc' Then $content = $obj.ExtractText($aFiles[$i], False) Else $content = FileRead($aFiles[$i]) EndIf ; the following regex captures the full lines containing $word $res = StringRegExp($content, '(?im)(.*\b\Q' & $word & '\E\b.*)\R?', 3) ; if $word must be a lone word ; $res = StringRegExp($content, '(?im)(.*\Q' & $word & '\E.*)\R?', 3) ; if $word can be part of another word If IsArray($res) Then $aResult[$n][0] = $aFiles[$i] ; file path For $j = 0 To UBound($res) - 1 $aResult[$n + $j][1] = $res[$j] ; lines Next $n += $j EndIf Next EndIf Next ReDim $aResult[$n][2] aGUI($aResult) SplashOff() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func aGUI($array, $title = "") Local $gui, $i, $findStrPos, _ $itemText, $replacedText, _ $leftStr ;$gui = GUICreate($title, 1024, 768, 192, 124) $gui = GUICreate($title, 800, 640, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_TABSTOP)) $Label1 = GUICtrlCreateLabel("", 100, 0, 400, 35, $SS_CENTER) GUICtrlSetFont(-1, 16, 400, 4, 'Comic Sans Ms') $listView = _GUICtrlListView_Create($gui, "file", 20, 35, @DesktopWidth - 20, @DesktopHeight - 120, BitOR($LVS_REPORT, $LVS_SINGLESEL)) $hFont1 = _WinAPI_CreateFont(25, 6, 0, 0, $FW_MEDIUM, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $DEFAULT_PITCH, 'Tahoma') ; <<<<<<<<<<<<<<<< make our own font using WinAPI _WinAPI_SetFont($listView, $hFont1, True) ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Here we set the font for the $listview items $header = HWnd(_GUICtrlListView_GetHeader($listView)) ; <<<<<<<<<<<<<<<< Here we get the header handle _WinAPI_SetFont($header, $hFont1, True) ; <<<<<<<<<<<<<<<<<<< Here we set the header font _GUICtrlListView_SetExtendedListViewStyle($listView, $LVS_EX_GRIDLINES) _GUICtrlListView_AddColumn($listView, "Text") _GUICtrlListView_AddColumn($listView, "") _GUICtrlListView_AddArray($listView, $array) For $i = 0 To UBound($array) - 1 Step 1 $itemText = _GUICtrlListView_GetItemText($listView, $i) If $itemText <> "" Then $findStrPos = StringInStr($itemText, "\", 0, -1) $leftStr = StringLeft($itemText, $findStrPos) $replacedText = StringReplace($itemText, $leftStr, "") _GUICtrlListView_SetItemText($listView, $i, $replacedText) EndIf Next _GUICtrlListView_SetColumnWidth($listView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($listView, 1, $LVSCW_AUTOSIZE_USEHEADER) GUISetState(@SW_SHOW) EndFunc ;==>aGUI Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, _ $sIndices, $sData, $sAdata, $file, $splitFile $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $listView Switch $iCode Case $NM_DBLCLK $sIndices = _GUICtrlListView_GetSelectedIndices($listView) $sData = _GUICtrlListView_GetItemText($listView, $sIndices) $sAdata = _ArraySearch($aResult, $sData, Default, Default, Default, 3) $file = _ArrayToString($aResult, Default, $sAdata, 0, Default) $splitFile = StringSplit($file, "|") ShellExecute($splitFile[1]) EndSwitch EndSwitch EndFunc ;==>WM_NOTIFY in this code I have to change the line $res = StringRegExp($content, '(?im)(.*\b\Q' & $word & '\E\b.*)\R?', 3) ; if $word must be a lone word with $aRet = _Zip_SearchInFile() It is this change right? for AZJIO, thanks for your advice, it's really interesting to your project
-
Melba23, It is really interesting this UDF for ZIP. I read its functions, in my case should be used _Zip_SearchInFile () right? but how do not understand it ... can you help me? thanks
-
Thanks Melba23, can you help me in the code? thanks
-
Mlipok, Your code # post13, you work with files .odt .pptx .docx .xlsx? thanks
-
Mlipok, Your code works fine! Even if I am not expert in the code, your examples were really clear. I do not know if it's a problem of my PC, but do not work file.odt, .docx, .xlsx, .pptx is a problem only for me? thanks
-
In this code, how can I insert the possibility to read files with xd2txcom.dll? #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstants.au3> #include <GUIlistview.au3> #include <FontConstants.au3> #include <WinAPI.au3> GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Global $listView Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 Local $obj = ObjCreate("xd2txcom.Xdoc2txt.1") Local $sFilter = "*.doc;*.txt;*.pdf;*xls" ; Create a string with the correct format for multiple filters Local $word = GUICtrlCreateInput("", 464, 24, 129, 37) $Form1 = GUICreate(" ", 623, 438, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP)) GUISetFont(18, 600, 0, "MS Sans Serif") ; Set the font for all controls in one call $Label1 = GUICtrlCreateLabel("Search:", 16, 24, 422, 41) ì GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $input = GUICtrlCreateInput("", 364, 24, 129, 37) ; $input is the ControlID of the input control GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $input ; When {ENTER} pressed in input $word = GUICtrlRead($input) ; Read the content of the input GUIDelete($Form1) ; Delete GUI SplashTextOn("", "...", 200, 200, -1, -1, 4, "", 24) ExitLoop EndSwitch WEnd For $k = 0 To UBound($folders) - 1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], "*" & $sFilter, 1, 1, 0, 2) ; list files If Not @error Then For $i = 1 To $aFiles[0] ; loop through files $content = FileRead($aFiles[$i]) ; the following regex captures the full lines containing $word $res = StringRegExp($content, '(?im)(.*\b\Q' & $word & '\E\b.*)\R?', 3) ; if $word must be a lone word ; $res = StringRegExp($content, '(?im)(.*\Q' & $word & '\E.*)\R?', 3) ; if $word can be part of another word If IsArray($res) Then $aResult[$n][0] = $aFiles[$i] ; file path For $j = 0 To UBound($res) - 1 $aResult[$n + $j][1] = $res[$j] ; lines Next $n += $j EndIf Next EndIf Next ReDim $aResult[$n][2] aGUI($aResult) SplashOff() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func aGUI($array, $title = "") Local $gui, $i, $findStrPos, _ $itemText, $replacedText, _ $leftStr ;$gui = GUICreate($title, 1024, 768, 192, 124) $gui = GUICreate($title, 800, 640, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP)) $Label1 = GUICtrlCreateLabel("", 100, 0, 400, 35, $SS_CENTER ) GUICtrlSetFont(-1, 16, 400, 4, 'Comic Sans Ms') $listView = _GUICtrlListView_Create($gui, "file", 20, 35, @DesktopWidth - 20, @DesktopHeight -120, BitOR($LVS_REPORT, $LVS_SINGLESEL)) $hFont1 = _WinAPI_CreateFont(25, 6, 0, 0, $FW_MEDIUM, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $DEFAULT_PITCH, 'Tahoma') ; <<<<<<<<<<<<<<<< make our own font using WinAPI _WinAPI_SetFont($listView, $hFont1, True) ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Here we set the font for the $listview items $header = HWnd(_GUICtrlListView_GetHeader($listView)) ; <<<<<<<<<<<<<<<< Here we get the header handle _WinAPI_SetFont($header, $hFont1, True) ; <<<<<<<<<<<<<<<<<<< Here we set the header font _GUICtrlListView_SetExtendedListViewStyle($listView, $LVS_EX_GRIDLINES) _GUICtrlListView_AddColumn($listView, "Text") _GUICtrlListView_AddColumn($listView, "") _GUICtrlListView_AddArray($listView, $array) For $i = 0 To UBound($array) - 1 Step 1 $itemText = _GUICtrlListView_GetItemText($listView, $i) If $itemText <> "" Then $findStrPos = StringInStr($itemText, "\", 0, -1) $leftStr = StringLeft($itemText, $findStrPos) $replacedText = StringReplace($itemText, $leftStr, "") _GUICtrlListView_SetItemText($listView, $i, $replacedText) EndIf Next _GUICtrlListView_SetColumnWidth($listView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($listView, 1, $LVSCW_AUTOSIZE_USEHEADER) GUISetState(@SW_SHOW) EndFunc ;==>aGUI Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, _ $sIndices, $sData, $sAdata, $file, $splitFile $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $listView Switch $iCode Case $NM_DBLCLK $sIndices = _GUICtrlListView_GetSelectedIndices($listView) $sData = _GUICtrlListView_GetItemText($listView, $sIndices) $sAdata = _ArraySearch($aResult, $sData, Default, Default, Default, 3) $file = _ArrayToString($aResult, Default, $sAdata, 0, Default) $splitFile = StringSplit($file, "|") ShellExecute($splitFile[1]) EndSwitch EndSwitch EndFunc
-
Thanks mlipok, today I learned how to insert file .dll in the system, thank you! Your code works fine. I can ask how I can change my code? Thanks
-
I tried your code mlipok I have this error Variable must be of type "Object".: Local $sfileText = $obj.ExtractText("sample.doc",False) Local $sfileText = $obj^ ERROR
-
Thanks orbs for the reply. Can you explain how to insert amb_xdocdiffPlugin.dll in the folders autoit? thank you
-
My idea was: search "words" in the file, displaying the string where there is the word, and then open the file, with the help of Melba23 and MikahS the final code is this: #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstants.au3> #include <GUIlistview.au3> #include <FontConstants.au3> #include <WinAPI.au3> GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Global $listView Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 Local $sFilter = "*.doc;*.txt" ; Create a string with the correct format for multiple filters Local $word = GUICtrlCreateInput("", 464, 24, 129, 37) $Form1 = GUICreate(" ", 623, 438, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP)) GUISetFont(18, 600, 0, "MS Sans Serif") ; Set the font for all controls in one call $Label1 = GUICtrlCreateLabel("Search:", 16, 24, 422, 41) ì GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $input = GUICtrlCreateInput("", 364, 24, 129, 37) ; $input is the ControlID of the input control GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $input ; When {ENTER} pressed in input $word = GUICtrlRead($input) ; Read the content of the input GUIDelete($Form1) ; Delete GUI SplashTextOn("", "...", 200, 200, -1, -1, 4, "", 24) ExitLoop EndSwitch WEnd For $k = 0 To UBound($folders) - 1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], "*" & $sFilter, 1, 1, 0, 2) ; list files If Not @error Then For $i = 1 To $aFiles[0] ; loop through files $content = FileRead($aFiles[$i]) ; the following regex captures the full lines containing $word $res = StringRegExp($content, '(?im)(.*\b\Q' & $word & '\E\b.*)\R?', 3) ; if $word must be a lone word ; $res = StringRegExp($content, '(?im)(.*\Q' & $word & '\E.*)\R?', 3) ; if $word can be part of another word If IsArray($res) Then $aResult[$n][0] = $aFiles[$i] ; file path For $j = 0 To UBound($res) - 1 $aResult[$n + $j][1] = $res[$j] ; lines Next $n += $j EndIf Next EndIf Next ReDim $aResult[$n][2] aGUI($aResult) SplashOff() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func aGUI($array, $title = "") Local $gui, $i, $findStrPos, _ $itemText, $replacedText, _ $leftStr ;$gui = GUICreate($title, 1024, 768, 192, 124) $gui = GUICreate($title, 800, 640, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP)) $Label1 = GUICtrlCreateLabel("", 100, 0, 400, 35, $SS_CENTER ) GUICtrlSetFont(-1, 16, 400, 4, 'Comic Sans Ms') $listView = _GUICtrlListView_Create($gui, "file", 20, 35, @DesktopWidth - 20, @DesktopHeight -120, BitOR($LVS_REPORT, $LVS_SINGLESEL)) $hFont1 = _WinAPI_CreateFont(25, 6, 0, 0, $FW_MEDIUM, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, $DEFAULT_PITCH, 'Tahoma') ; <<<<<<<<<<<<<<<< make our own font using WinAPI _WinAPI_SetFont($listView, $hFont1, True) ; <<<<<<<<<<<<<<<<<<<<<<<<<<< Here we set the font for the $listview items $header = HWnd(_GUICtrlListView_GetHeader($listView)) ; <<<<<<<<<<<<<<<< Here we get the header handle _WinAPI_SetFont($header, $hFont1, True) ; <<<<<<<<<<<<<<<<<<< Here we set the header font _GUICtrlListView_SetExtendedListViewStyle($listView, $LVS_EX_GRIDLINES) _GUICtrlListView_AddColumn($listView, "Text") _GUICtrlListView_AddColumn($listView, "") _GUICtrlListView_AddArray($listView, $array) For $i = 0 To UBound($array) - 1 Step 1 $itemText = _GUICtrlListView_GetItemText($listView, $i) If $itemText <> "" Then $findStrPos = StringInStr($itemText, "\", 0, -1) $leftStr = StringLeft($itemText, $findStrPos) $replacedText = StringReplace($itemText, $leftStr, "") _GUICtrlListView_SetItemText($listView, $i, $replacedText) EndIf Next _GUICtrlListView_SetColumnWidth($listView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($listView, 1, $LVSCW_AUTOSIZE_USEHEADER) GUISetState(@SW_SHOW) EndFunc ;==>aGUI Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, _ $sIndices, $sData, $sAdata, $file, $splitFile $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $listView Switch $iCode Case $NM_DBLCLK $sIndices = _GUICtrlListView_GetSelectedIndices($listView) $sData = _GUICtrlListView_GetItemText($listView, $sIndices) $sAdata = _ArraySearch($aResult, $sData, Default, Default, Default, 3) $file = _ArrayToString($aResult, Default, $sAdata, 0, Default) $splitFile = StringSplit($file, "|") ShellExecute($splitFile[1]) EndSwitch EndSwitch EndFunc The problem is that they are "read" files: .doc .txt .html but are not "read" important files as .xls .ppt .pdf .rtf It is possible to improve this code? Or, in the Forum exists an example of Omga4000 that reads any file '?do=embed' frameborder='0' data-embedContent>> it is also possible to receive in the file Log.txt the string with the search word? thank you