AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Put simple Tips and Tricks that are not entire Tutorials in this forum
User avatar
tadamm
Posts: 40
Joined: 27 Sep 2020, 11:41

AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by tadamm » 31 Oct 2020, 14:40

Got sick of always using AHK and IE. So I made the switch over to AHK and Chrome. I finally made a video on how to do this.

Very little JS is needed and the AHK script is super simple. In this first video of hopefully many i show how to get started with a simple filling of a textbox.
The AHK script send out a key combo that chrome then detects to trigger the JS.



https://www.reddit.com/r/AutoHotkey/comments/jlb946/using_ahk_with_chrome/
Last edited by tadamm on 31 Oct 2020, 21:19, edited 1 time in total.

gregster
Posts: 8921
Joined: 30 Sep 2013, 06:48

Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)

Post by gregster » 31 Oct 2020, 14:47

Huh, what should we find there? I only see a single javascript line... so you are using a custom browser extension (which I don't see) to execute it ?
Or you paste it into the console or address bar? Or something like a bookmarklet? And where is the AHK involved?

Is it a halloween mystery ? 8-)👻 A scavenger hunt ? 🎁🔎
In it's current state, your post is a bit underwhelming. Please elaborate!

When there is a meaningful script or function (or a useful tip or trick), we can move it back to an appropriate subforum. Edit: Done (now that we have something).

User avatar
tadamm
Posts: 40
Joined: 27 Sep 2020, 11:41

Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)

Post by tadamm » 31 Oct 2020, 21:15

On there i ask if this is something people would think worth while in seeing a video made

gregster
Posts: 8921
Joined: 30 Sep 2013, 06:48

Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)

Post by gregster » 01 Nov 2020, 01:51

Ok, I see, so you are using an third-party Chrome extension. That's certainly not unheard of, but obviously it can be useful, although some people might also hesitate to go this way.

I haven't looked very closely at the extension yet, but I guess you can still do more complex stuff with Selenium and Chrome.ahk - eg, headless browsing - but obviously, that's not always needed.

I have moved this now to 'Tips and Tricks' as there is not much specific AHK code involved, and you have to mainly watch a video and set up the extension with javascript, but if someone has a better idea...
AHK with Chrome extension would probably be a clearer topic title for this :think: .

anyway, thank you for your contribution to the AHK community!


User avatar
tadamm
Posts: 40
Joined: 27 Sep 2020, 11:41

Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)

Post by tadamm » 01 Nov 2020, 10:14

You can do a lot more complex stuff with JS for sure then you could ever do with Selenium

gregster
Posts: 8921
Joined: 30 Sep 2013, 06:48

Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)

Post by gregster » 01 Nov 2020, 10:26

tadamm wrote:
01 Nov 2020, 10:14
You can do a lot more complex stuff with JS for sure then you could ever do with Selenium
How so? You can actually execute JS lines or whole scripts in the browser context via Chrome.ahk (by leveraging the chrome debugging protocol) - I am pretty sure that this is also possible with Selenium, when necessary.

But yes, there are also other ways to run JS - one has been linked above, another one would be the third-party Chrome extension you mentioned in your video (which - most likely - has more permissions than JS alone on a website would have).

So imho the functionality which is individually built around the JS differs in these solutions (but also syntax and requirements), not the possibility of executing JS (which they all have).

User avatar
tadamm
Posts: 40
Joined: 27 Sep 2020, 11:41

Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)

Post by tadamm » 01 Nov 2020, 12:34

well that's the point no No Selenium, no debug mode, no web connectors. At my job we cant go into debug mode so this is our only option. also way easier then using Selenium at least in my view.

Also is there a way to edit my title I agree with your title as being better?

gregster
Posts: 8921
Joined: 30 Sep 2013, 06:48

Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)

Post by gregster » 01 Nov 2020, 12:53

The point was the complexity, I thought, and that you could do things with javascript; and I was just replying that javascript is actually available with all these approaches (apart from additional features like headless browsing or manipulating and tracking the network activities of the browser, eg).
tadamm wrote:
01 Nov 2020, 12:34
well that's the point no No Selenium, no debug mode, no web connectors. At my job we cant go into debug mode so this is our only option. also way easier then using Selenium at least in my view.
Sure, but installing random extensions isn't always an option either, especially the ones which are probably equally "dangerous"/powerful like debug mode ;)
But hey, the more options the better...

tadamm wrote:
01 Nov 2020, 12:34
Also is there a way to edit my title I agree with your title as being better?
You could edit your first post, but that would break the youtube link again (because you are still a new user), so I did it for you.
(I think youtube.com links are actually whitelisted, but you used the youtu.be link format...)

btw, I don't think that teadrinker's approach (linked by swagfag above) uses any of these requirements like extension, selenium or debug mode, just the Acc.ahk (accessibility) library.

User avatar
tadamm
Posts: 40
Joined: 27 Sep 2020, 11:41

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by tadamm » 01 Nov 2020, 13:30

ah ok ty I will leave it as is then for the title. Ill take a look at teadrinker's approach. Off the bat it looks pretty long compared to this way but if its easier I diff wanna give it a shot. ty. Out of 10+ langs. I know AHK has been a huge fan fav at work for how much it can do with a easy learning curve. (their fear is if I leave who can still support this)

gregster
Posts: 8921
Joined: 30 Sep 2013, 06:48

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by gregster » 01 Nov 2020, 13:34

tadamm wrote:
01 Nov 2020, 13:30
ah ok ty I will leave it as is then for the title. Ill take a look at teadrinker's approach. Off the bat it looks pretty long compared to this way but if its easier I diff wanna give it a shot.
Well, afaics, teadrinker's post contains a long js script example and re-usable library functions (mostly functions called by the one function the user would use, RunJsFromChromeAddressBar() ); the actual hotkey code is quite short.
I don't think that the internal code of the Chrome extension will be any shorter :)
That said, I still have to try that code myself... but teadrinker is usually quite responsive, if there are problems with his code. Edit: A first quick test (with different js) worked quite well. I am intrigued. 8-)

Good to hear that you successfully use AHK at your workplace :thumbup: The fear about you leaving is not an unusual one, I am afraid (but this doesn't solely concern AHK).

User avatar
tadamm
Posts: 40
Joined: 27 Sep 2020, 11:41

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by tadamm » 01 Nov 2020, 14:20

RunJsFromChromeAddressBar() ); oh this is cool will play with

User avatar
Thoughtfu1Tux
Posts: 125
Joined: 31 May 2018, 23:26

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by Thoughtfu1Tux » 01 Nov 2020, 22:36

@tadamm

How would i pass variables to the javascript when using your way? I use selenium for billing automation, and i grab a bunch of data from an excel spreadsheet and input it into an online billing form.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by BoBo » 02 Nov 2020, 00:19

@Thoughtfu1Tux I'd guess AC's "include" command (one of its API options) might come handy. That way you should be able to edit an external js-file on-the-fly without changing the calling trigger itself.

https://www.autocontrol.app/scripting/include

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by boiler » 02 Nov 2020, 08:23

@tadamm - I noticed in your video that you compiled the script before running it, but I didn’t see you mention a reason for it. Do you know that you can run AHK script files directly without compiling them? AHK is not a compiled language, so all the “compiler” does is wrap the script and the interpreter binary into one (larger) file.

User avatar
tadamm
Posts: 40
Joined: 27 Sep 2020, 11:41

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by tadamm » 02 Nov 2020, 09:11

boiler wrote:
02 Nov 2020, 08:23
@tadamm - I noticed in your video that you compiled the script before running it, but I didn’t see you mention a reason for it. Do you know that you can run AHK script files directly without compiling them? AHK is not a compiled language, so all the “compiler” does is wrap the script and the interpreter binary into one (larger) file.
At work we need it to be compiled so just went that way

User avatar
tadamm
Posts: 40
Joined: 27 Sep 2020, 11:41

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by tadamm » 02 Nov 2020, 09:12

Thoughtfu1Tux wrote:
01 Nov 2020, 22:36
@tadamm

How would i pass variables to the javascript when using your way? I use selenium for billing automation, and i grab a bunch of data from an excel spreadsheet and input it into an online billing form.
I just used clipboard var

User avatar
Thoughtfu1Tux
Posts: 125
Joined: 31 May 2018, 23:26

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by Thoughtfu1Tux » 02 Nov 2020, 15:23

Ah, that's not useful for me as i'm doing dozens of inputs.

william_ahk
Posts: 481
Joined: 03 Dec 2018, 20:02

Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)

Post by william_ahk » 04 Nov 2020, 03:40

swagfag wrote:
01 Nov 2020, 08:27
:arrow: RunJsFromChromeAddressBar()
I just wish I had found this earlier..I wrote a similar one earlier and it was so much coarse compared to this :D

william_ahk
Posts: 481
Joined: 03 Dec 2018, 20:02

Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)

Post by william_ahk » 04 Nov 2020, 04:06

Has anyone considered using Tampermonkey to communicate with AHK? If not I'll write one.

Post Reply

Return to “Tips and Tricks (v1)”