Jump to content
seangriffin

Chrome UDF

Recommended Posts

JohnOne

Something is not right here.
Since I re-installed, device manager network tab says I'm uploading at my full capacity.
I don't know what I'm uploading or what is uploading it, I have nothing running which should do that.

EDIT:

For the record.

This issue was with my AV not recognizing new files and uploading them for inspection.

Nothing to do with this UDF or its components.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
lbordier

Hi Folks, 

I have kind of an issue here:

I've strictly followed the instruction for the installation. But I face kind of a weird situation when I run the script #1.

OS: W7 64-bit.

AutoIt: V3.3.8.1

When I launch the script ( chrome_example.au3 ) ==> Nothing happens or appears...

But When I use the AutoIt debugger tool, it works like a charm. 

Any thought would tremendously appreciated. 

Cheer

L

Share this post


Link to post
Share on other sites
seangriffin

Something is not right here.

Since I re-installed, device manager network tab says I'm uploading at my full capacity.

I don't know what I'm uploading or what is uploading it, I have nothing running which should do that.

 

Hmmm, odd that something is uploading.  There certainly isn't anything in this solution that uploads or downloads.

Here's a description of exactly what the 3 components to the UDF do (in case anyone was wondering):

  1. The Chrome UDF - is an AutoIT UDF that sends requests to the Native Messaging Host (below), via a text file, and waits for a response from the Native Messaging Host (below), via a text file.
  2. The Native Messaging Host - is a Python application that listens for requests from the AutoIT UDF (above), via a text file, and forwards those requests onto the Chrome Extension (below).  It also listens for output from the Chrome Extension (below) and forwards that back to the AutoIT UDF (above), via a text file.
  3. The Chrome Extension - is a collection of Javascript files that wait for a request from the Native Message Host (above), and then injects that request (Javascript) into the page within Chrome to interact with the elements in that page.  The response from this request is then sent back to the Native Message Host (above).

All these components communicate to each other through a combination of text files and stdio.  There are no HTTP requests involved, and as such I wouldn't expect any uploads or downloads to occur through the UDF.

Try Example #2 because it works "offline".  It should work without an internet connection, and that will eliminate any uploading or downloading going on.

Edited by seangriffin

Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia

Share this post


Link to post
Share on other sites
JohnOne

I noticed now that native messaging host is no longer starting with chrome when the example is started.

I've tried a number of things, with chrome already running and without.

If I manually start messaging host, it ends when example is ran.

Is the value in registry supposed to be an escaped path...

"C:UsersJOHNAppDataRoamingAutoIt3Chrome Native Messaging Hostmanifest.json"?

I don't see any other paths in registry where the backslashes are escaped.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
seangriffin

I noticed now that native messaging host is no longer starting with chrome when the example is started.

I've tried a number of things, with chrome already running and without.

If I manually start messaging host, it ends when example is ran.

Is the value in registry supposed to be an escaped path...

"C:UsersJOHNAppDataRoamingAutoIt3Chrome Native Messaging Hostmanifest.json"?

I don't see any other paths in registry where the backslashes are escaped.

 

Yes, it might seem odd that the registry value is escaped, though it must be this way or the native messaging host won't start.  That's my experience.

Here's more information to help in troubleshooting.  Thanks for spending the time on this.  Might help others too.

To confirm the native messaging host is starting with Chrome as expected, I would first try starting Chrome on it's own, without loading any pages or using the UDF.  Then go to Windows Task Manager and you should see the a process named autoit-chrome-native-messaging-host.exe.   This will confirm that the registry value above is set correctly, as this points Chrome to the location of the Native Messaging Host such that it can start it when Chrome starts..  

If autoit-chrome-native-messaging-host.exe isn't running when you start Chrome then get the value of the registry key above, and in Windows Explorer go to this location (i.e. C:UsersJOHNAppDataRoamingAutoIt3Chrome Native Messaging Host).  Check the file  autoit-chrome-native-messaging-host.exe and manifest.json exist.  Open manifest.json in Notepad.  Make sure "path" is set to the full path of autoit-chrome-native-messaging-host.exe, and the path includes double-backslashes.  Also make sure the value for "allowed_origins"opmlbgppkkdeleedejakphgmgiigjjga/) matches the value in the ID field of the Chrome Extension.  Check this by opening Chrome and go to the Tools -> Extensions menu item.  In the Extensions page make sure Developer mode is ticked, and then locate the ID field for the AutoIT for Chrome extension.  This value should match the value for "allowed_origins" in the manifest.json file.

If the settings above are correct, then every time you start Chrome, irrespective of whether you are using AutoIT or not, you should also have the autoit-chrome-native-messaging-host.exe process running.

The next step is to confirm if the AutoIT UDF is talking properly to the Native Messaging Host (autoit-chrome-native-messaging-host.exe).  Run an AutoIT script that uses the UDF (Chrome.au3), like one of the Examples from the top post.  When a function in the UDF is called, it should create a file named input.txt in the same location as autoit-chrome-native-messaging-host.exe (i.e. C:UsersJOHNAppDataRoamingAutoIt3Chrome Native Messaging Hostinput.txt).  This file should contain some Javascript relating to the UDF function called (i.e. document.getElementsByName('ExampleForm')[0].method;).  If Chrome and the Native Messaging Host (autoit-chrome-native-messaging-host.exe) are running, then the Native Messaging Host should immediately detect this file (i.e. C:UsersJOHNAppDataRoamingAutoIt3Chrome Native Messaging Hostinput.txt) whenever it's created, read it's contents and remove the file.  The Native Messaging Host is so fast at doing this that you may not even see the existence of input.txt.  Try running a UDF function without Chrome running and make sure input.txt is created. 

If input.txt is successfully created, then autoit-chrome-native-messaging-host.exe should automatically consume it (as described above), pass the Javascript onto the Chrome Extension, which uses it in Chrome and sends a response back to autoit-chrome-native-messaging-host.exe which should in turn create an output.txt file in the same location as input.txt.  The Chrome UDF then detects this file, reads in the response, and the UDF function completes.


Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia

Share this post


Link to post
Share on other sites
lbordier

Hi Folks, 

I have kind of an issue here:

I've strictly followed the instruction for the installation. But I face kind of a weird situation when I run the script #1.

OS: W7 64-bit.

AutoIt: V3.3.8.1

When I launch the script ( chrome_example.au3 ) ==> Nothing happens or appears...

But When I use the AutoIt debugger tool, it works like a charm. 

Any thought would tremendously appreciated. 

Cheer

L

 

Mhmhmmh here is the deal:

The library use "@ProgramFilesDir" which return the directory for 64 bits. But Chrome is still 32 bits. 

So I used this code:

$ProgramFilesDir = EnvGet('ProgramFiles(x86)') ; for 64bit Win it will return a valid path.
if not $ProgramFilesDir then $ProgramFilesDir = @ProgramFilesDir ; for 32bit Win this will "repair" the broken return from above.
 
or
 
Func _ProgramFilesDir()
    Local $ProgramFileDir
    Switch @OSArch
        Case "X32"
            $ProgramFileDir = "Program Files"
        Case "X64"
            $ProgramFileDir = "Program Files (x86)"
    EndSwitch
    Return @HomeDrive & "" & $ProgramFileDir
EndFunc   ;==>_ProgramFilesDirh

 

Cheers

L

Share this post


Link to post
Share on other sites
chachew

When i look at the documentation inside the UDF the timeout periods state that the timeouts are for 'X' number of minutes, when you look at the code as well as the console output, the timeout is in 'seconds'

No big deal, just noticed it was documented wrong.

Share this post


Link to post
Share on other sites
seangriffin

V0.5 of the UDF is now released.

Python has now been replaced with AutoIT as the Native Messaging Host.  This brings significant performance improvements over the previous Python solution, and also allows easier maintenance in the future with a complete AutoIT solution.

If you already have a previous version of the UDF installated, then you must repeat Steps 1, 2 and 3 from the INSTALLATION section of the top post.

  • Like 1

Cheers, Sean.

See my other UDFs:

Chrome UDF - Automate Chrome | SAP UDF - Automate SAP | Java UDF - Automate Java Applications & Applets | Tesseract (OCR) UDF - Capture text from applications, controls and the desktop | Textract (OCR) UDF - Capture text from applications and controls | FileSystemMonitor UDF - File, Folder, Drive and Shell Monitoring | VLC (Media Player) UDF - Creating and controlling a VLC control in AutoIT | Google Maps UDF - Creating and controlling Google Maps (inc. GE) in AutoIT | SAPIListBox (Speech Recognition) UDF - Speech Recognition via the Microsoft Speech (SAPI) ListBox | eBay UDF - Automate eBay using the eBay API | ChildProc (Parallel Processing) UDF - Parallel processing functions for AutoIT | HyperCam (Screen Recording) UDF - Automate the HyperCam screen recorder | Twitter UDF - Automate Twitter using OAuth and the Twitter API | cURL UDF - a UDF for transferring data with URL syntax

See my other Tools:

Rapid Menu Writer - Add menus to DVDs in seconds | TV Player - Automates the process of playing videos on an external TV / Monitor | Rapid Video Converter - A tool for resizing and reformatting videos | [topic130531]Rapid DVD Creator - Convert videos to DVD fast and for free | ZapPF - A tool for killing processes and recycling files | Sean's eBay Bargain Hunter - Find last minute bargains in eBay using AutoIT | Sean's GUI Inspector - A scripting tool for querying GUIs | TransLink Journey Planner with maps - Incorporating Google Maps into an Australian Journey Planner | Automate Qt and QWidgets | Brisbane City Council Event Viewer - See what's going on in Brisbane, Australia

Share this post


Link to post
Share on other sites
levshkatov

Hi, everybody! 

Great topic, but I didn't find a function that allows me to click on a button with necessary text on it. 

Could you help me with this problem?

Edited by levshkatov

Share this post


Link to post
Share on other sites
NizonRox

Is there a way to find a surtend Word and then execute a command? that would be great :)

Share this post


Link to post
Share on other sites
jdelaney

I don't suppose there would be a way to use objects, since this is all read in from a text file...such as, having multiple windows/documents open, and differentiating between them.  Or looking for an element under an object?

Small fix, the _ChromeDocWaitForExistenceByTitle is not properly comparing the return string, so it always timesout.

Expected return string is like:

{"text":"HTML Form Example"}

if StringCompare($title_from_chrome, '{"text":"' & $title & '"}') = 0 Then

this fixes it ( inside _ChromeDocWaitForExistenceByTitle)

Func _ChromeDocWaitForExistenceByTitle($title, $timeout = 5)

    dim $error = 2, $response = "", $begin, $title_from_chrome

    $begin = TimerInit()

    While TimerDiff($begin) < ($timeout * 1000)

        $title_from_chrome = _ChromeDocGetTitle()
        if StringCompare($title_from_chrome, '{"text":"' & $title & '"}') = 0 Then
            $error = 0
            ExitLoop
        EndIf

        sleep(100)
    WEnd

    SetError($error)

    Return $response
EndFunc
Edited by jdelaney
  • Like 1

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
itotua

Would this work on a locked Windows like the ControlSend ControlClick commands?

Share this post


Link to post
Share on other sites
Azzurr0

Wow compliments! thank you for the work you are sharing with us!

I'm working on the function _IELinkClickByText 
someone has already done? I'm having trouble!

Share this post


Link to post
Share on other sites
nullschritt

Seems really nice, though I would recommend not using file to communicate between scripts, this would speed up the process considerably, as it takes much longer to read/write data to the hard disk than it does to transfer it in RAM. 

Share this post


Link to post
Share on other sites
ddevil

_IELinkClickByText chrome alternative ?

Share this post


Link to post
Share on other sites
Jordanoise

_IELinkClickByText chrome alternative ?

Too long for a response to this question. Interested in a simple click on the link in chrome. Who knows the answer?

Edited by Jordanoise

Share this post


Link to post
Share on other sites
McCookieM

I think I may have stumbled on the cause of the problem that some people are coming across where this UDF does not appear to work.

I too had issues with Chrome opening fine, shutting down fine, but no communication could be made with the messaging host.  Everything always timed out.

My software info:

Win 7 x64

Chome 33

AutoIt 3.3.6

Firstly I discovered that no registry entry had been made for me during installation. I did have a SoftwareGoogleChrome entry under HKEY_CURRENT_USER but no NativeMessagingHosts key.

As per a previous post, I decided to put the keys where specified so had to create a SoftwareGoogleChromeNativeMessagingHosts key tree under HKEY_LOCAL_MACHINE. Still having problems I put the same registry entries under HKEY_CURRENT_USER but still no go (after discovering the actual problem later I think either location should be fine)

After finding the great post detailing a full breakdown of the UDF and how it all works, I went though step by step and discovered that the first time Chrome is run, the autoit-chrome-native-messaging-host process was running.

Now, here comes the root problem (I think). If you run the command _ChromeShutdown() from AutoIt at the beginning of your script (which closes Chrome windows and kills the autoit-chrome-native-messaging-host process), then your next _ChromeStartup command will NOT re-open the messaging process. I think it's down to having multiple chrome processes still running (non-windowed like other plugins) so Chrome doesn't do a fresh startup and doesn't restart it's messaging hosts.

So, short answer just now is to close your chrome windows (and chrome processes) manually and only use _ChromeShutdown() at END of script.

Now the UDF works fine. Although you've still got to end all chrome processes manually before you run your script again.

Over to the developer. Not sure it's the best way, but you could end all chrome.exe processes in the _Shutdown function rather than closing any open Chrome windows. I'm sure you'll find a better way.

Hope this helps some of you.

  • Like 1

Share this post


Link to post
Share on other sites
ZiFFeL

Hello, first of all thankyou!!

I have try to use this on local files, but even in your second example is not working for me, online or works fine, but on local doesn´t change any value (inputs (textfield/checkboxes/radio...))

Any idea?

Regards.

Share this post


Link to post
Share on other sites
bootybay

I'm not directly using the chrome UDF but i took a lot of tricks from it that don't work anymore!

For example the basic "[REGEXPTITLE:.*- Google Chrome]" was glorious to get a quick window handle.

But for some reason there is no "- Google Chrome" at the end of tabs anymore (or only rarely instead of on everything)

Do you know how to reenable it?

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

    • stafe
      By stafe
      Hello
      I am trying to get chrome to save it's current webpage to a pdf using autoit.  I wold like to save the file into a folder on the desktop called "ChromeFiles" .  However when I use the send command chrome only occasionally responds.
      Thank you
      Simon
       
    • Tersion
      By Tersion
      Here the this wiki page with list of available UDFs for data compression. For my tasks I only need ZIP support, so I started looking at pure AutoIt UDFs without any 3rd party dlls. And found out that most of available realizations uses standard ("native method") Windows dll - "zipfldr.dll". So for now I chose ZIP UDF by wraithdu. I've tested it on Windows 7 (x64) and it seem works fine. But here the comment from another topic where user says that Windows 10 discontinued support of "zipfldr.dll". Now I confused. I don't have around any Windows 10 machine to tested it. So maybe someone could confirm or deny that? Or maybe would better to switch to UDF with 7zip dll?
      I need an advice...
    • TheSaint
      By TheSaint
      Here is the bare bones of a UDF I have started work on.
      Mostly just a proof of concept at this stage, and still need to add some functions and dress the UDF up a bit ... to look like a UDF ... though it has my own distinct styling, especially as I have never really developed a UDF before now .... used plenty and modified plenty though. I've even invented my own UDF variable naming convention, which I am sure some of you will be aghast at. I work with what feels best for me, but others are free to adapt if they wish.
      The idea is to emulate the simplicity of INI files, but gain the benefits of SQL.
      Two scripts are provided.
      (1) The UDF, a work in progress - SimpleSQL_UDF.au3
      (2) An example or testing script - UDF_Test.au3
      Another first for me, is creating a 2D array from scratch, never done that before, that I can recall ... never had a need, and even for 1 dimension arrays, for a long time now, I have just used _StringSplit to create them. So I needed a bit of a refresher course, which my good buddy @TheDcoder assisted me with ... not without some angst I might add. LOL
      SimpleSQL_UDF.zip  (12 downloads previously)
      (I have now completed all the functions I intended to. My next update will be a big improvement, bringing things more inline with my latest INItoSQL DB program changes.)
      Program requires the sqlite3.dll, not included, but easily enough obtained.
      Hopefully the usage is self-evident ... just change the Job number variable in the UDF_Test.au3 file to check the existing functions out.
      Enjoy!
      P.S. This is also related to a new program I have just finished and uploaded - INItoSQL DB
    • nooneclose
      By nooneclose
      I want to check some Excel data against data on a website in Chrome. I use Chrome because the site I use does not function properly in Internet Explorer or Firefox. I know how to do the Excel stuff I just can not figure out how to send to Chrome, let alone check to see if the data matches or not. I am also having trouble finding any help online while searching for Chrome functions for Autoit. I have a Chrome UDF installed but I still can not figure out how to get my code to properly function. (I am not posting code because I am  sure my code isn't right, to begin with)
      As usual, any and all help would be greatly appreciated. 
    • xtcislove
      By xtcislove
      Hello,
      as a start in Autoit i tried something i was missing since im using Autoit. 

      I build a custom MessageBox which has a large amount of custom options and which scales its size on the parameters you set. 

      Aviable Settings:
      -Title
      -Unlimited Buttons
      -Text Color (Buttons, Text)

      -Background Color (Msgbox, Buttons, Label) 

      -Button Timeout
      -Autoclose Timeout
      -Icon (Default, No Icon, Custom)

      -Label/ Button Style. 
      -Transparency

      I tried to keep this as close as i could to a Msgbox i was used too on my batch times.

      After i was ready i realised, @Melba23 probably build a way better msgbox which would have suit my needs enterly, anyway thanks to @Melba23 because i use his Stringsize UDF. 

       
       
      local $Message = _sMsgBox("Test", 6, "Continue?") if @extended <> -1 Then MsgBox(0, @extended, $Message&" Button pressed")  
      ScalingMessageBox.au3
×