Jump to content

frank10

Active Members
  • Posts

    499
  • Joined

  • Last visited

Recent Profile Visitors

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

frank10's Achievements

Universalist

Universalist (7/7)

10

Reputation

  1. Thank you Nine! .ShapeRange did it!
  2. Thank you Nine. That's an improvement! I got every QR and I can see which title there is on the paragraph near to the shape with: local $par = $oShape.Anchor.Paragraphs(1).Range.Text This way I could make an array with all the titles with QR. Then I should make another loop, searching all titles and searching in the previous array to see if there is a QR. But I would like to get the inverse., much linear..: Having a range with the title, I would like to get the shape near it, if any... How to get a shape in a range instead of all shapes in doc?
  3. Thank you for the workaround. But it's not that easy to detect which picture belongs to which title... they are named generically "ImageXX.png" without reference to the title. I don't need to extract the QR png, I need to find out which title hasn't a picture (to add a QR with a script) Of course I have a lot of them, the file attached is a tiny example...
  4. I have a .docx that has some wrapped images in it. If I use "^g" into search, it does not find them (I think because they are not inline pictures). If I use the Go-To with Graphic, it correctly detects them. How can I find them with Word UDF? I attach a docx example: I want to detect that recipe 2 has not a picture near the title. I used this to detect the titles with style Header 3 : #include <Array.au3> #include <String.au3> #include <Word.au3> global $oDoc = _Word_DocOpen($oWord, "filename.docx") global $oRangeFound = _Word_DocFind($oDoc," ", Default, Default) While 1 $oRangeFound = _Word_DocFindEX($oDoc, Default, Default, $oRangeFound, Default, Default, Default, Default, Default, Default, "Heading 3") ;.... wend testQR.docx
  5. Yes, but in my case I must stay locally.
  6. I explain what I do: I need to pass some data I collected in a txt file from several xlsx into a JS page on chrome to further evaluation and creation of tables, graphs etc. There are ads data over the years, by kw, campaigns etc And also selling data by markets, types and so on... Browser side, with JS I will convert the string var to array to manipulate it better. But since Autoit is very slow creating huge arrays and passing them to JS, I ended up it's a lot faster reading a txt file and directly passing it as a string to chrome that later will transform it to array. It worked well up to now with this size problem. Now I ended up as Nine suggestion, reading the file into a string and splitting the string in a for cycle with StringMid() in 30000000 chuncks of bytes and passing them to chrome concatenating the string on JS. It works well and fast as a single passing!
  7. For the global var problem, the problem seems to be the word "var" or even "let" before the var you want to become global: How to test: insert these lines separately, look at the console and you see the correct output from console.log(), BUT this is only a local var output, not a proof of the creation of an accessible global var. Manually write the name of the var in the console and see if it appears the correct value -> global var created; if it gives error var not defined -> not created. ;This does not work in creating a global var: _WD_ExecuteScript($sSession, 'var sTemp = ""; sTemp = "222"; console.log(sTemp)' ) ;This works because the first line with "var" is ignored, the line working is only the 2°: _WD_ExecuteScript($sSession, 'var sTemp = "";' ) _WD_ExecuteScript($sSession, 'sTemp = "222"; console.log(sTemp)' ) ;In fact this single line alone works : _WD_ExecuteScript($sSession, 'sTemp = "222"; console.log(sTemp)' ) ;and also this one works: _WD_ExecuteScript($sSession, 'sTemp = ""; sTemp += "222"; console.log(sTemp)' ) ;but this does not work because of "var": _WD_ExecuteScript($sSession, 'var sTemp = ""; sTemp += "222"; console.log(sTemp)' ) ;the same err using "let" instead of "var"...: _WD_ExecuteScript($sSession, 'let sTemp = ""; sTemp += "222"; console.log(sTemp)' ) So, it seems the actual workaround is avoiding declaring a var with "var" or "let" or even "const". But the code should be corrected to accept these keywords...
  8. Interesting, I thought it was something with winhhtp or _WD_Post, instead...
  9. Yes, that's a good workaround. Waiting for the correct fix...
  10. BTW1: I don't know why it spaces the post like this, I wrote it into Code... I tried to edit it but I can't justify correctly...?? BTW2: once it crashed my browser, but after reloading the page it seems it didn't save the text I wrote... sometimes it restores it sometimes not (it keeped the pic uploaded but not the text...)
  11. I'm not sure what you mean. But, yes, of course in JS code is perfectly fine declaring and assigning a var all in one line. The problem is making this with _WD_ExecuteScript This works inside the browser, you can test in the console: var sTest = ""; sTest = "testString"; console.log(sTest); And the global var sTest is correctky created. But if you do this in Autoit: _WD_ExecuteScript( $sSession, 'var sTest = ""; sTest = "testString"; console.log(sTest); ') it correctly outputs the value (as if the var has a local scope), BUT if you call the sTest var it says it's not defined! I uploaded a pic with the first lines executed by Autoit and not finding the global var and the last ones by console, correctly creating global var. Instead if you split the code into 2 calls, it works also creating a global var: _WD_ExecuteScript( $sSession, 'var sTest = "";') _WD_ExecuteScript( $sSession, 'sTest = "testString"; console.log(sTest);')
  12. Ok, but this part is working to test the error, but it's not working browser side (with "ok.txt"): $sStr = 'var sTemp = "";' & @CRLF & 'sTemp = `' & $sStr & '`;' _WD_ExecuteScript($sSession, $sStr) If you want to declare a var in the browser and then assign a value to it from WD, you must first declare it with one _WD_ExecuteScript and then assign it with another one, like I did. Otherwise, if you open the chrome console and write this: console.log(sTemp) it says the var isn't declared and so it has no value... So, it should remain: _WD_ExecuteScript($sSession, 'var sTemp = "";' ) _WD_ExecuteScript($sSession, 'sTemp = `' & $sStr & '`;' ) And after, if you write console.log(sTemp) you get the correct string value.
  13. I updated, but the result is the same. The unknown error with unexpected token ")" appears only when you use the big size: if you test with the "ok.txt" size, it does not give the error. So the problem isn't in the script or in the generated string, but maybe in some truncating process of _WD_post or similar... it seems due to size exceeding some limit...
  14. I must send a huge string file with WD to JS var on chrome. Up to now it worked well, but now the file reached more than 31MB size (and it's growing...): 31,4 MB (33.000.029 bytes) and it gives error. I made this reproducible script to simulate my file: #include "au3WebDriver-1.11/wd_helper.au3" #include "au3WebDriver-1.11/wd_core.au3" #include "au3WebDriver-1.11/wd_capabilities.au3" #AutoIt3Wrapper_UseX64=Y $_WD_DEBUG = $_WD_DEBUG_Info _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', _WD_GetFreePort() ) Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT _WD_Option('DriverParams', $sDriverParams) _WD_Startup() global $sSession = _WD_CreateSession() global $sStr = '' global $fileName = "ko.txt" ;********** use this line if you want to see the ERROR ;~ $fileName = "ok.txt" ;********** use this line if you want to test a slighlty less string size that WORKS ;********** generate string size: ;~ 32.000.000 bytes OK 31.251 KB filesize ;~ 33.000.000 bytes KO 32.227 KB filesize for $i=0 to 365000 ; string rows $sStr &= stringformat("%014d",$i) & "|" & _MakeString(6,12) & "|USD|" & _MakeString(6,23) & "|" & _MakeString(8,25) & "|" & "|BROAD|2|0|0||0|||0|0|0|0|0|" & @crlf if Mod($i, 5000) = 0 then ConsoleWrite(".") if Mod($i, 50000) = 0 then ConsoleWrite(@crlf & $i) if ($fileName = "ok.txt" And StringLen($sStr) >= 32000000) Or ($fileName = "ko.txt" And StringLen($sStr) >= 33000000) then ExitLoop Next ConsoleWrite( @crlf & $i & "_len:_" & StringLen($sStr) & @CRLF) ; **** if you want to save the file: ;~ local $hFile = FileOpen($fileName, 2 ) ;~ FileWrite($hFile, $sStr) ;~ FileClose($hFile) ConsoleWrite( StringLeft($sStr,500) & @CRLF) ; test example string _WD_ExecuteScript($sSession, 'var sTemp = "";' ) _WD_ExecuteScript($sSession, 'sTemp = `' & $sStr & '`;' ) ConsoleWrite(@error & "___" & @extended & @CRLF) MsgBox(0,'','sent?') Func _MakeString($min, $max) Local $aSplit = StringSplit(' abcdefghijklmnopqrstuvwxyz0123456789', '') Local $sHoldString = '' For $iCC = 1 To Random($min, $max, 1) $sHoldString &= $aSplit[Random(1, 36, 1)] Next Return $sHoldString EndFunc and this is Scite log on the "ko.txt" string size: Why this size limit? How can I solve? TIA
  15. Ok, I see. Do you mean making something like this, disabling those default behaviour on the 2nd call? ; 1st normal chrome: local $aSessions = ["normal","noCors"] Global $sChromeH10 = _WD_SetupChrome(false, "", false, $aSessions[0] ) _WD_Startup() ; 1st $sSessionH10 = _WD_CreateSession($sChromeH10) ;2nd noCORS chrome: $sDesiredCapabilitiesNoSecur = _WD_SetupChrome(false, "", false, $aSessions[1] ) _WD_Option('DriverClose', False) _WD_Option('DriverDetect', False) _WD_Startup() ; 2nd global $sSession = _WD_CreateSession($sDesiredCapabilitiesNoSecur) ; noCORS But it doesn't work. It looses the 1st sessionID and gives error: Invalid session ID [16]
×
×
  • Create New...