COM Event Handler
NEED DebugView to display the triggered event.
#Include CoHelper.ahk #Include AtlAx.ahk #SingleInstance force GoSub, GuiStart Gui, +Resize +LastFound Gui, Show, w800 h600 Center, WebBrowser hWnd := WinExist() pwb := ActiveXObject("Shell.Explorer") AtlAxAttachControl(pwb, hWnd) psink := ConnectObject(pwb, "Web_") ; ConnectObject(pwb, "Web_", "DWebBrowserEvents2") Invoke(pwb, "Navigate", "http://www.autohotkey.com/") Sleep 5000 Invoke(pwb, "Navigate", "http://www.autohotkey.com/forum/") Sleep 5000 Invoke(pwb, "GoBack") Sleep 3000 Invoke(pwb, "GoForward") Return GuiStart: CoInitialize() AtlAxWinInit() Return GuiClose: Gui, Destroy Release(pwb) AtlAxWinTerm() CoUninitialize() ExitApp [color=green]Web_[/color][color=red]NavigateComplete2[/color](prms, this) { OutputDebug, DONE! }
#SingleInstance force GoSub, GuiStart Gui, +LastFound Gui, Show, w800 h600 Center, WebBrowser hGui := WinExist() pwb1 := AtlAxGetControl(AtlAxCreateContainer(hGui, 10, 10, 380, 580, "Shell.Explorer")) pwb2 := AtlAxGetControl(AtlAxCreateContainer(hGui, 410, 10, 380, 580, "Shell.Explorer")) psink := ConnectObject(pwb1, "Web_") Invoke(pwb1, "Navigate", "http://www.autohotkey.com/") Sleep 5000 Invoke(pwb1, "Navigate", "http://www.autohotkey.com/forum/") Sleep 5000 Invoke(pwb1, "GoBack") Sleep 3000 Invoke(pwb1, "GoForward") Return GuiStart: CoInitialize() AtlAxWinInit() Return GuiClose: Gui, Destroy Release(psink) Release(pwb1) Release(pwb2) AtlAxWinTerm() CoUninitialize() ExitApp ;Web_NavigateComplete2(prms, this) Web_BeforeNavigate2(prms, this) { Global pwb2 Invoke(pwb2, "Navigate", DispGetParam(prms,1)) } #Include CoHelper.ahk #Include AtlAx.ahk
incredible, mind-bending stuff....
wow.
unclear of Invoke( vs. Invoke_(
is there a post/thread that points the way ?
ps: find your COM wrapper much more AHK functional than using 'Windows Scripting for AutoHotkey'...
Joy2DWorld, you're the only one who shows interest in it.incredible, mind-bending stuff....
As a matter of fact, it's incomplete in the strict sense, but looks like no need to complete it.
I intentionally avoided talking about Invoke_() as it could confuse the users who have no experience with Variant and its VT_TYPE. And, I now suppose Invoke_() is needed only when some of the parameters are of VT_BYREF type, so, Invoke() would be sufficient in most cases.unclear of Invoke( vs. Invoke_(
The difference is that you have to specify both VT_TYPE and argument with Invoke_(), somewhat analogous with
SendMessage, uMsg, wParam, lParam, , ahk_id %hWnd% [color=red]vs[/color] DllCall("SendMessage", "Uint", hWnd, "Uint", uMsg, "Uint", wParam, "Uint", lParam)
There are some examples using Invoke_():
<!-- m -->http://www.autohotke... ... &start=120<!-- m -->
<!-- m -->http://www.autohotke...pic.php?t=21808<!-- m -->
You may utilize the ScriptControl directly from CoHelper.ahk. I took an example from the thread:ps: find your COM wrapper much more AHK functional than using 'Windows Scripting for AutoHotkey'...
<!-- m -->http://www.autohotke...ic21674-30.html<!-- m -->
#Include CoHelper.ahk Code= ( sh=new ActiveXObject("WScript.Shell"); sh.Popup('Hello, world!', 2); ) CoInitialize() psc := ActiveXObject("MSScriptControl.ScriptControl") Invoke(psc, "Language[color=red]=[/color]", "JScript") Invoke(psc, "ExecuteStatement", Code) Release(psc) CoUninitialize()
Ah, you are getting patheticJoy2DWorld, you're the only one who shows interest in it
Well, if you care, I think you did amazing job. I can imagine what kind of things your COM functions can produce, and with events now, world of oportunities is endless.
Not indeed! I'm always fascinated about the functionalites/modules you 'connect' to AHK (same with Laszlo/PhiLho/majkinetor/Skan/daonlyfreez/..).Joy2DWorld, you're the only one who shows interest in it.
Cool stuff!
Unfortuantely (TBH, an assumption) a high percentage of the users here will end up within a 'consumer' position when it comes to express their interest in it.
Eg. I'd have to ask for each and every bit and bite, params etc. to get something like this running.
Beside the fact that I immediately become frustrated not to be able to make it myself, I often think "don't ask for that thing, you'll be responsible to waste the time of a rocket scientist". Others might have thought something similar in the past. So, it's getting silent out there ... :wink:
Thx for listening. 8)
99.9% of active AHK developers poorly document their stuff, or don't document it at all.
Others tend not to create reusable code, but just to present idea, like PhiLho or have limited functionality due to the bad design of some features (like what was the case with IE control at the start, where only 1 control could be created)
On the other hand, even well documented code often doesn't get any response if not directly usable by the members in their latests scripts, which is the reason I find this community as selfish in nature (although relaxing comparing to other communities on the net) and its members generaly can not look further then 1 metter ahead.
No wonder why ppl that did the most for AHK community left one day.
As regards the documentation, that's really a headache to me. That postpones the implementation of the standard library of COM/CoHelper etc. And, I already wrote the wrapper of the Accessibility, but didn't post it due to the documentation stuff, even though it's a real fun as combining with ISpeechVoice it can be a screen reader.
I'm not so sure if it can be used that way. That should be done through DOM, I think. As you seem to be well versed in JavaScript, why don't you try to implement DOM? I suppose Titan is considering to implement XML DOM, OTOH.This comes very close to controlling a webpage contents with JavaScript. Could you give an example where you get/set data with JavaScript from the contents of a webpage inside an IEControl?
The purpose of the above example was just to show that it's possible to use the MSScriptControl via Invoke() too, so it can be handy in some circumstances. If heavily use the VBScript/JScript, then better use WS4AHK.ahk as erictheturtle well organizes it to be easily handled.
it's incomplete in the strict sense, but looks like no need to complete it.
1. Keep in mind that genius takes a while for others to appreciate. You're natural ability to grasp the complexities of MS's structures and procedures is *far* beyond my own, and I imagine, the *vast* majority of everyone else as well.
2. What you've done with the COM is so giant, may take a while for realization of what you've done!
trouple of questions:
A. just showing my COM ignorance, what is incomplete in the function ?
B. have looked and tried to figure out, how/where does the extension get added for the "Web_" callback name ?
C. On totally different subject: For functions that return an array structure, is there a standard way to deal with that, or does one need to be coded ? (if necessary to code, possible to give some direction on what is needed code wise?)
I'm not so sure if it can be used that way. That should be done through DOM, I think. As you seem to be well versed in JavaScript, why don't you try to implement DOM? I suppose Titan is considering to implement XML DOM, OTOH.
True. I thought this might be used to hook into the DOM, but it seems it "only" directly calls the script-interpreter. I might know a bit about JavaScript, but this COM-stuff is way over my head, so implementing DOM support with IEControl I myself will probably never be able to accomplish. :?
#Include CoHelper.ahk CoInitialize() psc := ActiveXObject("MSScriptControl.ScriptControl") Invoke(psc, "Language[color=red]=[/color]", "JScript") Invoke(psc, "ExecuteStatement", "sh=new ActiveXObject(""WScript.Shell"");`nsh.Popup('Hello, world!', 2);") Release(psc) CoUninitialize()Clean!!
please forgive these questions:
Why is CoInitialize necessary ?
possible to create an object from a dll ... ? How to ?
possible to do script eval and get return value ? How to ?
(and sorry if these q's seem so ignorant.)
ps: possible to *add* standard wrapper option for "." in place of "=" ?