seangriffin

Chrome UDF

100 posts in this topic

Try using the class instead

[CLASS:Chrome_WidgetWin_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



Hello Friends.
please guide me for how to navigate chrome by its autoit udfs.
 

_ChromeStartup() ... this function takes url and opne chrome with this url. i want to navigate the chrome frome this url to another url. how i can do it?

Thanks in Advance

Share this post


Link to post
Share on other sites

I assume you can do something like

Not tested but should lead to something like

_ChromeEval("window.location = "http://www.mozilla.org";");

alternate udf is to search for iuiautomation in example forum

1 person likes this

Share this post


Link to post
Share on other sites

I assume you can do something like

Not tested but should lead to something like

_ChromeEval("window.location = "http://www.mozilla.org";");

alternate udf is to search for iuiautomation in example forum

 

I tried to use _ChromeEval("window.location = "http://www.mozilla.org";"); this but it dosn't work. i also find iuiautomation example but it was mouse movement. i want to automate chrome without using mouse like IE and FF.

Is there any other way to navigate chorome?

Share this post


Link to post
Share on other sites

#45 ·  Posted (edited)

where  _ChromeObjSetValueById ?

 i try add

Func _ChromeObjSetValueById($objid, $value, $index = 0, $timeout = 5)

    dim $response = ""

    $response = _ChromeEval("document.getElementsById('" & $objid & "')[" & $index & "].value = '" & $value & "';", $timeout)

    SetError(@error)

    return $response
EndFunc

Html Target

<TITLE>Chrome Example Form</TITLE>

<input type='text' id='textExample' value='http://' size='20' maxlength='30'>
#Include <Array.au3>
#Include <Chrome.au3>

_ChromeShutdown()
_ChromeStartup("http://192.168.2.100/x/cromeauto1")
_ChromeDocWaitForExistenceByTitle("Chrome Example Form", 5)

_ChromeObjSetValueById("textExample", "12121218") ;<<<<<<<---- BUT not working

>_<


tanks..

Edited by arthalita01

Share this post


Link to post
Share on other sites

#46 ·  Posted (edited)

Hello Friends.

please guide me for how to navigate chrome by its autoit udfs.

 

_ChromeStartup() ... this function takes url and opne chrome with this url. i want to navigate the chrome frome this url to another url. how i can do it?

Thanks in Advance

_ChromeEval("document.location.replace('YOUR URL');")

that worked for me

Edited by neonoff

Share this post


Link to post
Share on other sites

#47 ·  Posted (edited)

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:

127.0.0.1 clients.google.com
127.0.0.1 clients1.google.com
127.0.0.1 clients2.google.com
127.0.0.1 clients3.google.com
127.0.0.1 clients4.google.com
127.0.0.1 clients5.google.com
127.0.0.1 clients6.google.com
127.0.0.1 clients7.google.com
127.0.0.1 clients8.google.com
127.0.0.1 clients9.google.com
127.0.0.1 lh1.googleusercontent.com
127.0.0.1 lh2.googleusercontent.com
127.0.0.1 lh3.googleusercontent.com
127.0.0.1 lh4.googleusercontent.com
127.0.0.1 lh5.googleusercontent.com
127.0.0.1 lh6.googleusercontent.com
127.0.0.1 lh7.googleusercontent.com
127.0.0.1 encrypted-tbn1.gstatic.com
127.0.0.1 encrypted-tbn2.gstatic.com
127.0.0.1 encrypted-tbn3.gstatic.com
127.0.0.1 encrypted-tbn4.gstatic.com
127.0.0.1 encrypted-tbn5.gstatic.com

 

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.

Edited by neonoff

Share this post


Link to post
Share on other sites

where  _ChromeObjSetValueById ?

 i try add

Func _ChromeObjSetValueById($objid, $value, $index = 0, $timeout = 5)

    dim $response = ""

    $response = _ChromeEval("document.getElementsById('" & $objid & "')[" & $index & "].value = '" & $value & "';", $timeout)

    SetError(@error)

    return $response
EndFunc

Html Target

<TITLE>Chrome Example Form</TITLE>

<input type='text' id='textExample' value='http://' size='20' maxlength='30'>
#Include <Array.au3>
#Include <Chrome.au3>

_ChromeShutdown()
_ChromeStartup("http://192.168.2.100/x/cromeauto1")
_ChromeDocWaitForExistenceByTitle("Chrome Example Form", 5)

_ChromeObjSetValueById("textExample", "12121218") ;<<<<<<<---- BUT not working

>_<

tanks..

 

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

Share this post


Link to post
Share on other sites

 

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.

 

I cannot get this file to download.

It keeps giving me an error message -

"Sorry, this file is infected with a virus

Only the owner is allowed to download infected files."

 

Looking forward to trying this out!

Share this post


Link to post
Share on other sites

I can install AutoIt extension but cannot enable it because it is not available on Chrome Web Store. Any ideas?

Share this post


Link to post
Share on other sites

#52 ·  Posted (edited)

Hi,

Thanks for the script. I have the problem, that when i use your first example, autoit opens chrome and navigate to the page. But nothing happens, no entry is filled or clicked.

Edited by Berfs

Share this post


Link to post
Share on other sites

#53 ·  Posted (edited)

@Berfs: Probably better to open a new thread in general help and support if you have issues with the iuiautomation and chrome. Most likely you missed chrome://accessibility page

For others using chrome you can communicate thru a textbox and addressbar commands

Type this once for each page and an edit will be added

javascript: var e = document.createElement("input");e.setAttribute("value","Hello world");document.body.appendChild(e);void(0); 

then if you want to have data in it you type in addressbar

javascript: e.setAttribute("value", document.documentElement.innerHTML);

and this data you can retrieve with regular IUIAutomation scripts

I just did not have time to wrap that into UIAWrappers logic (as this concept works on all browsers that support bookmarklets)

Edited by junkew

Share this post


Link to post
Share on other sites

Is there any plans of getting the Chrome UDF submitted to the Chrome Store?  I see that you are going a different way with IUI automation?    Can we still get support for the Chrome UDF such as downloading the files required?  Would you be willing to let someone else pursue the submitting extension to the Google store?

Share this post


Link to post
Share on other sites

Any ideas for how I can automatically disable the Save Password box that pops up every time someone logs in to a password protected website?

Share this post


Link to post
Share on other sites

Hello. I too am wondering if there are any plans to submit this to the store so that it can be used with current versions of chrome.

Share this post


Link to post
Share on other sites

#58 ·  Posted (edited)

Extensions can be loaded in unpacked mode by following these steps:

  1. Visit chrome://extensions (via omnibox or menu -> Tools -> Extensions).
  2. Enable Developer mode by ticking the checkbox in the upper-right corner.
  3. Click on the "Load unpacked extension..." button.
  4. Select the directory containing your unpacked extension.

The crx file needs to be extracted first. CRX files are zip files with a different header. Any capable zip program should be able to open it. If you don't have such a program, I recommend 7-zip.

Edited by amartinez

Share this post


Link to post
Share on other sites

#59 ·  Posted (edited)

Hi I have a problem with querySelector.

When i use my code, extension is down and doesn't work 

 image: http://screencast.com/t/AT1F45pF

Translation image

"There has been a breakdown AutoIT for Google Chrome. Click on this message to re-download this extension"

$class="input.mailbox__auth__button[type='submit']"
$oInputs = 'document.querySelector("'&$class&'").click()'
_ChromeEval("document.getElementsByName('Login')[0].value='petrsbu62'")
_ChromeEval("document.getElementsByName('Password')[0].value='z123456'")
_ChromeEval($oInputs)

I check full js in input.txt all is right 

document.querySelector("input.mailbox__auth__button[type='submit']").click()

I know that i can use some of the function from chrome.au3, but i need to now is querySelector are work in Chrome.ua3 or not. 

Edited by mazinasm

Share this post


Link to post
Share on other sites

hi,polymath.

i have a question:i have opened one chrome browser,can i use the opening chrome  navigate another url by the chrome UDF? thank you very much!! 

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

    • fenhanxue
      By fenhanxue
      Q 1:
      How to judge whether the Chrome has been installed. How to get the complete route of chrome if it is installed?

      Q 2:
      How to judge whether the Adobe Flash Player has been installed.
    • FMS
      By FMS
      Hello,
      I'm trying to wright a automated process to show some URL's in chrome browsers on multiple screens.
      I've 4 screens and want to show on each screen another instance of chrome whit its own URL.
      In mine search on the site i din't find any topic for this specific problem.
      The way I was trying is something like :
      ShellExecute("chrome.exe", "http://URL1 --start-maximized") so I'll not see the addressbar but it was not opend full screen .
      I've some questions about this way:
      -Is there a way to maximize it on a dedicated screen ?
      (like URL1 on screen 1 , URL2 on screen 2 etc...)
      -Shellexecute will add a tab on a existing browser and will not open another instance, is there a way to work around this?
      Is there somebody who had the same problem whit chrome?
      thanks in advanced.
      edit: I've checked the chrome UDF but it din't same to get the job done....
    • imitto
      By imitto
      Hello all!
      I use Autoit for a while, already made some automation for a TV station's master control room with it. I made a UDF to easily work with PAL timecode and time with milliseconds, convert, add or subtract them. Feel free to use it if you want something like this
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Description=PAL Timecode Calculator UDF #AutoIt3Wrapper_Res_LegalCopyright=horvath.imre@gmail.com #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ; #FUNCTION# ; Name...........: _tcAdd ; Description....: Returns addition of two timecodes ; Syntax.........: _tcAdd($fTc1, fTc2 [, $fFormat = "P"]) ; ; Parameters.....: $fTc1 - First timecode in hh:mm:ss.ff format ; $fTc2 - Second timecode in hh:mm:ss.ff format ; $fFormat - Time base - "P" (default): PAL (25 fps) ; "M" : millisecond ; ; Return value...: Sum of the two timecode in the selected format Func _tcAdd($fTc1, $fTc2, $fFormat = "P", $fHourFormat = 1) Local $fMs1 = _tcToMs($fTc1) Local $fMs2 = _tcToMs($fTc2) Local $fSumMs = $fMs1 + $fMs2 Return _msToTc($fSumMs, $fFormat, $fHourFormat) EndFunc ; #FUNCTION# ; Name...........: _tcsSub ; Description....: Returns addition of two timecodes ; Syntax.........: _tcSub($fTc1, fTc2 [, $fFormat = "P"]) ; ; Parameters.....: $fTc1 - First timecode in hh:mm:ss.ff format ; $fTc2 - Second timecode in hh:mm:ss.ff format ; $fFormat - Time base - "P" (default): PAL (25 fps) ; "M" : millisecond ; ; Return value...: Subtract $fTc2 from $fTc1 in the source format Func _tcSub($fTc1, $fTc2, $fFormat = "P") Local $fMs1 = _tcToMs($fTc1) Local $fMs2 = _tcToMs($fTc2) Local $fSumMs = $fMs1 - $fMs2 If $fSumMs < 0 Then $fSumMs = _tcToMs("24:00:00.00") - ($fSumMs * -1) EndIf Return _msToTc($fSumMs, $fFormat) EndFunc ; #FUNCTION# ; Name...........: _tcToMs ; Description....: Returns timecode converted to total milliseconds ; Syntax.........: _tcToMs($fTc) ; ; Parameters.....: $fTc - Timecode in hh:mm:ss.ff or hh:mm:ss:xxx format, where xxx are milliseconds ; ; Return value...: Milliseconds as an integer value Func _tcToMs($fTc) Local $fTemp = StringSplit($fTc, ":.") Local $fChr = StringLen($fTemp[4]) Switch $fChr Case 2 Return ($fTemp[4] * 40) + ($fTemp[3] * 1000) + ($fTemp[2] * 60000) + ($fTemp[1] * 3600000) Case 3 Return ($fTemp[4]) + ($fTemp[3] * 1000) + ($fTemp[2] * 60000) + ($fTemp[1] * 3600000) EndSwitch EndFunc ; #FUNCTION# ; Name...........: _msToTc ; Description....: Converts total milliseconds to timecode ; Syntax.........: _msToTc($fIn, $fFormat = "P", $fHourFormat = 1) ; ; Parameters.....: $fIn - Time in milliseconds ; $fFormat - Output format "P": PAL TC (default) ; "M": hh:mm:ss.xxx where xxx are milliseconds ; $fHourFormat - Hour format "1": max. value is 23, then starts from 0 (default) ; "0": hours can be more then 23 ; ; Return value...: Timecode as string in the selected format Func _msToTc($fIn, $fFormat = "P", $fHourFormat = 1) Switch $fFormat Case "P" Local $fFr = StringFormat("%02i", (StringRight($fIn, 3) - Mod(StringRight($fIn, 3), 40)) / 40) Case "M" Local $fFr = StringFormat("%03i", StringRight($fIn, 3)) EndSwitch $fIn = StringTrimRight($fIn, 3) Local $fSec = StringFormat("%02i", Mod($fIn, 60)) $fIn -= $fSec Local $fMinTot = $fIn / 60 Local $fMin = StringFormat("%02i", Mod($fMinTot, 60)) $fIn -= $fMin*60 Local $fHourTot = $fIn / 60 / 60 Switch $fHourFormat Case 1 $fHour = StringFormat("%02i", Mod($fHourTot, 24)) Case 0 $fHour = StringFormat("%02i", $fHourTot) EndSwitch Return($fHour & ":" & $fMin & ":" & $fSec & "." & $fFr) EndFunc ; #FUNCTION# ; Name...........: _tcFormatChange ; Description....: Toggle TC format ; Syntax.........: _tcFormatChange($fTc) ; ; Parameters.....: $fTc - Timecode in hh:mm:ss.ff or hh:mm:ss:xxx format, where xxx are milliseconds ; ; Return value...: PAL timecode or time with milliseconds as string, depends on input Func _tcFormatChange($fTc) Local $fTemp = StringSplit($fTc, ":.") Local $fChr = StringLen($fTemp[4]) Switch $fChr Case 2 Return $fTemp[1]&":"&$fTemp[2]&":"&$fTemp[3]&"."&StringFormat("%03i", $fTemp[4]*40) Case 3 Return $fTemp[1]&":"&$fTemp[2]&":"&$fTemp[3]&"."&StringFormat("%02i", ($fTemp[4]-Mod($fTemp[4], 40))/40) EndSwitch EndFunc And the example script:
      #include<_PAL_TC_Calc.au3> $palTC1 = "00:01:12.20" $palTC2 = "23:59:50.02" $msTC1 = "00:01:12.800" $msTC2 = "23:59:50.120" MsgBox(0, "1", _tcAdd($palTC1, $palTC2)); Adds $palTC1 to $palTC2, turns hour back to 0 after 23, returns PAL TC format MsgBox(0, "2", _tcAdd($palTC1, $palTC2, "M")); Adds $palTC1 to $palTC2, turns hour back to 0 after 23, returns time with milliseconds format MsgBox(0, "3", _tcAdd($palTC1, $palTC2, "M", 0)); Adds $palTC1 to $palTC2, hours can be infinite, returns time with milliseconds format MsgBox(0, "4", _tcAdd($msTC1, $msTC2)); Adds $palTC1 to $palTC2, turns hour back to 0 after 23, returns PAL TC format MsgBox(0, "5", _tcAdd($msTC1, $msTC2, "M")); Adds $palTC1 to $palTC2, turns hour back to 0 after 23, returns time with milliseconds format MsgBox(0, "6", _tcAdd($msTC1, $msTC2, "M", 0)); Adds $palTC1 to $palTC2, hours can be infinite, returns time with milliseconds format MsgBox(0, "7", _tcSub($palTC2, $palTC1)); Subtract $palTC1 from $palTC2, returns PAL TC format MsgBox(0, "8", _tcSub($palTC2, $palTC1, "M")); Subtract $palTC1 from $palTC2, time with milliseconds format MsgBox(0, "9", _tcSub($msTC1, $msTC2)); Subtract $palTC1 from $palTC2, returns PAL TC format - when hits zero, counts back from 24:00:00.00 MsgBox(0, "10", _tcSub($msTC1, $msTC2, "M")); Subtract $palTC1 from $palTC2, time with milliseconds format - when hits zero, counts back from 24:00:00.000 MsgBox(0, "11", _tcFormatChange($palTC2)); Convert PAL TC to time with milliseconds and back MsgBox(0, "12", _tcFormatChange($msTC2)); Convert PAL TC to time with milliseconds and back  
      TC_CALC_example.au3
      _PAL_TC_Calc.au3
    • TRAGENALPHA
      By TRAGENALPHA
      A small UDF to Modify the Console Interface.
      #include-once ;#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; =============================================================================================================================== ; Name...........: Console Modify ; Description ...: A small UDF to manipulate the Console Interface for scripts that are compiled as a console application. ; Syntax.........: _ConsoleClear() -- Clears the Console ; _ConsoleTitle("VALUE") - Sets the console title. ; _ConsoleWindow([WIDTH BUFFER SIZE], [HEIGHT BUFFER SIZE]) - Sets the Width and Height Buffer size of the console. ; Parameters ....: $bh6e5v_ctval = Title of the Console Window. ; $bh6e5v_cwwidth = Window width buffer size. ; $bh6e5v_cwheight = Window height buffer size. ; Return values .: True = Console window buffer size has been changed ; False = Failed to change console window buffer size. ; Author ........: TRAGENALPHA <3 ; Example .......: _ConsoleTitle("This is the new title") // _ConsoleWindow(200, 60) ; =============================================================================================================================== ; -- This is here because writing RunDos and including a whole UDF is too much. But this is basically just _RunDos() ;Func cmd($bh6e5v_ldvar) ; RunWait(@ComSpec & " /c " & $bh6e5v_ldval) ;EndFunc Func _ConsoleClear() RunWait(@ComSpec & " /c cls") EndFunc Func _ConsoleTitle($bh6e5v_ctval) RunWait(@ComSpec & " /c title " & $bh6e5v_ctval) EndFunc Func _ConsoleWindow($bh6e5v_cwwidth, $bh6e5v_cwheight) If IsNumber($bh6e5v_cwwidth) And IsNumber($bh6e5v_cwheight) And ($bh6e5v_cwwidth > 0) And ($bh6e5v_cwheight > 0) Then RunWait(@ComSpec & " /c mode con: cols=" & $bh6e5v_cwwidth & " lines=" & $bh6e5v_cwheight) Return True Else Return False EndIf EndFunc  
      ConsoleModify.au3
    • BlazerV60
      By BlazerV60
      Hello all,
      I've been trying to figure out how to launch Google Chrome in the background (hidden) but it doesn't seem possible. I've tried the following methods:
      ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", "", "", @SW_HIDE) Also I've tried:
      ShellExecute(@ComSpec, "/c start chrome.exe","","",@SW_HIDE) Lastly I tried:
      RunWait('"'&@ProgramFilesDir&'\Google\Chrome\Application\chrome.exe" --silent-launch',@ScriptDir)  
      But all of them launch my chrome browser without hiding it. Does anyone know a workaround for this or if AutoIT just can't Chrome? 
      Bonus points if you know how to make it launch chrome hidden and make it go to https://www.autoitscript.com
       
      Thank you,
      Brian