 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Tue Jul 10, 2007 6:13 am Post subject: COM Event Handler |
|
|
It's now merged into CoHelper.ahk.
Last edited by Sean on Wed Sep 05, 2007 12:12 pm; edited 9 times in total |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Tue Jul 10, 2007 6:22 am Post subject: |
|
|
One example is DWebBrowserEvents2. And, I implemented only for NavigateComplete2, with the prefix Web_.
NEED DebugView to display the triggered event.
| Code: | #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
Web_NavigateComplete2(prms, this)
{
OutputDebug, DONE!
}
|
Last edited by Sean on Mon Oct 22, 2007 7:14 am; edited 2 times in total |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Tue Aug 14, 2007 4:32 am Post subject: |
|
|
Another example. Create two web browsers and the second one will mirror the first one, i.e., if you navigate the web in the first browser, the second one also will navigate to the new address.
| Code: | #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
|
Last edited by Sean on Mon Oct 22, 2007 7:14 am; edited 2 times in total |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 425 Location: Galil, Israel
|
Posted: Tue Sep 04, 2007 12:20 am Post subject: |
|
|
@Sean,
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'... _________________ Joyce Jamce |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Tue Sep 04, 2007 1:20 am Post subject: |
|
|
| Joy2DWorld wrote: | | incredible, mind-bending stuff.... |
Joy2DWorld, you're the only one who shows interest in it.
As a matter of fact, it's incomplete in the strict sense, but looks like no need to complete it.
| Quote: | | unclear of Invoke( vs. Invoke_( |
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.
The difference is that you have to specify both VT_TYPE and argument with Invoke_(), somewhat analogous with
| Code: | SendMessage, uMsg, wParam, lParam, , ahk_id %hWnd%
vs
DllCall("SendMessage", "Uint", hWnd, "Uint", uMsg, "Uint", wParam, "Uint", lParam) |
There are some examples using Invoke_():
http://www.autohotkey.com/forum/viewtopic.php?t=16631&postdays=0&postorder=asc&start=120
http://www.autohotkey.com/forum/viewtopic.php?t=21808 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Tue Sep 04, 2007 10:27 am Post subject: |
|
|
| Joy2DWorld wrote: | | ps: find your COM wrapper much more AHK functional than using 'Windows Scripting for AutoHotkey'... |
You may utilize the ScriptControl directly from CoHelper.ahk. I took an example from the thread:
http://www.autohotkey.com/forum/topic21674-30.html
| Code: | #Include CoHelper.ahk
Code=
(
sh=new ActiveXObject("WScript.Shell");
sh.Popup('Hello, world!', 2);
)
CoInitialize()
psc := ActiveXObject("MSScriptControl.ScriptControl")
Invoke(psc, "Language=", "JScript")
Invoke(psc, "ExecuteStatement", Code)
Release(psc)
CoUninitialize()
|
|
|
| Back to top |
|
 |
daonlyfreez
Joined: 16 Mar 2005 Posts: 755 Location: Berlin
|
Posted: Tue Sep 04, 2007 12:03 pm Post subject: |
|
|
Wow!
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?
 _________________ (sorry, homesite offline atm) |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3652 Location: Belgrade
|
Posted: Tue Sep 04, 2007 12:09 pm Post subject: |
|
|
| Quote: | | Joy2DWorld, you're the only one who shows interest in it |
Ah, you are getting pathetic
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. _________________
 |
|
| Back to top |
|
 |
BoBoĻ Guest
|
Posted: Tue Sep 04, 2007 12:22 pm Post subject: |
|
|
| Quote: | | Joy2DWorld, you're the only one who shows interest in it. | Not indeed! I'm always fascinated about the functionalites/modules you 'connect' to AHK (same with Laszlo/PhiLho/majkinetor/Skan/daonlyfreez/..).
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 ...
Thx for listening.  |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3652 Location: Belgrade
|
Posted: Tue Sep 04, 2007 1:07 pm Post subject: |
|
|
Nothing but the truth.
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. _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Tue Sep 04, 2007 2:56 pm Post subject: |
|
|
Oops, guys, I wasn't serious. I didn't complain. I also seldom posted under the threads even if I found them great. So, I'm well aware that no reply doesn't necessarily mean the work is useless. I just felt the forum is rather calm recently, but that's only my feeling too. BTW, I found myself posting strange needless messages recently, I don't know why. Maybe I'm not in the normal condition, at least emotionally.
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. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Tue Sep 04, 2007 3:12 pm Post subject: |
|
|
| daonlyfreez wrote: | | 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? |
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.
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. |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 425 Location: Galil, Israel
|
Posted: Tue Sep 04, 2007 3:53 pm Post subject: |
|
|
| Sean wrote: | | 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?) _________________ Joyce Jamce |
|
| Back to top |
|
 |
daonlyfreez
Joined: 16 Mar 2005 Posts: 755 Location: Berlin
|
Posted: Tue Sep 04, 2007 4:04 pm Post subject: |
|
|
| Sean wrote: | | 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.  _________________ (sorry, homesite offline atm) |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 425 Location: Galil, Israel
|
Posted: Tue Sep 04, 2007 4:20 pm Post subject: |
|
|
| Code: | #Include CoHelper.ahk
CoInitialize()
psc := ActiveXObject("MSScriptControl.ScriptControl")
Invoke(psc, "Language=", "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 "=" ? _________________ Joyce Jamce |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|