
frank10
Active Members-
Posts
499 -
Joined
-
Last visited
Everything posted by frank10
-
Find wrapped images in Word document
frank10 replied to frank10's topic in AutoIt General Help and Support
Thank you Nine! .ShapeRange did it! -
Find wrapped images in Word document
frank10 replied to frank10's topic in AutoIt General Help and Support
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? -
Find wrapped images in Word document
frank10 replied to frank10's topic in AutoIt General Help and Support
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... -
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
-
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!
-
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...
-
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...)
-
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);')
-
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.
-
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...
-
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
-
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
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] -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
Maybe I could suggest something else: Before, I created 2 WD sessions with 2 chrome instances, because I need one normal chrome on default profile and another chrome with noCORS controls to make ajax call on different domains. It worked fine, having 2 sessionsID and working on both of them with autoit script. Something like this: _WD_Startup() ; 1st normal chrome: global $sChromeH10 = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", " --user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}' global $sSessionH10 = _WD_CreateSession($sChromeH10) ;2nd noCORS chrome: global $sDesiredCapabilitiesNoSecur = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--disable-web-security", "--user-data-dir=yourCustomPath", "--auto-open-devtools-for-tabs", "--profile-directory=Default"]}}}}' global $sSession = _WD_CreateSession($sDesiredCapabilitiesNoSecur) Now I can't do the same thing using the new capabilities method (I slightly modified the _WD_SetupChrome to make multiple calls with different capabilities set) : ; 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_Startup() ; 2nd global $sSession = _WD_CreateSession($sDesiredCapabilitiesNoSecur) ; noCORS It opens 2 sessions with correct sessionID, BUT the problem is the 2nd _WD_Startup() overwrites the previous sessionID, so it remains active only the last sessionID. But if I delete the 2nd _WD_Startup() it doesn't open the 2nd chrome instance! One solution could be to move the initial lines outside from _WD_SetupChrome, at the beginning of the WD section script: Local $sTimeStamp = @YEAR & '-' & @MON & '-' & @MDAY & '_' & @HOUR & @MIN & @SEC _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', _WD_GetFreePort() ) Local $sDriverParams = '--verbose --log trace --port=' & $_WD_PORT If $bLogToFile Then $sDriverParams &= ' --log-path="' & @ScriptDir & '\log\' & $sTimeStamp & '_WebDriver_chrome.log"' _WD_Option('DriverParams', $sDriverParams) This way WD is initialized once at the beginning and you can call _WD_Startup() 1 time and you will have 2 different working sessionID. -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
Hi Danp2, I'm glad to help! Installed and tested: it works very well. Uploading .js code as-is is the best solution even for me. Good work! -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
Yes, this way it's working. -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
It's definitely an error removing tabs, because for example I had this: let allTotImp = 0 let totAdsUS = 0, totRoyUS = 0 And casually there was a tab instead of space in "let totAdsUS", but visually it seemed a normal space... But it loaded as lettotAdsUS = 0, totRoyUS = 0 giving error... -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
I insert tabs (but not hardcoded \t) when I'm coding with Code, then I save the .js file and then I reload in Autoit with $scriptJS = FileRead($latestFile) and inject to the browser with WD. I always did this way and had no problem at all up to now in chrome. -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
Yes, now it's working. Thank you. But you loose the correct indentation on the script loaded in the browser... not a technical problem, but it could be more pleasant to see the code as it was. Maybe you could add an option to trim the code or leave it as is. -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
I have also another problem: before I loaded a JS script into chrome with this: $scriptJS = FileRead($latestFile) $scriptJS = StringReplace($scriptJS,'\', '\\') ConsoleWrite( "____myScript___" & @crlf & $scriptJS & @crlf) local $jqueryCommand = "jQuery('head').append(`<script id='myScriptJS'>" & $scriptJS & "</script>`)" _WD_ExecuteScript($sSession, $jqueryCommand ) with this Output: And it was fine. EDIT BTW: the two initial ` inside .append are template literals in JS, not normal quotation marks... But now when I check the script into chrome it is all in one line (so, after the first // it's all commented out) as: So, it seems it's deleting all newlines... Any changes into _WD_ExecuteScript ? EDIT (with chrome115 problems I updated from an older WD version) Or is it the new chromedriver 114 / chrome115 ? -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
Ok, it must be something on certain opened tabs of the previous session, because if I leave only one tab opened on the same profile, now it works! A bit disappointing anyway, because you can't trust an automated environment this way... to be sure you should always open a blank browser session instead of an old one... -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
There are a lot of rows... also with sensible data... Here are the last rows in which there is some errors, but I can't interpret them... it seems initially there is a sessionID, but then it disconnects: -
WebDriver UDF - Help & Support (IV)
frank10 replied to Danp2's topic in AutoIt General Help and Support
I tried with "Default", and now the is correct. But the session doesn't work anyway: same Err 10. Here it says if it's the Default profile, it's not even necessary to use "--profile-directory": But even without the "--profile-directory" the session doesn't work.