[Library] Neutron.ahk - AutoHotkey Web GUIs on Steroids

Post your working scripts, libraries and tools
User avatar
kczx3
Posts: 1254
Joined: 06 Oct 2015, 21:39

Re: [Library] Neutron.ahk - AutoHotkey Web GUIs on Steroids

07 Jan 2021, 12:10

@KiddoV
See here - https://github.com/G33kDude/Neutron.ahk/issues/2

EDIT: Actually, if you instead download the source code, it should work. Updates have been made to the accelerator handling but have not been incorporated into a GitHub "Release".
KiddoV
Posts: 9
Joined: 11 May 2020, 20:29

Re: [Library] Neutron.ahk - AutoHotkey Web GUIs on Steroids

14 Jan 2021, 10:22

Thank you, @kczx3!
Everyone,
I recently using function ObjRegisterActive() to access Neutron object from the outer script.

Code: Select all

ObjRegisterActive(Object, CLSID, Flags:=0) {
    static cookieJar := {}
    if (!CLSID) {
        if (cookie := cookieJar.Remove(Object)) != ""
            DllCall("oleaut32\RevokeActiveObject", "uint", cookie, "ptr", 0)
        return
    }
    if cookieJar[Object]
        throw Exception("Object is already registered", -1)
    VarSetCapacity(_clsid, 16, 0)
    if (hr := DllCall("ole32\CLSIDFromString", "wstr", CLSID, "ptr", &_clsid)) < 0
        throw Exception("Invalid CLSID", -1, CLSID)
    hr := DllCall("oleaut32\RegisterActiveObject"
        , "ptr", &Object, "ptr", &_clsid, "uint", Flags, "uint*", cookie
        , "uint")
    if hr < 0
        throw Exception(format("Error 0x{:x}", hr), -1)
    cookieJar[Object] := cookie
}
Outer script...

Code: Select all

NeutronWebObj := ComObjActive("{AAAAAAAA-1111-0000-116D-616E61676572}")
...So everything works perfectly except I cannot access the NeutronWebObj.wnd.customFunction() from the outer script. (Inner script was ok) The NeutronWebObj.wnd.alert("Hello") still ok tho, only it cannot access custom javascript functions.
Does anyone know why?
Thanks all!
20170201225639
Posts: 38
Joined: 01 Feb 2017, 22:57

Re: [Library] Neutron.ahk - AutoHotkey Web GUIs on Steroids

17 Jan 2021, 15:14

Wow. Thank you Geekdude. This is going to make my life so much easier.

I have a general question about the usage of Neutron, if you don't mind. Basically: when it comes to manipulating HTML DOMs, two methods seem possible:

(A) Use Neutron to manipulate the DOM directly.

Code: Select all

neutron.doc.getElementById("ahk_x").innerText := x
(B) Define a JS function, call that function from Neutron.

Code: Select all

neutron.doc.parentWindow.customDefinedJS("please do this dom update for me")
I'm wondering if, there's any difference between (A) and (B) (esp. performance-wise) which may mean there are situations where one is prefered over the other and vice versa?

I especially have in mind time-sensitive applications (think: live filtering a huge table, find-as-you-type style) where major updates are made to the DOM on each single keystroke.
tuzi
Posts: 77
Joined: 27 Apr 2016, 23:40

Re: [Library] Neutron.ahk - AutoHotkey Web GUIs on Steroids

17 Jan 2021, 22:59

Is it possible to provide a library based on the chrome kernel to do what Neutron.ahk does?
The advantages are
1. People just need a latest version of chrome.dll.
2. Most people use chrome, and most websites are optimized for chrome only, so if we want to learn the web effect of a website, this is the best solution.
3. Microsoft dropped the support for IE.
4. Different versions of IE show a big difference.
5. IE is not as fast as chrome.
7JfbcEU4prPAFEws
Posts: 3
Joined: 19 Jan 2021, 07:39

Re: [Library] Neutron.ahk - AutoHotkey Web GUIs on Steroids

19 Jan 2021, 10:26

Excellent work! I've been playing with this for a couple of days and it's really nice. :bravo:

The only thing I'd change is the "borderless window" effect for a variety of reasons:

1. it doesn't really work for me (title bar appearing/disappearing every time I switch windows, flickering, etc.)
2. I like title bars and borders and I don't need any neutron window to be without
3. I found out that WinSet, Style, +0xC40000 does a better job at it

Anyway it's not a problem for me, I already changed that part of the code.

Thanks! :beer:
aerodatilo
Posts: 1
Joined: 09 Oct 2018, 04:49

Re: [Library] Neutron.ahk - AutoHotkey Web GUIs on Steroids

22 Feb 2021, 16:40

Hello, guys! And @GeekDude

Thanks for the script but i'm having trouble to use gLabel, goto and gosub

Well, my script is not only a screen, have others actions and i need to break the neutron and use goto/gosub (like a "gui, add, button, gLabel")

Have any way to do it on Neutron?


Edit::Hello again, guys

After 2 days thinking about it, I decided to come to the forun, and NOW (exactly) I finally have found an alternative with SetTimer.

Please, enjoy

Full Code (No Explain, detailed explain is above it)
<button type="submit" onclick="ahk.LoginEvent(event)" class="btn btn-primary">Login ></button>

LoginEvent(neutron, event)
{
SetTimer, LoginEvent, 100
}

LoginEvent:
if(Server = "")
Server:=formData.Server,Password:=formData.Password
else goto Loggin
return

Loggin:
neutron.destroy()
SetTimer, LoginEvent, off
return


HTML Button:

<button type="submit" onclick="ahk.LoginEvent(event)" class="btn btn-primary">Login ></button>


Function Call (starts on button):
LoginEvent(neutron, event)
{
SetTimer, LoginEvent, 100
}


Activate the Timer to start with 100ms (use anytime, but care with processor)
LoginEvent:
if(Server = "")
Server:=formData.Server,Password:=formData.Password
else goto Loggin
return


After server and password is ok, starts the function normaly:
Loggin:
neutron.destroy()
SetTimer, LoginEvent, off ; to not repeat anymore
return

Return to “Scripts and Functions”

Who is online

Users browsing this forum: FonBass and 29 guests