Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/26/2025 in Posts

  1. Uia and event hooks are different things. UIA cannot catch all. The event windows hooks are technically a deeper layer. For this example I would just find a message with an event spy and build an example for that in the help file. UIA cannot do much with java ui controls or browser things like playwright can do. So most likely there is not one UI interception framework. Yes, a uia udf as part of AutoIT would be nice but it's a lot of work.😀
    3 points
  2. This is not true, and the second example that counts "," proves it. and this is the reason for failure
    2 points
  3. You can also try the function _StringSplit2D_EX() based on @AspirinJunkie function (link in the script below) . It splits nicely "items1.csv" which has a non-fixed number of columns. #include <Array.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> Local $sFilePath = @ScriptDir & "\items1.csv" Local $sFileRead = FileRead($sFilePath) If @error Then Exit MsgBox($MB_TOPMOST, "FileRead", "@error = " & @error) Local $aRetArray = _StringSplit2D_EX($sFileRead, ",", @CRLF, True) ; True to allow a variable number of columns. If @error Then Exit MsgBox($MB_TOPMOST, "_StringSplit2D_EX", _ "@error = " & @error & @CRLF & _ "All rows don't have the same number of fields (line " & (@extended + 1) & ")") _ArrayDisplay($aRetArray, "2D array from delimited file") ;============================================== Func _StringSplit2D_EX(ByRef $sString, $sDelim_Col = "|", $sDelim_Row = @CRLF, $bExpand = False, $iAdd_EmptyCol = 0) ; based on AspirinJunkie's function _StringSplit2D found at https://autoit.de/thread/85380-1d-array-in-2d-array-splitten/ ; Thanks Nine for suggesting the 4th parameter $bExpand, to allow or not the same number of fields per row (as in _FileReadToArray) Local $a_FirstDim = StringSplit($sString, $sDelim_Row, $STR_ENTIRESPLIT + $STR_NOCOUNT) Local $iKeep_NbCol = Ubound(StringSplit($a_FirstDim[0], $sDelim_Col, $STR_ENTIRESPLIT + $STR_NOCOUNT)) ; keep nb cols row 0 Local $a_Out[UBound($a_FirstDim)][1 + $iAdd_EmptyCol], $a_Line, $i_2DMax = 1 For $i = 0 To UBound($a_FirstDim) - 1 $a_Line = StringSplit($a_FirstDim[$i], $sDelim_Col, $STR_ENTIRESPLIT + $STR_NOCOUNT) If (Not $bExpand) And (Ubound($a_Line) <> $iKeep_NbCol) Then Return SetError(3, $i, 0) ; same error # as _FileReadToArray If UBound($a_Line) > $i_2DMax Then ; when $bExpand = False, this test will be True maximum 1 time, never more. $i_2DMax = UBound($a_Line) ReDim $a_Out[UBound($a_Out)][$i_2DMax + $iAdd_EmptyCol] EndIf For $j = 0 To UBound($a_Line) - 1 $a_Out[$i][$j] = $a_Line[$j] Next Next Return $a_Out EndFunc ;==>_StringSplit2D_EX Edit: @ioa747 & @Musashi thanks for your appreciation. I already used several times this interesting function _StringSplit2D_EX . In case you'll use it one day, I just made a minor change in it, based on the "@extended idea" described in my other post later in this thread. For example, let's run the amended script above, with : 1) items1.csv is the one from OP's 1st post (the bad csv with a non-fixed number of columns) 2) Now this line : Local $aRetArray = _StringSplit2D_EX($sFileRead, ",", @CRLF, True) ; True to expand, it allows a variable number of columns in the rows. Please change its 4th param. True to False , which means that a variable number of columns is not allowed : Local $aRetArray = _StringSplit2D_EX($sFileRead, ",", @CRLF, False) ; False doesn't expand, it means the number of columns must be the same in all rows. Now a normal message error is displayed : Please notice "line 17" in the message : this is what @extended returned, apart from @error, it helps the user to quickly point at the 1st line where the error appears. This can be interesting in case of a big file in input. For the record, the 5th optional parameter allows to add 1 or more empty columns at the right of the array, during its creation, because sometimes we need them. Well... if I added this 5th optional parameter, then you can be sure I needed it one day If you want to try the 5th parameter, just use this line in the script, it will add 5 empty columns on the right, from Col6 to Col10 Local $aRetArray = _StringSplit2D_EX($sFileRead, ",", @CRLF, True, 5) Thanks for reading
    2 points
  4. MattyD

    WinRT - WinUI3

    Hi all - This is an offshoot of the WinRT Project. I'm posting my progress here while I'm bumbling around with WinUI3 - just so the main project doesn't get too cluttered. If I get things working I'll merge the two projects back together. That's the plan anyway! Theres not much there at the moment, but if you wish to try it out you'll need to: download and extract the example (The attachment it too big for here, so I've popped it in sourceforge) Go here and download the latest Redistributable package of the Windows App SDK. Currently this is 1.7.3 (look in the table for the link.). Once you've extracted that, go to the MSIX > win10-x64 folder and install Microsoft.WindowsAppRuntime.1.7.msix It seems the x86 libraries don't work at the moment. (thanks for testing Gianni) Progress so far... Cheers, Matt
    1 point
  5. items1.csv : 16 first lines got 5 commas each Line 17 ("Large house/mansion") got only 4 Plenty of other lines got only 4 commas, one line got only 3 commas etc... Edit: the 1st thing to do in your script is to check @error so you'll know what is happening : _FileReadToArray($sFilePath, $aRetArray, Default, ",") If @error Then Exit MsgBox(0, "_FileReadToArray", "@error = " & @error) It will show an error = 3, which means (help file) : 3 - File lines have different numbers of fields (only if $FRTA_INTARRAYS flag not set) To retrieve the 1st line where this error occured, I modified temporarily a line in _FileReadToArray, to return also the line number in @extended : ; Return error ; Return SetError(3, 0, 0) ; Return error AND extended Return SetError(3, $i, 0) It would be great in this function (and in a few others too !) to return not only @error but also @extended when possible. It would help the user to quickly point the line where the issue appears etc...
    1 point
  6. Take also a look at _FileReadToArray using the $FRTA_INTARRAYS flag...
    1 point
  7. Nine

    edit ListView sub-items

    Of course, you just need to edit a few lines. #include <GUIConstants.au3> #include <GuiListView.au3> Opt("GUICloseOnESC", 0) Opt("MustDeclareVars", True) Global $hList, $idDummy Example() Func Example() Local $hMain = GUICreate("Example", 230, 170) Local $idList = GUICtrlCreateListView("Column 1|Column 2", 10, 10) GUICtrlCreateListViewItem("Item 1|Item 2", $idList) GUICtrlCreateListViewItem("Item 3|Item 4", $idList) $hList = GUICtrlGetHandle($idList) $idDummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState() Local $iItem, $iSubItem, $aRect, $sData, $aPos = ControlGetPos($hMain, "", $idList) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idDummy $iItem = _WinAPI_LoWord(GUICtrlRead($idDummy)) $iSubItem = _WinAPI_HiWord(GUICtrlRead($idDummy)) If $iSubItem = 0 Then ContinueLoop $aRect = _GUICtrlListView_GetSubItemRect($idList, $iItem, $iSubItem) $sData = GUICreateInput($hMain, _GUICtrlListView_GetItemText($idList, $iItem, $iSubItem), $aRect[0] + $aPos[0], $aRect[1] + $aPos[1], $aRect[2] - $aRect[0], $aRect[3] - $aRect[1]) If $sData Then _GUICtrlListView_SetItemText($idList, $iItem, $sData, $iSubItem) EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) If $tInfo.hWndFrom = $hList And $tInfo.Code = $NM_DBLCLK Then GUICtrlSendToDummy($idDummy, _WinAPI_MakeLong($tInfo.Index, $tInfo.SubItem)) Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func GUICreateInput($hWnd, $sText, $iLeft, $iTop, $iWidth, $iHeight) Local $hGUI = GUICreate("", $iWidth, $iHeight, $iLeft, $iTop + 1, $WS_POPUP, $WS_EX_MDICHILD, $hWnd) Local $idInput = GUICtrlCreateInput($sText, 1, 1, $iWidth - 1, $iHeight - 1) Local $idOut = GUICtrlCreateDummy() GUISetState() Local $aAccel[2][2] = [["{ENTER}", $idInput], ["{ESC}", $idOut]], $sInput GUISetAccelerators($aAccel, $hGUI) While WinActive($hGUI) Switch GUIGetMsg() Case $idInput $sInput = GUICtrlRead($idInput) ExitLoop Case $idOut ExitLoop EndSwitch WEnd GUIDelete($hGUI) GUISetState(@SW_RESTORE, $hWnd) Return $sInput EndFunc ;==>GUICreateInput
    1 point
×
×
  • Create New...