AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COM Standard Library
Goto page Previous  1, 2, 3, 4, 5 ... 11, 12, 13  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Mon Oct 22, 2007 2:26 pm    Post subject: Re: rhetorical post Reply with quote

Sean wrote:
I'd like to emphasize again:
The real question is not about why should not use the fast mode, but about why should use the fast mode in spite of its less-safe nature.
In what way is it less safe?
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1336

PostPosted: Mon Oct 22, 2007 3:37 pm    Post subject: Re: rhetorical post Reply with quote

lexikos wrote:
In what way is it less safe?

Maybe error-prone a better term? You may start from the post of mine in this page:
http://www.autohotkey.com/forum/topic14560-75.html
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Mon Oct 22, 2007 10:19 pm    Post subject: Reply with quote

If you're talking about:
Chris wrote:
If it becomes the default and is ever used by mistake, the script might begin displaying unpredictable behavior that would be very difficult to track down and isolate.
...the cause of such behaviour would be the function running in whatever thread it "interrupted." As I have tried to explain, the thread interrupted will always be the DispInterface thread, so this is not an issue. It is no more error-prone than directly calling the function.

In any case, it is not likely worth further discussion.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1336

PostPosted: Tue Oct 23, 2007 1:10 am    Post subject: Reply with quote

I updated COM.ahk. The corresponding COM event functions now receive two parameters like Web_BeforeNavigate2(pDispParams, psink).
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1336

PostPosted: Tue Oct 23, 2007 12:46 pm    Post subject: Reply with quote

I reuploaded COM.ahk as there was an obvious bug with new functions
Code:
COM_Init(bOLE = False) / COM_Term(bOLE = False)

which are wrappers around
Code:
COM_CoInitialize()  / COM_CoUninitialize()  ; bOLE = False
COM_OleInitialize() / COM_OleUninitialize() ; bOLE = True
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Wed Nov 21, 2007 6:05 pm    Post subject: Reply with quote

Sean, thanks for all the great work on COM.ahk. I hope to distribute this and/or www.autohotkey.net/~easycom/ in the stdlib soon. (But since I know so little about COM, I keep having to refresh my memory about what the differences are.)

In case it affects your plans, what lexikos said about a callback's fast mode is correct: it shouldn't matter whether a fast-callback thread is interrupted by another thread. This is because by definition, whichever thread interrupted it will restore the proper settings for the fast-callback, which by definition are the proper settings for the thread beneath the fast-callback. This is because AutoHotkey "threads" always collapse in reverse order (i.e. no multithreading).
Back to top
View user's profile Send private message Send e-mail
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Wed Nov 21, 2007 8:08 pm    Post subject: Reply with quote

@Chris,

The advancement that Sean has made to AHK is almost beyond comprehension.


How to put this... for example, using a simple command " Invoke() ",

you can now, with AHK, directly control *any* part of any webpage being displayed in IExplorer on your machine.

as for windows scripting,

Code:
psc := ActiveXObject("MSScriptControl.ScriptControl")    ; Handle to script control instance 
Invoke(psc, "Language=", "JScript")           ; sent langauge to Java for this instance
msgbox  % wow := Invoke(psc, "Eval", "sh=new ActiveXObject(""WScript.Shell"");`nsh.Popup('Hello, world!', 2); sh ")          ; invokes EVAL for the javascript sh=...  which sets an active X object inside java to create the popup 
         
invoke(wow, "Popup","Sean, this is really, really cool!!!!")     ;      the same thing,  using the same handle,  directly for AHK!
         
Release(psc)           
CoUninitialize()



or more simply ?

Code:
CoInitialize()           
wow := ActiveXObject("WScript.Shell")           
invoke(wow, "Popup","Hello world!",2)             
Release(wow)           
CoUninitialize() 



but then again,

what do i know...

edit: it looks to complex so, retry:

Code:
psc := ActiveXObject("MSScriptControl.ScriptControl") 
Invoke(psc, "Language=", "JScript")

JavaCode := "x = 'WOW' ; x" ; whatever and as much java code you want !!

result := Invoke(psc, "Eval", JavaCode)


Release(psc)           
CoUninitialize()


which my AHK errors on on the JavaCode := line (????)

so last try:


Code:
com_CoInitialize()         
psc := com_ActiveXObject("MSScriptControl.ScriptControl")         
com_Invoke(psc, "Language=", "JScript")         
         
JavaCode =         
(         
x = "Wow"  ;         
x         
) ; whatever and as much java code you want !!         
         
result := com_Invoke(psc, "Eval", JavaCode)         
         
         
com_Release(psc)         
com_CoUninitialize()         
msgbox % result

_________________
Joyce Jamce
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1336

PostPosted: Thu Nov 22, 2007 1:15 am    Post subject: Reply with quote

Chris wrote:
In case it affects your plans, what lexikos said about a callback's fast mode is correct: it shouldn't matter whether a fast-callback thread is interrupted by another thread. This is because by definition, whichever thread interrupted it will restore the proper settings for the fast-callback, which by definition are the proper settings for the thread beneath the fast-callback. This is because AutoHotkey "threads" always collapse in reverse order (i.e. no multithreading).

Thanks for the clarification. lexicos had said that, and I think I must apologize him for that, I didn't read his post very carefully at the time. I should've read AHK's source-code myself to discuss it properly.

BTW, what I'd really like to know was/is how much performance the Fast mode gains over the default Slow mode. I switched from Fast to (default) Slow at some time, not because I actually met a problem with the Fast mode, but because there had been nothing Slow mode couldn't do where Fast mode could do, so I decided to stick with the default.

Anyway, I may reconsider adding Fast mode. In the same token, I may add Cdecl too. Due to the (undocumented) stack correction procedure at the end of DllCall, I believe Cdecl is actually faster than Stdcall. Although it's undocumented, I suppose it's unlikely to change as it makes DllCall really robust against crash. May I assume it?
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Nov 22, 2007 1:41 am    Post subject: Reply with quote

Sean wrote:
...how much performance the Fast mode gains over the default Slow mode.
The perceived impact on performance probably depends mostly on how many calls are made to the callback in a short period of time. If thousands of calls are made in a few seconds, "Fast" could help a lot. If performance is important, it's probably best to benchmark it for that particular task.

Sean wrote:
Due to the (undocumented) stack correction at the end of DllCall, I believe Cdecl is actually faster than Stdcall. Although it's undocumented, I suppose it's unlikely to change as it makes DllCall very robust against crash. May I assume it?
Although I can't say for sure that Cdecl is faster, in theory "yes" (due to the way DllCall is implemented). However, I suspect the difference is negligible compared to Fast vs. Slow mode.
Back to top
View user's profile Send private message Send e-mail
Sean



Joined: 12 Feb 2007
Posts: 1336

PostPosted: Wed Nov 28, 2007 2:41 am    Post subject: Reply with quote

The script is updated. Cdecl Fast options are added to the callback. Thanks to lexikos and Chris.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1336

PostPosted: Tue Dec 04, 2007 4:26 am    Post subject: Reply with quote

A new function is added, COM_ScriptControl(sCode, sLanguage = "", bEval = False), which executes external VBScript/JScript/etc.

Example:
Code:
Code=
(
  sh=new ActiveXObject("WScript.Shell");
  sh.Popup('Hello, world!', 2);
)

COM_ScriptControl(Code, "JScript")
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Tue Dec 04, 2007 10:01 am    Post subject: Reply with quote

Very Happy
_________________
Back to top
View user's profile Send private message MSN Messenger
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Thu Dec 06, 2007 7:18 am    Post subject: Reply with quote

likely am mssing something basic, but with
Code:
objWord = com_CreateObject("Word.Application")


am unable to see my way to:

Code:
objWord.Documents.Open("FILE")


or

Code:
objWord.WordBasic



Code:
com_Invoke(objWord, "Documents")



also brought no joy...



suggestions ?
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Thu Dec 06, 2007 7:51 am    Post subject: Reply with quote

Joy2DWorld wrote:
likely am mssing something basic, but with
Code:
objWord = com_CreateObject("Word.Application")
Make sure you used ":=" and not "=" in your actual code. Also, I don't have Word installed, but...
Code:
objWord.Documents.Open("FILE")

...should translate to...
Code:
Documents := COM_Invoke(objWord, "Documents")
COM_Invoke(Documents, "Open", "FILE")
COM_Release(Documents)
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Thu Dec 06, 2007 1:19 pm    Post subject: Reply with quote

sorry,

code was figurative, not literal..

Code:
com_CoInitialize()
objWord  := com_CreateObject("Word.Application")
msgbox  % objword
msgbox % invoke(objWord,"Documents")


also tried variants of (objword, "Documents=", "Open)
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5 ... 11, 12, 13  Next
Page 4 of 13

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group