Leaderboard
Popular Content
Showing content with the highest reputation on 01/22/2020 in all areas
-
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 -
Peace Equalizer shows power of AutoIt
Zedna reacted to PeterVerbeek for a topic
In this post I take the opportunity to show the awesome capabilities of AutoIt and its libraries. My open source project Peace is a long running AutoIt based app located on SourceForge. It provides users with a system-wide equalizer and effects machine. It's an interface using the power of Equalizer APO, an audio processing object software. Peace has been download over 2,600,000 times by various kind of users. Amongst others it gives them possibilities like these: Hearing impaired - Amplify the gain of frequencies which are impaired. Home Theatre - Create Equalizer presets for watching movies and listening to music. Music lovers & audiophiles - Create presets for listening to music on their high quality speakers and headphones. Gamers - Enhance frequencies to get an edge over other gamers. Headphones - Improve the sound quality of cheap headphones and get the max out of expensive ones. Bass lovers - Boost low frequencies for extra bass. Voice - Make a microphone sound better and improve the voice, for instance for YouTube usage. Low audio - Boost low audio of an input source to a comfortable level. This list covers the main needs of the Peace user. Many people have contacted me over the years asking for new features and telling me how they use Peace for their (sometimes specific) needs. I was able to use AutoIt and its libraries for all of their needs. So what are the main features of Peace? Equalize your computer audio by using up to 31 sliders. Support of equalizing 9 speakers : left/right, center, subwoofer, left/right rear, left/right side. Per slider a filter can be chosen such as peak, low/high pass, shelving. The graph windows shows your equalization so you see exactly what you're doing. Apply an effect such as crossfeed simple/Jan Meier/Chu Moy, stereo balance, bass/treble, upmix/downmix, channel routing. Save presets (called configurations) and activate by mouse click, hotkey, desktop shortcut or Peace system tray. Select a target device to equalize, microphone as input can also be equalized. Automate: you can let Peace automatically activate presets on a switch to another device and another process. Peace is available in these languages: English, Czech, Deutsch, Français, Italiano, Nederlands, Pусский, Українська So who am I? I'm a Dutch programmer who happens the stumble upon AutoIt 5 years ago and created a small Equalizer interface app of less than 400 program lines with it. Nowadays Peace has grown to more than 18,000 lines as many features were added. Although Peace is open source, the program code isn't of the best possible quality. The reason being that I didn't expect it to become so popular. It caught me by supprise. I've created a Library of functions called Pal (link to forum post) which quality is up to the AutoIt community standard as counterpart to the Peace program code. I want to state here that AutoIt is a mature program language as Peace obviously shows. I wish it to be used more extensively for professional or semi-professional apps. In my view AutoIt deserves a place amongst the major programming languages for Windows computers. Regards, Peter Verbeek1 point -
File Open Handle Mode Check
seadoggie01 reacted to Subz for a topic
@SmOke_N wrote a UDF a while back which I use from time to time when trying to read sections larger than 32kb, it also includes _IniDeleteEx function which does something similar, it may give you ideas on how to handle FileOpen.1 point -
File Open Handle Mode Check
seadoggie01 reacted to Nine for a topic
How can you read a file you just overwrited before ? I don't get it. Anyway, you could close it and reopen it with the right mode ? Or if the file has write mode and is empty ? But really read the file before you overwrite it1 point -
Array to Combo-box [SOLVED]
Musashi reacted to Colduction for a topic
Whoaaa, i didn't think that Combo-box supports array data from _ArrayToString() and it does't require loop for set all datas in it😀 I should test it first, then ask it :) Thanks @Nine and @Subz, both of you helped me!1 point -
Array to Combo-box [SOLVED]
Colduction reacted to Subz for a topic
As Nine pointed out, you've already converted the array to string "_ArraytoString", so you just use "GuiCtrlSetData" to add that string to the combo box, there is no need for a loop1 point -
Array to Combo-box [SOLVED]
Colduction reacted to Subz for a topic
Unfortunately in a domain environment Win32_UserAccount (takes forever to resolve domain users) if your disconnected from the network it works fine or if you only require local users you can use that within the query. Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount Where LocalAccount = True") Couple of days ago I needed to query a couple of hundred user accounts that had profiles on multiple RDS servers and used the following method to get the user accounts: #include <Array.au3> #include <Security.au3> Global $g_aProfileList[0] _UserProfiles(4) _ArrayDisplay($g_aProfileList) ;~ $_vDomain : 0 - All Users on the system ;~ : 1 = NT Authority Users on the system ;~ : 2 = Local Users on the system ;~ : 3 = NT Authority + Local Users on the system ;~ : 4 = Domain Users on the system ;~ : 5 = NT Authority + Domain Users on the system ;~ : 6 = Local + Domain Users on the system Func _UserProfiles($_vDomain = 0) Local $sRegProfileList = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" Local $aAccountSid, $sRegProfileGuid, $i = 1 While 1 $sRegProfileGuid = RegEnumKey($sRegProfileList, $i) If @error Then ExitLoop $aAccountSid = _Security__LookupAccountSid($sRegProfileGuid) If @error Then ContinueLoop If IsArray($aAccountSid) Then While 1 Switch $_vDomain Case 1 If ($aAccountSid[1] <> "NT Authority") Then ExitLoop Case 2 If ($aAccountSid[1] <> @ComputerName) Then ExitLoop Case 3 If Not ($aAccountSid[1] = "NT Authority" Or $aAccountSid[1] = @ComputerName) Then ExitLoop Case 4 If ($aAccountSid[1] = "NT Authority" Or $aAccountSid[1] = @ComputerName) Then ExitLoop Case 5 If $aAccountSid[1] = @ComputerName Then ExitLoop Case 6 If $aAccountSid[1] = "NT Authority" Then ExitLoop EndSwitch ReDim $g_aProfileList[UBound($g_aProfileList) + 1] $g_aProfileList[UBound($g_aProfileList) - 1] = $aAccountSid[0] ExitLoop WEnd EndIf $i += 1 WEnd EndFunc1 point -
Array to Combo-box [SOLVED]
Colduction reacted to Nine for a topic
For #1 it is very easy. Just create a GUI with a combo-box and use GUICtrlSetData ($idCombo, $Users) to store the values into the combo For #2, can you run this, see if you get all users this way (show the result if you can) : #include <Constants.au3> Global $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") Local $Output = "Computer: " & @ComputerName & @CRLF $Output &= "==========================================" & @CRLF Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount") If not IsObj($colItems) then Exit Msgbox(0,"WMI Output","No WMI Objects Found") For $objItem In $colItems $Output &= "Caption: " & $objItem.Caption & @CRLF Next MsgBox ($MB_SYSTEMMODAL,"",$Output)1 point -
Have you tried just running #RequireAdmin RunWait(@ScriptDir & "\Nextcloud-2.6.2-setup.exe /S /norestart", "", @SW_HIDE)1 point
-
Why AutoIt, and not another language like C# or Python?
CiaronJohn reacted to Jos for a topic
Great first post! Jos1 point -
Resources viewer and compiler. You can drop file (dll, exe ...) on treeview or use menu control to load file, or drop file on executable after compiled or just run and use it as a resource dll compiler. Constructive comments are always welcomed. New script attached (16th April 2009) How to use compiling option: - click on Action menu. - choose Initialize Compiler. - go to menu again and choose Generate Initial DLL - any file that you want to add to your resource dll drop on tree view or use Add Resource button. New window pops up. You need to chose type, name and language of resource. You can choose to use predifined values, only name is required in that case. - when you are done with modifications save new dll file. File menu will have Save as... option - that's it. You have your resource dll compiled with AutoIt Supported resources: - RT_CURSOR - RT_BITMAP - RT_ICON - RT_MENU - RT_DIALOG - RT_STRING - RT_ACCELERATOR - RT_GROUP_CURSOR - RT_GROUP_ICON - RT_VERSION - RT_ANICURSOR - RT_ANIICON - RT_HTML - RT_MANIFEST - AVI (special) - WAV (special) - JPEG (special) - PNG (special) - GIF (special) By supported I mean that resource can be viewed and/or saved. Other resources are shown as hexadecimals, with ASCII character and address display. Download script (zip format due to upload size limit): ResourcesViewerAndCompiler.zip edit: had to remove the old attachment to make more space in my attachment folder.1 point
-
#include <array.au3> ;.. Dim $aArray[2] $aArray[0] = 'Monday, 23:50' $aArray[1] = 'Tuesday, 11:45' ;... Dim $aArray2D[UBound($aArray)][2] For $i = 0 To UBound($aArray)-1 $aSplitted = StringSplit(StringStripWS($aArray[$i], 8), ',') If $aSplitted[0] <> 2 Then MsgBox(16, 'Error', 'Wrong text!') Exit EndIf $aArray2D[$i][0] = $aSplitted[1] $aArray2D[$i][1] = $aSplitted[2] Next _ArrayDisplay($aArray2D)1 point