Jump to content

31290

Active Members
  • Posts

    142
  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    31290 reacted to Subz in Net Local group with Space Name Psexec   
    Shouldn't it be '..."MYDomain\' & $sADGroupName & '"...'
  2. Like
    31290 got a reaction from lIlIIlIllIIIIlI in Keyboard remapping   
    Hi There, 
    I'm currently rebinding some of my keys (multimedia ones) and I have two keys that handle the Zoom (+ & -)
     (just after the calc key)
     
    I looked everywhere (in the help file and on Google) but I was not able to find the matching code.
    Do some of you could have a little idea on how to get their "name" so I'll be able to remap them?
    Thanks
  3. Thanks
    31290 reacted to Subz in Combine 32 & 64 Reg values   
    I've never used that method, I've always used something like:
    Func _Uninstall() Local $sUninstallString = _GUICtrlListView_GetItemText($idListView, _GUICtrlListView_GetSelectionMark($idListView), 4) If StringStripWS($sUninstallString, 8) = "" Then Return -1 Return $sUninstallString EndFunc  
  4. Like
    31290 reacted to Earthshine in Combine 32 & 64 Reg values   
    change your function that reads the reg. pass it the key once for 32 bit, once for 64 in main loop
    Func _ComputerGetSoftware(ByRef $aSoftwareInfo, $UnInstKey)
    then don;t do this, remark that out.
    Local Const $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" pass that key to your function 2 times, 32 and 64 values and add them to the one array.
  5. Thanks
    31290 reacted to Earthshine in Combine 32 & 64 Reg values   
    look at subz example
  6. Haha
    31290 reacted to Trong in Combine 32 & 64 Reg values   
    "HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
     
    AutoItScript List installed programs and system information:
    #include <GuiListView.au3> Opt("TrayAutoPause", 0) Opt('GUIOnEventMode', 1) Opt('GUICloseOnEsc', 1) ;Opt("MustDeclareVars", 1) ; Global $SoftwList = 'ALL', $iAskSoftName = 0, $sSft[1][0] Global $sGui = GUICreate('Currently Installed Software', 810, 650, -1, -1) Global $sLvw = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600) _ComputerGetSoftware($sSft) For $i = 1 To UBound($sSft) - 1 GUICtrlCreateListViewItem($i & '|' & $sSft[$i][0] & '|' & $sSft[$i][1] & '|' & $sSft[$i][2] & '|' & $sSft[$i][3], $sLvw) Next GUICtrlSendMsg($sLvw, 0x101E, 1, 175) GUICtrlSendMsg($sLvw, 0x101E, 2, 65) GUICtrlSendMsg($sLvw, 0x101E, 3, 150) GUICtrlSendMsg($sLvw, 0x101E, 4, 350) Global $mMen = GUICtrlCreateContextMenu($sLvw) Global $CopI = GUICtrlCreateMenuItem('Uninstall Current Selection', $mMen) GUICtrlSetOnEvent($CopI, '_Uninstall') Global $exp = GUICtrlCreateButton(' Expand ', 720, 615) GUICtrlSetOnEvent($exp, '_Expand') GUISetOnEvent(-3, '_AllExit') GUISetState(@SW_SHOW, $sGui) ; While 1 Sleep(10) WEnd ; Func _AllExit() GUIDelete($sGui) Exit EndFunc ;==>_AllExit ; Func _Uninstall() Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1) If $proc[1] == 0 Then Return -1 If $proc[5] Then RunWait($proc[5]) Exit EndFunc ;==>_Uninstall ; Func _Copy2Clip() Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1) If $proc[1] == 0 Then Return -1 If $proc[5] Then ClipPut($proc[5]) EndFunc ;==>_Copy2Clip ; ; Author JSThePatriot - Modified June 20, 2010 by ripdad - Modified 2018/29/05 by Dao Van Trong - Trong.LIVE Func _ComputerGetSoftware(ByRef $aSoftwareInfo) Local Const $UnInstKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Local $i = 1, $Reg, $string, $AppKey ReDim $aSoftwareInfo[1][4] If ($iAskSoftName) Then $SoftwList = InputBox("Which Software", "You are running " & @OSVersion & " " & @OSArch & @CRLF & @CRLF & "Which Software would you like to view?", 'ALL') If @error = 1 Then Exit If $SoftwList = 'ALL' Then For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then ExitLoop If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4] $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1 If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0) Return _ArraySort($aSoftwareInfo, 0, 1) Else For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then ExitLoop Local $Reg = RegRead($UnInstKey & "\" & $AppKey, "DisplayName") $string = StringInStr($Reg, $SoftwList) If $string = 0 Then ContinueLoop ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4] $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1 If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0) Return _ArraySort($aSoftwareInfo, 0, 1) EndIf EndFunc ;==>_ComputerGetSoftware ; Func _Expand() _GUICtrlListView_SetColumnWidth($sLvw, 1, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($sLvw, 2, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($sLvw, 3, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($sLvw, 4, $LVSCW_AUTOSIZE) EndFunc ;==>_Expand  
  7. Thanks
    31290 reacted to Subz in Combine 32 & 64 Reg values   
    Maybe something like:
    #include <GuiListView.au3> Opt("TrayAutoPause", 0) Opt('GUIOnEventMode', 1) Opt('GUICloseOnEsc' , 1) Global $aSoftwareInfo[0][5] _SoftwareInfo("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") _SoftwareInfo("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") Global $hGui = GUICreate('Currently Installed Software', 810, 650, -1, -1) Global $idListView = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600) _GUICtrlListView_AddArray($idListView, $aSoftwareInfo) GUICtrlSendMsg($idListView, 0x101E, 1, 175) GUICtrlSendMsg($idListView, 0x101E, 2, 65) GUICtrlSendMsg($idListView, 0x101E, 3, 150) GUICtrlSendMsg($idListView, 0x101E, 4, 350) Local $mMen = GUICtrlCreateContextMenu($idListView) Local $Uninstall = GUICtrlCreateMenuItem('Proceed to Software uninstallation', $mMen) GUICtrlSetOnEvent($Uninstall, '_Uninstall') Local $exp = GUICtrlCreateButton(' Expand ', 720, 615) GUICtrlSetOnEvent($exp, '_Expand') GUISetOnEvent(-3, '_AllExit') GUISetState(@SW_SHOW, $hGui) While 1 Sleep(10) WEnd ; Func _AllExit() GUIDelete($hGui) Exit EndFunc Func _Uninstall() Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($idListView)), '|', 1) If $proc[1] == 0 Then Return -1 ShellExecuteWait ($proc[5]) EndFunc Func _SoftwareInfo($_sHKLMUninstall) Local $i = 1 While 1 $sRegKey = RegEnumKey($_sHKLMUninstall, $i) If @error Then Exitloop If RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayName") = '' Then $i += 1 ContinueLoop EndIf $sDisplayName = StringStripWS(StringReplace(RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayName"), " (remove only)", ""), 3) $sDisplayVersion = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayVersion"), 3) $sPublisher = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "Publisher"), 3) $sUninstallString = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "UninstallString"), 3) _ArrayAdd($aSoftwareInfo, "|" & $sDisplayName & "|" & $sDisplayVersion & "|" & $sPublisher & "|" & $sUninstallString) $i += 1 WEnd _ArraySort($aSoftwareInfo,0,1) For $i = 0 To UBound($aSoftwareInfo) - 1 $aSoftwareInfo[$i][0] = $i Next EndFunc ; Func _Expand() _GUICtrlListView_SetColumnWidth($idListView, 1, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($idListView, 2, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($idListView, 3, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($idListView, 4, $LVSCW_AUTOSIZE) EndFunc  
  8. Thanks
    31290 reacted to JohnOne in find specific piece of link in web page   
    Just test if the link ends with .exe or .txt
  9. Thanks
    31290 reacted to Danp2 in find specific piece of link in web page   
    You should be able to do this with the standard IE UDF commands. Here's an example --
    #include <ie.au3> Example() Func Example() Local $oIE = _IECreate("http://downloads.dell.com/published/pages/latitude-12-5280-laptop.html", 1) Local $oDiv = _IEGetObjById($oIE, "Drivers-Category.BI") Local $oTable = _IETagNameGetCollection($oDiv, "Table", 0) Local $oRow = _IETagNameGetCollection($oTable, "TR", 1) Local $oCell = _IETagNameGetCollection($oRow, "TD", 5) Local $oLinks = _IETagNameGetCollection($oCell, "A") ConsoleWrite("Found " & $oLinks.length & " links!" & @CRLF) For $oLink In $oLinks ConsoleWrite($oLink.href & @CRLF) Next EndFunc ;==>Example  
  10. Thanks
    31290 reacted to Danp2 in find specific piece of link in web page   
    @31290 Remove the quotes around '$oLink.href' and your InetGet should work.
  11. Like
    31290 reacted to rootx in [Solved] AD update from csv file   
    #include <File.au3> #include <Array.au3> Global $csv_file = @DesktopDir & "\Book1.csv" Global $aRecords If Not _FileReadToArray($csv_file,$aRecords) Then ; MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to UBound($aRecords) -1 ConsoleWrite("ROW "&$x &" "&$aRecords[$x]&@CRLF) ; Shows the line that was read from file $csv_line_values = StringSplit($aRecords[$x], ",",1) ; Splits the line into 2 or more variables and puts them in an array For $z = 1 to UBound($csv_line_values) -1 If $z = 1 Then ConsoleWrite(" A " &$csv_line_values[$z]&@CRLF) ElseIf $z = 2 Then ConsoleWrite(" B " &$csv_line_values[$z]&@CRLF) ElseIf $z = 3 Then ConsoleWrite(" C " &$csv_line_values[$z]&@CRLF) EndIf Next ; _ArrayDisplay($csv_line_values) ; Shows what's in the array you just created. ; $csv_line_values[0] holds the number of elements in array ; $csv_line_values[1] holds the value ; $csv_line_values[2] holds the value ; etc ; Msgbox(0, 0, $csv_line_values[1]) Next  
  12. Like
    31290 reacted to water in Extract "never the same" string from filename   
    Use StringInStr to get the position of the first "A" and then use this as starting position for your calculation.
  13. Like
    31290 reacted to AutoBert in Strange progress behavior   
    Make it this way: SEE_Delete_Temp_Functions.au3 This isn't tested (i don't want to clean my caches yet).
     
    And here my extended Example: ArrayOfCheckBoxesOE.au3 (only simulating)
  14. Like
    31290 reacted to InunoTaishou in Show button when clicking a checkbox   
    GUICtrlSetPos
    Also, it's bad practice to create global variables inside a function. Declare them outside f_MainGui and initialize them in your function.
    #include <ButtonConstants.au3> #Include <Constants.au3> #include <Date.au3> #include <File.au3> #Include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> Global $hGui Global $btnExample Global $chkExample Opt("GUIOnEventMode", 1) Example() While 1 Sleep (100) Wend Func Example() $hGUI = GUIcreate("Example", 120, 80) $btnExample = GUICtrlCreateButton("Hidden Button", 400, 0, 100, 30) $chkExample = GUICtrlCreateCheckbox("Click me!", 10, 10, 100, 30) GUICtrlSetOnEvent($btnExample, "ButtonExample") GUICtrlSetOnEvent($chkExample, "SetButton") GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUISetState(@SW_SHOW, $hGUI) EndFunc Func SetButton() If (GUICtrlRead($chkExample) = $GUI_CHECKED) Then GUICtrlSetPos($btnExample, 10, 40, 100, 30) Else GUICtrlSetPos($btnExample, 400, 0, 100, 30) EndIf EndFunc Func ButtonExample() MsgBox("", "", "Hidden button has been clicked!") EndFunc Func Close() GUIDelete($hGUI) Exit 0 EndFunc  
  15. Like
    31290 reacted to AutoBert in Show button when clicking a checkbox   
    and which of the checkBoxes is the one which should toggle buttonstate? And where are the func's for the events?
    Here's a small script: ArrayOfCheckBoxesOE.au3, which shows the logic you need if any checkbox should enable Button.
  16. Like
    31290 reacted to mikell in Download a variable link   
    Hmm this looks like a great confusion between declaring an array, walking through an array [$i] and selecting the first element of an array [0]
    Please try this one and guess what 
    Edit
    BTW be careful with the syntax, $a... is for arrays, $s... for strings, and $b... for booleans
    #include <String.au3> f_e5440Drivers() Func f_e5440Drivers() Local $sRead = InetRead('http://downloads.dell.com/published/pages/latitude-e5450-laptop.html', 1) Local $aDataBIOS = _StringBetween(BinaryToString($sRead), 'Type: BIOS', 'Category: Communications') Local $aDataGraphics = _StringBetween(BinaryToString($sRead), 'Category: Video', 'Type: Firmware') Local $aDataNetwork = _StringBetween(BinaryToString($sRead), 'Category: Network', 'Type: Utility') TrayTip("", "Downloading latest drivers, please wait...", 10, 3) Local $aLinksBIOS = _StringBetween($aDataBIOS[0], '<TR><TD>', '</TD></TR>') Local $aLinksGraphics = _StringBetween($aDataGraphics[0], '<TR><TD>', '</TD></TR>') Local $aLinksNetwork = _StringBetween($aDataNetwork[0], '<TR><TD>', '</TD></TR>') Local $slinksBIOS = "" Local $sLinksGraphics = "" Local $sLinksNetwork = "" For $i = 0 To UBound($aLinksBIOS) - 1 ;~ $aLinksBIOS[$i] = 'http://downloads.dell.com/' & $aLinksBIOS[$i] If StringInStr($aLinksBIOS[$i], "E5450") Then Local $a2LinksBIOS = _StringBetween($aLinksBIOS[$i], '<A HREF="/', '"><IMG') $sLinksBIOS = 'http://downloads.dell.com/' & $a2LinksBIOS[0] ConsoleWrite($sLinksBIOS & @LF) ExitLoop EndIf Next For $i = 0 To UBound($aLinksGraphics) - 1 ;~ $aLinksGraphics[$i] = 'http://downloads.dell.com/' & $aLinksGraphics[$i] If (StringInStr($aLinksGraphics[$i], "Intel HD, HD 4000/4200/4400/4600/5000/5100/5200/5300/5500 Graphics Driver") AND StringInStr($aLinksGraphics[$i], "Windows 7, 8 and 8.1 32-bit OS")) Then Local $a2LinksGraphics = _StringBetween($aLinksGraphics[$i], '<A HREF="/', '"><IMG') $sLinksGraphics = 'http://downloads.dell.com/' & $a2LinksGraphics[0] ConsoleWrite($sLinksGraphics & @LF) ;~ $slink = $aLinks[$i] ExitLoop EndIf Next For $i = 0 To UBound($aLinksNetwork) - 1 ;~ $aLinksNetwork[$i] = 'http://downloads.dell.com/' & $aLinksNetwork[$i] If (StringInStr($aLinksNetwork[$i], "Intel 7265/3165/7260/3160 WiFi Driver") AND StringInStr($aLinksNetwork[$i], "Windows 7 32-bit")) Then Local $a2LinksNetwork = _StringBetween($aLinksNetwork[$i], '<A HREF="/', '"><IMG') $sLinksNetwork = 'http://downloads.dell.com/' & $a2LinksNetwork[0] ConsoleWrite($sLinksNetwork & @LF) ExitLoop EndIf Next EndFunc  
  17. Like
    31290 reacted to JohnOne in Download a variable link   
    #include <String.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> Local $sRead = InetRead('http://downloads.dell.com/published/pages/latitude-e5450-laptop.html', 1) ;(BinaryToString($sRead) & @CRLF) Local $aData = _StringBetween(BinaryToString($sRead), 'Type: BIOS', 'Category:') TrayTip("", "Downloading latest BIOS Version, please wait...", 10, 3) Local $aLinks = _StringBetween($aData[0], '<A HREF="/', '"><IMG') Local $slink = "" For $i = 0 To UBound($aLinks) - 1 $aLinks[$i] = 'http://downloads.dell.com/' & $aLinks[$i] If StringInStr($aLinks[$i], "E5450") Then $slink = $aLinks[$i] ExitLoop EndIf Next Exit Local $hDownload = InetGet($slink, @DesktopDir & "\BIOSE5450.exe", 1, 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) Local $iBytesSize = InetGetInfo($hDownload, 0) Local $iFileSize = Round(FileGetSize(@DesktopDir & "\BIOSE5450.exe") / 1048576) InetClose($hDownload) MsgBox(0, "", "The latest E5450 BIOS (" & $iFileSize & " MB) have been downloaded")  
  18. Like
    31290 reacted to Danyfirex in Download file with name changing   
    You're Wellcome.
     
    Saludos
  19. Like
    31290 reacted to Danyfirex in Download file with name changing   
    Hi. You can do this.
     
    #include <String.au3> #include <Array.au3> Local $sRead = InetRead('http://downloads.dell.com/published/pages/optiplex-7010.html', 1) ConsoleWrite(BinaryToString($sRead) & @CRLF) Local $aData = _StringBetween(BinaryToString($sRead), 'Type: BIOS', 'Category:') Local $aLinks = _StringBetween($aData[0], '<A HREF="/', '"><IMG') For $i = 0 To UBound($aLinks) - 1 $aLinks[$i] = 'http://downloads.dell.com' & $aLinks[$i] Next ;~ _ArrayDisplay($aLinks) MsgBox(0, "Lastest Version BIOS", $aLinks[0]) Saludos
  20. Like
    31290 reacted to Melba23 in File into list view and other   
    31290,
    Not very difficult - look for the <<<<<<<<<<<< lines:
    #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> #include <Array.au3> #include <GuiListView.au3> ; Read file into array $aLines = FileReadToArray("EPES18.txt") ; Deal with title line $aLines[0] = StringRegExpReplace($aLines[0], "(\x20+)", "|") ; Now the other lines For $i = 1 To UBound($aLines) - 1 ; Extract line $sLine = $aLines[$i] ; Replace tabs with spaces $sLine = StringReplace($sLine, @TAB, " ") ; Extract possible name field $sName = StringRegExpReplace($sLine, "(?U)^.*(\x20.*\x20)(connected|notconnect|err-disabled).*$", "$1") ; Convert multiple spaces to singles $sStrippedName = StringRegExpReplace($sName, "\x20+", " ") ; Set placeholder if no name field If $sStrippedName = " " Then $sStrippedName = " ~ " ; Replace original name string in line with stripped version - add spaces to ensure multiple spaces before and after $sLine = StringReplace($sLine, $sName, " " & $sStrippedName & " ") ; Set delimiters by replacing multiple spaces $sLine = StringRegExpReplace($sLine, "(\x20{2,19})", "|") ; Remove placeholders $sLine = StringReplace($sLine, "~", "") ; Replace existing line with delimited line $aLines[$i] = $sLine Next ; Read IP Phone ID file $sID = Fileread("id.txt") $hGUI = GUICreate("Test", 500, 500) ; Create ListView with first 4 headers plus "IP Phone" $cLV = GUICtrlCreateListView(StringRegExpReplace($aLines[0], "(?U)^(.*\|.*\|.*\|.*)\|.*$", "$1") & "|IP Phone", 10, 10, 480, 380) ; Set column widths For $i = 0 To 4 _GUICtrlListView_SetColumnWidth($cLV, $i, 90) Next ; Add content of first 4 fields in each line plus the IP Phone result For $i = 1 To UBound($aLines) - 1 ; Assume not IP Phone $sIPPhone = "|Not set" ; Look for the port ID in the file - it will be preceded by a space and followed by either a comma or an EOL If StringRegExp($sID, " " & StringRegExpReplace($aLines[$i], "(?U)^(.*)\|.*$", "$1") & "[,\x0D]") Then ; If found change the set value $sIPPhone = "|Set" EndIf ; Add fields and IP Phone to the ListView $cLVItem = GUICtrlCreateListViewItem(StringRegExpReplace($aLines[$i], "(?U)^(.*\|.*\|.*\|.*)\|.*$", "$1") & $sIPPhone, $cLV) Next $cDummyCheckRow = GUICtrlCreateDummy() ; Create dummy control <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() ; Set sort state Local $aSortSense[_GUICtrlListView_GetColumnCount($cLV)] While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cDummyCheckRow ; Fired by the handler, but only once the handler has exited <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $iRow = GUICtrlRead($cDummyCheckRow) ; Read the row value <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< MsgBox($MB_SYSTEMMODAL, $iRow, StringReplace(_GUICtrlListView_GetItemTextString($cLV, $iRow), "|", @CRLF)) ; Display the row data <<<<<<<<<<<<<<<<< EndSwitch WEnd Func _WM_NOTIFY($hWnd, $imsg, $wParam, $lParam) ; Struct = $tagNMHDR and "int Item;int SubItem" from $tagNMLISTVIEW Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If @error Then Return Local $iCode = BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) Switch $iCode Case $LVN_COLUMNCLICK ; Get column index Local $iCol = DllStructGetData($tStruct, 5) If $iCol <> 0 Then ; Sort column _GUICtrlListView_SimpleSort($cLV, $aSortSense, $iCol) EndIf Case $NM_DBLCLK $iRow = DllStructGetData($tStruct, 4) GUICtrlSendToDummy($cDummyCheckRow, $iRow) ; Send the row value to the dummy control and fire it once returned <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $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 BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $iItem = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index ; Gte text of item $sText = _GUICtrlListView_GetItemText($cLV, $iItem, $iSubItem) ; Set default back colour $iBkColour = 0xC4C4C4 ; Now check for our spoecific items Switch $iSubItem Case 2 ; connection Switch $sText Case "connected" $iBkColour = 0x00FF00 Case "notconnect" $iBkColour = 0x0000FF Case "err-disabled" $iBkColour = 0xC4C4C4 EndSwitch Case 3 ; vlan Switch $sText Case "trunk" $iBkColour = 0x00FFFF Case "1" $iBkColour = 0xFFFF00 Case "10" $iBkColour = 0xC4FFC4 Case "13" $iBkColour = 0xFF00FF EndSwitch EndSwitch ; Set required back colour DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", $iBkColour) Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndFunc ;==>_WM_NOTIFY Now you can move the MsgBox around as much as you like.
    M23
  21. Like
    31290 reacted to Melba23 in File into list view and other   
    31290,
    Glad I could help.
    M23
  22. Like
    31290 reacted to Melba23 in File into list view and other   
    31290,
    Il n'y a pas de quoi.
    M23
  23. Like
    31290 reacted to Melba23 in File into list view and other   
    31290,
    I have completely recoded the delimiter parsing section to deal with the annoying "Name" section - please test this and see if it works for you:
    #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> #include <Array.au3> #include <GuiListView.au3> ; Read file into array $aLines = FileReadToArray("EPES18.txt") ; Deal with title line $aLines[0] = StringRegExpReplace($aLines[0], "(\x20+)", "|") ; Now the other lines For $i = 1 To UBound($aLines) - 1 ; Extract line $sLine = $aLines[$i] ; Replace tabs with spaces $sLine = StringReplace($sLine, @TAB, " ") ; Extract possible name field $sName = StringRegExpReplace($sLine, "(?U)^.*(\x20.*\x20)(connected|notconnect|err-disabled).*$", "$1") ; Convert multiple spaces to singles $sStrippedName = StringRegExpReplace($sName, "\x20+", " ") ; Set placeholder if no name field If $sStrippedName = " " Then $sStrippedName = " ~ " ; Replace original name string in line with stripped version - add spaces to ensure multiple spaces before and after $sLine = StringReplace($sLine, $sName, " " & $sStrippedName & " ") ; Set delimiters by replacing multiple spaces $sLine = StringRegExpReplace($sLine, "(\x20{2,19})", "|") ; Remove placeholders $sLine = StringReplace($sLine, "~", "") ; Replace existing line with delimited line $aLines[$i] = $sLine Next $hGUI = GUICreate("Test", 500, 500) ; Create ListView with first 4 headers $cLV = GUICtrlCreateListView(StringRegExpReplace($aLines[0], "(?U)^(.*\|.*\|.*\|.*)\|.*$", "$1"), 10, 10, 480, 380) ; Set column widths For $i = 0 To 3 _GUICtrlListView_SetColumnWidth($cLV, $i, 110) Next ; Add content of first 4 fields in each line For $i = 1 To UBound($aLines) - 1 $cLVItem = GUICtrlCreateListViewItem(StringRegExpReplace($aLines[$i], "(?U)^(.*\|.*\|.*\|.*)\|.*$", "$1"), $cLV) Next GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() ; Set sort state Local $aSortSense[_GUICtrlListView_GetColumnCount($cLV)] While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_NOTIFY($hWnd, $imsg, $wParam, $lParam) ; Struct = $tagNMHDR and "int Item;int SubItem" from $tagNMLISTVIEW Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If @error Then Return Local $iCode = BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) Switch $iCode Case $LVN_COLUMNCLICK ; Get column index Local $iCol = DllStructGetData($tStruct, 5) If $iCol <> 0 Then ; Sort column _GUICtrlListView_SimpleSort($cLV, $aSortSense, $iCol) EndIf Case $NM_DBLCLK $iRow = DllStructGetData($tStruct, 4) ; Row 0 in ListView is row 2 in the array $sData = $aLines[$iRow + 2] ; Split $aData = StringSplit($sData, "|") ConsoleWrite("Row Data: " & $aData[1] & " - " & $aData[2] & " - " & $aData[3] & " - " & $aData[4] & @CRLF) Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $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 BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $iItem = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index ; Gte text of item $sText = _GUICtrlListView_GetItemText($cLV, $iItem, $iSubItem) ; Set default back colour $iBkColour = 0xC4C4C4 ; Now check for our spoecific items Switch $iSubItem Case 2 ; connection Switch $sText Case "connected" $iBkColour = 0x00FF00 Case "notconnect" $iBkColour = 0x0000FF Case "err-disabled" $iBkColour = 0xC4C4C4 EndSwitch Case 3 ; vlan Switch $sText Case "trunk" $iBkColour = 0x00FFFF Case "1" $iBkColour = 0xFFFF00 Case "10" $iBkColour = 0xC4FFC4 Case "13" $iBkColour = 0xFF00FF EndSwitch EndSwitch ; Set required back colour DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", $iBkColour) Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndFunc ;==>_WM_NOTIFY If you still have problems, then please let me see the file containing the lines causing difficulty so I can refine the process further.
    M23
  24. Like
    31290 reacted to Melba23 in File into list view and other   
    31290,
    Here is LarsJ's code integrated into mine - I enjoyed doing that:
    #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> #include <Array.au3> #include <GuiListView.au3> ; Read file and replace tabs $sContent = StringReplace(FileRead("EPES18.txt"), @TAB, " ") ; Replace orphaned dashes $sNoDashes = StringReplace($sContent, " - ", "  ") ; Expand possible single space before connection status $sExpanded = StringRegExpReplace($sNoDashes, "(\x20(connected|notconnect|err-disabled))", " $1") ; Replace multiple spaces with | delimiter - max 19 to allow for empty fields $sDelimed = StringRegExpReplace($sExpanded, "(\x20{2,19})", "|") ; Split on @CRLF $aLines = StringSplit($sDelimed, @CRLF, $STR_ENTIRESPLIT) ;_ArrayDisplay($aLines, "", Default, 8) $hGUI = GUICreate("Test", 500, 500) ; Create ListView with first 4 headers $cLV = GUICtrlCreateListView(StringRegExpReplace($aLines[1], "(?U)^(.*\|.*\|.*\|.*)\|.*$", "$1"), 10, 10, 480, 380) ; Set column widths For $i = 0 To 3 _GUICtrlListView_SetColumnWidth($cLV, $i, 110) Next ; Add content of first 4 fields in each line For $i = 2 To $aLines[0] $cLVItem = GUICtrlCreateListViewItem(StringRegExpReplace($aLines[$i], "(?U)^(.*\|.*\|.*\|.*)\|.*$", "$1"), $cLV) Next GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() ; Set sort state Local $aSortSense[_GUICtrlListView_GetColumnCount($cLV)] While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_NOTIFY($hWnd, $imsg, $wParam, $lParam) ; Struct = $tagNMHDR and "int Item;int SubItem" from $tagNMLISTVIEW Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If @error Then Return Local $iCode = BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) Switch $iCode Case $LVN_COLUMNCLICK ; Get column index Local $iCol = DllStructGetData($tStruct, 5) If $iCol <> 0 Then ; Sort column _GUICtrlListView_SimpleSort($cLV, $aSortSense, $iCol) EndIf Case $NM_DBLCLK $iRow = DllStructGetData($tStruct, 4) ; Row 0 in ListView is row 2 in the array $sData = $aLines[$iRow + 2] ; Split $aData = StringSplit($sData, "|") ConsoleWrite("Row Data: " & $aData[1] & " - " & $aData[2] & " - " & $aData[3] & " - " & $aData[4] & @‌CRLF) Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $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 BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $iItem = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index ; Gte text of item $sText = _GUICtrlListView_GetItemText($cLV, $iItem, $iSubItem) ; Set default back colour $iBkColour = 0xC0B0B0 ; Now check for our spoecific items Switch $iSubItem Case 2 ; connection Switch $sText Case "connected" $iBkColour = 0x00FF00 Case "notconnect" $iBkColour = 0x0000FF Case "err-disabled" $iBkColour = 0xC4C4C4 EndSwitch Case 3 ; vlan Switch $sText Case "trunk" $iBkColour = 0x00FFFF Case "1" $iBkColour = 0xFFFF00 Case "10" $iBkColour = 0xC4FFC4 Case "13" $iBkColour = 0xFF00FF EndSwitch EndSwitch ; Set required back colour DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", $iBkColour) Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndFunc ;==>_WM_NOTIFY It looks as if the file parsing could do with a bit more work - there are a couple of lines where the delimiters are not correct. It does not help that the file uses a mixture of spaces and tabs to separate the items on each line - and on some lines there are items missing. Can you get the file in a more reasonable CSV format or are you stuck with what you have posted?
    M23
    Edit: Recoded the file parsing - it now works for the test file, but I would still recommend trying to get a better delimited file initially as the parsing requirements are a bit arbitrary at the moment.
  25. Like
    31290 reacted to Melba23 in File into list view and other   
    31290,
    If you want to prevent sorting certain columns, then just check which column was clicked inside the handler - this prevents the first column being sorted:
    Case $LVN_COLUMNCLICK ; Get column index Local $iCol = DllStructGetData($tStruct, 5) If $iCol <> 0 Then ; Sort column _GUICtrlListView_SimpleSort($cLV, $aSortSense, $iCol) EndIfM23:
     
×
×
  • Create New...