Leaderboard
Popular Content
Showing content with the highest reputation on 12/27/2019 in all areas
-
just a simple festive decoration for our screen Happy holidays to all! p.s. to turn it off just click on any "light" and then press esc #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> Global $aColors = StringSplit("0x000000,0x0000AA,0x00AA00,0x00AAAA,0xAA0000,0xAA00AA,0xAAAA00,0xAAAAAA,0x555555,0x0000FF,0x00FF00,0x00FFFF,0xFF0000,0xFF00FF,0xFFFF00,0xFFFFFF", ',', 2) Global $iColors = UBound($aColors) - 1 Global $iX = @DesktopWidth, $iY = @DesktopHeight Global $iNrX = Int($iX/17), $iNrY = Int($iY/17) - 2 Global $hGui1 = GUICreate("", $iX, 17, 0, 0, $WS_POPUPWINDOW, $WS_EX_TOPMOST) ; top bar Global $idListview1 = GUICtrlCreateListView("", 0, 0, $iX, 17) GUICtrlSetStyle($idListview1, BitOR($LVS_ICON, $LVS_NOSCROLL)) GUISetState() Global $hGui2 = GUICreate("", 17, $iY - 17 - 17 , 0, 17, $WS_POPUPWINDOW, $WS_EX_TOPMOST) ; left bar Global $idListview2 = GUICtrlCreateListView("", 0, 0, 17, $iY - 17 - 17) GUICtrlSetStyle($idListview2, BitOR($LVS_ICON, $LVS_NOSCROLL)) GUISetState() Global $hGui3 = GUICreate("", $iX, 17, 0, $iY - 17, $WS_POPUPWINDOW, $WS_EX_TOPMOST) ; bottom bar Global $idListview3 = GUICtrlCreateListView("", 0, 0,$iX, 17) GUICtrlSetStyle($idListview3, BitOR($LVS_ICON, $LVS_NOSCROLL)) GUISetState() Global $hGui4 = GUICreate("", 17, $iY -17 -17, $iX - 17 , 17, $WS_POPUPWINDOW, $WS_EX_TOPMOST) ; right bar Global $idListview4 = GUICtrlCreateListView("", 0, 0,17, $iY -17 -17) GUICtrlSetStyle($idListview4, BitOR($LVS_ICON, $LVS_NOSCROLL)) GUISetState() Global $hImage = _GUIImageList_Create() For $i = 0 To $iColors _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview1, $aColors[$i], 16, 16)) Next _GUICtrlListView_SetImageList($idListview1, $hImage) _GUICtrlListView_SetImageList($idListview2, $hImage) _GUICtrlListView_SetImageList($idListview3, $hImage) _GUICtrlListView_SetImageList($idListview4, $hImage) For $x = 1 To $iNrX _GUICtrlListView_AddItem($idListview1, '', Random(0, $iColors, 1)) _GUICtrlListView_AddItem($idListview3, '', Random(0, $iColors, 1)) Next For $y = 1 To $iNrY _GUICtrlListView_AddItem($idListview2, '', Random(0, $iColors, 1)) _GUICtrlListView_AddItem($idListview4, '', Random(0, $iColors, 1)) Next _GUICtrlListView_SetIconSpacing($idListview1, 16 + 1, 16 + 1) _GUICtrlListView_Arrange($idListview1) _GUICtrlListView_SetIconSpacing($idListview2, 16 + 1, 16 + 1) _GUICtrlListView_Arrange($idListview2) _GUICtrlListView_SetIconSpacing($idListview3, 16 + 1, 16 + 1) _GUICtrlListView_Arrange($idListview3) _GUICtrlListView_SetIconSpacing($idListview4, 16 + 1, 16 + 1) _GUICtrlListView_Arrange($idListview4) _GUICtrlListView_EndUpdate($idListview1) Do _GUICtrlListView_SetItem($idListview1, '', Random(0, $iNrX, 1), 0, Random(0, $iColors, 1)) _GUICtrlListView_SetItem($idListview3, '', Random(0, $iNrX, 1), 0, Random(0, $iColors, 1)) _GUICtrlListView_SetItem($idListview2, '', Random(0, $iNrY, 1), 0, Random(0, $iColors, 1)) _GUICtrlListView_SetItem($idListview4, '', Random(0, $iNrY, 1), 0, Random(0, $iColors, 1)) WinSetOnTop($hGui1, '', 1) WinSetOnTop($hGui2, '', 1) WinSetOnTop($hGui3, '', 1) WinSetOnTop($hGui4, '', 1) Until GUIGetMsg() = $GUI_EVENT_CLOSE2 points
-
CSV file editor
AutoBert reacted to pixelsearch for a topic
Hi everybody The script below (901f) allows to wander easily through a listview, selecting any item or subitem by using the 4 direction keys. The Enter key is also managed and allows to fire an event (as double-click does) With the help of mikell (many thanks !) and after several tests based on 1000 rows & 6 columns, we succeeded to code a clear WM_NOTIFY function, which is simple (though solid) and should be reusable without any modification in other scripts dealing with basic listviews (we didn't use or check any particular style for the listview) Trapping the Enter key has been done by using a dummy control + Accelerators, though we spent the whole last week trapping it in another way, using Yashied's Wsp.dll (without any problem) . Finally we choosed the dummy control option... to have a smaller code. Version 901f (Nov 11, 2019) : the pic below shows how the selected subitem appears, with its specific background colour (light blue) Version 901f code : #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <WinAPIvkeysConstants.au3> Global $hGUI = GUICreate("Wandering through ListView (901f)", 460, 500) Global $idListView = GUICtrlCreateListView _ (" Col 0 | Col 1| Col 2| Col 3", 15, 60, 430, 400) Global $hListView = GuiCtrlGetHandle($idListView) For $iRow = 0 To 99 $sRow = StringFormat("%2s", $iRow) GUICtrlCreateListViewItem( _ "Row " & $sRow & " / Col 0 |" & _ "Row " & $sRow & " / Col 1 |" & _ "Row " & $sRow & " / Col 2 |" & _ "Row " & $sRow & " / Col 3", $idListView) Next Global $g_iColumnCount = _GUICtrlListView_GetColumnCount($idListView) -1 Global $g_iItem = -1, $g_iSubItem = -1 ; item/subitem selected in ListView control Global $idDummy_Dbl_Click = GUICtrlCreateDummy() Global $idDummy_Enter = GUICtrlCreateDummy() Global $aAccelKeys[1][2] = [["{ENTER}", $idDummy_Enter]] GUISetAccelerators($aAccelKeys) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Exit Case $idDummy_Dbl_Click MsgBox($MB_TOPMOST, "Double-click activated cell", _ "Row " & $g_iItem & " / Col " & $g_iSubItem) Case $idDummy_Enter If _WinAPI_GetFocus() = $hListView And $g_iItem > -1 Then MsgBox($MB_TOPMOST, "Enter activated cell", _ "Row " & $g_iItem & " / Col " & $g_iSubItem) EndIf EndSwitch WEnd ;============================================ Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iIDFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Static $bMouseDown = False, $bNotXP = Not (@OSVersion = "WIN_XP") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iColor = 0xFF000000 ; this is $CLR_DEFAULT in ColorConstants.au3 If $iItem = $g_iItem And $iSubItem = $g_iSubItem Then $iColor = 0xFFFFC0 ; light blue for 1 subitem (BGR) EndIf DllStructSetData($tCustDraw, "clrTextBk", $iColor) Return $CDRF_NEWFONT Case $LVN_KEYDOWN If $bMouseDown Or $g_iItem = -1 Then Return 1 ; don't process Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam) Local $iVK = DllStructGetData($tInfo, "VKey") Switch $iVK Case $VK_RIGHT If $g_iSubItem < $g_iColumnCount Then $g_iSubItem += 1 If $bNotXP Then _GUICtrlListView_RedrawItems($hListview, $g_iItem, $g_iItem) EndIf Case $VK_LEFT If $g_iSubItem > 0 Then $g_iSubItem -= 1 If $bNotXP Then _GUICtrlListView_RedrawItems($hListview, $g_iItem, $g_iItem) EndIf Case $VK_SPACE ; spacebar would select the whole row Return 1 EndSwitch Case $NM_RELEASEDCAPTURE $bMouseDown = True Local $iItemSave = $g_iItem Local $aHit = _GUICtrlListView_SubItemHitTest($hListView) $g_iItem = $aHit[0] $g_iSubItem = $aHit[1] If $g_iItem = -1 And $iItemSave > -1 Then _GUICtrlListView_RedrawItems($hListview, $iItemSave, $iItemSave) EndIf Case $LVN_ITEMCHANGED Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iNewState = DllStructGetData($tInfo, "NewState") Switch $iNewState Case BitOr($LVIS_FOCUSED, $LVIS_SELECTED) $g_iItem = DllStructGetData($tInfo, "Item") _GUICtrlListView_SetItemSelected($hListview, $g_iItem, False) EndSwitch Case $NM_CLICK, $NM_RCLICK $bMouseDown = False Case $NM_DBLCLK $bMouseDown = False If $g_iItem > -1 Then GUICtrlSendToDummy($idDummy_Dbl_Click) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Version 901k (Dec 16, 2019) What started with a simple "wander through listview" has turned now to a functional CSV file editor, which can be useful to modify your CSV files with AutoIt : Here are the instructions to use the script, based on a CSV file starting like this : street,city,zip,state,beds,baths,sq__ft,type,sale_date,price,latitude,longitude 3526 HIGH ST,SACRAMENTO,95838,CA,2,1,836,Residential,Wed May 21 00:00:00 EDT 2008,59222,38.631913,-121.434879 51 OMAHA CT,SACRAMENTO,95823,CA,3,1,1167,Residential,Wed May 21 00:00:00 EDT 2008,68212,38.478902,-121.431028 ... 1) Import options : comma delimited (default) No need to change anything if your CSV is comma delimited (other options are Semicolon delimited, Tab delimited) 2) Import options : First row = headers (default = checked) * Keep it checked if the 1st row of your imported file contains headers (that's the case in our example) * UNcheck it if the 1st row contains data, making listview headers appear like this : Col 0 | Col 1 | Col 2 ... 3) Import your CSV file : Only now the listview will be created dynamically. As soon as it is populated, GUI becomes resizable/maximizable, which can be helpful during modifications of a listview containing many columns. 4) Selection color : light blue (default) You can change the selected cell background color by clicking the "Selection color" button : this will open Windows color picker. 5) Editing a listview cell : done by Enter key (or double-click), this is how the edited cell will appear : * Please note that the edited background color (green in the pic) depends on each computer theme. It is not related to the selected background we discussed in 4) * Validate your modification with Enter key, or cancel the modification (revert) with Escape Key 6) Edit Font size : 15 (default) 15 was good in the precedent pic, the edited cell had its content "RIO LINDA" perfectly aligned with all other cells (on my computer). Here again, the font height required depends on each computer : if you want the edited font to be bigger (or smaller), just use the updown control. 7) Chained Edit ? (default = No) * "No" => when you finish editing a cell (Enter key), the same cell stays selected. * "Horizontally" => If checked, edition will automatically continue with the cell on its right. * "Vertically" => If checked, edition will automatically continue with the cell below. This feature can be very useful when you modify cells of a whole colum (vertically) or cells by row (horizontally) 8 ) Inserting a blank line (not in Gui) : press the "Ins" key : 9) Deleting a line (not in Gui) : press the "Del" key : 10) Export CSV file : Filename automatically suggested for export will be : Filename import & actual date & actual time, for example : Import name = "Sales Results.csv" => suggested Export name = "Sales Results_2019-12-16 16:00:59.csv" Version 901m (Dec 18, 2019) Yesterday, mikell suggested to import the csv file by dropping it directly into the GUI, good idea This new version 901m allows it. Now there are 2 ways to import the csv file : * Import button * Drag and drop into the large droppable zone, as shown in the pic below (this zone will be reused to create the listview at same coords) Version 901n (Dec 20, 2019) As t0nZ got tons of csv files, pipe "|" separated, here is a new version allowing this 4th separator Version 901p (Dec 25, 2019) New functionality : now you can drag headers to reorder columns. It may help some users who need it while editing their file. Exported CSV file will be saved according to the new columns order. Version 901r (Dec 29, 2019) New functionality : Numeric sort on any column (right click on column header) It is recommended to backup (export) your file before sorting, just in case you need a copy of it, unsorted. Version 901s (Dec 30, 2019) 1 functionality added : String sort (right click on column header) Numeric sort is alright in most cases, but sometimes we also need a String sort like shown in the following picture. Both ways of sorting (numeric and string) are found in this new release. Version 901t (Jan 3, 2020) 3 functionalities added Rename Header , Insert Column , Delete Column (right click on column header to display its context menu) Version 901u (Jan 6, 2020) 1 functionality added : Natural sort. Thanks to jchd for the idea and Melba23 for his function ArrayMultiColSort() included in the script. Though this natural sort isn't fully implemented, it should work when numbers precede letters (see pic below or better, try it on the "street" column found in the downloadable csv test file below) Natural sort duration + listview update are fast, maybe because of the new function _BufferCreate() described here and now added to the script. Version 901w (Jan 10, 2020) Two functionalities added : 1) Close File button, which allows to import other csv file(s) during the same session 2) Import speed has been improved because the listview control is now populated directly by an Array and not anymore by GUICtrlCreateListViewItem() This explains why, in this version, there are no more Control id's for listview items, allowing to empty the listview content in a snap with this line of code : _SendMessage($g_hListView, $LVM_DELETEALLITEMS) That's what it took to add the Close File button and import several csv files during the same session, avoiding id leaks. Please report if any issue is encountered. Version 901x (Jan 14, 2020) One minor functionality added : number of rows is now displayed just under the listview, it may be handy sometimes. Other minor changes included (natural sort speed improved) Credits : Many thanks to Czardas for his function _CSVSplit() and guinness for his function _SaveCSV(), guys you did a great job. Thanks to Musashi : your suggestions and time passed on testing beta versions of the script, that was really helpful and challenging. Not sure I would have ended this script without your detailed reports. Mikell : the 1st step above (901f) that we wrote together, it all started from here. Your knowledge and kindness are legendary ! Not forgetting all other persons who were inspiring : LarsJ, Melba23, jpm, that list could be endless... Download link : version 901x - Jan 14, 2020 (minor update on Jan 15) 901x - CSV file editor.au3 Test csv file (986 rows/12cols) : Sacramento real estate transactions.csv1 point -
I couldn't find such a function (could be I'm not looking in the right place), but I thought this was useful. ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUICtrlListView_GetContents ; Description ...: A function to captures the contents of a SysListView32 control into an Array ; Syntax.........: _GUICtrlListView_GetContents($hWnd) ; Parameters ....: $hWnd - A handle to a SysListView32 control. ; Return values .: Success - An array containing SysListView32 control contents. ; Failure - Returns zero and sets the @error flag: ; |1 - $hWnd Parameter failed IsHwnd type check. ; |2 - If Row or Column count of SysListView32 control equals zero. ; Author ........: Paul Wilson (spudw2k) ; Modified.......: 11/05/2020 (spudw2k) ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _GUICtrlListView_GetContents($hWnd) If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ;Verify input variable is valid Handle $iCols = _GUICtrlListView_GetColumnCount($hWnd) ;Get SysListView control Column count $iRows = _GUICtrlListView_GetItemCount($hWnd) ;Get SysListView control Row count If $iCols = 0 Or $iRows = 0 Then Return SetError (2, 0, 0) ;If Column or Row count + 0, then error Dim $aListView[$iRows+1][$iCols] ;Instantiate Array, sized to hold SysListView contents (rows & columns) For $iX = 0 to $iCols-1 ;Loop through Columns $aListView[0][$iX] = _GUICtrlListView_GetColumn($hWnd,$iX)[5] ;Get Column name and set first row of array Next ;Continue Loop for each Column For $iX = 0 to $iRows-1 ;Loop through Rows For $iY = 0 To $iCols-1 ;Loop Through Columns $aListView[$iX+1][$iY]=_GUICtrlListView_GetItemText($hWnd,$iX,$iY) ;Get Column value and set Rou# / Col# in array Next ;Continue Loop for each Column Next ;Continue Loop through each Row Return $aListView ;Return array containing SysListView contents EndFunc ;==>_GUICtrlListView_GetContents Demo #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <Array.au3> Local $hGUI, $hImage, $hListView $hGUI = GUICreate("(UDF Created) ListView Create", 400, 300) $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268) _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100) _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2) GUISetState(@SW_SHOW) $aListViewContents = _GUICtrlListView_GetContents($hListView) _ArrayDisplay($aListViewContents) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func _GUICtrlListView_GetContents($hWnd) If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ;Verify input variable is valid Handle $iCols = _GUICtrlListView_GetColumnCount($hWnd) ;Get SysListView control Column count $iRows = _GUICtrlListView_GetItemCount($hWnd) ;Get SysListView control Row count If $iCols = 0 Or $iRows = 0 Then Return SetError (2, 0, 0) ;If Column or Row count + 0, then error Dim $aListView[$iRows+1][$iCols] ;Instantiate Array, sized to hold SysListView contents (rows & columns) For $iX = 0 to $iCols-1 ;Loop through Columns $aListView[0][$iX] = _GUICtrlListView_GetColumn($hWnd,$iX)[5] ;Get Column name and set first row of array Next ;Continue Loop for each Column For $iX = 0 to $iRows-1 ;Loop through Rows For $iY = 0 To $iCols-1 ;Loop Through Columns $aListView[$iX+1][$iY]=_GUICtrlListView_GetItemText($hWnd,$iX,$iY) ;Get Column value and set Rou# / Col# in array Next ;Continue Loop for each Column Next ;Continue Loop through each Row Return $aListView ;Return array containing SysListView contents EndFunc ;==>_GUICtrlListView_GetContents1 point
-
Are my AutoIt exes really infected?
seadoggie01 reacted to JLogan3o13 for a topic
Did you really think, for as long as AutoIt has supported Windows 10 (on systems with Defender), that if this was the case it wouldn't have been advertised far and wide?? In the future, rather than making a definitive statement such as this and then having to come back and retract it, perhaps start by asking a question in the forum about the problems you're encountering.1 point -
Monitor a folder before moving to next command
Buster2000 reacted to Nine for a topic
You mean : CheckDirSize("C:\Temp") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error reading directory") Task1() CheckDirSize("C:\Temp") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error reading directory") Task2() CheckDirSize("C:\Temp") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error reading directory") Task3() ... Or you could make a loop : For $i = 1 to $NUMBER_OF_TASKS CheckDirSize("C:\Temp") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error reading directory") Call ("Task" & $i) Next1 point -
1 point
-
Try sending keys first : Local $hWnd = WinActivate ("Place Window title or class here") If Not $hWnd Then Exit MsgBox (0,"","Bad title or class") WinWaitActive ($hWnd) Send ("!e") Sleep (500) Send ("a") Sleep (500) Send ("^c") Sleep (500) MsgBox (0,"",ClipGet ())1 point
-
Use mine : #include <Constants.au3> Opt("MustDeclareVars", 1) Const $sZipFile = @ScriptDir & "\Test.zip" Const $sDestFolder = @ScriptDir & "\Temp" UnZip($sZipFile, $sDestFolder) If @error Then Exit MsgBox ($MB_SYSTEMMODAL,"","Error unzipping file : " & @error) Func UnZip($sZipFile, $sDestFolder) If Not FileExists($sZipFile) Then Return SetError (1) ; source file does not exists If Not FileExists($sDestFolder) Then If Not DirCreate($sDestFolder) Then Return SetError (2) ; unable to create destination Else If Not StringInStr(FileGetAttrib($sDestFolder), "D") Then Return SetError (3) ; destination not folder EndIf Local $oShell = ObjCreate("shell.application") Local $oZip = $oShell.NameSpace($sZipFile) Local $iZipFileCount = $oZip.items.Count If Not $iZipFileCount Then Return SetError (4) ; zip file empty For $oFile In $oZip.items $oShell.NameSpace($sDestFolder).copyhere($ofile) Next EndFunc ;==>UnZip1 point
-
Can you show us the @error value after run ? Maybe it is because Windows system redirection. Try running x64, see if that works.1 point
-
Combining string and varibale to run in CMD
TanjimReza reacted to Nine for a topic
Read the help file, it tells you how to do it. It truly helps reading it run (@ComSpec & ' /c slmgr /ipk ' & $code, "", @SW_HIDE, $STDERR_MERGED) Merry xmas...1 point -
WORKS!! Many thanks <3 you are genius1 point