Jump to content

Norm73

Active Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by Norm73

  1. I know this is very old, but if this code doesn't work for anyone: $oExcel.ActiveSheet.HPageBreaks($nPage).Location = $oExcel.ActiveSheet.Range("A" & $iRow) is there an alternative: With $oWorkbook.Worksheets(1) .HPageBreaks.Add($oExcel.ActiveCell) .HPageBreaks.Add(.Range("A" & $iRow)) .VPageBreaks.Add(.Range("A" & $iRow)) EndWith
  2. I needed such a function, but it was necessary to compare the values in stilts in certain rows. I decided to make a universal function that compares both 1D and 2D values by columns or rows By default, all values are compared as strings and optionally as numbers. #include <Array.au3> Local $Array1[2][12] = [[0,0,0,0,0,0,0,0,0,0,0,0],["TA",1,3,5,17,6,7,8,9,10,11,"MG"]] Local $Array2[10][2] = [[1,0], [2,0], [2,0], [3,0], [4,0], [5,0], [6,0], [8,0], [10,0], ["MG",0]] Local $aExRet = _ArrayCompare($Array1, $Array2, 0, 1, 2, 0, 0, 1, 0, 1) _ArrayDisplay($aExRet) Dim $Array1[14] = [1,"ZU",3,5,17,6,7,8,"GH",10,11,12] Dim $Array2[12][2] = [[0,1], [0,1], [0,3], [0,5], [0,17], [0,6], [0,7], [0,"GH"], [0,9], [0,10], [0,11], [0,12]] Local $aExRet = _ArrayCompare($Array1, $Array2, 0, 0, 1, 0, 1, 1, 0, 1) _ArrayDisplay($aExRet) Func _ArrayCompare($Array1, _ ; Array1 zum Abgleich Const ByRef $Array2, _ ; Array2 zum Abgleich $iStr1 = 0, _ ; Startindex für Array1 $i1rc = 0, _ ; Param. für Array1; Spalte von 1 oder 2D Array1 // Zeile von 2D wenn $iRg1 = 2 $iRg1 = 1, _ ; Param. für Array1; nur 1 oder 2; Bei 1 wird in allen Zeilen gesucht, bei 2 in allen Spalten $iStr2 = 0, _ ; Startindex für Array2 $i2rc = 0, _ ; Param. für Array2; Spalte von 1 oder 2D Array2 // Zeile von 2D wenn $iRg1 = 2 $iRg2 = 1, _ ; Param. für Array2; nur 1 oder 2; Bei 1 wird in allen Zeilen gesucht, bei 2 in allen Spalten $iDig = 0, _ ; 0 => alle Werte werden als String vergliechen; wenn 1 als Zahlen $iRtS = 1) ; 1 => ein 2D-Array mit dem Ergebnis für [x][0]-$Array1, [x][1]-$Array1 und [x][2]-Spalte mit allen vorhandenen in beiden Arrays ; ^^^^^ wenn 0 => ohne Spalte [x][2]-Spalte mit allen vorhandenen in beiden Arrays If Not IsArray($Array1) Or Not IsArray($Array2) Then Return SetError(-1) If ($iRg1 > 2) Or ($iRg1 < 1) Then Return SetError(-3) If ($iRg2 > 2) Or ($iRg2 < 1) Then Return SetError(-4) Local $iDmsA = UBound($Array1, 0) Local $iDmsB = UBound($Array2, 0) If ($iRg1 = 2 And $iDmsA = 1) Or ($iRg2 = 2 And $iDmsB = 1) Then Return SetError(-5) Local $nUb1 = UBound($Array1, $iRg1) Local $nUb2 = UBound($Array2, $iRg2) Local $oDic1 = ObjCreate("Scripting.Dictionary") Local $oDic2 = ObjCreate("Scripting.Dictionary") Local $oDic3 = ObjCreate("Scripting.Dictionary") For $iN = $iStr1 To $nUb1 -1 If $iDmsA = 1 Then $Array1[$iN] = ($iDig ? (Number($Array1[$iN])) : (String($Array1[$iN]))) $oDic1.Item($Array1[$iN]) Else If $iRg1 = 1 Then $Array1[$iN][$i1rc] = ($iDig ? (Number($Array1[$iN][$i1rc])) : (String($Array1[$iN][$i1rc]))) $oDic1.Item($Array1[$iN][$i1rc]) Else $Array1[$i1rc][$iN] = ($iDig ? (Number($Array1[$i1rc][$iN])) : (String($Array1[$i1rc][$iN]))) $oDic1.Item($Array1[$i1rc][$iN]) EndIf EndIf Next For $iN = $iStr2 To $nUb2 -1 If $iDmsB = 1 Then $oDic2.Item($iDig ? (Number($Array2[$iN])) : (String($Array2[$iN]))) Else If $iRg2 = 1 Then $oDic2.Item($iDig ? (Number($Array2[$iN][$i2rc])) : (String($Array2[$iN][$i2rc]))) Else $oDic2.Item($iDig ? (Number($Array2[$i2rc][$iN])) : (String($Array2[$i2rc][$iN]))) EndIf EndIf Next For $iN = $iStr1 To $nUb1 -1 If $iDmsA = 1 Then If $oDic2.Exists($Array1[$iN]) Then $oDic3.Item($Array1[$iN]) EndIf Else If $iRg1 = 1 Then If $oDic2.Exists($Array1[$iN][$i1rc]) Then $oDic3.Item($Array1[$iN][$i1rc]) EndIf Else If $oDic2.Exists($Array1[$i1rc][$iN]) Then $oDic3.Item($Array1[$i1rc][$iN]) EndIf EndIf EndIf Next Local $aRet3 = $oDic3.Keys() Local $nUb3 = UBound($aRet3)-1 For $iN = 0 To $nUb3 If $oDic1.Exists($aRet3[$iN]) Then $oDic1.Remove($aRet3[$iN]) EndIf If $oDic2.Exists($aRet3[$iN]) Then $oDic2.Remove($aRet3[$iN]) EndIf Next $oDic3.RemoveAll() Local $aRet1 = $oDic1.Keys() $nUb1 = UBound($aRet1)-1 $oDic1.RemoveAll() Local $aRet2 = $oDic2.Keys() $nUb2 = UBound($aRet2)-1 $oDic2.RemoveAll() If Not $iRtS Then $nUb3 = -1 EndIf Local $nExUB = (($nUb1 > $nUb2) ? (($nUb1 > $nUb3) ? $nUb1 : $nUb3) : (($nUb2 > $nUb3) ? $nUb2 : $nUb3)) Local $aExRet[$nExUB+1][($iRtS ? 3 : 2)] For $iN = 0 To $nExUB If $iN <= $nUb1 Then $aExRet[$iN][0] = $aRet1[$iN] EndIf If $iN <= $nUb2 Then $aExRet[$iN][1] = $aRet2[$iN] EndIf If $iN <= $nUb3 Then $aExRet[$iN][2] = $aRet3[$iN] EndIf Next Return $aExRet EndFunc
  3. Maybe it will help someone. The problem with name conflict also happens very often when AutoFiler is used. At the end, before saving you have to delete all names I solved it like this: $oExcel = _Excel_Open() $oBook_BFSM = _Excel_BookOpen($oExcel, @ScriptDir &"\EXCEL\BFSM.xlsx") For $rNme In $oBook_BFSM.Worksheets(1).Names $rNme.Delete Next ; Code ; Code ; Code ; Code ; Code _Excel_BookSave($oBook_BFSM)
  4. You're right, GUISetOnEvent() is still missing here It would be correct to ask where I should set the GUISetOnEvent() to use the UDF in OnEvent mode. I suspect that the UDF is not suitable for OnEvent, which also makes it impossible for me to use it.
  5. Hello everyone, Does anyone know how to do it with Opt("GUIOnEventMode", 1) ?
  6. If it's not feasible, I probably don't have a choice.
  7. Thanks for the quick reply It works very well! I want to make this message more reliable, but I don't know how to send a combination to a control in a window. Like this: #include <SendMessage.au3> #include <WindowsConstants.au3> Run("notepad.exe") $hWnd = WinWait("[CLASS:Notepad]", "", 10) $hControl = ControlGetHandle($hWnd, "", "Edit1") $text = "this is a line" $struct_string = DllStructCreate("char[" & StringLen($text) + 1 & "]") DllStructSetData($struct_string, 1, $text) _SendMessageA($hControl, $WM_SETTEXT, 0, DllStructGetPtr($struct_string))
  8. please tell me how to send a virtual key combination, for example, Alt+a, "^a", "{LCTRL}a" When I send $VK_SELECT (SELECT key) nothing happens _Send_Virtual_Key(0x29) ; -> VK_SELECT - SELECT key Func _Send_Virtual_Key($iCode) If Not IsInt($iCode) Then Return DllCall('user32.dll', 'int', 'keybd_event', 'int', $iCode, 'int', 0, 'int', 0, 'ptr', 0) DllCall('user32.dll', 'int', 'keybd_event', 'int', $iCode, 'int', 0, 'int', 2, 'ptr', 0) EndFunc
  9. Good afternoon, I'm looking for a solution to a search problem with the _ArrayBinarySearch() function. There are duplicates in my array (1D or 2D). For some reason, the output is always wrong. Here is a variant with a function from BrewManNH. This is my attempt to make an analogue of the _ArrayFindAll() function. #include <Array.au3> Global $Array1[40], $Array2[39][2], $TLV_Array[40], $Count = 0 For $I = 0 To 39 For $X = 1 To 6 $Array1[$I] &= Chr(Random(65, 90, 1)) Next Next For $I = 0 To 38 $Array2[$I][0] = $Array1[$I] $Array2[$I][1] = ($I > 8 And $I < 19) ? 12 : $I Next _ArraySort($Array2,0,0,0,1) _ArrayDisplay($Array2, "Sorted $Array2 by first column") Local $DelDup = _Array2D_BinarySearch($Array2, 12, 1, 12) Func _Array2D_BinarySearch(Const ByRef $avArray, $vValue, $iColumn = 0, $iStart = 0, $iEnd = 0) If UBound($avArray, 0) > 2 Then Return SetError(6, 0, -1) Local $i2D = False If UBound($avArray, 0) > 1 Then $i2D = True EndIf If UBound($avArray, 2) < $iColumn Then Return SetError(5, 0, -1) If Not IsArray($avArray) Then Return SetError(1, 0, -1) Local $iUBound = UBound($avArray) - 1 ; Bounds checking If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(4, 0, -1) Local $iMid = Int(($iEnd + $iStart) / 2) If Not $i2D Then If $avArray[$iStart] > $vValue Or $avArray[$iEnd] < $vValue Then Return SetError(2, 0, -1) ; Search While $iStart <= $iMid And $vValue <> $avArray[$iMid] If $vValue < $avArray[$iMid] Then $iEnd = $iMid - 1 Else $iStart = $iMid + 1 EndIf $iMid = Int(($iEnd + $iStart) / 2) WEnd If $iStart > $iEnd Then Return SetError(3, 0, -1) ; Entry not found Return $iMid Else If $avArray[$iStart][$iColumn] > $vValue Or $avArray[$iEnd][$iColumn] < $vValue Then Return SetError(2, 0, -1) ; Search While $iStart <= $iMid And $vValue <> $avArray[$iMid][$iColumn] If $vValue < $avArray[$iMid][$iColumn] Then $iEnd = $iMid - 1 Else $iStart = $iMid + 1 EndIf $iMid = Int(($iEnd + $iStart) / 2) WEnd If $iStart > $iEnd Then Return SetError(3, 0, -1) ; Entry not found Return $iMid EndIf EndFunc ;==>_Array2D_BinarySearch Here is a variant with a function from RRRR This is my attempt to make an analogue of the _ArrayFindAll() function #include <Array.au3> Local $avArray[10] $avArray[0] = 1 $avArray[1] = 2 $avArray[2] = 2 $avArray[3] = 2 $avArray[4] = 5 $avArray[5] = 6 $avArray[6] = 4 $avArray[7] = 2 $avArray[8] = 9 $avArray[9] = 10 _ArraySort($avArray) _ArrayDisplay($avArray, "$avArray ПОСЛЕ _ArraySort()") $iKeyIndex = _ArrayBinaryFindAll($avArray, 2) If Not @error Then _ArrayDisplay($iKeyIndex) Else MsgBox(4096,'Error',' Error: ' & @error) EndIf Func _ArrayBinaryFindAll(Const ByRef $aArray, $vValue, $iStart = 0, $iEnd = 0, $iSubItem = 0) If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If $iSubItem = Default Then $iSubItem = 0 $iStart = _ArrayBinarySearch($aArray, $vValue, $iStart, $iEnd, $iSubItem) If @error Then Return SetError(@error, 0, -1) Local $iIndex = 0, $avResult[UBound($aArray)] ; Set dimension for Column/Row Do $avResult[$iIndex] = $iStart $iIndex += 1 $iStart = _ArrayBinarySearch($aArray, $vValue, $iStart + 1, $iEnd, $iSubItem) Until @error ReDim $avResult[$iIndex] Return $avResult EndFunc ;==>_ArrayBinaryFindAll
  10. Thanks @pixelsearchfor the quick response I checked it a few more times. All three options work very well. It's hard to say which is better in terms of functionality, but the second variant (with +6 Pxl) looks really better.
  11. Hello @pixelsearch, Thanks for the latest version I'm busy with right now. I stumbled upon one problem that appears if any column has Align set to 0. If there is such a column, then after moving it to the left, it becomes empty. For example: Global $ g_aColAligns [$ g_iCols] = [2, 0, 1, 0, 1, 2]
  12. Hi @LarsJ, @pixelsearch I discovered another problem. I've made the second column extra narrower to show that. Can this be somehow removed?
  13. For @pixelsearch Drag and drop works as advertised. The described problem, with the disappearance of the window into the background, is also present for me.
  14. For me (2s with adjustment) all scroll options work fine. There are still two minor things to fix. P.S. If the width of the columns cannot be changed, and all of the text is not visible, then it makes sense to try to show it through the ToolTip when you hover over the SubItem or Heading.
  15. Hi ldub If no errors are found, this script will no longer be corrected. I think it's better to keep an eye on the latest versions from pixelsearch. VrtListView_Search.zip
  16. Thank you very much! I fixed everything. I thought you weren't going to release your latest version so I decided to do the best I can myself. Now I will deal with the latest version. And I'm looking forward to your CSV editor. I hope one day you will post it too.
  17. Hi pixelsearch Thank you for your efforts and explanations. Sorry if I was too impatient or persistent. I understand you well as I have had similar problems lately myself.☹️ I don't know if this would be appropriate, but I wish you a speedy recovery... P.S. I was not very attentive, but after looking at my code with a fresh head, I found a solution for my question. The solution turned out to be very simple. Added two new lines and that's it.
  18. I've tried your example. It worked well too, that's why I incorporated your idea into my code so that anyone can use it if necessary. Here I tried to implement different search options using great examples from LarsJ and pixelsearch. Everything (seems) to be working fine, but I am bothered by one little thing that I cannot change myself. So I ask for help from more experienced people. The point is that the search is always performed in a "static" array and the search result is always sorted exactly like the array. For example, if I sorted the second column before searching, the sorting isn't preserved after the search. If a filter is used to search, ie unnecessary lines are deleted, this is usually not noticed and is not a problem. However, if the scrolling search is used, it is immediately noticeable that the sorting has been reset. Please help me to solve this problem so that the sorting would also be saved after the search.
  19. This is my attempt to make the pixselsearch script a little more flexible so that it can be used in any GUI with virtual ListView. Realized functions: Registration Search Sorting Selected row text Unregistration
  20. Thank LarsJ and pixelsearch for helping beginners. For two weeks I've been struggling with the fact that this will work as a universal UDF function for all of my ListViews. It would be a wrong way to always create the same function for every list. If possible, please post this version as well:
  21. Hollo together I couldn't change the column size of the virtual ListView. When I deleted this block, it worked again. Maybe it was also because of the operating system? I have Windows 8.1 Pro 64 bit. ; No ListView column resizing by dragging header dividers (LarsJ) ;_WinAPI_SetWindowLong( $hHeader, $GWL_STYLE, _WinAPI_GetWindowLong( $hHeader, $GWL_STYLE ) + $HDS_NOSIZING ) ; AutoIt 3.3.14.5 issue DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "SetWindowLongPtrW" : "SetWindowLongW", "hwnd", $g_hHeader, "int", $GWL_STYLE, "long_ptr", _ DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "GetWindowLongPtrW" : "GetWindowLongW", "hwnd", $g_hHeader, "int", $GWL_STYLE )[0] + $HDS_NOSIZING ) I also tried to integrate the LatsJ's ColAlign.au3 script into the last version, but unfortunately it didn't work. I couldn't cope with it. ; Subitem rectangle for right and center aligned columns If $g_aColAligns[$g_iSearchCol] = $HDF_RIGHT Or $g_aColAligns[$g_iSearchCol] = $HDF_CENTER Then DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sSubItemText, "int", StringLen( $sSubItemText ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 Switch $g_aColAligns[$g_iSearchCol] Case $HDF_RIGHT DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tSize, "X" ) - 6 ) Case $HDF_CENTER DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + ( DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tRect, "Left" ) - DllStructGetData( $tSize, "X" ) ) / 2 - 3 ) EndSwitch EndIf
  22. Sorry, accidentally created the message
  23. Thank you LarsJ and Pixelsearch @Pixelsearch I used the correction from LarsJ and now everything works great. You are right, you don't have to do without it. Make the search even more flexible. All | 0 | 1 | 2 | 3 | 4 .... I have one more request. Your virtual ListView with the search can be used in many cases. But there are many lists where the content may not be changed. For example, a log protocol. How can you do this in such a way that the lines are not deleted, but the first one found is scrolled up? Similar to _GUICtrlListView_EnsureVisible. For example, if I sort your list in column 0 and then search in RegExp mode like this ^ u. In this case, the list should not get smaller, but should be scrolled up. It won't be hard to realize in order for the lines to stay in place. I have no idea how to implement the analog of the _GUICtrlListView_EnsureVisible() function.
  24. I realized the search like this: I can't figure out how to mark the found rows in all columns at the same time. At this point my autoit knowledge is unfortunately at an end.
×
×
  • Create New...