Jump to content

Chrome UDF


seangriffin
 Share

Recommended Posts

Recently Google has  disabled all extensions not from the google extension store. That's why this UDF stopped work, cause autoit extension was disabled by chrome. There are several ways to hack this but the most appropriate for my goals was to downgrade chrome.

This politics was annonced by Google in the January 2014 so all versions of Chrome after January automatically disables non store extensions. I chose the latest stable version of Chrome before 2014, it is 31.0.1650.63. Then I modified my host file (C:WINDOWSsystem32driversetchosts) with usual Windows notepad and added this strings:

this strings prevent Chrome from upgrading.

Pros

I have working version of Chrome where I can install any extension I want and this extansions are enabled each time I start up Chrome.

Cons

I have not the latest version of Chrome with possible drawbacks, but I have this version installed on my virtual machine so for me it's not a minus at all.

P.S. One can have up-to-date Chrome and working extension, but each time you start up Chrome you will see annoying message about non store extension with suggestion to disable it.

 

And i have a easy  way to slove this problem:

1, open the chrome extension;

2, open development model;

3, drag  the plugin  into the extended chrome!

Ok! Fixed! Enjoy

For any version of chrome.

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Are you still supporting this.  This has been very useful but we ran into some conditions when using various constructions kits like JFace, JQuery, etc..  The html elements do not have "name" attributes but do have generated "id" attributes.  I added some additional routines to support this:

; #FUNCTION# ;===============================================================================
;
; Name...........: _ChromeLoadURL()
; Description ...: Load a URL web page based.
; Syntax.........: _ChromeLoadURL($url, $timeout = 5)
; Parameters ....: $url         - the URL to load
;     $timeout     - Optional: a number of minutes before exiting the function.
; Return values .:  On Success     - Returns "".
;                  On Failure     - Returns "", and sets @ERROR = 2.
; Author ........: seangriffin
; Modified.......:
; Remarks .......: A prerequisite is that the Chrome browser is open
;     (Window title = "[REGEXPTITLE:.*- Google Chrome]").
;
; Related .......:
; Link ..........:
; Example .......: Yes
;
; ;==========================================================================================
Func _ChromeLoadURL($url, $timeout = 30)

 Dim $response = ""

 $response = Chrome_Eval("Chrome_LoadURL=" & $url, $timeout)

 SetError(@error)

 Return $response
EndFunc


; #FUNCTION# ;===============================================================================
;
; Name...........: _ChromeInputClickByID()
; Description ...: Clicks an <input> element based on it's "ID" attribute.
; Syntax.........: _ChromeInputClickByID($objid, $timeout = 5)
; Parameters ....: $objid       - the value of the "name" attribute
;     $timeout     - Optional: a number of minutes before exiting the function.
; Return values .:  On Success     - Returns "".
;                  On Failure     - Returns "", and sets @ERROR = 2.
; Author ........: seangriffin
; Modified.......:
; Remarks .......: A prerequisite is that the Chrome browser is open
;     (Window title = "[REGEXPTITLE:.*- Google Chrome]").
;
; Related .......:
; Link ..........:
; Example .......: Yes
;
; ;==========================================================================================
Func _ChromeInputClickByID($objid, $timeout = 5)

 dim $response = ""

 $response = _ChromeEval("document.getElementByID('" & $objid & "').click();", $timeout)

 SetError(@error)

 return $response
EndFunc

; #FUNCTION# ;===============================================================================
;
; Name...........: _ChromeObjGetValueByID()
; Description ...: Gets the value of an element based on it's "id" attribute.
; Syntax.........: _ChromeObjGetValueByID($objid, $index = 0, $timeout = 5)
; Parameters ....: $objid       - the value of the "id" attribute
;     $timeout     - Optional: a number of minutes before exiting the function.
; Return values .:  On Success     - Returns $value.
;                  On Failure     - Returns "", and sets @ERROR = 2.
; Author ........: seangriffin
; Modified.......:
; Remarks .......: A prerequisite is that the Chrome browser is open
;     (Window title = "[REGEXPTITLE:.*- Google Chrome]").
;
; Related .......:
; Link ..........:
; Example .......: Yes
;
; ;==========================================================================================
Func _ChromeObjGetValueByID($objID, $timeout = 5)

 dim $response = ""

 $response = _ChromeEval("document.getElementByID('" & $objid & "').value;", $timeout)

 SetError(@error)

 return $response
EndFunc

; #FUNCTION# ;===============================================================================
;
; Name...........: _ChromeObjSetValueByID()
; Description ...: Sets the "value" attribute of a element based on it's "id" attribute.
; Syntax.........: _ChromeObjSetValueByID($objid, $value, $timeout = 5)
; Parameters ....: $objid       - the value of the "id" attribute
;     $value      - The text to set the "value" attribute to
;     $timeout     - Optional: a number of minutes before exiting the function.
; Return values .:  On Success     - Returns $value.
;                  On Failure     - Returns "", and sets @ERROR = 2.
; Author ........: seangriffin
; Modified.......:
; Remarks .......: A prerequisite is that the Chrome browser is open
;     (Window title = "[REGEXPTITLE:.*- Google Chrome]").
;
; Related .......:
; Link ..........:
; Example .......: Yes
;
; ;==========================================================================================
Func _ChromeObjSetValueByID($objid, $value, $timeout = 5)

 dim $response = ""

 $response = _ChromeEval("document.getElementByID('" & $objid & "').value = '" & $value & "';", $timeout)

 SetError(@error)

 return $response
EndFunc

 

Would you be able to add these to your base?  We also added _ChromeLoadURL to change the current URL  I added the following to contentscript.js:

 if (request.greeting.indexOf("Chrome_LoadURL=") == 0)
 {
  var arg = request.greeting.substr("Chrome_LoadURL=".length);

  window.location.assign(arg);
 }

chrome_additional.au3

contentscript.js

Link to comment
Share on other sites

  • 2 weeks later...

 

And i have a easy  way to slove this problem:

1, open the chrome extension;

2, open development model;

3, drag  the plugin  into the extended chrome!

Ok! Fixed! Enjoy

For any version of chrome.

I can not activate the extension , I can not follow the steps you indicate . How I can do step 2 ??

Link to comment
Share on other sites

  • 1 month later...

Wow,

This is exactly what I'm looking for, but like "conmed", I cannot get the extension enabled using the workaround. 

Can you elaborate wowxoxo? or maybe this no longer works in the latest versions of Chrome.

I don't suppose it's feasible to actually get the extension published on the Chrome Web Store? I guess Google might not allow it anyway since the tool could be used maliciously.  

Link to comment
Share on other sites

I am also stuck and unable to use the extension at all.

I followed install instructions including using admin install for autoit_chrome_native_messaging_host_install.exe

I checked "Developer Mode" in Chrome when installing AutoIT for Google Chrome.crx (actually I installed it in both developer and non-developer).

I am not observing that the correct registry entries have been made during the install process.  Should I manually create these keys?  The first example script will load the form but not fill it out, and eventually times out.

Every time I check the Chrome Extensions, the "Enable" box for AutoIT for Google Chrome has been unchecked, even in developer mode, and "Not from Chrome web store" sites underneath the unchecked box.

Downgrading chrome is not an option for me as my autoit application serves an environment in which other software requires specific modern versions of Chrome.

Any hope or is Chrome automation dying off from Autoit?  Would obviously be very supportive of attempts to get the tool added to the Chrome store if that is the obstacle.

Cheers

 

Autoit v3.3.12.0

Win 7 64 bit

Chrome 44.0.2403.89 m

Edited by wliebkem
Link to comment
Share on other sites

  • 1 month later...

Chrome support for AutoIT is here!  :D

This UDF includes a Chrome Extension (http://developer.chrome.com/extensions/getstarted.html) and Native Messaging Host (http://developer.chrome.com/extensions/messaging.html#native-messaging-host) that integrate with a new Chrome UDF (Chrome.au3) to provide automation support for the Chrome browser.

Several steps are required to install the Chrome Extension and Native Messaging Host prior to using the UDF.  Please read the INSTALLATION section below.

REQUIREMENTS:

  • Windows XP 32-bit, Windows 7 32-bit or Windows 7 64-bit
  • AutoIt3 3.2 or higher
  • Chrome v29 or later (earlier versions are untested)
  • AutoIT for Google Chrome (Chrome extension - see below)
  • AutoIT Chrome Native Messaging Host (see below)

INSTALLATION:

STEP 1: Install the AutoIT extension into Chrome.

Open the following link and download the file named AutoIT for Google Chrome.crx:

https://docs.google.com/file/d/0B_6JmwNIIZ06enotRTVFNVdKOXM/edit?usp=sharing

Note - you may be prompted to login with a Google account as this file is hosted on Google Drive.

In your Chrome browser click on the Chrome menu, then select Tools -> Extensions.  Drag the AutoIT for Google Chrome.crx file that you downloaded above, from Windows Explorer, into this page in Chrome.  You should now see AutoIT for Google Chrome listed in the Extensions page in Chrome.  Ensure that the Enabled checkbox next to AutoIT for Google Chrome is checkedAlso make sure the Allow access to file URLs box is checked (very important to make EXAMPLE 2 work below)!!

STEP 2: Install the AutoIT Chrome Native Messaging Host.

Open the following link and download the file named autoit_chrome_native_messaging_host_install.exe:

https://docs.google.com/file/d/0B_6JmwNIIZ06eDgxaVJPNUNxa28/edit?usp=sharing

Note - you may be prompted to login with a Google account as this file is hosted on Google Drive.

Run this file (autoit_chrome_native_messaging_host_install.exe).  An installation window will display.  Click the Install button.  The window will display "Completed" and you can click the Close button.

STEP 3: Install the Chrome UDF into AutoIT.

Scroll to the DOWNLOAD section below, and save the Chrome.au3 file into your AutoIT Include folder (C:Program FilesAutoIt3Include).

Please close your Chrome browser once you've completed these steps.

LIST OF FUNCTIONS:

 

EXAMPLE #1:

This following example starts up Chrome and navigates to the URL http://www.december.com/html/demo/form.html.  It then automatically completes the HTML form in this page (a series of text, radio, and checkbox input elements and select elements) and clicks the Send this survey button.  The script waits for the next page to load, and retrieves the various elements from the page to the AutoIT console.

chrome_example.au3

EXAMPLE #2:

The following is an example of the automation of an offline HTML page (file URL).  First, download the file named chrome_udf_example_2.html to your C: folder:

https://docs.google.com/file/d/0B_6JmwNIIZ06SWduMjZGTVViNlU/edit?usp=sharing

Then run the following AutoIT script:

chrome_example_2.au3

Note that you must have checked the Allow access to file URLs box in the Chrome extension to make this work!

DOWNLOAD:

Latest Version - v0.5 (29/09/13)

Chrome.au3

Hi Seangriffin,

I have done all these steps but when I test my script, chrome disables the Extension for AutoIt because it is not from Chrome web store. If says that uploading extension to chrome web store will resolve the issue.

Is there any other solution to it?

Thanks,

PD

Link to comment
Share on other sites

This is also not working. I have same code in UDF. but when I run chrome, it opens up the page but in editor gives below error.

C:\Program Files (x86)\AutoIt3\Include\Chrome.au3 (829) : ==> Variable used without being declared.:
$response = _ChromeEval("document.getElementByID('" & $objname & "').value = '" & $value & "';", $timeout)
$response = _ChromeEval("document.getElementByID('" & ^ ERROR

Thanks,

-PD

 

 

Not getElementsById but getElementById, and maybe without $index.

Try this:

Func _ChromeObjSetValueById($objid, $value,  $timeout = 5)
    dim $response = ""
    $response = _ChromeEval("document.getElementById('" & $objid & "').value = '" & $value & "';", $timeout)
    SetError(@error)
    return $response
EndFunc

Link to comment
Share on other sites

  • 2 months later...

Hi Seangriffin,

I have done all these steps but when I test my script, chrome disables the Extension for AutoIt because it is not from Chrome web store. If says that uploading extension to chrome web store will resolve the issue.

Is there any other solution to it?

Thanks,

PD

http://superuser.com/questions/767286/re-enable-extensions-not-coming-from-chrome-web-store-on-chrome-v35-with-enhan

  1. Download the crx file and unpack the extension using your favorite decompresser. Take note of the directory where you placed it.
  2. Open the extension page, activate "Developer Mode"
  3. Click "Load unpacked extension..."
  4. Search trough your directory tree for the directory where you unpacked your extension and click OK. If your extension is called "my extension" then select "my extension" directory.

Advantages: You don't have to install anything else. Disadvantages: Chrome nags you to disable the extension each start up.

 

I've tried this with Chrome 48, it keeps the extension enabled, but pops up a dialog if you want to disable it or cancel.

 

The other option is to whitelist the extension with the Windows policy editor: https://productforums.google.com/forum/#!msg/chrome/9NlMAr6uEVc/ambkrcKpi1cJ

This doesn't bother you with a popup every time you start Chrome.

Edited by JoeF
Link to comment
Share on other sites

  • 2 months later...

Hey, sorry, I hope this script is still being supported. I've followed the above directions, installed the autoit extension in developer mode, and allowed it access to file URL's, however running the first example script still doesn't work. Have things changed? I'm honestly not sure where to go from here.

Link to comment
Share on other sites

  • 3 months later...
On 11/2/2016 at 6:04 AM, JaysCogs said:

Hey, sorry, I hope this script is still being supported. I've followed the above directions, installed the autoit extension in developer mode, and allowed it access to file URL's, however running the first example script still doesn't work. Have things changed? I'm honestly not sure where to go from here.

 

it's very very long time ago :( i want some code the same

Link to comment
Share on other sites

I like many of you started out with ffload.au3 which would pixelsearch for a green pixel at the end of the loading bar in firefox 3. I got tired of running an outdated browser and moved over to chrome, it seems better these days anyway. Here is my setup..

 

Download Pace4Chrome extention, once in set it to color 2299DD and the loading to Centeratom, now we have a fairly reliable load indicator.

Here is your modified ffload function module below, feel free to critique my poor habits in a friendly manner.

Func _FfLoadWaitTime ($x, $y)
    Global $pop = 0
    While 1
       $pop = $pop + 1
        Sleep ( 0 )
    $loading = PixelGetColor ( $x, $y )
if $loading = 0x2299DD Then
       ;MsgBox(0, "loading detected", "blue loading started")
        ExitLoop
        ;Set the pop numbe below to what you want it to wait at untill it figures the load indicato didn't load, 900 is about 9seconds, i dunno why.
     elseif $pop = 900 Then
         ;MsgBox(0, "loading not detected", "first pop")
      ExitLoop
    EndIf
 WEnd

 While 1
       $pop = $pop + 1
        Sleep ( 0 )
    $loading = PixelGetColor ( $x, $y )
;if $loading <> 0x2299DD Then
   if Not ($loading == 0x2299DD) Then
      ;MsgBox(0, "loading detected", "blue loading ended")
      ExitLoop
  ;the pop below isn't even needed but i'm just posting this as it with debug msgbox's and all
  elseif $pop = 1400 Then
      ;MsgBox(0, "loading not detected", "second pop")

      ExitLoop
   EndIf
Wend

 EndFunc;==>_FfLoadWaitTime

Your cords to use when calling the function should be obvious but vary depending on you display res. Sometime the load indicator doesn't display, like 1 outs 25, so other is a pop to bypass if pixelseach doesn't find it's thing in x amount of time, default is 900 which is about 9 seconds on my machine, not sue why, would assume 9000 would be 9 seconds.

 

Anyway I think that's it, Hope some of you can use this.

Link to comment
Share on other sites

  • 5 weeks later...
  • 3 months later...

I know this is probably an old thread but I wanted to point out to anyone that treks here that THIS UDF STILL WORKS AS OF CHROME 53.

For anyone wants to know how to get back on track or up and running, it's fairly simple but rather complex as well...I'm writing a guide because there some people who come here looking to find a way to automate Chrome for their workplace (like me) but can't get going because there aren't much answers as to if this might work or not. This UDF can work WITHOUT admin rights, it theoretically can if you tune the registry to CURRENT_USER.

There's THREE IMPORTANT components that come into play in order to make it work really well:

1. The Native Messaging Host (The Author called it  autoit_chrome_native_messaging_host). I simply call it the NMH.

2. The AutoIT Chome Extension

3. The Registry

FOR PEOPLE THAT NEED TO GET THIS UP ASAP:

1. INSTALL  autoit_chrome_native_messaging_host_install.exe

2. Install the chrome extension, the MESSAGING HOST should activate (please refer to the bottom as this extension is not fully working), you can tell in the little tray icon. THIS MEANS you are good to go and the host is awaiting instructions from the AUTOIT Script.

If it doesn't activate, something is wrong! It could be the registry, it could be way you set up your system, who knows. YOU will need to read further in order to figure where something went wrong.

3. To test, do: 

_ChromeEval("alert('hello world');")

 

FOR PEOPLE NOT GETTING THE CHROME EXTENSION TO WORK PROPERLY:

Chrome has stopped supporting third party or custom extensions for awhile now. This leads to the problem of having the extension not being able to work when you check mark ALLOW ACCESS TO FILE URLS. It can work without that but seangriffin seems to imply it would work much better if it had the ability to.  JoeF proposed the correct idea of extracting the CRX file (you can use anything: winZip, WinRar, 7zip), and placing the files in a folder. From there, get Chrome to go into developer mode ,and load that folder that you extracted into. This WILL break the NMH i guarantee you that! That's okay! WE CAN FIX IT EASILY. Go to the file of where the NHM is, which is AppData/Roaming/AutoIt/Chrome Native Messaging Host/. From there, you'll see there are two files. the autoit-chrome-native-messaging-host.exe and manifest.json. Open that manifest.json with notepad or whatever edit too. Now go back into your chrome and look at the ID of the unpacked extension that you loaded, it should give you an ID. YOU NEED TO TAKE THAT ID and replace it in the manifest json. It looks somewhat like this:

chrome-extension://nmocofiopaekephdbaeokkcnplpnenkg/

replace that green looking string with your ID given from Chrome. This is for security and everyone gets a different ID. If you want consistency, you will have to read further down because there is a way to make sure the same ID can always be used (This is useful portability or deployment). Now reload and the NHM should activate by itself and you'll see it as the little tray icon.

I'm gonna have to stop right here for now due to a time strain. It's a little late over here, so once i have time, i will update this guide some more for sure.

Spoiler

 

FOR PEOPLE THAT WANT TO KNOW IT WORKS (THIS WILL HELP RESOLVE ANY RUNNING ISSUES):

The Messaging Host installer installs the files into your AppData/Roaming/AutoIt/Chrome Native Messaging Host/ directory. The NMH nstaller also leaves a registry key in which the Autoit Chrome Extension can read its location and active the NHM from that particular directory.

So this is how it communicates:

First you load Chrome. Chrome will run that extension...

 

 

 

Edited by 7121
Link to comment
Share on other sites

  • 1 month later...
On 9/29/2013 at 10:23 AM, seangriffin said:

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.

Python has now been replaced with AutoIT as the Native Messaging Host.

If this is the case can you please post the source Au3 for the native message host?

Thanks in advance!

 

Link to comment
Share on other sites

  • 2 weeks later...

Is Udf Still Wroking

I tried extracting file and loading as packet

but still m not getting it working

please help me on this

chrome startup is working correctly but no other functions are working

some one please correct me if m doing something wrong or missing something important

Edited by n3wbie
Link to comment
Share on other sites

  • 1 month later...

Quick HOW TO install AutoIT for Google Chrome.crx Chrome extension.

1, Download from here: https://docs.google.com/file/d/0B_6JmwNIIZ06enotRTVFNVdKOXM/edit?usp=sharing
2, Rename the file extension  from crx to zip (result will be: AutoIT for Google Chrome.zip)
3, Unzip the file in a folder
4, Open Chrome and navigate to the Extensions (chrome://extensions/)
5, Tick the "Developer mode"
6, Click to the "Load unpacked extension..." button and navigate to your previously unzipped folder

That's it!

Tested, working in Chrome Version 55.0.2883.87 m (64-bit)

Link to comment
Share on other sites

  • 4 weeks later...
On 1/23/2017 at 1:58 AM, zuliasro said:

Quick HOW TO install AutoIT for Google Chrome.crx Chrome extension.

1, Download from here: https://docs.google.com/file/d/0B_6JmwNIIZ06enotRTVFNVdKOXM/edit?usp=sharing
2, Rename the file extension  from crx to zip (result will be: AutoIT for Google Chrome.zip)
3, Unzip the file in a folder
4, Open Chrome and navigate to the Extensions (chrome://extensions/)
5, Tick the "Developer mode"
6, Click to the "Load unpacked extension..." button and navigate to your previously unzipped folder

That's it!

Tested, working in Chrome Version 55.0.2883.87 m (64-bit)

Step 3 not working.

I rename crx into zip, but 7zip, winzip, report corrupted file

Do you have another location to download it? The file on google sizes only 23k

Link to comment
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
 Share

×
×
  • Create New...