seangriffin

Chrome UDF

100 posts in this topic

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.

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

 

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 ??

Share this post


Link to post
Share on other sites

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.  

Share this post


Link to post
Share on other sites

#66 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Are you still supporting this?

Microsoft Security Essentials says autoit_chrome_native_messaging_host_install.exe is a Trojan, Win32/Spursint.A 

What gives?

 

Share this post


Link to post
Share on other sites

#71 ·  Posted (edited)

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
1 person likes this

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Google Chrome won't let me activate the extension

Share this post


Link to post
Share on other sites

#76 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites
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!

 

Share this post


Link to post
Share on other sites

#78 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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)

1 person likes this

Share this post


Link to post
Share on other sites
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

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