-
Posts
243 -
Joined
-
Last visited
Everything posted by RichardL
-
Limit on COM interaction with MS Word
RichardL replied to RichardL's topic in AutoIt General Help and Support
Hadn't realised there was a newer AutoIt - I'll try that. -
Limit on COM interaction with MS Word
RichardL replied to RichardL's topic in AutoIt General Help and Support
I repeated the program in vbs, and running it on the same computer it's able to run for 5000 loops where the AutoIt breaks after 249. Set oWord = CreateObject("Word.Application") oWord.Visible = True oWord.Documents.Open "C:\AutoIt_Word_Test\Test.doc" WScript.Echo oWord.Documents(1).Name & " " & oWord.Documents(1).Paragraphs.count Set oWDoc = oWord.Documents(1) WScript.Echo oWDoc.Words.Count iLoopCount = 0 For iLoopCount = 1 To 5000 For iParaIx = 1 To 10 iColrIx = oWDoc.Paragraphs(iParaIx).Range.Font.ColorIndex If iColrIx <> 1 Then WScript.Echo "Loop " & iLoopCount & ", P " & iParaIx & " " & oWDoc.Paragraphs(iParaIx).Range.Text sParaText = oWDoc.Paragraphs(iParaIx).Range.Text For iWrdIx = 1 To oWDoc.Paragraphs(iParaIx).Range.Words.Count iColrIx = oWDoc.Paragraphs(iParaIx).Range.Words(iWrdIx).Font.ColorIndex sWrdText = oWDoc.Paragraphs(iParaIx).range.Words(iWrdIx).Text Next End If Next Next WScript.Echo "End " & oWDoc.Paragraphs(iParaIx).Range.Text Run: cscript Word_Read_Test.vbs I tried the same programs on another PC. W10 Enterprise 22H2. AutoIt 3.3.14.5, Microsoft Office Word 2003 (11.5604,5606). The AutoIt program runs fine, >6000 loops without problem. The vbs is also fine, and clearly about twice as fast as the AutoIt. I'm not sure what to think. I have possible workarounds using AutoIt in 2 passes, or vbs, or the the other PC. I haven't thought about the patch situation yet. The first PC has SP3, the other doesn't. -
Limit on COM interaction with MS Word
RichardL replied to RichardL's topic in AutoIt General Help and Support
@NineThank you for trying it. The doc I was working on is hundreds of lines long. The problem happens after about 300 lines. I added the the while loop just to demo the issue by repeatedly using the first 10 lines of a smaller doc. For me this goes wrong after about 250 lines, as in the output in the first post. Please try with the loop back in, or use cut and paste in the doc to make 500 lines. -
Limit on COM interaction with MS Word
RichardL replied to RichardL's topic in AutoIt General Help and Support
@argumentum thanks but I tried Office 2007, and even after 4 months my fingers didn't know where anything is. So I went back to 2003. -
Hi @mr-es335, Here's part of something I've been using for years (see comment re XP). It opens and positions notepad. I think the main difference is I'm using WinWaitActive, and you have WinWait. ShellExecute("Notepad", $sInf1) $sTitle = $sInf1 & " - Notepad" ; XP $sTitle = $sInf & " - Notepad" ; W7 If WinWaitActive($sTitle, "", 5) Then ; Continue Else $sMsg = StringFormat("Can't find %s.\nCurrent %s.", $sTitle, WinGetTitle("[Active]")) $Ans = MsgBox($MB_OKCANCEL, Default, $sMsg) If $Ans = $IDCANCEL Then Exit EndIf WinMove($sTitle, "", 250, 0, 595, 900)
-
I’m using AutoIt to extract data from an office doc. In outline the format of the doc was a coloured section title (not a heading in the Word sense), then a few lines in black. I keep getting a com error. Tried various things to eliminate: - Add com error handle – no better, after one failure, all other interaction failed. - Remove failing data – it just failed on the next data - Disconnect the Word object and reconnect every 100 interactions – no better. - Close all Word windows and start again – no better. - Run from start of doc to half way, then separately for the second half – Clear! It really looks like an interaction count limit between AutoIt and Word. I’ve reduced the program and the doc to a minimum. It usually fails on reading the ColorIndex of a word, but on this occasion reading a word-count. L 250, P 7 6 HIJ KLM L 251, P 1 12 ABC DEF L 251, P 7 6 HIJ KLM "C:\AutoIt_Word_Test\Word_Read_Test.au3" (39) : ==> The requested action with this object has failed.: For $iWrdIx = 1 To $oWDoc.Paragraphs($iParaIx).Range.Words.Count For $iWrdIx = 1 To $oWDoc^ ERROR I’m surprised I’ve never run into this before as have used AutoIt to drive Word and Excel many times in the last 15 years. Winows 7 Enterprise SP1, MS Office Word 2003, AutoIt 3.3.14.5 Opt('MustDeclareVars', 1) Func ConFmtWr($sCntrl, $a = "", $b = "", $c = "", $d = "", $e = "", $f = "", $g = "", $h = "", $i = "", $j = "", $k = "", $l = "") ConsoleWrite(StringFormat($sCntrl, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l)) EndFunc Func OpenOrGetWord($sDocPath, ByRef $oWord, ByRef $oWDoc) $oWDoc = ObjGet($sDocPath) ; (Good if doc is already open or not. Surprise) $oWord = $oWDoc.Parent $oWord.Visible = 1 ConFmtWr("WC %4d\n", $oWDoc.Words.Count) ConFmtWr("PC %4d\n", $oWDoc.Paragraphs.Count) EndFunc Local $oWDoc Local $oWord Local $sDocName = @ScriptDir & "\Test.doc" Local $iWrdIx Local $iParaIx Local $iColrIx Local $sWrdText Local $iLoops OpenOrGetWord($sDocName, $oWord, $oWDoc) $iLoops = 0 While 1 For $iParaIx = 1 To 10 $iColrIx = $oWDoc.Paragraphs($iParaIx).Range.Font.ColorIndex If $iColrIx <> 1 Then ConFmtWr("L %4d, P %4d %2d %s\n", $iLoops, $iParaIx, $iColrIx, $oWDoc.Paragraphs($iParaIx).Range.Text) For $iWrdIx = 1 To $oWDoc.Paragraphs($iParaIx).Range.Words.Count $iColrIx = $oWDoc.Paragraphs($iParaIx).Range.Words($iWrdIx).Font.ColorIndex $sWrdText = StringStripWS($oWDoc.Paragraphs($iParaIx).range.Words($iWrdIx).Text, 3) Next EndIf Next $iLoops += 1 WEnd Test.doc
-
Read Status of Num/Caps/Scroll Lock -
RichardL replied to RichardL's topic in AutoIt General Help and Support
Thanks, but I've received separate advice that the keycodes in the original code are wrong (now). Copied the codes from here and it works perfectly. Const $VK_NUMLOCK = 0x90 Const $VK_SCROLL = 0x91 Const $VK_CAPITAL = 0x14 -
Hi, I want to read status of Num/Caps/Scroll Lock and I'm running @XinLu's code here. post 2. For me it's just giving zero for all 3 whatever the state of the keys. That was 2008 and I have Windows 10 Enterprise 22H2. Does anyone have recent code that works. Thanks.
-
Occasionally I'm typing into SciTE and the text is entering in two places. One is the correct place and the other is somewhere else on the screen. I think it happens after a copy and paste, and possibly I've accidentally touched the laptop mousepad. I've also seen it paste into two places. I've tried to reproduce it but can't. Anyone else seen this?
-
SciTE for AutoIt Minor Improvements
RichardL replied to RichardL's topic in AutoIt Technical Discussion
The suggestions I was hoping for would be more like "that's there already, you just have to..." -
Wouldn't it be nice if (well, IMO anyway)... All In SciTE (editing .au3) - Pressing F5 stopped the current run before running. (I use Alt T S, wait). - When editing file.au3 that's included in another, there was a #don't_run_this_file_run: that_one.au3 - The active tab had more visual difference from the others. Notepad++ has an orange stripe. Any suggestions welcome.
-
Well, thank you everyone. That's all fascinating and more than I was expecting. Sadly I won't remember it all but will bookmark it for next time I'm using a regex.
-
Yes, that works. Thanks.
-
Some help with a regex please. I want to select blocks of text and the pattern I have is doing that almost correctly. The problem is the first item also includes everything before that in the source. #include <Debug.au3> $sStr = "aBa¬aCa¬aCa¬aCa¬aCa¬aCa" $sPatn = "(?U)a.*C.*¬" $sAry = StringRegExp($sStr, $sPatn, 3) _DebugArrayDisplay($sAry) Output: aBa¬aCa¬ aCa¬ aCa¬ aCa¬ I thought (?U) made it not greedy, so it shouldn't do that? (The ¬ are replacing @CRLF from reading a file, could use the original if easier.)
-
Oh, alright that's good, thank you.
-
Hi, On this page there is a note about last version to support Windows 2000. Please could we have a similar note about Windows XP?
-
ListView Flicker, and failing to DeleteAll.
RichardL replied to RichardL's topic in AutoIt GUI Help and Support
@kurtykurtyboy Thanks, wow! I've put your ExtendedViewStyle solution into the test program and the real one and it's perfect. Now we can look at the info without being annoyed by the flicker. I have tried the 2nd one, but can't resist the single line fix. I'll keep it in mind for next time. -
ListView Flicker, and failing to DeleteAll.
RichardL replied to RichardL's topic in AutoIt GUI Help and Support
@Melba23, I have another listview with a flicker and I think you might be saying it can't be fixed. "There will always be some flicker as using colour..." With fewer than about 20 rows the flicker is very fast, almost unnoticible. With 40 rows or more it's annoying. The action is: - if the LV is full, delete the top row. - insert a new row at the end - Update the text of one sub-item in the new row (possibly a few times) - change the colour on that sub-item. The delete and insert each make a flicker but combined into one with BlockRedraw. The new row and the change sub-item each make a flicker. The colour change works very nicely, changes the colour without any flicker. Is any improvement possible? #include <GUIConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" Opt("MustDeclareVars", 1) Local $iGW = 700 Local $iGH = 600 Local $hGUI Local $cLV Local $iLVIndex Local $vRet Local $sData Local $sColSet Local $iMsg Local $iColWid $hGUI = GUICreate("Coloured ListView Example", $iGW, $iGH) ; Create ListView $cLV = GUICtrlCreateListView("Column 0|Colourable|Column 2|Column 3|C4|C5", 10, 10, $iGW - 20, $iGH - 20, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS)) For $i = 0 To 5 $iColWid = 100 If $i = 3 Then $iColWid = 160 _GUICtrlListView_SetColumnWidth($cLV, $i, $iColWid) Next ; Initiate ListView = user colours $iLVIndex = _GUIListViewEx_Init($cLV, "", 0, 0, True, 32) ; Set default colours to use ;Global $aDefCols[4] = ["0x000000", "0xFEFEFE", "0xFFFFFF", "0x0000FF"] ;_GUIListViewEx_SetDefColours($iLVIndex, $aDefCols) ; If colours used then this function must be run BEFORE GUISetState _GUIListViewEx_MsgRegister() GUISetState() ; Create array and fill listview Global $aLVArray[6][4] _GUIListViewEx_BlockReDraw($iLVIndex, True) For $i = 0 To 5 $sData = "Item " & $i & "-0" $aLVArray[$i][0] = $sData For $j = 1 To 3 $sData &= "|SubItem " & $i & "-" & $j $aLVArray[$i][$j] = "SubItem " & $i & "-" & $j Next _GUIListViewEx_InsertSpec($iLVIndex, 0, $sData) _GUIListViewEx_InsertSpec($iLVIndex, 0, $sData) ; Some simple conditions for colour $sColSet = ";0x00FF00" If Mod($i, 2) = 0 Then $sColSet = ";0xFFFF00" ElseIf Mod($i, 3) = 0 Then $sColSet = ";0xFF0000" EndIf ; Set item colour _GUIListViewEx_SetColour($iLVIndex, $sColSet, 0, 1) Next _GUIListViewEx_BlockReDraw($iLVIndex, False) ConsoleWrite(StringFormat("Count %3d\n", _GUICtrlListView_GetItemCount($cLV))) Sleep(1000) ; Try deleting an item. ;_GUICtrlListView_DeleteItem($cLV, 3) !NO _GUIListViewEx_DeleteSpec($iLVIndex, 3) ConsoleWrite(StringFormat("Count %3d\n", _GUICtrlListView_GetItemCount($cLV))) Sleep(1000) Local $iNofRows Local $iDly ; Insert more lines For $iIx = 1 To 5000 $iDly = 200 _GUIListViewEx_BlockReDraw($iLVIndex, True) If $iIx > 20 Then $iDly = 400 $iNofRows = _GUICtrlListView_GetItemCount($cLV) If $iNofRows > $iGH / 18 + 5 Then _GUIListViewEx_DeleteSpec($iLVIndex, 0) EndIf Sleep($iDly) $sData = StringFormat("Count %3d|Rows %3d|---------|------------|-----------|---------", $iIx, $iNofRows) ;_GUIListViewEx_BlockReDraw($iLVIndex, True) _GUIListViewEx_InsertSpec($iLVIndex, -1, $sData) _GUIListViewEx_BlockReDraw($iLVIndex, False) Local $iLVItmNo $iLVItmNo = _GUICtrlListView_GetItemCount($cLV) - 1 ConsoleWrite(StringFormat("Count %3d\n", $iLVItmNo)) Sleep($iDly) _GUIListViewEx_ChangeItem($iLVIndex, $iLVItmNo, 3, _Now()) Sleep($iDly) _GUIListViewEx_SetColour($iLVIndex, ";0x00FF00", $iLVItmNo, 3) Next Local $iLoops = 0 While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit EndSwitch ;$vRet = _GUIListViewEx_EventMonitor() If 0 Then ; Try delet all and add again. If $iLoops = 50 Then _GUICtrlListView_DeleteAllItems($cLV) _GUIListViewEx_Close($iLVIndex) $iLVIndex = _GUIListViewEx_Init($cLV, "", 0, 0, True, 32) EndIf If $iLoops = 100 Then _GUIListViewEx_InsertSpec($iLVIndex, 0, "More|Data") _GUIListViewEx_InsertSpec($iLVIndex, 0, "More|Data") EndIf EndIf Sleep(100) $iLoops += 1 WEnd -
ListView Flicker, and failing to DeleteAll.
RichardL replied to RichardL's topic in AutoIt GUI Help and Support
Fixed, stupid error, it's all fine. -
ListView Flicker, and failing to DeleteAll.
RichardL replied to RichardL's topic in AutoIt GUI Help and Support
Hi @Melba23 Thanks. The example program is working fine now. I've copied the changes into the real program. The update is looking smooth, but the DeleteAllItems is causing a crash when new items are added. I'm puzzling what I've done different from the example. Should the _GUIListViewEx_EventMonitor() be done just once? at the start? -
Hi, I wanted a multi-column listview, with coloured cells, and I found @Melba23’s example here. That works, but the listview has a flicker. It redraws all the rows whenever you add one. It’s not so obvious with the few lines in the original example, but becomes worse with more items and wider. It’s the same whether you add the new items at the top, as in the example, or on the end. I tried _GUICtrlListView_BeginUpdate and _GUICtrlListView_EndUpdate but that didn’t seem to make any difference. I tried GUICtrlSetState($iGUI1_LV, $GUI_HIDE) before adding multiple items, and $GUI_SHOW after. With this you only see one redraw for multiple items, but still a full redraw for adding a single item. I tried @jpm’s Lock/ResetLock but that seems the same as hide/show. Not directly connected, I tried _GUICtrlListView_DeleteAllItems, that seemed to work, but when I added another item, all the deleted ones reappeared. The code below adds some items, wait 2 seconds, and adds another, see full redraw. After a few more seconds it deletes all the items, you can see them gone. Then it adds a item, which appears at the top, but all the deleted ones reappear below. AutoIt 3.3.14.5 Any help appreciated. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" $hGUI = GUICreate("Coloured ListView Example", 500, 300) ; Create ListView $cLV = GUICtrlCreateListView("Column 0|Colourable|Column 2|Column 3", 10, 10, 480, 260, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS)) For $i = 0 To 3 _GUICtrlListView_SetColumnWidth($cLV, $i, 100) Next ; Initiate ListView = user colours $iLVIndex = _GUIListViewEx_Init($cLV, "", 0, 0, True, 32) ; Set default colours to use Global $aDefCols[4] = ["0x000000", "0xFEFEFE", "0xFFFFFF", "0x0000FF"] _GUIListViewEx_SetDefColours($iLVIndex, $aDefCols) ; If colours used then this function must be run BEFORE GUISetState _GUIListViewEx_MsgRegister() GUISetState() ; Create array and fill listview Global $aLVArray[6][4] ;_GUICtrlListView_BeginUpdate($cLV) For $i = 0 To 5 $sData = "Item " & $i & "-0" $aLVArray[$i][0] = $sData For $j = 1 To 3 $sData &= "|SubItem " & $i & "-" & $j $aLVArray[$i][$j] = "SubItem " & $i & "-" & $j Next _GUIListViewEx_InsertSpec($iLVIndex, 0, $sData) _GUIListViewEx_InsertSpec($iLVIndex, 0, $sData) ; Some simple conditions for colour $sColSet = ";0x00FF00" If Mod($i, 2) = 0 Then $sColSet = ";0xFFFF00" ElseIf Mod($i, 3) = 0 Then $sColSet = ";0xFF0000" EndIf ; Set item colour ;_GUIListViewEx_SetColour($iLVIndex, $sColSet, 0, 1) Next Sleep(2000) _GUIListViewEx_InsertSpec($iLVIndex, 0, $sData) ;_GUICtrlListView_EndUpdate($cLV) Local $iLoops = 0 While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $vRet = _GUIListViewEx_EventMonitor() If $iLoops = 50 Then _GUICtrlListView_DeleteAllItems($cLV) EndIf If $iLoops = 100 Then _GUIListViewEx_InsertSpec($iLVIndex, 0, "More|Data") EndIf Sleep(100) $iLoops += 1 WEnd
-
MouseMove didn't Move - (Moved)
RichardL replied to RichardL's topic in AutoIt General Help and Support
@careca - other way round. For the other topic MousePos says it's moving. For me no MousePos change. And what I should have said as well, no Send, no MouseClick. -
MouseMove didn't Move - (Moved)
RichardL replied to RichardL's topic in AutoIt General Help and Support
Sorry, gave up watching this, but now it's happened again, with the same application. @jvanegmond - thanks, run as administrator fixed it. If I compiled to .exe and run that as administrator that worked. For running from SciTE I looked at what it was running in the console window, Aut2exe_x64.exe, set that to 'run as administrator' - completely stopped it running from SciTE, It would run from a shortcut with the file.au3 as a parameter. So exit SciTE, set SciTE.exe as 'run as admin'. Restart SciTE and it works Thanks again. -
_ArrayDisplay - Select All & Copy
RichardL replied to RichardL's topic in AutoIt General Help and Support
Thank you. I had glanced in there but at the moment I have lots of other uninteresting things to do, followed by other interesting things... -
_ArrayDisplay is very useful, but wouldn't it be extra nice if it accepted ^a for select all and ^c for copy?