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

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

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?

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 ? 

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 ! :'( 

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 

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

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

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

    • smud
      By smud
      Currently, I'm working on a program that will display Dialog boxes with either Yes or No.
      For each dialog, I reward the user with X amount of Credits.
      I'm hoping to output the amount of credits to a cell in a column (there will be 20 different columns).
      It will only post to a row that is equal to today's date (first column). If no row exists yet with the current date, it will start a new row.
      Any suggestions?
      Thank you
    • reida
      By reida
      Hello. On page there is mail address. How to keep in a text file this address? 
      It is page and email
      https://alpari.com/
      info@alpari.com
    • nacerbaaziz
      By nacerbaaziz
      hi dears
      am using an ini files as a History
      Sometimes the file size is be larger to 5 MB
      AutoIt does not recognize the full content of the file
      When I did a search to find out why, I discovered that INI files could not be read if they size larger than 64 KB.
      for that I preferred to ask here if is there any way to bypass this obstacle.
      The contents of the file are  as follows
      [filesList]
      c:\...\...\f1.mp3=00:15:20
      c:\...\...\f2.mp3=00:10:20
      c:\...\...\f3.wav=00:59:20
      ....... Etc
      This is the section for reading the file (adapted from my main script)

      case $continue     Local $aArray = IniReadSection($WaitingListFile, StringEncrypt(true, "filesList", $MyPassword))     If Not @error Then Opt("GUICloseOnESC", 1) _GUICtrlListView_DeleteAllItems($scList)         For $i = 1 To $aArray[0][0] $path = path_list(StringEncrypt(false, $aArray[$i][0], $MyPassWord), 1) if FileExists(StringEncrypt(false, $aArray[$i][0], $MyPassWord)) then GUICtrlCreateListViewItem(_GetFileName(FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord))) & Opt("GUIDataSeparatorChar") & " : " & Opt("GUIDataSeparatorChar") & FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord)), $scList) else $path = $path endIf         Next GUISetState(@sw_disable, $hGUI) GUISetState(@sw_show, $hGUI2) GUICtrlSetState($SClist, $GUI_FOCUS) else if $accessibilitymode = 1 then speak(str("listEmpty")) endIf endIf
      Is there any way to solve this problem, please?
      am waiting your answers...
      Greetings to All
    • therks
      By therks
      I'm trying to create a simple clock widget that automatically scales the text to the size of the window. I came up with the following method, but it doesn't work as well as I'd like. It especially has trouble scaling to the width of the window for some reason (in the example, try resizing the window to be narrow and tall).
      Does anyone have a better method?
      #include <Misc.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) Global $_FONT_FAMILY = 'Arial', $_LB_TEXT Main() Func Main() _GDIPlus_Startup() Local $hGUI GUIRegisterMsg($WM_SIZE, WM_SIZE) $hGUI = GUICreate('', 300, 100, Default, Default, $WS_OVERLAPPEDWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $_LB_TEXT = GUICtrlCreateLabel('This is a string', 0, 0, 300, 100, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont($_LB_TEXT, _MeasureString($hGUI, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) GUISetState() Local $iGM While 1 $iGM = GUIGetMsg() Switch $iGM Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GDIPlus_Shutdown() EndFunc Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) GUICtrlSetFont($_LB_TEXT, _MeasureString($hWnd, GUICtrlRead($_LB_TEXT), $_FONT_FAMILY), 0, 0, $_FONT_FAMILY, 5) EndFunc Func _MeasureString($hWnd, $sString, $sFont = 'Arial') Local $iError, $aSize, $hGraphic, $hFormat, $hFamily, $tLayout, $iFontSize, $hFont, $aInfo If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf $aSize = WinGetClientSize($hWnd) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate($sFont) $tLayout = _GDIPlus_RectFCreate(0, 0, $aSize[0], $aSize[1]) $iFontSize = 0 Do If Not $hFamily Then $iError = 1 $iFontSize = 10 ExitLoop EndIf $iFontSize += 1 $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_FontDispose($hFont) If $aInfo[1] = 0 Then ExitLoop Until DllStructGetData($aInfo[0], 3) >= $aSize[0] Or DllStructGetData($aInfo[0], 4) >= $aSize[1] $iFontSize -= 1 _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) Return SetError($iError, 0, $iFontSize) EndFunc
    • dadalt95
      By dadalt95
      Hi!
      I want to get the signal in this website:
      https://binary-signal.com/pt/chart/eurusd
      I have tried using _IEBodyReadText  and some _StringBetween. What happens is that the text are being update every tick and _IEBodyReadText doesn't.
      To perform the update I used  _IEAction($oIE, "refresh") but it's not good because the website block me after some time due too many requests..
      Is there any other way to get this text every tick?
      PS: The text I want to get is WAIT, CALL or PUT.
       
      Here is the code:
      global $oIE = _IECreate ('https://binary-signal.com/pt/chart/eurusd', 0, 1 , 1 , 0) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') ;MsgBox ( 0, "asf", $result[0]) $espera=StringInStr($result[0], "WAIT") $compra=StringInStr($result[0], "CALL") $venda=StringInStr($result[0], "PUT") ;MsgBox($MB_SYSTEMMODAL, "", $espera) $n=0 $c=0 Captar() Func Captar() ;_IENavigate($oIE, "https://binary-signal.com/pt/chart/eurusd") ;MsgBox($MB_SYSTEMMODAL, "", $n) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') If (Not $compra=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "COMPRE") $n=1 $c=$c+1 ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "VENDA") $c=$c+1 $n=1 ;_IEAction($oIE, "refresh") ;MsgBox($MB_SYSTEMMODAL, "", $n) Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() Else ;MsgBox("", "", "ESPERE") $n=0 Sleep(1000) ;_IEAction($oIE, "refresh") Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') Captar() EndIf EndFunc  
×