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

Post your working scripts, libraries and tools
gregster
Posts: 5171
Joined: 30 Sep 2013, 06:48

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

24 Aug 2020, 10:43

This might be related:
Instead, Microsoft Edge’s Internet Explorer Legacy mode means that users can stay on one browser – to “seamlessly experience the best of the modern web in one tab while accessing a business-critical legacy IE 11 app in another tab”, the company says.
User avatar
kczx3
Posts: 1166
Joined: 06 Oct 2015, 21:39

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

24 Aug 2020, 11:21

Technically, yes. However, no version prior to IE11 is supported. Nor is it recommended by Microsoft to my knowledge. I wouldn't personally put any work in to supporting anything other than IE11. And even then, soon the WebView2 control will be GA and you can ship the Edge (Chromium) RunTime installer with your application which installs the runtime in the background for your app to use. And Edge is supposed to be usable all the way back to Windows 7.
KiddoV
Posts: 5
Joined: 11 May 2020, 20:29

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

31 Aug 2020, 07:25

Hi, all.
No body mentions about how to create an additional gui using neutron. Let say I want to create a custom messagebox that popup as a neutron webapp. Is anyone know how to do that. The code seem to crash when I try to create a new Neutron object.
Thanks!
User avatar
Chunjee
Posts: 690
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

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

31 Aug 2020, 22:26

KiddoV wrote:
31 Aug 2020, 07:25
No body mentions about how to create an additional gui using neutron.

This seems to work:

Code: Select all

neutron := new NeutronWindow()
; neutron.load("html\index.html")
neutron.Show("w2080 h1000")
neutron.Maximize()

neutron2 := new NeutronWindow()
; neutron2.load("html\index.html")
neutron2.Show("w2080 h1000")
neutron2.Maximize()
I commented out the load line only because it's unlikely you have a \html\index.html file exactly like me. You just need to make a new instance of the class and interact with each window through its associated object.
KiddoV
Posts: 5
Joined: 11 May 2020, 20:29

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

01 Sep 2020, 06:19

Thanks @Chunjee for the reply!
I put it in a function:

Code: Select all

HtmlMsgBox(Options := "", Title := "", Text := "", Timeout := 0) {
    NeutronMsgBox := new NeutronWindow()
    NeutronMsgBox.Load("html_msgbox.html")
    NeutronMsgBox.Gui("-Resize +LabelHtmlMsgBox")
    
    NeutronMsgBox.Show("")
    
    Return
    
    NeutronMsgBoxClose:
        NeutronMsgBox.Destroy()     ;Free memory
    Return
}

Code: Select all

TestBttn(neutron, event) {
    HtmlMsgBox("", "Test Msgbox")
}
...and call it in HTML

Code: Select all

<button id="test-btn" type="button" class="btn btn-primary btn-xs" onclick="ahk.TestBttn(event)">Test MsgBox</button>
it seem to crashes my program right away after clicking the button?
Any idea why?
Thanks!
KiddoV
Posts: 5
Joined: 11 May 2020, 20:29

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

14 Oct 2020, 06:59

Hi all,
Anyone know how to stop the mouse cursor to change to "resize-icon" when hover the edges of the window? I made an app that do not resize window, so it doesn't make sense when hover the edges of the window and cursor changed to resize-icon.
Thanks!
User avatar
kczx3
Posts: 1166
Joined: 06 Oct 2015, 21:39

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

14 Oct 2020, 08:43

@KiddoV
It is probably possible but why? There's nothing wrong with letting it resize since the browser should handle resizing any UI elements for you.
GeekDude
Posts: 886
Joined: 02 Oct 2013, 22:13

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

14 Oct 2020, 21:27

kczx3 wrote:
24 Aug 2020, 11:21
Technically, yes. However, no version prior to IE11 is supported. Nor is it recommended by Microsoft to my knowledge. I wouldn't personally put any work in to supporting anything other than IE11. And even then, soon the WebView2 control will be GA and you can ship the Edge (Chromium) RunTime installer with your application which installs the runtime in the background for your app to use. And Edge is supposed to be usable all the way back to Windows 7.
I've picked up on your work with WebView and managed to backport it to AHKv1, as well as solved a few of the problems that you were facing with, for example, AddHostObjectToScript and reading object properties (AHK's IDispatch implementation and WebView2's IDispatch implementation are both quirky, and in a way that conflicts. I had to rebuild the IDispatch support from the ground up in AHK). I don't have the code posted anywhere outside of Discord, but it might make its way online soon so keep an eye out. It looks like the WebView2 control is more usable in v2 and v1 thanks to anonymous functions, but the unique way in which Microsoft implement things like thread locking and callbacks mean that it will likely never be as easy to use as IE11/ActiveX/Neutron.

Also, to anyone who is concerned about IE disappearing from the OS--don't be too concerned. The component that Edge will use to display IE content in Edge is, as far as I am aware, the same component that is used by Neutron. As long as Edge retains IE backward compatibility Neutron should still work fine.
KiddoV wrote: it seem to crashes my program right away after clicking the button?
Any idea why?
Thanks!
One of the first things that was brought to my attention after releasing Neutron was the fact that multiple-window support was broken. It turned out to be an easy fix ( https://github.com/G33kDude/Neutron.ahk/commit/63a0785d140202eb013226afd84da65bc19a56ca ) but it hasn't yet made its way to a release. Time constraints and other commitments have kept me from doing it justice. Either implement that small patch yourself, or grab the latest development copy instead of the release build: https://github.com/G33kDude/Neutron.ahk/blob/master/Neutron.ahk
KiddoV wrote: Hi all,
Anyone know how to stop the mouse cursor to change to "resize-icon" when hover the edges of the window? I made an app that do not resize window, so it doesn't make sense when hover the edges of the window and cursor changed to resize-icon.
Thanks!
This was a feature that I neglected for release 1.0.0. Right now, my best recommendation would be to set a minimum size and, if you really need to, a maximum size that the window should be. It's 2020, windows should be resizable. That said, if you really do need to get rid of resizing altogether you can comment out the contents of the if statement where it says if (Msg == this.WM_NCHITTEST) in the _WindowProc(Msg, wParam, lParam) method.
KiddoV
Posts: 5
Joined: 11 May 2020, 20:29

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

15 Oct 2020, 08:47

Thank you @GeekDude. Really love your work!
Do you think if it is possible to make a Neutron library (maybe in the future) that won't need IE in the window system?. I mean to make a stand-alone Neutron lib that does not depend on IE browser.
User avatar
kczx3
Posts: 1166
Joined: 06 Oct 2015, 21:39

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

15 Oct 2020, 12:22

@GeekDude
Glad that my efforts (that were only possible due to the efforts by @Flipeador) helped you to pick up and continue with it. I find most tasks are easier with AHK v2 due to GUI objects and fat-arrow functions (scope inheritance!). That said, I agree that WebView2 will never be as simple as the Web Browser control because WebView2 doesn't expose the DOM at all. Everything must be handled by messaging to my knowledge. I think its worth it though considering how much better of a browser and JavaScript environment that WebView2 gives.

I didn't explicitly catch this but are you backporting it to v1 to then use with Neutron?
GeekDude
Posts: 886
Joined: 02 Oct 2013, 22:13

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

16 Oct 2020, 18:13

KiddoV wrote:
15 Oct 2020, 08:47
Thank you @GeekDude. Really love your work!
Do you think if it is possible to make a Neutron library (maybe in the future) that won't need IE in the window system?. I mean to make a stand-alone Neutron lib that does not depend on IE browser.
Not Neutron, but later libraries that take advantage of Edge's upcoming desktop app integration API won't need IE (they'll need Edge :P )
kczx3 wrote: @GeekDude
Glad that my efforts (that were only possible due to the efforts by @Flipeador) helped you to pick up and continue with it. I find most tasks are easier with AHK v2 due to GUI objects and fat-arrow functions (scope inheritance!). That said, I agree that WebView2 will never be as simple as the Web Browser control because WebView2 doesn't expose the DOM at all. Everything must be handled by messaging to my knowledge. I think its worth it though considering how much better of a browser and JavaScript environment that WebView2 gives.

I didn't explicitly catch this but are you backporting it to v1 to then use with Neutron?
I haven't used v2 at all, and I think more people find my libraries more useful as v1 compatible than as v2 compatible. I started with WebView2 in v1 before I saw any of your/@Flipeador/others' work on it, but wasn't able to get it to work until I started comparing my implementation against the v2 code all of you had provided. The v2 implementation is much simpler than v1, so long-term I think it will be more attractive to move over to v2.

WebView2 won't ever make it to Neutron simply because its core behavior is fundamentally different, but I've been thinking about how I could best go about creating a similar library for WebView2. It will probably be called Positron (if it ever sees daylight).

Also, it does kind of expose the DOM through the CallDevToolsProtocolMethod (DOM endpoints are available for that) but it's much more complicated than just invoking JavaScript and, as all calls use serialized IPC, not significantly different than invoking JS. Maybe I can wrap that in a way that makes sense, but I'm not sure the effort is warranted.
User avatar
kczx3
Posts: 1166
Joined: 06 Oct 2015, 21:39

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

16 Oct 2020, 19:38

@GeekDude be careful! Once you start using v2 you might not go back!
KiddoV
Posts: 5
Joined: 11 May 2020, 20:29

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

20 Oct 2020, 09:40

@GeekDude ,
@ I am looking forward to see the future of Neutron on Edge. In my opinion tho, I would rather implement it into Chrome (If that possible) . What do you think?
@ Maybe it just me who cares so much about the UI. But, do you know how to change the scroll bar outlook? It looks so ugly and cannot customize on IE11. Is there a way to customize it either on HTML/CSS side or AHK side?

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 24 guests