MikahS Posted February 9, 2015 Posted February 9, 2015 In Avast clicking on "Options" (It should be Options in english version), a window will be open and then click on exclusion and add the directory of the program you need. Let me know if this does the trick. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
gius Posted February 9, 2015 Author Posted February 9, 2015 Thanks again Melba23.No, I have not changed anything.If I add the line _ArrayDisplay($aFiles, "Files found in " & $folders[$k], Default, 8) I receive an error. This is all the code: expandcollapse popup#include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> Local $hUserFunction = _UserFunc Local $sFilter = "*.doc;*.docx;*.txt;" ; Create a string with the correct format for multiple filters <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 Local $word = InputBox(" ", "Search: ", " ", "", 100, -1, 500, 300) For $k = 0 to UBound($folders)-1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], $sFilter, 1, 1, 0, 2) ; 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 Func _UserFunc($aArray, $aSelected) ; Check something is selected and is valid If $aSelected[0] And UBound($aArray) > $aSelected[0] Then ; Get first selected element $sFilePath = $aArray[$aSelected[1]][0] ; Remove the filename and just leave the folder path $sFolderPath = StringRegExpReplace($sFilePath, "(^.*)\\(.*)", "\1") ; Open the folder ShellExecute($sFolderPath) Else ; Display error dialog MsgBox(0, "Error", "No file selected") EndIf EndFunc Redim $aResult[$n][2] _ArrayDisplay($aResult, "Files returned", Default, 8, Default, Default, Default, Default, $hUserFunction) ;_ArrayDisplay($aFiles, "Files found in " & $folders[$k], Default, 8) I wished to ask you though:it is possible to change the font size of InputBox?is very small. I wanted to ask you though:it is possible to change the font size of InputBox?is very small.thanks MikahS for the tip. thanks to all
MikahS Posted February 9, 2015 Posted February 9, 2015 My pleasure. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
Moderators Melba23 Posted February 9, 2015 Moderators Posted February 9, 2015 gius,You are putting that extra debugging line in the correct place? For $k = 0 to UBound($folders)-1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], $sFilter, 1, 1, 0, 2) _ArrayDisplay($aFiles, "Files found in " & $folders[$k], Default, 8) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If not @error ThenM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
gius Posted February 9, 2015 Author Posted February 9, 2015 Now that's fine, thank you! I wished ask:1) it is possible to change the font size of InputBox?is very small.2) when the result is formed by only a Row element 0,does not work, why?thanks to all
MikahS Posted February 9, 2015 Posted February 9, 2015 You'll have to make your own Inputbox to change the font size. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
Moderators Melba23 Posted February 9, 2015 Moderators Posted February 9, 2015 gius,Glad to hear it! As to the other questions: - 1. The font size is set by the system default. If you want a larger font then you would need to create your own dialog with an input control.- 2. Change this line:Func _UserFunc($aArray, $aSelected) ; Check something is selected and is valid If $aSelected[0] And UBound($aArray) >= $aSelected[0] Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< At present it uses > aloneM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
gius Posted February 10, 2015 Author Posted February 10, 2015 Sorry if I am doing many questions.Thanks for your answers Melba23.For many people with visual problemsthe size of the default font of 8.5 is an important problem.So with Koda, I started to develop a small GUI,with GUICtrlCreateInput instead of InputBox.this is the code: expandcollapse popup#include <EditConstants.au3> #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 438, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP)) $Label1 = GUICtrlCreateLabel("Search:", 16, 24, 422, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $hUserFunction = _UserFunc Local $sFilter = "*.doc;*.docx;*.txt" ; Create a string with the correct format for multiple filters <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 Local $word = GUICtrlCreateInput("", 464, 24, 129, 37) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Exit Case $word ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> GUIDelete() EndSwitch WEnd For $k = 0 to UBound($folders)-1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], $sFilter, 1, 1, 0, 2) ; 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 Func _UserFunc($aArray, $aSelected) ; Check something is selected and is valid If $aSelected[0] And UBound($aArray) > $aSelected[0] Then ; Get first selected element $sFilePath = $aArray[$aSelected[1]][0] ; Remove the filename and just leave the folder path $sFolderPath = StringRegExpReplace($sFilePath, "(^.*)\\(.*)", "\1") ; Open the folder ShellExecute($sFolderPath) Else ; Display error dialog MsgBox(0, "Error", "No file selected") EndIf EndFunc Redim $aResult[$n][2] _ArrayDisplay($aResult, "Files returned", Default, 8, Default, Default, Default, Default, $hUserFunction) The sequence mode of application is:opens the GUI and insert the word,after pressing the ENTER key, will close the GUIand the application continues with ArrayDisplay.I think something is missing afterCase $word, and it does not work,can you help me understand where I wrong?For MikahS, in your code on the previous pageI do not think you use ArrayDisplay,it is possible to increase the font size?thanks to all
Moderators Melba23 Posted February 10, 2015 Moderators Posted February 10, 2015 gius,This works as you wish: expandcollapse popup#include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $hUserFunction = _UserFunc Local $sFilter = "*.doc;*.docx;*.txt" ; Create a string with the correct format for multiple filters Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 $Form1 = GUICreate("Form1", 623, 438, 192, 124) GUISetFont(18, 400, 0, "MS Sans Serif") ; Set the font for all controls in one call $Label1 = GUICtrlCreateLabel("Search:", 16, 24, 422, 41) $input = GUICtrlCreateInput("", 464, 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 ExitLoop EndSwitch WEnd For $k = 0 To UBound($folders) - 1 ; loop through folders $aFiles = _FileListToArrayRec($folders[$k], $sFilter, 1, 1, 0, 2) ; 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 Func _UserFunc($aArray, $aSelected) ; Check something is selected and is valid If $aSelected[0] And UBound($aArray) >= $aSelected[0] Then ; You had not changed this line <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Get first selected element $sFilePath = $aArray[$aSelected[1]][0] ; Remove the filename and just leave the folder path $sFolderPath = StringRegExpReplace($sFilePath, "(^.*)\\(.*)", "\1") ; Open the folder ShellExecute($sFolderPath) Else ; Display error dialog MsgBox(0, "Error", "No file selected") EndIf EndFunc ;==>_UserFunc ReDim $aResult[$n][2] _ArrayDisplay($aResult, "Files returned", Default, 8, Default, Default, Default, Default, $hUserFunction)You really need to learn a bit more about how AutoIt works. Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at this excellent tutorial - you will find other tutorials in the Wiki (the link is at the top of the page). M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
MikahS Posted February 10, 2015 Posted February 10, 2015 For MikahS, in your code on the previous pageI do not think you use ArrayDisplay,it is possible to increase the font size? You'd have to increase the font size by specifying your own for the header and the listview in the Function aGUI, like so: ; Must include these at the top <<<< #include <FontConstants.au3> #include <WinAPI.au3> ;======================= ; create the dialog Func aGUI($array, $title = "display that array!") Local $gui, $i, $findStrPos, _ $itemText, $replacedText, _ $leftStr, $hFont1, $header $gui = GUICreate($title, 800, 800) $listView = _GUICtrlListView_Create($gui, "Col0", 0, 0, 800, 800, 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, "Col1") _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() EndFunc ;==>aGUI ;======================= Hope that helps. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
gius Posted February 11, 2015 Author Posted February 11, 2015 Thanks again Melba23.it's really interesting to studyLearning to Script with AutoIt V3 (Last Updated 17 Feb 2010).pdfThanks again!For MikahS, I modified your code expandcollapse popup#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") Local $sFilter = "*.doc;*.docx;*.txt" ; Create a string with the correct format for multiple filters Global $folders[2] = [@DesktopDir, @MyDocumentsDir] Global $aResult[100000][2], $n = 0 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("text", 16, 24, 422, 41) $Label2 = GUICtrlCreateLabel("text", 16, 54, 422, 41) $Label3 = GUICtrlCreateLabel("text", 16, 84, 401, 28) 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 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) ; create the dialog Func aGUI($array, $title = "text") 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("text", 100, 0, 350, 35, $SS_CENTER ) $Label1 = GUICtrlSetFont(-1, 16, 400, 4, 'Comic Sans Ms') $listView = _GUICtrlListView_Create($gui, "file", 5, 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() EndFunc ;==>aGUI ;======================= ;======================= ; here is where we check for the Double click on the listview item 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 have created a Gui to enter the search string, it works but then is interruptedwith this error:Variable used without being declared .:Case $ listViewHouses ^ ERRORWhat I'm wrong?Thank You
Moderators Melba23 Posted February 11, 2015 Moderators Posted February 11, 2015 gius,The error occurs because you have declared the $listview variable inside the aGUI function and so it is invisible to anything outside. Declare the variable as Global at the top of your script so that it is visible inside the message handler and the script will run. You might want to read the Variables - using Global, Local, Static and ByRef tutorial in the Wiki to learn more about scoping variables. M23 MikahS 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
MikahS Posted February 11, 2015 Posted February 11, 2015 Thanks again Melba23.it's really interesting to studyLearning to Script with AutoIt V3 (Last Updated 17 Feb 2010).pdfThanks again! I have created a Gui to enter the search string, it works but then is interruptedwith this error:Variable used without being declared .:Case $ listViewHouses ^ ERRORWhat I'm wrong?Thank You It is my pleasure. The error occurs because you have declared the $listview variable inside the aGUI function and so it is invisible to anything outside. Declare the variable as Global at the top of your script so that it is visible inside the message handler and the script will run. Exactly as Melba described (thanks Melba!). Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
gius Posted February 11, 2015 Author Posted February 11, 2015 I put at the top Global $listView but does not work,the program closes without error. why? Thank You
Moderators Melba23 Posted February 11, 2015 Moderators Posted February 11, 2015 gius,It works when I do it - please post your whole code. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
gius Posted February 11, 2015 Author Posted February 11, 2015 expandcollapse popup#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;*.docx;*.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("text", 16, 24, 422, 41) $Label2 = GUICtrlCreateLabel("text", 16, 54, 422, 41) $Label3 = GUICtrlCreateLabel("text", 16, 84, 401, 28) 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 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) ; create the dialog Func aGUI($array, $title = "text") 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("text", 100, 0, 350, 35, $SS_CENTER ) $Label1 = GUICtrlSetFont(-1, 16, 400, 4, 'Comic Sans Ms') $listView = _GUICtrlListView_Create($gui, "file", 5, 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() EndFunc ;==>aGUI ;======================= ;======================= ; here is where we check for the Double click on the listview item 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 ;======================= Thank You
Moderators Melba23 Posted February 11, 2015 Moderators Posted February 11, 2015 gius,You are exiting immediately you return from the aGUI function - you need to add a GUIGetMsg loop so the script remains active until you close the GUI: ReDim $aResult[$n][2] aGUI($aResult) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndYou really do need to read through those tutorials and get a better idea of how AutoIt works. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
MikahS Posted February 11, 2015 Posted February 11, 2015 (edited) expandcollapse popup#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;*.docx;*.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("text", 16, 24, 422, 41) $Label2 = GUICtrlCreateLabel("text", 16, 54, 422, 41) $Label3 = GUICtrlCreateLabel("text", 16, 84, 401, 28) 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 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) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func aGUI($array, $title = "text") Local $gui, $i, $findStrPos, _ $itemText, $replacedText, _ $leftStr ;$gui = GUICreate($title, 1024, 768, 192, 124) $gui = GUICreate($title, @DesktopWidth - 200, @DesktopHeight - 220, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX)) $Label1 = GUICtrlCreateLabel("text", 100, 0, 350, 35, $SS_CENTER ) GUICtrlSetFont(-1, 16, 400, 4, 'Comic Sans Ms') $listView = _GUICtrlListView_Create($gui, "file", 0, 0, @DesktopWidth - 200, @DesktopHeight -320, 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 You forgot the while loop for the display GUI. EDIT: same as Melba's didn't see he posted. Edited February 11, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
gius Posted February 11, 2015 Author Posted February 11, 2015 (edited) but in the code existsWhile 1 .... WEnd 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 ExitLoop EndSwitch WEnd I also added to your While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd but does not work,do not see any column and row Thank You now it all works,thanks Melba23,thanks MikahS. Edited February 11, 2015 by gius
MikahS Posted February 11, 2015 Posted February 11, 2015 My pleasure. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
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