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/
AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
Last edited by tadamm on 31 Oct 2020, 21:19, edited 1 time in total.
Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)
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 ? 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).
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 ? 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).
Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)
On there i ask if this is something people would think worth while in seeing a video made
Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)
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 .
anyway, thank you for your contribution to the AHK community!
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 .
anyway, thank you for your contribution to the AHK community!
Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)
You can do a lot more complex stuff with JS for sure then you could ever do with Selenium
Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)
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).
Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)
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?
Also is there a way to edit my title I agree with your title as being better?
Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)
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).
But hey, the more options the better...
(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.
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...
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.
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
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)
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
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.
Good to hear that you successfully use AHK at your workplace The fear about you leaving is not an unusual one, I am afraid (but this doesn't solely concern AHK).
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
RunJsFromChromeAddressBar() ); oh this is cool will play with
- Thoughtfu1Tux
- Posts: 125
- Joined: 31 May 2018, 23:26
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
@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.
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.
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
@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
https://www.autocontrol.app/scripting/include
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
@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.
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
At work we need it to be compiled so just went that wayboiler 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.
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
I just used clipboard varThoughtfu1Tux 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.
- Thoughtfu1Tux
- Posts: 125
- Joined: 31 May 2018, 23:26
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
Ah, that's not useful for me as i'm doing dozens of inputs.
-
- Posts: 493
- Joined: 03 Dec 2018, 20:02
Re: AHK with Chrome (No Selenium, no debug mode, no web connectors)
I just wish I had found this earlier..I wrote a similar one earlier and it was so much coarse compared to this
-
- Posts: 493
- Joined: 03 Dec 2018, 20:02
Re: AHK with Chrome extension (No Selenium, no debug mode, no web connectors)
Has anyone considered using Tampermonkey to communicate with AHK? If not I'll write one.
Return to “Tips and Tricks (v1)”
Who is online
Users browsing this forum: No registered users and 18 guests