Jump to content

RichardL

Active Members
  • Posts

    243
  • Joined

  • Last visited

About RichardL

  • Birthday 02/12/1953

Profile Information

  • Location
    England

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

RichardL's Achievements

Polymath

Polymath (5/7)

5

Reputation

  1. Hadn't realised there was a newer AutoIt - I'll try that.
  2. 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.
  3. @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.
  4. @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.
  5. 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)
  6. 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
  7. 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
  8. 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.
  9. 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?
  10. The suggestions I was hoping for would be more like "that's there already, you just have to..."
  11. 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.
  12. 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.
  13. Yes, that works. Thanks.
  14. 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.)
  15. Oh, alright that's good, thank you.
×
×
  • Create New...