Page 3 of 8

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 21 Apr 2016, 19:16
by gallaxhar
Is it possible for AHK to see javascript events that are created by Html/CSS/JS entities on ActiveX controls and respond to them?

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 05 May 2016, 14:39
by kczx3
Take a look at Installer.ahk in your installation directory. Lexikos makes use of something like this. I think you can make a JS function and within that, call an AHK function and pass the events to it.

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 05 May 2016, 20:45
by joedf
Yes, Installer.ahk is indeed a very good example. :)

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 08 Aug 2016, 12:06
by Phatricko
This is very cool! If you have written a full blown class for this please let me know!

Thought I'd share this too, it registers the event for all input tags so you don't have to do it manually for each button. :D

Code: Select all

loop % wb.document.getElementsByTagName("input").length{
    ;ComObjConnect needs a unique variable for each iteration for all to work
    button%a_index% := wb.document.getElementsByTagName("input")[A_Index-1]
    id := button%a_index%.id
    ComObjConnect(button%a_index%, id . "_")
}

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 08 Aug 2016, 22:13
by joedf
Cool :3
I should make a class library... Webkit.ahk 8-)
https://github.com/joedf/Webkit.ahk

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 09 Aug 2016, 03:26
by Bruttosozialprodukt
Webkit is a bit misleading if it's using IE's Trident engine don't you think?

Oh and btw:
https://github.com/cocobelgica/AutoHotk ... ebView.ahk

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 10 Aug 2016, 10:07
by joedf
@Bruttosozialprodukt
You're right haha
thanks for the link, I remember seeing that. seems quite complete.
I'm thinking maybe using Exo, so we would only need to edit HTML and js files.
I guess this would be more like a wrapper to simplify the work of making web+ahk apps.

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 10 Aug 2016, 12:47
by kczx3
Are either of you savvy enough to figure out why CWebView.ahk doesn't let any accelerator keys through?

In my only implementation, I modified the function used in Installer.ahk to let ctrl+a, ctrl+x, ctrl+c, ctrl+v through, and Enter also seems to be recognized. But can't seem to figure out how to do the same with this class.

Code: Select all

/*  Fix keyboard shortcuts in WebBrowser control.
 *  References:
 *    http://www.autohotkey.com/community/viewtopic.php?p=186254#p186254
 *    http://msdn.microsoft.com/en-us/library/ms693360
 */

gui_KeyDown(wParam, lParam, nMsg, hWnd) {
    global wb
    if (Chr(wParam) ~= "[B,D-U,W,Y-Z]" || wParam = 0x74) ; Disable Ctrl+O/L/F/N and F5.
        return
    pipa := ComObjQuery(wb, "{00000117-0000-0000-C000-000000000046}")
    VarSetCapacity(kMsg, 48), NumPut(A_GuiY, NumPut(A_GuiX
    , NumPut(A_EventInfo, NumPut(lParam, NumPut(wParam
    , NumPut(nMsg, NumPut(hWnd, kMsg)))), "uint"), "int"), "int")
    Loop 2
    r := DllCall(NumGet(NumGet(1*pipa)+5*A_PtrSize), "ptr", pipa, "ptr", &kMsg)
    ; Loop to work around an odd tabbing issue (it's as if there
    ; is a non-existent element at the end of the tab order).
    until wParam != 9 || wb.Document.activeElement != ""
    ObjRelease(pipa)
    if r = 0 ; S_OK: the message was translated to an accelerator.
        return 0
}

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 10 Aug 2016, 14:40
by kczx3
Was able to figure that part out by doing the below and passing my own function:

Code: Select all

cwb := new CWebView(1, "x0 y20 w250 h500", html)
cwb.TranslateAccelerator := ["D", gui_KeyDown]
Now, the problem is that setting cwb.Window.AHK := Func("JS_AHK") is now not working.

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 10 Aug 2016, 22:43
by lexikos
CWebView.Window returns a CWebPage, not a window object. Your assignment doesn't work because CWebPrototype.__Set forwards assignments only when _IsMemberOf() returns true. I suppose it will return false for properties that haven't been defined yet, like 'AHK'.

It looks like all the wrapping is just to add a few helper functions to HTML nodes and document objects.

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 11 Aug 2016, 07:34
by kczx3
My main reason for trying this class out is because in this weather widget I've been slowly working on, it almost always shows the AutoHotkey has stopped responding window when I close it. And it wouldn't even run on my Win10 machine (untested using this class yet). Using this class, I haven't had any problems with that whatsoever.

This seems to work... whether or not its the correct way to do so.

Code: Select all

cwb := new CWebView(1, "x0 y20 w250 h500", html, Func("JS_AHK"))
cwb.TranslateAccelerator := ["D", gui_KeyDown]
w := cwb.__Ptr.document.parentWindow
w.AHK := Func("JS_AHK")

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 12 Aug 2016, 10:37
by joedf
Will be adding this to the post soon, targeting newbie/intermediate.
https://github.com/joedf/Webapp.ahk

Sadly its not a class, there's some weird stuff going on.

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 18 Aug 2016, 20:52
by func
Joedf, could your webapp.ahk be configured to detect javascript events like when a row on a table is selected? Such as at this link https://datatables.net/extensions/selec ... vents.html

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 18 Aug 2016, 22:16
by joedf
Actually, try simply loading your webpages with the javascript. What webapp.ahk does, it allows you to access AHK scripting and wraps it into a lightweight "app" which can be compiled to an exe. Try it, maybe throw in a few messageboxes/alert() to debug it. :)

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 28 Aug 2016, 10:43
by xandu
Newbie here... ;)
Is there a special requirement for running webapp.ahk applications (OS/IE version/anything else...)?
It works fine in Windows 10, but when I try to run Example.ahk on Vista/IE9 it throws an error when clicking a link.
Image
Any ideas?
Thanks

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 28 Aug 2016, 18:23
by joedf
Hmm....
Try commenting-out line 38... -> ;;;;SetWBClientSite() ? :?

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 28 Aug 2016, 19:49
by lexikos
@xandu: Make sure AutoHotkey is up to date.

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 29 Aug 2016, 10:03
by Guest
joedf wrote:Hmm....
Try commenting-out line 38... -> ;;;;SetWBClientSite() ? :?
Nope, same error after commenting that line.

@lexikos: I downloaded it yesterday, so it should be up-to-date...

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 29 Aug 2016, 14:21
by xandu
(I have to repost, I guess my reply was lost somehow)
joedf wrote:Hmm....
Try commenting-out line 38... -> ;;;;SetWBClientSite() ? :?
That didn't help, same error received...

@lexikos: I installed it yesterday, so it should be up-to date.

Re: [GUI] Use HTML and CSS for your GUIs!

Posted: 30 Aug 2016, 03:26
by lexikos
Evidently your post was not lost, but probably required moderator approval because you were not logged in.

That you downloaded and installed it yesterday means very little, because you didn't say what you downloaded or from where. To actually verify that AutoHotkey is up to date, just check the version number of the program and compare it to the download link at the top of this page (currently "Download - 1.1.24.01"). The version number can be found in various places, but to be sure, the most reliable way is to run MsgBox %A_AhkVersion% within your script.

This is important because the line in question most likely requires v1.1.18+ ("Added support for creating new properties in JavaScript/IE DOM objects.")