Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/20/2021 in all areas

  1. Done. You have to set parameter "flag" to $MB_CANCELTRYCONTINUE to get return values $IDTRYAGAIN or $IDCONTINUE Works here with Windows 10 and AutoIt 3.3.14.5
    2 points
  2. Dam How do you know fishing is my second life ?
    2 points
  3. pixelsearch

    CSV file editor

    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.csv
    1 point
  4. Problems with a bad connection. I try to watch videos online and they play a few seconds then stop. Over and over. Seeking through videos would also cause problems and the videos would have to start over, loading. Also reduces wasting bandwidth by watching the same video multiple times. Additionally save space by scaling the video and audio down. After some consideration I though about an elaborate way to resolve this problem, by landing a rover on mars and ....... ,yet then decided I can simply accomplish it with autoit. After some research while considering different approaches I found the best way to do it with RSS feeds.RSS feed downloading. The most practicable use is downloading while away. To watch videos later. A example of feeds file with RSS links feeds https://vimeo.com/adultswim/videos/rss https://vimeo.com/channels/bestoftheyear2016/videos/rss https://vimeo.com/channels/bestofthemonth/videos/rss https://vimeo.com/channels/bestofstaffpicks2017/videos/rss https://vimeo.com/newyorktimes/videos/rss https://vimeo.com/gopro/videos/rss https://vimeo.com/user703283/videos/rss in the folder it creates data.ini which associates the file with vlc title, there are some errors from the split. edit2 fix v1.16 logData($user[1], $user[2], $file) which later can be use for videoplaying main.au3 ; major - Version 1.17 #include <InetConstants.au3> #include <File.au3> Opt("WinTitleMatchMode", 2) $sFilePath = @ScriptDir & "\feeds" Local $iCountLines = _FileCountLines($sFilePath) ConsoleWrite("$iCountLines" & ":" & $iCountLines & @CRLF) Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Local $oXML = ObjCreate("Microsoft.XMLDOM") Local $titleInfo For $i = 1 To $iCountLines $sFileRead = FileReadLine($hFileOpen, $i) $url = $sFileRead If (@error) Then ConsoleWrite($i & ":" & "ExitLoop ... FileReadLine ERROR" & @CRLF) ExitLoop Else ConsoleWrite($i & ":" & $url & @CRLF) Local $sFile = @ScriptDir & "/rss.xml" Local $hDownload = InetGet($url, $sFile, $INET_FORCERELOAD) InetClose($hDownload) $oXML.load($sFile) $oParameters = $oXML.SelectNodes("/rss/channel/item") For $oParameter In $oParameters $oVideoId = $oParameter.SelectSingleNode("./link").text $split = StringSplit($oVideoId, '/') $file = $split[$split[0]] ConsoleWrite('+' & "link:" & $oVideoId & @CRLF) ConsoleWrite('+' & "file:" & $file & @CRLF) $fSaveDir = @ScriptDir & "\downlink\" If (FileExists($fSaveDir) == 0) Then DirCreate($fSaveDir) EndIf $fSave = $fSaveDir & $file & ".mp4" If (FileExists($fSave) == 0) Then ;https://wiki.videolan.org/Transcode ;https://wiki.videolan.org/Documentation:Modules/transcode/ ;https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/ ;;;;;; vb="1024" is bitrate adjust or remove for better quyality. 1024 is for lower bandwidth $pram = ' -vvv "' & $oVideoId & '" --qt-notification=0 --sout=#transcode{vcodec="h264",vb="1024",fps="25",vfilter=canvas{width=960,height=540},acodec="mp3",ab="12","channels=2",samplerate="32000"}:standard{access="file",dst=' & $fSave & '} vlc://quit"' ConsoleWrite('+' & 'C:\Progra~2\VideoLAN\VLC\vlc.exe' & $pram & @CRLF) Local $iPID = ShellExecute("vlc.exe", $pram, @ProgramFilesDir & "\VideoLAN\VLC\") Sleep(5000) $title = StringTrimRight(WinGetTitle("VLC"), 19) ConsoleWrite('>' & $iPID & ":" & $title & @CRLF) $user = StringSplit($title, '-') For $i = 2 To $user[0] ; Loop through the array returned by StringSplit to display the individual values. If ($i > 2) Then ;; needs tested to confirm replacing - $titleInfo = $titleInfo & "-" & $user[$i] Else $titleInfo = $titleInfo & $user[$i] EndIf Next ConsoleWrite('+' & $titleInfo & @CRLF) logData($user[1], $titleInfo, $file) ConsoleWrite('>' & $iPID & ":::ProcessWaitClose" & @CRLF) ProcessWaitClose($iPID) Else ConsoleWrite('!' & "Pass:::" & $fSave & @CRLF) EndIf Next ConsoleWrite($i & ":" & $sFileRead & @CRLF) EndIf Next Func logData($user, $title, $code) Local Const $sFilePath = $fSaveDir & "data.ini" ConsoleWrite($sFilePath & @CRLF) ConsoleWrite('+' & $user & ":" & $title & ":" & $code & @CRLF) IniWrite($sFilePath, $user, $code, $title) EndFunc ;==>logData Additionally, I haven't spent extensive time to testing it. It's functional for me after a few test. I am not sure if scaling video down through vlc effects download bandwidth. VLC could be downloading the HD version then scaling down through the pc. Might be something to look into. I will not endorse/support this use for other websites. Edit 2 - replaceCode ; Version 1.16 $title = WinGetTitle("VLC") ConsoleWrite('>' & $iPID & ":" & $title & @CRLF) $user = StringSplit($title, '-') logData($user[1], $user[2], $file) This remove most failures in title split. For data.ini video info Edit 3 - : fix split with for loop, add version identifier ; Version 1.17 $title = StringTrimRight (WinGetTitle("VLC"), 19 ) ConsoleWrite('>' & $iPID & ":" & $title & @CRLF) $user = StringSplit($title, '-') For $i = 2 To $user[0] ; Loop through the array returned by StringSplit to display the individual values. If ($i > 2) Then ;; needs tested to confirm replacing - $titleInfo = $titleInfo & "-" $user[$i] Else $titleInfo = $titleInfo & $user[$i] EndIf Next ConsoleWrite('+' & $titleInfo & @CRLF) logData($user[1], $titleInfo, $file) Edit 4 - Comments added vimeoDownload_descritpions.au3 The most simple version. If you don't want all the extra stuff and just want to learn from it with experimentation. Trimmed down to 16 lines vimeoDownload_basic.au3 Edit 5 - Line 43 added --qt-start-minimized to background the tasks. $pram = ' -vvv --qt-start-minimized "' & $oVideoId & '" --qt-notification=0 --sout=#transcode{vcodec="h264",vb="1024",fps="25",vfilter=canvas{width=960,height=540},acodec="mp3",ab="12","channels=2",samplerate="32000"}:standard{access="file",dst=' & $fSave & '} vlc://quit"' All Source files. majorangle/vimeoDownloader: Download vimeo videos from RSS feeds while away. (github.com) VLC is required Official download of VLC media player, the best Open Source player - VideoLAN If you have any questions I'll do my best to help.
    1 point
  5. Nine

    Date macros safe to use?

    No time for that foolish timer...
    1 point
  6. Exit ConsoleWrite(TimeNow() & @CRLF) Func TimeNow( $iReturnArray = 0 ) Local $aArray[8] = [7] Do $aArray[7] = @MSEC $aArray[6] = @SEC $aArray[5] = @MIN $aArray[4] = @HOUR $aArray[3] = @MDAY $aArray[2] = @MON $aArray[1] = @YEAR Until $aArray[6] = @SEC If $iReturnArray Then Return $aArray Return $aArray[1] & "-" & $aArray[2] & "-" & $aArray[3] & "_" & $aArray[4] & ":" & $aArray[5] & ":" & $aArray[6] & "." & $aArray[7] EndFunc ..now your time, is the time that of that time.
    1 point
  7. Nine

    Date macros safe to use?

    Sorry to say you are not right. It will always depends when each statements are executed. Best approach is to get full time at once. There is multiple ways to reach this goal.
    1 point
  8. Virtual listview It's certainly doable: #include <ComboConstants.au3> #include <EditConstants.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "RandomArray.au3" ; LarsJ Opt("MustDeclareVars", 1) Global $g_iRows = 1000, $g_iCols = 6, $g_iLeftLV = 10, $g_iTopLV = 40, $g_hGui, $g_hListView, $g_hHeader, $g_hEdit Global $g_aCols = ["Strings", "Integers", "Floats", "Dates", "Times", "R/C"], $g_aWidths = [230, 61, 124, 70, 60, 60] Global $g_idListView, $g_idMarker, $g_idComboCol, $g_idComboColDummy, $g_idEditDummy Global $g_sSearch, $g_iSearchCol, $g_iSortDir, $g_iSearch = $g_iRows Global $g_aArray, $g_aSubArray, $g_tDefaultIndex, $g_tIndex = DllStructCreate("uint arr[" & $g_iRows & "]") Global $g_aIndex[$g_iCols], $g_aIndexTemp[$g_iCols] ; VarGetType's : $g_aIndex => "Array", $g_aIndex[0] => "String" Example() Func Example() ; Generate array & one index _Generate_All($g_aArray) $g_aSubArray = $g_aArray $g_tDefaultIndex = $g_tIndex ; Create GUI $g_hGui = GUICreate("Virtual ListView + Sort + Incremental search + CustomDraw (2k)", 630 + 20, 788 + 30 + 20) ; Create Edit control (search) + dummy control Local $idEdit = GUICtrlCreateEdit("", 120, 10, 305, 20, BitXOR($GUI_SS_DEFAULT_EDIT, $WS_HSCROLL, $WS_VSCROLL)) $g_hEdit = GUICtrlGetHandle($idEdit) $g_idEditDummy = GUICtrlCreateDummy() ; Create ComboBox control (how to search : RegEx or Normal ?) Local $idSearchHow = GUICtrlCreateCombo("RegEx search", 11, 9, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) Local $sSearchHow = "RegEx search", $sSearchHowPrev = $sSearchHow ; default way of searching (changeable) GUICtrlSetData($idSearchHow, "Normal search", $sSearchHow) ; Create ComboBox control (column where to search) + dummy control GUICtrlCreateLabel("Col", 429, 10, 20, 20, BitOR($SS_CENTERIMAGE, $SS_CENTER)) $g_idComboCol = GUICtrlCreateCombo("0", 452, 9, 41, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) $g_iSearchCol = 0 ; default column where to search (changeable) Local $iSearchColPrev = $g_iSearchCol For $i = 1 To $g_iCols - 1 GUICtrlSetData($g_idComboCol, $i & "|", $g_iSearchCol) Next $g_idComboColDummy = GUICtrlCreateDummy() ; Create Label control (number of matching results) Local $idResult = GUICtrlCreateLabel(" " & $g_iRows & " rows (no pattern)", 501, 10, 135, 20, BitOR($SS_CENTERIMAGE, $SS_SUNKEN)) ; Create ListView $g_idListView = GUICtrlCreateListView("", $g_iLeftLV, $g_iTopLV, 630, 788, BitOr($GUI_SS_DEFAULT_LISTVIEW, $LVS_OWNERDATA), $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($g_idListView, BitOr($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) $g_hListView = GUICtrlGetHandle($g_idListView) $g_hHeader = _GUICtrlListView_GetHeader($g_idListView) For $i = 0 To $g_iCols - 1 _GUICtrlListView_AddColumn($g_idListView, $g_aCols[$i], $g_aWidths[$i]) Next ; Create Marker (an orange line placed above the header of the column being searched) $g_idMarker = GUICtrlCreateLabel("", 0, 0) GUICtrlSetBkColor(-1, 0xFFA060) ; orange _MoveMarker($g_iSearchCol) _GUICtrlListView_SetSelectedColumn($g_idListView, $g_iSearchCol) ; Sorting information $g_iSortDir = 0x0400 ; $HDF_SORTUP Local $iSortCol = -1, $iSortColPrev = -1 GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUICtrlSendMsg($g_idListView, $LVM_SETITEMCOUNT, $g_iRows, 0) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $g_idComboCol, $g_idComboColDummy, $idSearchHow $g_iSearchCol = GUICtrlRead($g_idComboCol) $sSearchHow = GUICtrlRead($idSearchHow) Select Case $g_iSearchCol <> $iSearchColPrev _MoveMarker($g_iSearchCol) ; Search column will be selected below, after ContinueCase $iSearchColPrev = $g_iSearchCol Case $sSearchHow <> $sSearchHowPrev $sSearchHowPrev = $sSearchHow Case Else ; no change in both Combo controls (same search column, same search way) ContinueLoop EndSelect ContinueCase Case $g_idEditDummy _GUICtrlHeader_SetItemFormat($g_hHeader, $iSortCol, $HDF_STRING) $g_sSearch = GUICtrlRead($idEdit) $g_tIndex = $g_tDefaultIndex If $g_sSearch = "" Then ; Empty search string, display all rows $g_aSubArray = $g_aArray $g_iSearch = $g_iRows Else ; Find rows matching the search string $g_iSearch = 0 If $sSearchHow = "RegEx search" Then For $i = 0 To $g_iRows - 1 ; duplicated For... Next for speed If StringRegExp($g_aArray[$i][$g_iSearchCol], "(?i)" & $g_sSearch) Then For $j = 0 To $g_iCols - 1 $g_aSubArray[$g_iSearch][$j] = $g_aArray[$i][$j] Next $g_iSearch += 1 EndIf Next Else ; "Normal search" For $i = 0 To $g_iRows - 1 ; duplicated For... Next for speed If StringInStr($g_aArray[$i][$g_iSearchCol], $g_sSearch) Then For $j = 0 To $g_iCols - 1 $g_aSubArray[$g_iSearch][$j] = $g_aArray[$i][$j] Next $g_iSearch += 1 EndIf Next EndIf ; Delete eventual temporary subindexes For $i = 0 To $g_iCols - 1 If VarGetType($g_aIndexTemp[$i]) = "DLLStruct" Then $g_aIndexTemp[$i] = "" ; "String" Next EndIf GUICtrlSetData($idResult, " " & $g_iSearch & ($g_sSearch = "" ? " rows (no pattern)" : " matching rows")) ;------ ; _GUICtrlListView_SetSelectedColumn($g_hListView, $g_iSearchCol) ; depending on search, crashes script when placed here ; _GUICtrlListView_SetSelectedColumn($g_idListView, $g_iSearchCol) ; strange behavior here ; GUICtrlSendMsg($g_idListView, $LVM_SETSELECTEDCOLUMN, $g_iSearchCol, 0) ; strange behavior here ;------ GUICtrlSendMsg($g_idListView, $LVM_SETITEMCOUNT, $g_iSearch, 0) _GUICtrlListView_SetSelectedColumn($g_hListView, $g_iSearchCol) ; seems ok here (after $LVM_SETITEMCOUNT) Case $g_idListView ; Sort $iSortCol = GUICtrlGetState($g_idListView) If $iSortCol <> $iSortColPrev Then _GUICtrlHeader_SetItemFormat($g_hHeader, $iSortColPrev, $HDF_STRING) EndIf ; Set $g_tIndex + eventual update of $g_aIndexTemp[$iSortCol] OR $g_aIndex[$iSortCol] If GUICtrlRead($idEdit) Then _UpdateIndex($g_aIndexTemp, $iSortCol) Else _UpdateIndex($g_aIndex, $iSortCol) EndIf $g_iSortDir = (($iSortCol = $iSortColPrev) ? ($g_iSortDir = $HDF_SORTUP ? $HDF_SORTDOWN : $HDF_SORTUP) : ($HDF_SORTUP)) _GUICtrlHeader_SetItemFormat($g_hHeader, $iSortCol, $HDF_STRING + $g_iSortDir) GUICtrlSendMsg($g_idListView, $LVM_SETSELECTEDCOLUMN, $iSortCol, 0) GUICtrlSendMsg($g_idListView, $LVM_SETITEMCOUNT, $g_iSearch, 0) $iSortColPrev = $iSortCol Case $GUI_EVENT_RESTORE ; needed, or Marker goes back in 0, 0 after Restore (why ?) _MoveMarker($g_iSearchCol) EndSwitch WEnd ; Cleanup GUIDelete($g_hGui) EndFunc ;==>Example ;======================================================================== Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Switch HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Case $g_hListView Switch DllStructGetData($tNMHDR, "Code") Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Switch DllStructGetData($tCustDraw, "dwDrawStage") ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any item-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any subitem-related drawing operations Case $CDDS_ITEMPREPAINT + $CDDS_SUBITEM ; Before painting a subitem If (DllStructGetData($tCustDraw, "iSubItem") = $g_iSearchCol) And $g_sSearch Then Return $CDRF_NOTIFYPOSTPAINT ; If $g_sSearch then paint $g_iSearchCol in postpaint stage Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors ; Paint all other columns in prepaint stage with default code Case $CDDS_ITEMPOSTPAINT + $CDDS_SUBITEM ; After painting a subitem ; Paints $g_iSearchCol ($g_iSearchCol only) if $g_sSearch Local Static $tRect = DllStructCreate( $tagRECT ), $pRect = DllStructGetPtr( $tRect ), $tSize = DllStructCreate( $tagSIZE ) Local Static $hBrushYellow = _WinAPI_CreateSolidBrush( 0x00FFFF ), $hBrushCyan = _WinAPI_CreateSolidBrush( 0xFFFF00 ) ; Yellow and cyan, BGR Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec"), $hDC = DllStructGetData( $tCustDraw, "hDC" ) ; Subitem text and matching text Local $sSubItemText = $g_iSortDir = 0x0400 ? $g_aSubArray[$g_tIndex.arr($iItem + 1)][$g_iSearchCol] _ ; 0x0400 = $HDF_SORTUP : $g_aSubArray[$g_tIndex.arr($g_iSearch - $iItem)][$g_iSearchCol] Local $sMatch = StringRegExp( $sSubItemText, "(?i)" & $g_sSearch, 1 ), $extended = @extended, $iLen = StringLen( $sMatch[0] ) ; Entire subitem rectangle DllStructSetData( $tRect, 2, $g_iSearchCol ) ; Top DllStructSetData( $tRect, 1, $LVIR_BOUNDS ) ; Left GUICtrlSendMsg( $g_idListView, $LVM_GETSUBITEMRECT, $iItem, $pRect ) DllStructSetData( $tRect, 1, DllStructGetData( $tRect, 1 ) + ( $g_iSearchCol ? 6 : 3 ) ) ; Left margin ; Set transparent background for the subitem DllCall( "gdi32.dll", "int", "SetBkMode", "handle", $hDC, "int", $TRANSPARENT ) ; _WinAPI_SetBkMode ; Draw entire subitem text DllStructSetData( $tRect, 2, DllStructGetData( $tRect, 2 ) + 2 ) ; Top margin DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $sSubItemText, "int", StringLen( $sSubItemText ), "struct*", $tRect, "uint", 0 ) ; _WinAPI_DrawText DllStructSetData( $tRect, 2, DllStructGetData( $tRect, 2 ) - 2 ) ; Top margin ; Rectangle for matching substring DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sSubItemText, "int", $extended - $iLen - 1, "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + DllStructGetData( $tSize, "X" ) ) DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sMatch[0], "int", $iLen, "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 DllStructSetData( $tRect, "Right", DllStructGetData( $tRect, "Left" ) + DllStructGetData( $tSize, "X" ) ) ; Fill matching rectangle with yellow or cyan background color DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", GUICtrlSendMsg( $g_idListView, $LVM_GETITEMSTATE, $iItem, $LVIS_SELECTED ) ? $hBrushYellow : $hBrushCyan ) ; _WinAPI_FillRect ; Redraw matching text on the yellow or cyan background DllStructSetData( $tRect, 2, DllStructGetData( $tRect, 2 ) + 2 ) ; Top margin DllCall( "gdi32.dll", "int", "SetTextColor", "handle", $hDC, "int", 0x000000 ) ; _WinAPI_SetTextColor DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $sMatch[0], "int", $iLen, "struct*", $tRect, "uint", 0 ) ; _WinAPI_DrawText Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate($tagNMLVDISPINFO, $lParam) If ($tNMLVDISPINFO.SubItem = $g_iSearchCol) And $g_sSearch Then Return ; Don't paint $g_iSearchCol if $g_sSearch Local Static $tText = DllStructCreate("wchar[50]"), $pText = DllStructGetPtr($tText) Local $s = $g_iSortDir = 0x0400 ? DllStructSetData($tText, 1, $g_aSubArray[$g_tIndex.arr($tNMLVDISPINFO.Item + 1)][$tNMLVDISPINFO.SubItem]) _ ; 0x0400 = $HDF_SORTUP : DllStructSetData($tText, 1, $g_aSubArray[$g_tIndex.arr($g_iSearch - $tNMLVDISPINFO.Item)][$tNMLVDISPINFO.SubItem]) DllStructSetData($tNMLVDISPINFO, "Text", $pText) EndSwitch Case $g_hHeader Switch DllStructGetData($tNMHDR, "Code") Case $HDN_ENDTRACKW, $HDN_DIVIDERDBLCLICKW ; let's forget $HDN_TRACKW... _MoveMarker(GUICtrlRead($g_idComboCol)) Case $NM_RCLICK Local $aHit = _GUICtrlListView_SubItemHitTest($g_hListView) ; $aHit[1] : 0-based index of the LV subitem... i.e. the column in our case (may be -1 if right click on empty part of header) If $aHit[1] > - 1 Then ; valid column GUICtrlSetData($g_idComboCol, $aHit[1]) GUICtrlSendToDummy($g_idComboColDummy) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;======================================================================== Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $hWndFrom = $lParam Local $iCode = BitShift($wParam, 16) ; High word Switch $hWndFrom Case $g_hEdit Switch $iCode Case $EN_CHANGE GUICtrlSendToDummy($g_idEditDummy) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND ;======================================================================== Func _Generate_All(ByRef $g_aArray) ConsoleWrite("$g_iRows = " & $g_iRows & " $g_iCols = " & $g_iCols & @CRLF) Local $hTimer = TimerInit() $g_aArray = FAS_Random2DArrayAu3($g_iRows, "sifdtr", "abcdefghijklmnopqrstuvwxyz") For $i = 0 To $g_iRows - 1 $g_tIndex.arr($i + 1) = $i Next ConsoleWrite("Generating array & one index = " & TimerDiff($hTimer) & @CRLF & @CRLF) EndFunc ;==>_Generate_All ;======================================================================== Func _SortArrayStruct(Const ByRef $aArray, $iCol, $iRows) Local $tIndex = DllStructCreate("uint arr[" & $iRows & "]") Local $pIndex = DllStructGetPtr($tIndex) Local Static $hDll = DllOpen("kernel32.dll") Local Static $hDllComp = DllOpen("shlwapi.dll") Local $lo, $hi, $mi, $r ; Sorting by one column For $i = 1 To $iRows - 1 $lo = 0 $hi = $i - 1 Do $mi = Int(($lo + $hi) / 2) $r = DllCall($hDllComp, 'int', 'StrCmpLogicalW', 'wstr', $aArray[$i][$iCol], 'wstr', $aArray[DllStructGetData($tIndex, 1, $mi + 1)][$iCol])[0] Switch $r Case -1 $hi = $mi - 1 Case 1 $lo = $mi + 1 Case 0 ExitLoop EndSwitch Until $lo > $hi DllCall($hDll, "none", "RtlMoveMemory", "struct*", $pIndex + ($mi + 1) * 4, "struct*", $pIndex + $mi * 4, "ulong_ptr", ($i - $mi) * 4) DllStructSetData($tIndex, 1, $i, $mi + 1 + ($lo = $mi + 1)) Next Return $tIndex EndFunc ;==>_SortArrayStruct ;======================================================================== Func _UpdateIndex(ByRef $aIndex, $iCol) If VarGetType($aIndex[$iCol]) = "DLLStruct" Then $g_tIndex = $aIndex[$iCol] Else $g_tIndex = _SortArrayStruct($g_aSubArray, $iCol, $g_iSearch) $aIndex[$iCol] = $g_tIndex ; "DLLStruct" (or "Int32" when no match found +++) EndIf EndFunc ;==>_UpdateIndex ;======================================================================== Func _MoveMarker($iCol) Local $aRect = _GUICtrlHeader_GetItemRect($g_hHeader, $iCol) ControlMove($g_hGui, "", $g_idMarker, $g_iLeftLV + $aRect[0], $g_iTopLV - 3, $aRect[2] - $aRect[0] + 1, 3) EndFunc ;==>_MoveMarker And the custom draw code is much more effective than the owner draw code. In the custom draw code, only the column provided with a search filter is drawn with GDI functions. Otherwise, all columns are drawn with default code in the Windows dll-files at the speed of real compiled code. This also applies when there is no search filter. In the owner draw code, all columns are drawn with GDI functions. It ends up being quite a lot of code that's executed as pure interpreted AutoIt code. In an example like this, it's a really good idea to use custom draw code. The code has been tested on Windows 7. From Windows 7 and newer Windows versions, the subitem rectangles appear to be implemented in a consistent manner. But this isn't the case on older Windows versions. Eg. on Windows XP, the size and location of subitem rectangles may vary by a few pixels. An example is seen in Multi-line ListView items (search for Windows XP). Custom draw documentation Column alignment
    1 point
  9. Thanks for pointing that out, I've lost track of if/when that version was actually made part of the standard setup. That's why I posted the code of that function as well for those requiring it. If someone needs a prime test, one can use the code below. In fact it's a compositeness test: #include "..\Include\bignum.au3" ; my own modified version which includes _BigNum_PowerMod (copied below) ; crude _BigNum implementation of probabilistic Miller-Rabin compositeness test Global Const $iIter = 25 ; number or iterations of the test ; number to test: here make it >= 100 else the test might fail Local $candidate = "4547337172374198670486519816108044840340489609" ConsoleWrite($candidate & " is " & (_IsBigNumComposite($candidate) ? "composite." : "prime with probalitity " & 1 - 0.25 ^ $iIter) & @LF) Func _IsBigNumComposite($n) If $n = "0" Or $n = "1" Then Return True ; technically speaking, $n is not prime If $n = "2" Then Return False ; 2 is always a poison in prime operations! If Mod(StringRight($n, 1), 2) = 0 Then Return True Local $n_1 = _BigNum_Sub($n, "1") Local $t, $q = $n_1 While Mod(StringRight($q, 1), 2) = 0 ; while $q even $t += 1 $q = _BigNum_Div($q, 2) WEnd Local $a, $e, $b, $any For $c = 1 To $iIter ; 10 test rounds are enough for demonstration purposes. 25 rounds are safer. $a = String(Random(2, 100, 1)) ; the range upper bound doesn't really matter as long as it is < $n $b = _BigNum_PowerMod($a, $q, $n) If $b <> "1" Then For $e = 1 To $t If $b = $n_1 Then ContinueLoop $b = _BigNum_Mod(_BigNum_Mul($b, $b), $n) Next If $b <> $n_1 Then Return True EndIf Next Return False EndFunc #cs ; #FUNCTION# ;==================================================================================== ; ; Name...........: _BigNum_PowerMod ; Description ...: Modular Exponentiation Mod($n^$e, $k) ; Syntax.........: _BigNum_Pow($n, $e, $k) ; Parameters ....: $n - Positive StringNumber: Digits"0"..."9" ; $e - Positive StringNumber: Exponent ; $k - Positive StringNumber: Modulus ; Return values .: Success - Result Mod($n^$e, $k) ; Failure - -1, sets @error to 1 if $n is not a positive valid StringNumber ; -1, sets @error to 2 if $e is not a positive valid StringNumber ; -1, sets @error to 3 if $k is not a positive valid StringNumber ; Author ........: jchd ; Date ..........: 17.12.13 ; Remarks .......: Fractional exponents not allowed - use BigNum_n_root instead. ; ;=============================================================================================== Func _BigNum_PowerMod($n, $e, $k) If Not __BigNum_IsValid($n) Then Return SetError(1, 0, -1) If Not __BigNum_IsValid($e) Then Return SetError(2, 0, -1) If Not __BigNum_IsValid($k) Then Return SetError(3, 0, -1) Local $res = "1" While $e <> "0" If Mod(StringRight($e, 1), 2) Then $res = _BigNum_Mod(_BigNum_Mul($res, $n), $k) $e = _BigNum_Sub($e, "1") EndIf $n = _BigNum_Mod(_BigNum_Mul($n, $n), $k) $e = _BigNum_Div($e, "2") WEnd Return $res EndFunc ;==>_BigNum_PowerMod #ce
    1 point
  10. i just wanted to thank you. using this tool, i was able to retrieve the current state and last date of the Kaspersky-AV-Virus-Database on my system. afterwards, to avoid all the loops and holes of all that comerror-handling i took the knowledge to output the wmic-results into a textfile to read. Local $sIniFile = @TempDir & "\Kaspersky_ProductInfo.ini" ; $FO_OVERWRITE (2) = Write mode (erase previous contents) ; $FO_CREATEPATH (8) = Create directory structure if it does not exist (See Remarks). ; $FO_UNICODE or $FO_UTF16_LE (32) = Use Unicode UTF16 Little Endian reading and writing mode. Local $hIniFile = FileOpen($sIniFile, 32+2+8) FileWriteLine($hIniFile, "[Kaspersky]") ; wrote this as an ini header before the wmic-output ; Close File handle to allow STDOUT from WMIC to be appended FileClose($hIniFile) RunWait(@ComSpec & " /c " & _ 'wmic.exe /namespace:\\root\kaspersky\security path kasperskysecurity_productinfo get * /VALUE >>' & $sIniFile) ; does output as UCS2 LE-BOM therefore created the file with that encoding. Local $sOutputTxt $sOutputTxt = "" $sOutputTxt&= "ConnectionState " & @TAB & "= " & Iniread($sIniFile, "Kaspersky", "ConnectionState", "----------") & @CRLF $sOutputTxt&= "AVBasesDateTime " & @TAB & "= " & Iniread($sIniFile, "Kaspersky", "AVBasesDatetime", "----------") & @CRLF $sOutputTxt&= "IsLicenseInstalled " & @TAB & "= " & Iniread($sIniFile, "Kaspersky", "IsLicenseInstalled","----------") & @CRLF $sOutputTxt&= "LicenseDaysLeft " & @TAB & "= " & Iniread($sIniFile, "Kaspersky", "LicenseDaysLeft", "----------") & @CRLF $sOutputTxt&= "ProductName " & @TAB & "= " & Iniread($sIniFile, "Kaspersky", "ProductName", "----------") & @CRLF $sOutputTxt&= "ProductVersion " & @TAB & "= " & Iniread($sIniFile, "Kaspersky", "ProductVersion", "----------") & @CRLF msgbox(0,"Date & Time of Database" , $sOutputTxt) sure - not THAT elegant - but even faster than waiting for the wmi-object to become ready to read. i added the scriptomatic-tool to my permanent tools-list. very handy, cool output alternatives. thank you all for your hard work !
    1 point
  11. You are getting the wrong result because you used the wrong data. The examples in the links that you provided used binary salts. You were not converting the salt to binary before passing it to the function. The example below, which is a modified version of the example supplied with the CryptoNG UDF lib, would be the equivalent conversion using CryptoNG: #include <MyIncludes\CryptoNG\CryptoNG.au3> ; <== Modify as needed pbkdf2_example() Func pbkdf2_example() Const $PASSWORD = "[test]" Const $SALT = _CryptoNG_CryptStringToBinary("fd4b1e6ad1b05db6ff288928fed3005ef4fdc9ade8be276220a8f41adcccda29", $CNG_CRYPT_STRING_HEX) ;~ Const $SALT = Binary("0xfd4b1e6ad1b05db6ff288928fed3005ef4fdc9ade8be276220a8f41adcccda29") ;Alternate way Const $ITERATIONS = 100 Const $KEY_BIT_LENGTH = 256 Const $ALGORITHM = $CNG_BCRYPT_SHA256_ALGORITHM Local $xPasswordHash = Binary("") ;PBKDF2 Example $xPasswordHash = _CryptoNG_PBKDF2($PASSWORD, $SALT, $ITERATIONS, $KEY_BIT_LENGTH, $ALGORITHM) If @error Then ConsoleWrite("ERROR: " & _CryptoNG_LastErrorMessage() & @CRLF) Exit 1 EndIf ;Display results ConsoleWrite(@CRLF) ConsoleWrite("CryptoNG Password-Based Key Derivation Function 2 (PBKDF2) Example" & @CRLF) ConsoleWrite(StringFormat("PBKDF2_%s Password = %s", $ALGORITHM, $PASSWORD) & @CRLF) ConsoleWrite(StringFormat("PBKDF2_%s Salt = %s", $ALGORITHM, $SALT) & @CRLF) ConsoleWrite(StringFormat("PBKDF2_%s Iterations = %s", $ALGORITHM, $ITERATIONS) & @CRLF) ConsoleWrite(StringFormat("PBKDF2_%s Key Length = %i bits / %i bytes", $ALGORITHM, $KEY_BIT_LENGTH, $KEY_BIT_LENGTH / 8) & @CRLF) ConsoleWrite(StringFormat("PBKDF2_%s Password Hash = %s", $ALGORITHM, $xPasswordHash) & @CRLF) EndFunc Console: CryptoNG Password-Based Key Derivation Function 2 (PBKDF2) Example PBKDF2_SHA256 Password = [test] PBKDF2_SHA256 Salt = 0xFD4B1E6AD1B05DB6FF288928FED3005EF4FDC9ADE8BE276220A8F41ADCCCDA29 PBKDF2_SHA256 Iterations = 100 PBKDF2_SHA256 Key Length = 256 bits / 32 bytes PBKDF2_SHA256 Password Hash = 0x5FC52BC04CBE1ED40E549B52E5C636168242C1395DF2DD696A327AD5E005198F
    1 point
  12. Nine

    IF else problem

    Hmmm. Do not take an habit to ask for help without making first an effort. I will give you a hand this time because you are new here and also because I am sometimes nice. BTW If you want to start having multiple relations between entities, you should think using a RDBMS like SQLite, instead (like I did) making it hard coded. Anyway there you go, and please next time, provide your code attempt even if it is not working at all. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #include <ComboConstants.au3> #include <ButtonConstants.au3> #include <Inet.au3> #include <FontConstants.au3> #include <EditConstants.au3> #include <file.au3> Local $aManager [] = ["Manager1","Manager2","Manager3","Manager4","Manager5","Manager6","Manager7","Manager8","Manager9","ManagerA","ManagerB","ManagerC","ManagerD","ManagerE","ManagerF","ManagerG","ManagerH","ManagerI"] Local $aDepartment [] = ["Production","Planing","Engineering","Materiales","Logistics","IT","Accounting","APM/APT","Quality","Security","Preparation","Maintenance","Purchasing","Health &Safety","HR","Training","QA Supplier","FAE PS"] If UBound($aDepartment) <> UBound($aManager) Then Exit MsgBox ($MB_SYSTEMMODAL, "Error", "Number of Managers should be same of Departments") Local Const $sFont = "Comic Sans Ms" ;~ Create a popup window ---------------------------------------------------------------------------------------------------------------------------- $Form = GUICreate(" Ticket System ", 320, 600, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $DS_MODALFRAME), $WS_EX_TOPMOST) ;~ $Form = GUICreate(" Ticket System ", 320, 600) GUISetBkColor(0xFFFFFF) ;~ Create a picture of LOGO ---------------------------------------------------------------------------------------------------------------------------- ;~ create header of form ---------------------------------------------------------------------------------------------------------------------------- Global $header = GUICtrlCreateLabel("Ticket Form", 90, 110, 165, 80) GUICtrlSetColor($header, 0x013b84) GUICtrlSetFont(-1, 20, $FW_EXTRABOLD) ;~ Create input of username ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("User Name", 10, 185, 100, 20) Global $idFile = GUICtrlCreateInput("", 100, 185, 200, 20) ;~ Create input of user code ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Operator Number", 10, 215, 100, 20) Global $operatorNumber = GUICtrlCreateInput("", 100, 215, 200, 20) ;~ Create input of Department drop down menu ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Department", 10, 245, 100, 20) Global $dropDepartment = GUICtrlCreateCombo("", 100, 245, 200, 20) GUICtrlSetData($dropDepartment,_ArrayToString($aDepartment)) GUICtrlCreateLabel("Manager", 10, 275, 100, 20) Global $idManager = GUICtrlCreateLabel("", 100, 275, 200, 20, $SS_SUNKEN) ;~ Create input of Plants drop down menu ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Plant", 10, 305, 100, 20) Global $dropPlants = GUICtrlCreateCombo("", 100, 305, 200, 20) GUICtrlSetData($dropPlants, "Plant1 |Plant2", "") ;~ Create input of Problems drop down ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Problem", 10, 335, 100, 20) Global $dropProblems = GUICtrlCreateCombo("Choose the problem...", 100, 335, 200, 20) GUICtrlSetData($dropProblems, "No Network|Need Skype account|Need access|Printing limit finished|Freezed form|Outlook Doen't work|Change Keyboard|Change Mouse|Change Monitor|Install Software|Don't work Printer|Doesn't Work Macros|Other problem", "") ;~ Create input of describing the problem ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Other Problem", 10, 440, 100, 20) Global $otherProblem = GUICtrlCreateEdit("", 100, 365, 200, 150, $ES_MULTILINE) GUICtrlSetState(-1, $GUI_DISABLE) Local $idBtn = GUICtrlCreateButton("OK", 60, 530, 200, 40) GUICtrlSetBkColor($idBtn, 0x00b9ef) GUICtrlSetFont(-1, 20, $FW_EXTRABOLD) $LabelError = GUICtrlCreateLabel("", 35, 165, 250, 20) GUICtrlSetColor($LabelError, $COLOR_RED) GUISetState(@SW_SHOW) Local $plant, $manager, $department, $problem, $name, $id, $description While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $dropDepartment $id = _ArraySearch($aDepartment, GUICtrlRead($dropDepartment)) GUICtrlSetData($idManager, $aManager[$id]) Case $dropProblems $problem = GUICtrlRead($dropProblems) If $problem = "Other problem" Then GUICtrlSetState($otherProblem, $GUI_ENABLE) Else GUICtrlSetState($otherProblem, $GUI_DISABLE) GUICtrlSetData($otherProblem, "") EndIf Case $idBtn $plant = GUICtrlRead($dropPlants) $manager = GUICtrlRead($idManager) $department = GUICtrlRead($dropDepartment) $problem = GUICtrlRead($dropProblems) $name = GUICtrlRead($idFile) $id = GUICtrlRead($operatorNumber) $description = GUICtrlRead($otherProblem) If $name = "" Then GUICtrlSetData($LabelError, "You have to enter your name") ElseIf $id = "" Then GUICtrlSetData($LabelError, "You have to enter your operator code") ElseIf $department = "" Then GUICtrlSetData($LabelError, "You have to choose your Department") ElseIf $problem = "Choose the problem..." Then GUICtrlSetData($LabelError, "You have to choose your Problem") ElseIf $problem = "Other problem" And $description = "" Then GUICtrlSetData($LabelError, "You have to describe your Problem") Else If $problem = "Other problem" Then $problem = $description GUISetState(@SW_HIDE) MsgBox($MB_OK, "OK", "Hello," & @CRLF & @CRLF & _ " [Full Name]: " & $name & @CRLF & _ " [FAE-SAU employee's number]: " & $id & @CRLF & _ " [Department]: " & $department & @CRLF & _ " [Plant location]:Moldova " & $plant & @CRLF & _ " [Your Manager's name]: " & $manager & @CRLF & _ " [Explain your problem]: Please, we have a problem: " & $problem & "." & @CRLF & @CRLF & _ "Thanks." & @CRLF & @CRLF & _ "Best Regards," & @CRLF & _ $name) Exit EndIf EndSwitch WEnd
    1 point
  13. this seems to work: "(User|Login-name|NTSecurity|Member):\s(.*)|.+\r\n?"
    1 point
  14. Nine

    IF else problem

    Glad you like it. But here a better version where the edit box gets only available when "other problem" is selected : #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #include <ComboConstants.au3> #include <ButtonConstants.au3> #include <Inet.au3> #include <FontConstants.au3> #include <EditConstants.au3> #include <file.au3> Local Const $sFont = "Comic Sans Ms" ;~ Create a popup window ---------------------------------------------------------------------------------------------------------------------------- $Form = GUICreate(" Ticket System ", 320, 600, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $DS_MODALFRAME), $WS_EX_TOPMOST) ;~ $Form = GUICreate(" Ticket System ", 320, 600) GUISetBkColor(0xFFFFFF) ;~ Create a picture of LOGO ---------------------------------------------------------------------------------------------------------------------------- ;~ create header of form ---------------------------------------------------------------------------------------------------------------------------- Global $header = GUICtrlCreateLabel("Ticket Form", 90, 110, 165, 80) GUICtrlSetColor($header, 0x013b84) GUICtrlSetFont(-1, 20, $FW_EXTRABOLD) ;~ Create input of username ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("User Name", 10, 185, 100, 20) Global $idFile = GUICtrlCreateInput("", 100, 185, 200, 20) ;~ Create input of user code ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Operator Number", 10, 215, 100, 20) Global $operatorNumber = GUICtrlCreateInput("", 100, 215, 200, 20) ;~ Create input of Manager drop down menu ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Manager", 10, 245, 100, 20) Global $dropManager = GUICtrlCreateCombo("", 100, 245, 200, 20) GUICtrlSetData($dropManager, "Manager1|Manager2|Manager3|Manager4|Manager5|Manager6|Manager7|Manager8|", "") ;~ Create input of Department drop down menu ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Department", 10, 275, 100, 20) Global $dropDepartment = GUICtrlCreateCombo("", 100, 275, 200, 20) GUICtrlSetData($dropDepartment, "Production|Planing|Engineering|Materiales|Logistics|IT|Accounting|APM/APT|Quality|Security|Preparation|Maintenance|Purchasing|Health &Safety|HR|Training|QA Supplier|FAE PS ", "") ;~ Create input of Plants drop down menu ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Plant", 10, 305, 100, 20) Global $dropPlants = GUICtrlCreateCombo("", 100, 305, 200, 20) GUICtrlSetData($dropPlants, "Plant1 |Plant2", "") ;~ Create input of Problems drop down ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Problem", 10, 335, 100, 20) Global $dropProblems = GUICtrlCreateCombo("Choose the problem...", 100, 335, 200, 20) GUICtrlSetData($dropProblems, "No Network|Need Skype account|Need access|Printing limit finished|Freezed form|Outlook Doen't work|Change Keyboard|Change Mouse|Change Monitor|Install Software|Don't work Printer|Doesn't Work Macros|Other problem", "") ;~ Create input of describing the problem ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Other Problem", 10, 440, 100, 20) Global $otherProblem = GUICtrlCreateEdit("", 100, 365, 200, 150, $ES_MULTILINE) GUICtrlSetState(-1, $GUI_DISABLE) Local $idBtn = GUICtrlCreateButton("OK", 60, 530, 200, 40) GUICtrlSetBkColor($idBtn, 0x00b9ef) GUICtrlSetFont(-1, 20, $FW_EXTRABOLD) $LabelError = GUICtrlCreateLabel("", 35, 165, 250, 20) GUICtrlSetColor($LabelError, $COLOR_RED) GUISetState(@SW_SHOW) Local $plant, $manager, $department, $problem, $name, $id, $description While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $dropProblems $problem = GUICtrlRead($dropProblems) If $problem = "Other problem" Then GUICtrlSetState($otherProblem, $GUI_ENABLE) Else GUICtrlSetState($otherProblem, $GUI_DISABLE) GUICtrlSetData($otherProblem, "") EndIf Case $idBtn $plant = GUICtrlRead($dropPlants) $manager = GUICtrlRead($dropManager) $department = GUICtrlRead($dropDepartment) $problem = GUICtrlRead($dropProblems) $name = GUICtrlRead($idFile) $id = GUICtrlRead($operatorNumber) $description = GUICtrlRead($otherProblem) If $name = "" Then GUICtrlSetData($LabelError, "You have to enter your name") ElseIf $id = "" Then GUICtrlSetData($LabelError, "You have to enter your operator code") ElseIf $manager = "" Then GUICtrlSetData($LabelError, "You have to choose your Manager") ElseIf $department = "" Then GUICtrlSetData($LabelError, "You have to choose your Department") ElseIf $problem = "Choose the problem..." Then GUICtrlSetData($LabelError, "You have to choose your Problem") ElseIf $problem = "Other problem" And $description = "" Then GUICtrlSetData($LabelError, "You have to describe your Problem") Else If $problem = "Other problem" Then $problem = $description GUISetState(@SW_HIDE) MsgBox($MB_OK, "OK", "Hello," & @CRLF & @CRLF & _ " [Full Name]: " & $name & @CRLF & _ " [FAE-SAU employee's number]: " & $id & @CRLF & _ " [Department]: " & $department & @CRLF & _ " [Plant location]:Moldova " & $plant & @CRLF & _ " [Your Manager's name]: " & $manager & @CRLF & _ " [Explain your problem]: Please, we have a problem: " & $problem & "." & @CRLF & @CRLF & _ "Thanks." & @CRLF & @CRLF & _ "Best Regards," & @CRLF & _ $name) Exit EndIf EndSwitch WEnd
    1 point
  15. Nine

    IF else problem

    I see. Try this if statement : If $name = "" Then GUICtrlSetData($LabelError, "You have to enter your name") ElseIf $id = "" Then GUICtrlSetData($LabelError, "You have to enter your operator code") ElseIf $manager = "" Then GUICtrlSetData($LabelError, "You have to choose your Manager") ElseIf $department = "" Then GUICtrlSetData($LabelError, "You have to choose your Department") ElseIf $problem = "Choose the problem..." Then GUICtrlSetData($LabelError, "You have to choose your Problem") ElseIf $problem = "Other problem" And $description = "" Then GUICtrlSetData($LabelError, "You have to describe your Problem") Else If $problem = "Other problem" Then $problem = $description GUISetState(@SW_HIDE) MsgBox($MB_OK, "OK", "Hello," & @CRLF & @CRLF & _ " [Full Name]: " & $name & @CRLF & _ " [FAE-SAU employee's number]: " & $id & @CRLF & _ " [Department]: " & $department & @CRLF & _ " [Plant location]:Moldova " & $plant & @CRLF & _ " [Your Manager's name]: " & $manager & @CRLF & _ " [Explain your problem]: Please, we have a problem: " & $problem & "." & @CRLF & @CRLF & _ "Thanks." & @CRLF & @CRLF & _ "Best Regards," & @CRLF & _ $name) Exit EndIf
    1 point
  16. Nine

    IF else problem

    Here how to streamline your if statements : #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #include <ComboConstants.au3> #include <ButtonConstants.au3> #include <Inet.au3> #include <FontConstants.au3> #include <EditConstants.au3> #include <file.au3> Local Const $sFont = "Comic Sans Ms" ;~ Create a popup window ---------------------------------------------------------------------------------------------------------------------------- $Form = GUICreate(" Ticket System ", 320, 600, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $DS_MODALFRAME), $WS_EX_TOPMOST) ;~ $Form = GUICreate(" Ticket System ", 320, 600) GUISetBkColor(0xFFFFFF) ;~ Create a picture of LOGO ---------------------------------------------------------------------------------------------------------------------------- ;~ create header of form ---------------------------------------------------------------------------------------------------------------------------- Global $header = GUICtrlCreateLabel("Ticket Form", 90, 110, 165, 80) GUICtrlSetColor($header, 0x013b84) GUICtrlSetFont(-1, 20, $FW_EXTRABOLD) ;~ Create input of username ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("User Name", 10, 185, 100, 20) Global $idFile = GUICtrlCreateInput("", 100, 185, 200, 20) ;~ Create input of user code ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Operator Number", 10, 215, 100, 20) Global $operatorNumber = GUICtrlCreateInput("", 100, 215, 200, 20) ;~ Create input of Manager drop down menu ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Manager", 10, 245, 100, 20) Global $dropManager = GUICtrlCreateCombo("", 100, 245, 200, 20) GUICtrlSetData($dropManager, "Manager1|Manager2|Manager3|Manager4|Manager5|Manager6|Manager7|Manager8|", "") ;~ Create input of Department drop down menu ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Department", 10, 275, 100, 20) Global $dropDepartment = GUICtrlCreateCombo("", 100, 275, 200, 20) GUICtrlSetData($dropDepartment, "Production|Planing|Engineering|Materiales|Logistics|IT|Accounting|APM/APT|Quality|Security|Preparation|Maintenance|Purchasing|Health &Safety|HR|Training|QA Supplier|FAE PS ", "") ;~ Create input of Plants drop down menu ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Plant", 10, 305, 100, 20) Global $dropPlants = GUICtrlCreateCombo("", 100, 305, 200, 20) GUICtrlSetData($dropPlants, "Plant1 |Plant2", "") ;~ Create input of Problems drop down ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Select Problem", 10, 335, 100, 20) Global $dropProblems = GUICtrlCreateCombo("Choose the problem...", 100, 335, 200, 20) GUICtrlSetData($dropProblems, "No Network|Need Skype account|Need access|Printing limit finished|Freezed form|Outlook Doen't work|Change Keyboard|Change Mouse|Change Monitor|Install Software|Don't work Printer|Doesn't Work Macros|Other problem", "") ;~ Create input of describing the problem ---------------------------------------------------------------------------------------------------------------------------- GUICtrlCreateLabel("Other Problem", 10, 440, 100, 20) Global $otherProblem = GUICtrlCreateEdit("", 100, 365, 200, 150, $ES_MULTILINE) Local $idBtn = GUICtrlCreateButton("OK", 60, 530, 200, 40) GUICtrlSetBkColor($idBtn, 0x00b9ef) GUICtrlSetFont(-1, 20, $FW_EXTRABOLD) $LabelError = GUICtrlCreateLabel("", 35, 165, 250, 20) GUICtrlSetColor($LabelError, $COLOR_RED) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBtn $plant = GUICtrlRead($dropPlants) $manager = GUICtrlRead($dropManager) $department = GUICtrlRead($dropDepartment) $problem = GUICtrlRead($dropProblems) $name = GUICtrlRead($idFile) $id = GUICtrlRead($operatorNumber) $description = GUICtrlRead($otherProblem) If $name = "" Then GUICtrlSetData($LabelError, "You have to enter your name") ElseIf $id = "" Then GUICtrlSetData($LabelError, "You have to enter your operator code") ElseIf $manager = "" Then GUICtrlSetData($LabelError, "You have to choose your Manager") ElseIf $department = "" Then GUICtrlSetData($LabelError, "You have to choose your Department") ElseIf $problem = "Choose the problem..." Then GUICtrlSetData($LabelError, "You have to choose your Problem") ElseIf $problem = "Other problem" And $description = "" Then GUICtrlSetData($LabelError, "You have to discribe your Problem") Else $problem = $description GUISetState(@SW_HIDE) MsgBox($MB_OK, "OK", "Hello," & @CRLF & @CRLF & _ " [Full Name]: " & $name & @CRLF & _ " [FAE-SAU employee's number]: " & $id & @CRLF & _ " [Department]: " & $department & @CRLF & _ " [Plant location]:Moldova " & $plant & @CRLF & _ " [Your Manager's name]: " & $manager & @CRLF & _ " [Explain your problem]: Please, we have a problem: " & $problem & "." & @CRLF & @CRLF & _ "Thanks." & @CRLF & @CRLF & _ "Best Regards," & @CRLF & _ $name) Exit EndIf EndSwitch WEnd
    1 point
  17. Please Try: $sText = FileRead("SECURITY.RPT") $sNames = "User|Login-name|Member|Domain|NTSecurity" $s = StringRegExpReplace($sText, _ ".*(?:" & $sNames & "):\s(.*)|(.+)\R", "\1") ConsoleWrite(StringStripWS($s, 3) & @CRLF)
    1 point
  18. Melba23

    IF else problem

    Orlina, Welcome to the AutoIt forums. When you post code in future please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation. M23
    1 point
  19. No, it is missing in all versions of the help file. But the post I linked you to holds this footnote. I have already opened a trac ticket so the footnote will be added to future help files. I will do some tests to check if the footnote is correct.
    1 point
  20. Seems TRY AGAIN and CONTINUE only work on Windows XP and 2000.
    1 point
  21. Happy to hear that it solves the issue to you too. I will make a Bug Tracker Ticket sometimes later.
    1 point
  22. No worries, until then, we'll go fishing with 9 to cool him down a bit.
    1 point
  23. Hi LarsJ I tried to use the Custom draw for incremental search but it didn't work fine, could you please help ? The only thing that "works" in the script below (named "2k") is this : * Please type . or .$ in the Search field, then hover over rows and you'll see the correct matching 1st (or last) character with cyan background in Col 0. Nothing appears if the rows aren't hovered over. * Then change the search column (right-click on a new header or use the Combo) and the cyan background never appears in any searched column (it should appear on 1st or last character, no matter the searched column, as RegEx search is "." or ".$") I checked the 4 values of the rectangle etc... and added some commented ConsoleWrite's during Case $NM_CUSTOMDRAW. Values seem correct, maybe hdc isn't correct when applied to Cols 1+ ? I didn't use at all "clrTextBk" or "clrText". Their value is constantly 0xFF000000 ($CLR_DEFAULT) and if we're able to see a cyan background on matched characters while hovering over Col 0, then it should be ok. Also, as soon as I tried to use "clrTextBk" during a test, then the whole subitem got its background colored. Finally, as the Owner draw script ("2i") worked fine in a precedent post , then we don't really need the Custom draw way (especially it's "extremely message intensive" as you indicated) , but I was just curious to see if it was doable or not. Thanks if you got any idea on how to make Case $NM_CUSTOMDRAW work correctly in the script : #include <ComboConstants.au3> #include <EditConstants.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "RandomArray.au3" ; LarsJ Opt("MustDeclareVars", 1) Global $g_iRows = 1000, $g_iCols = 6, $g_iLeftLV = 10, $g_iTopLV = 40, $g_hGui, $g_hListView, $g_hHeader, $g_hEdit Global $g_aCols = ["Strings", "Integers", "Floats", "Dates", "Times", "R/C"], $g_aWidths = [230, 61, 124, 70, 60, 60] Global $g_idListView, $g_idMarker, $g_idComboCol, $g_idComboColDummy, $g_idEditDummy Global $g_sSearch, $g_iSearchCol, $g_iSortDir, $g_iSearch = $g_iRows Global $g_aArray, $g_aSubArray, $g_tDefaultIndex, $g_tIndex = DllStructCreate("uint arr[" & $g_iRows & "]") Global $g_aIndex[$g_iCols], $g_aIndexTemp[$g_iCols] ; VarGetType's : $g_aIndex => "Array", $g_aIndex[0] => "String" Example() Func Example() ; Generate array & one index _Generate_All($g_aArray) $g_aSubArray = $g_aArray $g_tDefaultIndex = $g_tIndex ; Create GUI $g_hGui = GUICreate("Virtual ListView + Sort + Incremental search + CustomDraw (2k)", 630 + 20, 788 + 30 + 20) ; Create Edit control (search) + dummy control Local $idEdit = GUICtrlCreateEdit("", 120, 10, 305, 20, BitXOR($GUI_SS_DEFAULT_EDIT, $WS_HSCROLL, $WS_VSCROLL)) $g_hEdit = GUICtrlGetHandle($idEdit) $g_idEditDummy = GUICtrlCreateDummy() ; Create ComboBox control (how to search : RegEx or Normal ?) Local $idSearchHow = GUICtrlCreateCombo("RegEx search", 11, 9, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) Local $sSearchHow = "RegEx search", $sSearchHowPrev = $sSearchHow ; default way of searching (changeable) GUICtrlSetData($idSearchHow, "Normal search", $sSearchHow) ; Create ComboBox control (column where to search) + dummy control GUICtrlCreateLabel("Col", 429, 10, 20, 20, BitOR($SS_CENTERIMAGE, $SS_CENTER)) $g_idComboCol = GUICtrlCreateCombo("0", 452, 9, 41, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) $g_iSearchCol = 0 ; default column where to search (changeable) Local $iSearchColPrev = $g_iSearchCol For $i = 1 To $g_iCols - 1 GUICtrlSetData($g_idComboCol, $i & "|", $g_iSearchCol) Next $g_idComboColDummy = GUICtrlCreateDummy() ; Create Label control (number of matching results) Local $idResult = GUICtrlCreateLabel(" " & $g_iRows & " rows (no pattern)", 501, 10, 135, 20, BitOR($SS_CENTERIMAGE, $SS_SUNKEN)) ; Create ListView $g_idListView = GUICtrlCreateListView("", $g_iLeftLV, $g_iTopLV, 630, 788, BitOr($GUI_SS_DEFAULT_LISTVIEW, $LVS_OWNERDATA), $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($g_idListView, BitOr($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) $g_hListView = GUICtrlGetHandle($g_idListView) $g_hHeader = _GUICtrlListView_GetHeader($g_idListView) For $i = 0 To $g_iCols - 1 _GUICtrlListView_AddColumn($g_idListView, $g_aCols[$i], $g_aWidths[$i]) Next ; Create Marker (an orange line placed above the header of the column being searched) $g_idMarker = GUICtrlCreateLabel("", 0, 0) GUICtrlSetBkColor(-1, 0xFFA060) ; orange _MoveMarker($g_iSearchCol) _GUICtrlListView_SetSelectedColumn($g_idListView, $g_iSearchCol) ; Sorting information $g_iSortDir = 0x0400 ; $HDF_SORTUP Local $iSortCol = -1, $iSortColPrev = -1 GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUICtrlSendMsg($g_idListView, $LVM_SETITEMCOUNT, $g_iRows, 0) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $g_idComboCol, $g_idComboColDummy, $idSearchHow $g_iSearchCol = GUICtrlRead($g_idComboCol) $sSearchHow = GUICtrlRead($idSearchHow) Select Case $g_iSearchCol <> $iSearchColPrev _MoveMarker($g_iSearchCol) ; Search column will be selected below, after ContinueCase $iSearchColPrev = $g_iSearchCol Case $sSearchHow <> $sSearchHowPrev $sSearchHowPrev = $sSearchHow Case Else ; no change in both Combo controls (same search column, same search way) ContinueLoop EndSelect ContinueCase Case $g_idEditDummy _GUICtrlHeader_SetItemFormat($g_hHeader, $iSortCol, $HDF_STRING) $g_sSearch = GUICtrlRead($idEdit) $g_tIndex = $g_tDefaultIndex If $g_sSearch = "" Then ; Empty search string, display all rows $g_aSubArray = $g_aArray $g_iSearch = $g_iRows Else ; Find rows matching the search string $g_iSearch = 0 If $sSearchHow = "RegEx search" Then For $i = 0 To $g_iRows - 1 ; duplicated For... Next for speed If StringRegExp($g_aArray[$i][$g_iSearchCol], "(?i)" & $g_sSearch) Then For $j = 0 To $g_iCols - 1 $g_aSubArray[$g_iSearch][$j] = $g_aArray[$i][$j] Next $g_iSearch += 1 EndIf Next Else ; "Normal search" For $i = 0 To $g_iRows - 1 ; duplicated For... Next for speed If StringInStr($g_aArray[$i][$g_iSearchCol], $g_sSearch) Then For $j = 0 To $g_iCols - 1 $g_aSubArray[$g_iSearch][$j] = $g_aArray[$i][$j] Next $g_iSearch += 1 EndIf Next EndIf ; Delete eventual temporary subindexes For $i = 0 To $g_iCols - 1 If VarGetType($g_aIndexTemp[$i]) = "DLLStruct" Then $g_aIndexTemp[$i] = "" ; "String" Next EndIf GUICtrlSetData($idResult, " " & $g_iSearch & ($g_sSearch = "" ? " rows (no pattern)" : " matching rows")) ;------ ; _GUICtrlListView_SetSelectedColumn($g_hListView, $g_iSearchCol) ; depending on search, crashes script when placed here ; _GUICtrlListView_SetSelectedColumn($g_idListView, $g_iSearchCol) ; strange behavior here ; GUICtrlSendMsg($g_idListView, $LVM_SETSELECTEDCOLUMN, $g_iSearchCol, 0) ; strange behavior here ;------ GUICtrlSendMsg($g_idListView, $LVM_SETITEMCOUNT, $g_iSearch, 0) _GUICtrlListView_SetSelectedColumn($g_hListView, $g_iSearchCol) ; seems ok here (after $LVM_SETITEMCOUNT) Case $g_idListView ; Sort $iSortCol = GUICtrlGetState($g_idListView) If $iSortCol <> $iSortColPrev Then _GUICtrlHeader_SetItemFormat($g_hHeader, $iSortColPrev, $HDF_STRING) EndIf ; Set $g_tIndex + eventual update of $g_aIndexTemp[$iSortCol] OR $g_aIndex[$iSortCol] If GUICtrlRead($idEdit) Then _UpdateIndex($g_aIndexTemp, $iSortCol) Else _UpdateIndex($g_aIndex, $iSortCol) EndIf $g_iSortDir = (($iSortCol = $iSortColPrev) ? ($g_iSortDir = $HDF_SORTUP ? $HDF_SORTDOWN : $HDF_SORTUP) : ($HDF_SORTUP)) _GUICtrlHeader_SetItemFormat($g_hHeader, $iSortCol, $HDF_STRING + $g_iSortDir) GUICtrlSendMsg($g_idListView, $LVM_SETSELECTEDCOLUMN, $iSortCol, 0) GUICtrlSendMsg($g_idListView, $LVM_SETITEMCOUNT, $g_iSearch, 0) $iSortColPrev = $iSortCol Case $GUI_EVENT_RESTORE ; needed, or Marker goes back in 0, 0 after Restore (why ?) _MoveMarker($g_iSearchCol) EndSwitch WEnd ; Cleanup GUIDelete($g_hGui) EndFunc ;==>Example ;======================================================================== Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Switch HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Case $g_hListView Switch DllStructGetData($tNMHDR, "Code") 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") ;~ ConsoleWrite("0x" & Hex($tCustDraw.clrText, 8) & " 0x" & Hex($tCustDraw.clrTextBk, 8) & @lf) ; both 0xFF000000 ($CLR_DEFAULT) If ($iSubItem = $g_iSearchCol) And $g_sSearch Then Local Static $tRect = DllStructCreate( $tagRECT ), $pRect = DllStructGetPtr( $tRect ), $tSize = DllStructCreate( $tagSIZE ) Local Static $hBrushYellow = _WinAPI_CreateSolidBrush( 0x00FFFF ), $hBrushCyan = _WinAPI_CreateSolidBrush( 0xFFFF00 ) ; Yellow and cyan, BGR Local $hDC = DllStructGetData( $tCustDraw, "hDC" ) ;~ ConsoleWrite("$hDC = " & $hDC & @lf) If $g_iSortDir = 0x0400 Then ; 0x0400 = $HDF_SORTUP Local $sItemText = $g_aSubArray[$g_tIndex.arr($iItem + 1)][$iSubItem] Else Local $sItemText = $g_aSubArray[$g_tIndex.arr($g_iSearch - $iItem)][$iSubItem] EndIf ;~ ConsoleWrite("$sItemText = " & $sItemText & @lf) Local $sMatch = StringRegExp( $sItemText, "(?i)" & $g_sSearch, 1 ), $extended = @extended, $iLen = StringLen( $sMatch[0] ) ; Subitem rectangle DllStructSetData( $tRect, 2, $g_iSearchCol ) ; Top DllStructSetData( $tRect, 1, $LVIR_BOUNDS ) ; Left GUICtrlSendMsg( $g_idListView, $LVM_GETSUBITEMRECT, $iItem, $pRect ) DllStructSetData( $tRect, 1, DllStructGetData( $tRect, 1 ) + 6 ) ; Left margin ;~ DllStructSetData( $tRect, 2, DllStructGetData( $tRect, 2 ) + 2 ) ; Top margin ;~ ConsoleWrite("Top = " & $tRect.Top & " " & "Bottom = " & $tRect.Bottom & " " & _ ;~ "Left = " & $tRect.Left & " " & "Right = " & $tRect.Right & @lf) ; Rectangle for matching substring DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sItemText, "int", $extended - $iLen - 1, "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + DllStructGetData( $tSize, "X" ) ) DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sMatch[0], "int", $iLen, "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 DllStructSetData( $tRect, "Right", DllStructGetData( $tRect, "Left" ) + DllStructGetData( $tSize, "X" ) ) ;~ ConsoleWrite("Top = " & $tRect.Top & " " & "Bottom = " & $tRect.Bottom & " " & _ ;~ "Left = " & $tRect.Left & " " & "Right = " & $tRect.Right & @lf) ; Fill rectangle with cyan background color DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", $hBrushCyan) ; _WinAPI_FillRect ; Draw matching substring in rectangle ; DllCall( "gdi32.dll", "int", "SetTextColor", "handle", $hDC, "int", 0x000000 ) ; _WinAPI_SetTextColor DllCall( "gdi32.dll", "int", "SetBkColor", "handle", $hDC, "int", 0xFFFF00 ) ; _WinAPI_SetBkColor (cyan) DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $sMatch[0], "int", $iLen, "struct*", $tRect, "uint", 0 ) ; _WinAPI_DrawText EndIf Return $CDRF_NEWFONT Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate($tagNMLVDISPINFO, $lParam) Local Static $tText = DllStructCreate("wchar[50]"), $pText = DllStructGetPtr($tText) If $g_iSortDir = 0x0400 Then ; 0x0400 = $HDF_SORTUP DllStructSetData($tText, 1, $g_aSubArray[$g_tIndex.arr($tNMLVDISPINFO.Item + 1)][$tNMLVDISPINFO.SubItem]) Else DllStructSetData($tText, 1, $g_aSubArray[$g_tIndex.arr($g_iSearch - $tNMLVDISPINFO.Item)][$tNMLVDISPINFO.SubItem]) EndIf DllStructSetData($tNMLVDISPINFO, "Text", $pText) EndSwitch Case $g_hHeader Switch DllStructGetData($tNMHDR, "Code") Case $HDN_ENDTRACKW, $HDN_DIVIDERDBLCLICKW ; let's forget $HDN_TRACKW... _MoveMarker(GUICtrlRead($g_idComboCol)) Case $NM_RCLICK Local $aHit = _GUICtrlListView_SubItemHitTest($g_hListView) ; $aHit[1] : 0-based index of the LV subitem... i.e. the column in our case (may be -1 if right click on empty part of header) If $aHit[1] > - 1 Then ; valid column GUICtrlSetData($g_idComboCol, $aHit[1]) GUICtrlSendToDummy($g_idComboColDummy) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;======================================================================== Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $hWndFrom = $lParam Local $iCode = BitShift($wParam, 16) ; High word Switch $hWndFrom Case $g_hEdit Switch $iCode Case $EN_CHANGE GUICtrlSendToDummy($g_idEditDummy) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND ;======================================================================== Func _Generate_All(ByRef $g_aArray) ConsoleWrite("$g_iRows = " & $g_iRows & " $g_iCols = " & $g_iCols & @CRLF) Local $hTimer = TimerInit() $g_aArray = FAS_Random2DArrayAu3($g_iRows, "sifdtr", "abcdefghijklmnopqrstuvwxyz") For $i = 0 To $g_iRows - 1 $g_tIndex.arr($i + 1) = $i Next ConsoleWrite("Generating array & one index = " & TimerDiff($hTimer) & @CRLF & @CRLF) EndFunc ;==>_Generate_All ;======================================================================== Func _SortArrayStruct(Const ByRef $aArray, $iCol, $iRows) Local $tIndex = DllStructCreate("uint arr[" & $iRows & "]") Local $pIndex = DllStructGetPtr($tIndex) Local Static $hDll = DllOpen("kernel32.dll") Local Static $hDllComp = DllOpen("shlwapi.dll") Local $lo, $hi, $mi, $r ; Sorting by one column For $i = 1 To $iRows - 1 $lo = 0 $hi = $i - 1 Do $mi = Int(($lo + $hi) / 2) $r = DllCall($hDllComp, 'int', 'StrCmpLogicalW', 'wstr', $aArray[$i][$iCol], 'wstr', $aArray[DllStructGetData($tIndex, 1, $mi + 1)][$iCol])[0] Switch $r Case -1 $hi = $mi - 1 Case 1 $lo = $mi + 1 Case 0 ExitLoop EndSwitch Until $lo > $hi DllCall($hDll, "none", "RtlMoveMemory", "struct*", $pIndex + ($mi + 1) * 4, "struct*", $pIndex + $mi * 4, "ulong_ptr", ($i - $mi) * 4) DllStructSetData($tIndex, 1, $i, $mi + 1 + ($lo = $mi + 1)) Next Return $tIndex EndFunc ;==>_SortArrayStruct ;======================================================================== Func _UpdateIndex(ByRef $aIndex, $iCol) If VarGetType($aIndex[$iCol]) = "DLLStruct" Then $g_tIndex = $aIndex[$iCol] Else $g_tIndex = _SortArrayStruct($g_aSubArray, $iCol, $g_iSearch) $aIndex[$iCol] = $g_tIndex ; "DLLStruct" (or "Int32" when no match found +++) EndIf EndFunc ;==>_UpdateIndex ;======================================================================== Func _MoveMarker($iCol) Local $aRect = _GUICtrlHeader_GetItemRect($g_hHeader, $iCol) ControlMove($g_hGui, "", $g_idMarker, $g_iLeftLV + $aRect[0], $g_iTopLV - 3, $aRect[2] - $aRect[0] + 1, 3) EndFunc ;==>_MoveMarker
    1 point
  24. Looks like you just want to install a bunch of packages you have in your downloads folder. You could prepare a list of which ones you want to install, and then use the 'run' facility to launch each installation process in sequence. I note you have a mix of 32 and 64 bit processes, so you could extract your environment first and make a decision tree based on which ones are more appropriate. If you just want to reinstall a whole bunch of the same programs, there are disk imaging packages that may be more efficient to create an image of what you want to install after you have completing installing it, take a snapshot, and then just reimage each drive any time you want to start from a clean slate. This is the industry way system administrators use to create a standard operating environment for new users and new PCs. There are even bootup disks that will pull images from the network based on your PC configuration. If I have offered you a completely different solution to your problem, please respecify further as to what you want.
    1 point
  25. I took that code and added what I felt was missing I thought of rewriting it and to do so in a UDF format. That would make the code cleaner and reusable but I have not have the time to do it nor I foresee doing it any time soon. Yes it was and I did not understand how WMI worked back then, so patching it was a way to continue the same look and feel and was never my intention to be the new maintainer of the code but that is what I ended up doing. Otherwise I would have started a new topic instead of hijacking this one. Also the new format, for what I see, is to distribute the utilities as source. For example AutoIt3Wrapper is no longer an executable, same with SciteConfig, etc. , so I should do a proper rewrite, so that it can be distributed in the same way. Unfortunately is not the case, right now. The ANSI version that is included in compiled format, is done with a very old version of autoit but is just as functional and my idea was to use that version alone, so it can be used everywhere, from Windows 95 all the way to Windows 10. Anyway, the code that it generates is a function that returns an array. Then it can be easily included to a script. It also generates a quite long help at the end of the page, along with helper functions. All in all I believe to be an excellent tool, if I say so myself. There are things that are not quite as I'd wanted it. My idea was to make it fully portable, and so on a portable ScITE but that is not the case. Since not many people use it, or complain, I did not push myself to correct that. One of these weekends I may just do it but so far I have'nt. So for now, use it as is, if you find something wrong with the generated code let me know. If you have a request, I'll add it in the to do list in my head.
    1 point
  26. Define the child window as a control parent: $Child[1] = GUICreate("", 540, 500, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $Main)
    1 point
×
×
  • Create New...