Jump to content
caramen

How to read the text of an active chrome windows?

Recommended Posts

caramen
Posted (edited)

Hey. :) 

 

I requested help about how to get a value from a text in a variable. 

Now i know how to do that. But i learned with the command FileRead. Now i whould like to know how to replace the command :

FileRead('Dossier.txt')

The purpose is to read a webpage text. To find some value inside. 

 

Btw i tryed to play with WindowsInfo.au3 but i dont got much thing.  

Edited by caramen

IUIAutomation From Junkew WebDriver From Danp2

 

Share this post


Link to post
Share on other sites
FrancescoDiMuro

Hi @caramen :)

What about _IEDocReadHTML() or _IEBodyReadHTML() ?

 


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
caramen
Posted (edited)

@FrancescoDiMuroUnfortunatly, it s on chrome :P . I watched chrome UDF and there is nothing about text reading... :( 

Edited by caramen

IUIAutomation From Junkew WebDriver From Danp2

 

Share this post


Link to post
Share on other sites
caramen

Or the question in more easy way :D 

 

How to read the text of an active chrome windows?


IUIAutomation From Junkew WebDriver From Danp2

 

Share this post


Link to post
Share on other sites
AutoBert

Can't believe that none of these functions: 

_ChromeObjGetHTMLById($objid, $timeout = 5)

_ChromeObjGetHTMLByName($objname, $index = 0, $timeout = 5)

_ChromeObjGetHTMLByTagName($tagname, $index = 0, $timeout = 5)

can do a part of the job for you. But you have to investigate time to learn about HTML, regex and/or string functions.  

If chrome.au3 isn't possible, try download site with HTTP or  with InetGet.

  • Like 1

Share this post


Link to post
Share on other sites
caramen

@AutoBert Plz dont laugth :P I am trying these things : 

#include <Array.au3>
#include <String.au3>
#include <IE.au3>
#include "C:\Users\Jordane.guemara\Desktop\AutoIT\Chrome.au3"

Global $objid = "[class:Chrome_renderWidgetHostHWND; INSTANCE:1]"
Global $test = _ChromeObjGetHTMLById($objid, 1 )

Msgbox(0,"", $test )

Return value = "" 

 

:( Is my syntaxt correct ? 


IUIAutomation From Junkew WebDriver From Danp2

 

Share this post


Link to post
Share on other sites
caramen
#include <Array.au3>
#include <String.au3>
#include <IE.au3>
#include "C:\Users\Jordane.guemara\Desktop\AutoIT\Chrome.au3"
#include <MsgBoxConstants.au3>

Opt("WinTitleMatchMode", 2)

Global $sText = WinGetText("Anah")

MsgBox($MB_SYSTEMMODAL, "", $sText)

Well this is working... But the return value is:

Chrome Legacy Windows

Help plz ! :'( 


IUIAutomation From Junkew WebDriver From Danp2

 

Share this post


Link to post
Share on other sites
AutoBert
20 hours ago, caramen said:

@AutoBert Plz dont laugth :P I am trying these things : 

I don't, as mentionened in a other thread: chrome isn't my browser and so i don't know the correct syntax.

Share this post


Link to post
Share on other sites
caramen

I am sorry guys... i will probably looks stupid... 

 

When i follow Chrome UDF steps i cant get the google extention working. So i think this breack the followings steps. 

When i follow FAQ 31 i am going on chrome UDF topic. Stuck again... 

 

When i try simple spy i dont know where to start. I got too much value. Too much controls and without help i dont know what to do with all that... Even if i am familiar with autoit. I am 100% stuck.

 

Does one of you got any exemple script of Google automation where i can read and learn everything... becose this is an important script I got 14 days left before not being able to complet the task. 

 

I dont ask from anyone of you to make the code for me. Just an orientation. A kick in my face or somthing :D 


IUIAutomation From Junkew WebDriver From Danp2

 

Share this post


Link to post
Share on other sites
FrancescoDiMuro

@caramen

If you are trying to automate Chrome, you should see the source code in the webpage, not use Spy++...


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
caramen
Posted (edited)

@FrancescoDiMuro Can you explain this reply ? Ok i watch the source code but what do i use with it ? Chrome UDF ? 

BTW i am looking for some exemple code but, I just found nothing... I only found peoples stuck like me. with all the same reply... Chrome udf that is not working... becose of the extention.

Edited by caramen

IUIAutomation From Junkew WebDriver From Danp2

 

Share this post


Link to post
Share on other sites
caramen
Posted (edited)

For exemple i located the source code that is interesting me : 

 

<table cellpadding="0" cellspacing="0" border="0" width="100%" class="dialog_line  dialog_memo_size"><tbody><tr><td><div aria-labelledby="label_SD_REQUEST_COMMENT" tabindex="0" id="SD_REQUEST_COMMENT1" name="SD_REQUEST_COMMENT1" class="dialog_memo"><p><b>[ANAH][42][Instructeur][21349_1521108952] Modification ROD   </b></p><br><br><br><br><p></p><p>Bonjour,</p><p>Pascale BERNARD vous envoie ce message :</p><p>Bonjour, Je réitère mon message du 16/07/2018 par mail : nous avons reçu la demande de subvention dématérialisée de Mme MIREILLE habitant Ville. lorsque l'on clique sur "créer le dossier dans OPAL", un message d'erreur apparaît indiquant que le code postal ne correspond pas à la commune alors que celui-ci est bien correct. merci de bien vouloir remédier à ce problème qui empeche l'enregistrement du dossier. bien cordialement</p><p>Coordonnées :<br>- email : @loire.gouv.fr<br>- tél. : </p> <br><img src="h4u8.mjt.lu/oo/AM4AABKSTu0AAAAAAAAAAGnAstAAASKBFzEAAAAAAAf4sQBbbCPoG4Yw2uOXQmWMxPwz8-jRuwAHlfY/4cfbd339/e.gif" height="1" width="1" alt="" border="0" style="height:1px;width:1px;border:0;"> <p></p></div></td></tr></tbody></table>

Inside this code this line interesting me : 

[ANAH][42][Instructeur][21349_1521108952] Modification ROD

How to get this line into a variable ?

Edited by caramen

IUIAutomation From Junkew WebDriver From Danp2

 

Share this post


Link to post
Share on other sites
junkew

See the thread on iuiautomation and there are examples for chrome firefox ie opera all in a similar way.

Getting to html in a generic way can be done by typing in addressbar of your browser

Javascript:alert(document.body.innerhtml);return void(0);

Please check above on casesensitivity.

I am not sure if chrome udf is still maintained for latest versions of chrone.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Epic007
      By Epic007
      Hey guys I'm stuck with a program.....I need a make an automation which copies text from a chat bot app and paste it in notepad to log the replies of my chat bot and to analyse stuff....a lil help pls
       
       
       
       
       
       
       
      Thanks in advance
    • nooneclose
      By nooneclose
      I need to send a string of text to this popup and click on the ok button to save it.
      Here is the code I have so far:
      ;Start IE Sleep(7000) $oIE = _IECreate("http://www.google.com") Sleep(500) _IELoadWait($oIE) $hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window Sleep(500) WinSetState($hIE, "", @SW_MAXIMIZE) ;Wait for a browser page load to complete Sleep(3000) _IENavigate($oIE, "https://properURL.com") Sleep(8000) _IELoadWait($oIE) ;Attach to a browser control embedded in another window $oIE = _IEAttach("https://"properURL.com", url") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & ' Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console Sleep(2000) ;Get the title of the webpage ;Local $wTitle = _IEPropertyGet($oIE, "title") ;MsgBox($MB_SYSTEMMODAL, "Webpage title:", $wTitle) ;Clicks the new button Sleep(3000) _IEAction($nWorkOrderB, "focus") _IEAction($nWorkOrderB, "click") Sleep(5000) ;Store the Element names where the important data will be sent ;Store the long description button Local $wLongDButton = _IEGetObjById($oIE, "m65d795a4-img") ;Store the long Description field id Local $wComments = _IEGetObjById($oIE, "ma6499a9c-rte_iframe") ;Store the ok button id that is in the long description Local $wCommOk = _IEGetObjById($oIE, "m74031266-pb") ;******************************************************************************* ; Send the stored data to the proper field ;******************************************************************************* ;Click the long description button Sleep(300) _IEAction($wLongDButton, "focus") _IEAction($wLongDButton, "click") Sleep(300) ;Sends the Comments Sleep(500) _IEAction($wComments, "focus") _IEAction($wComments, "click") Sleep(500) _IEFormElementSetValue($wComments, "hello darkness my old friend") ;Click the ok button Sleep(500) _IEAction($wCommOk, "focus") _IEAction($wCommOk, "click") Sleep(500)  
      Here is the popup:

    • reida
      By reida
      Hello. Help to write the text.
      <textarea tabindex="4" class="js-input compose__labels__input" style="width: 407px; max-width: 413px;" wrap="off" autocomplete="off" data-original-name="To"></textarea>  I can not make.
      #include <IE.au3> $sLogin = 'adv' $iError = 1 $sUrl = 'https://......' $oIE = _IECreate($sUrl) ;;; _IELoadWait($oIE) $oLogin = _IEGetObjByName($oIE, "To") Sleep(7000) If IsObj($oLogin) Then _IEFormElementSetValue($oLogin, $sLogin) _IELoadWait($oIE) ; EndIf EndIf Through the selector it can be possible?
      #toolkit-154163367424641composeForm > div:nth-child(1) > div > div.compose-head__content.js-collapsed-off > div.compose-head__row-wrapper.compose-head__row-wrapper_to.js-row > div > div > div:nth-child(2) > div > div > div > textarea.js-input.compose__labels__input  
    • Blueman
      By Blueman
      Hey Guys,
      Hope that you can help me with something, maybe this is a bug in the new version of AUTOIT but first i will check it with you to know for sure.
      I have made a simple GUI with a Embedded IE Object, then i would like to read the HTML with _IEBodyReadHTML(), easy right?
      When i use the old IE.au3 include from a year back or so, it is working fine!
      When i use the new IE.au3 include came with the new installation that is currently available on autoitscript.com it isnt working (i get a result that says; 0).
      Let me show you.
       
      Working Example
      #include <GUIConstantsEx.au3> #include <IE_EmbeddedVersioning.au3> #include <IE_PreVersion.au3> ;Older Version Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 1000, 1000) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Global $oIE_1 = _IECreateEmbedded() ; CREATE IE OBJECT(S) GUICtrlCreateObj($oIE_1, 355, 5, 600, 360) _IENavigate($oIE_1, "https://www.google.nl", 1) Local $CheckHTML_T = _IEBodyReadHTML($oIE_1) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(48,"",$CheckHTML_T) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
      Failing Example
      #include <GUIConstantsEx.au3> #include <IE_EmbeddedVersioning.au3> #include <IE.au3> ;New Version Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 1000, 1000) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Global $oIE_1 = _IECreateEmbedded() ; CREATE IE OBJECT(S) GUICtrlCreateObj($oIE_1, 355, 5, 600, 360) _IENavigate($oIE_1, "https://www.google.nl", 1) Local $CheckHTML_T = _IEBodyReadHTML($oIE_1) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(48,"",$CheckHTML_T) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
      I have attachted all files and i am testing on Windows 10 with the latest SciTe Program (Not compiled). 
      When i compile the script it is showing the same result.
      Thanks guys!
      IE_PreVersion.au3
      IE.au3
      IE_EmbeddedVersioning.au3
    • cramaboule
      By cramaboule
      Hi all,
       
      I was wondering if it is possible (and how) to put text on video on-the-fly (like VLC displays Title movie at the begining)
      and of course doing that in AutoIt
      Thanks in advance...
       
      C.
×