Why can AHK inject functions into IE such that they can be called from JS so easily?

Get help with using AutoHotkey and its commands and hotkeys
sancarn
Posts: 211
Joined: 01 Mar 2016, 14:52

Why can AHK inject functions into IE such that they can be called from JS so easily?

23 Jun 2018, 08:51

Hi all,

So last week I posted this stackoverflow question. For those who don't already know you can inject AHK functions into Internet Explorer such that they can be called from JavaScript. An Example:


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



By registering someFunc we can now call it directly from JavaScript using document.someFunc()

My question is, why does this work so well?! What are the conditions that ie.document.setVar("someFunc",Func("someFunc")) actually injects the function into JS, like on a low level I mean. Does someFunc need to be wrapped in some IDispatch? Or does it have to have some other COM properties?

The reason I am asking is because I can't for the life of me figure out how I can do the same in Ruby... So far everything I have tried seemed like it could work, but nothing really did... Any ideas?

Note:
I am using Ruby on Windows (Cygwin), FYI.

EDIT:

I've also seen that Function objects are a little different in AHK. Is this part of the reason? Do passed functions have to be actual objects which have a Call() and a __Call() method?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Return to “Ask For Help”

Who is online

Users browsing this forum: MK18, Relayer, S7ewie, swagfag and 22 guests