ComDispatch (for v1.1) compatibility update for v2.0-a048

Post your working scripts, libraries and tools
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

ComDispatch (for v1.1) compatibility update for v2.0-a048

13 Jul 2014, 13:23

I've updated ComDispatch to be compatible for v2.0-a048. This version should work on the latest(as of this post) v2.0-a release, specifically 2.0-a048-573f142.

File(s) included in the repository: Example (for v2):

Code: Select all

#Include ComDispatch.ahk
#Include ComDispTable.ahk
#Include ComVar.ahk

html := '
(
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/javascript">
var ahk; // store ComDispatch() object here

function buttonClick() {
	var ahkRes = ahk.Message("Hello from JavaScript");
	var hello = document.getElementById("hello");
	hello.innerText = ahkRes;
}
</script>
<body>
<h1 id="hello">Hello World!</h1>
<input type="button"  value="Press Me"></input>
</body>
)'

Gui New, +LastFound
Gui Margin, 0, 0
Gui Add, ActiveX, w500 h300 vWb, Shell.Explorer
Wb.Navigate("about:blank")
while (Wb.ReadyState != 4)
	Sleep 10
Wb.Document.open()
, Wb.Document.write(html)
, Wb.Document.close()
, Wb.Document.parentWindow.ahk := ComDispatch("", "Message")
Gui Show
return
GuiClose:
ExitApp

Message(this, msg) {
	static i := 0
	
	MsgBox %msg%
	return "(%(i+=1)%) Hello from AutoHotkey"
}
Last edited by Coco on 14 Jul 2014, 09:10, edited 3 times in total.
User avatar
joedf
Posts: 7247
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: ComDispatch compatibility update for v1.1 and v2.0-a

13 Jul 2014, 22:46

Starred!
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 3143 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]
lexikos
Posts: 6608
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: ComDispatch compatibility update for v1.1 and v2.0-a

14 Jul 2014, 03:56

I've updated ComDispatch to be compatible for both v1.1 and v2.0-a.
I assume you mean that you updated it to be compatible with a specific v2.0 alpha version, since it was already compatible with (written for) v1.1. You should note which alpha version, because it might not be compatible with the next version (or the one after that...).
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: ComDispatch (for v1.1) compatibility update for v2.0-a04

14 Jul 2014, 09:11

OP updated as per lexikos' advise
User avatar
Apollo
Posts: 5
Joined: 02 Aug 2014, 05:16

Re: ComDispatch (for v1.1) compatibility update for v2.0-a04

03 Aug 2014, 06:25

Hi. I'm new to AHK COM interface. I currently trying to create a COM server exposing AHK functions or class object methods.
Seem ComDispatch might be the solution for it.

Is there any available documentation I could refer?

Thanks
I need help here --> boards/viewtopic.php?f=5&t=4138
Thank you...
Coco
Posts: 771
Joined: 29 Sep 2013, 20:37
GitHub: cocobelgica

Re: ComDispatch (for v1.1) compatibility update for v2.0-a04

03 Aug 2014, 06:45

fincs might be able to help regarding your COM server requirement. I believe he had done it for SciTE4AutoHotkey...
tmplinshi
Posts: 1504
Joined: 01 Oct 2013, 14:57

Re: ComDispatch (for v1.1) compatibility update for v2.0-a04

20 Apr 2015, 04:12

Hello,
How to modify the example code so that it works for AHK V1.1? thanks.

I've tried change html := '(...)' to html = (...), but nothing happens when pressed "Press Me".
lexikos
Posts: 6608
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: ComDispatch (for v1.1) compatibility update for v2.0-a04

21 Apr 2015, 00:21

ComDispatch is obsolete as of AutoHotkey v1.1.17.

The example script has nothing linking the buttonClick function to the actual button. Here's a working example for v1.1.17+:

Code: Select all

html =
(
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/javascript">
function buttonClick() {
    var ahkRes = ahk.Message("Hello from JavaScript");
    var hello = document.getElementById("hello");
    hello.innerText = ahkRes;
}
</script>
<body>
<h1 id="hello">Hello World!</h1>
<input type="button" value="Press Me" onclick="buttonClick()">
</body>
)

Gui New, +LastFound
Gui Margin, 0, 0
Gui Add, ActiveX, w500 h300 vWb, Shell.Explorer
Wb.Navigate("about:blank")
while (Wb.ReadyState != 4)
    Sleep 10
Wb.Document.open()
Wb.Document.write(html)
Wb.Document.close()
Wb.Document.parentWindow.ahk := { Message: Func("Message") }
Gui Show
return
GuiClose:
ExitApp

Message(this, msg:="") {
    static i := 0
    
    MsgBox %msg%
    return "(" (i+=1) ") Hello from AutoHotkey"
}
You can skip the Navigate/open/write/close calls if you replace Shell.Explorer with about:%html%, but in that case you cannot use // JavaScript line comments.
tmplinshi
Posts: 1504
Joined: 01 Oct 2013, 14:57

Re: ComDispatch (for v1.1) compatibility update for v2.0-a04

21 Apr 2015, 05:01

Thanks lexikos! I really like this feature. And I Didn't know about:%html% before, this seems useful to me.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: AHK_user, TheBestPessimist and 61 guests