gius Posted March 3, 2015 Posted March 3, 2015 Hello everyone Can anyone help me to use the ZIP UDF to open and read text in files .docx .xlsx .pptx with this code? expandcollapse popup#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
orbs Posted March 3, 2015 Posted March 3, 2015 i seem to recall that xdoc2txt supports OOXML files natively, is that not so? Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
TheSaint Posted March 3, 2015 Posted March 3, 2015 (edited) I've only had a quick look, as I'm aware of your other topic, and I'm also no expert in this area, but it seems to me, that you would NOT be wanting to copy your docx file into a zip file. They way i understand it, is that the docx file is already zipped as is. I'm not sure if the ZIP UDF will open a docx file with that extension, but perhaps it might if you rename .docx to .zip? EDIT I also understood that the xdoc2txt program (CLI or DLL) would do what you want with all those file types, as orbs suggested. Still, I can understand wanting to do it all natively with just AutoIt, though you may not get as nice a result. Edited March 7, 2015 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
orbs Posted March 3, 2015 Posted March 3, 2015 the extension matters not. the OP may look at the UDF thread for examples of use, it's not that complicated - but it is not needed for this specific task, as i just verified xdoc2txt supports these types of files natively. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
gius Posted March 5, 2015 Author Posted March 5, 2015 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 alsowith .docx .xlsx .pptx .odt file? thank you
Kyan Posted March 5, 2015 Posted March 5, 2015 (edited) .*x is already in zip deflate, I'll see what I can do, if I don't reply soon,is bc I failed EDIT: I need to update my scite, my _ArrayToString only has 4parameters xD Edited March 5, 2015 by Kyan Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
orbs Posted March 5, 2015 Posted March 5, 2015 gius, i know for a fact that the command line version of xdoc2txt supports docx, xlsx, pptx, odt (and many other formats) natively. i see no reason the DLL version will not support them. have you tried it? Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
gius Posted March 6, 2015 Author Posted March 6, 2015 Thanks Orbs for your reply,my code is incomplete: expandcollapse popup#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
orbs Posted March 8, 2015 Posted March 8, 2015 gius, since you asked so nicely, i will try to explain what needs to be done so your script can utilize the xdoc2txt tool to check also for docx files and similar. first, update the filter - replace this line: Local $sFilter = "*.doc;*.txt;*.pdf;*xls" ; Create a string with the correct format for multiple filters with this (b.t.w. you had a missing dot there, which you probably did not notice): Local $sFilter = "*.txt;*.pdf;*.doc;*.xls;*.docx;*.xlsx" ; Create a string with the correct format for multiple filters then change the condition to consider all the relevant files. change this section: If StringRight($aFiles[$i],4) = '.doc' Then $content = $obj.ExtractText($aFiles[$i], False) Else $content = FileRead($aFiles[$i]) EndIf to this: 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 and of course, you'll need this function: Func _FileGetExt($sTarget) Return StringTrimLeft($sTarget, StringInStr($sTarget, '.', 0, -1)) EndFunc there are plenty of variants on this issue, this is just one example of getting file extension (and not a very robust one). of course you may need to customize these steps according to your specific requirements. note that i do not use the ZIP UDF whatsoever, as it is not needed. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
gius Posted March 8, 2015 Author Posted March 8, 2015 Thanks Orbs for the reply.I used your advice to update the code: expandcollapse popup#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 .pptxI was wrong again? thanks
orbs Posted March 8, 2015 Posted March 8, 2015 this line is correct, since _FileGetExt() returns the extension without the dot sign: Case 'pdf', 'doc', 'xls', 'ppt', 'docx', 'xlsx', 'pptx' i now tested the script. it works fine, and the search phrase is detected in doc,docx,xls,xlsx - but not in pptx, as you have omitted that from the filter. now you should introduce some troubleshooting measures: check the return values of _FileListToArrayRec, _FileGetExt, $obj.ExtractText, etc. - so you can see when you get unexpected results and why. check the help for _ArrayDisplay(), MsgBox(), ConsoleWrite(). Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now