AutoHotkey Community

It is currently May 27th, 2012, 10:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 44  Next
Author Message
 Post subject: Re: rhetorical post
PostPosted: October 22nd, 2007, 2:26 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: rhetorical post
PostPosted: October 22nd, 2007, 3:37 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2007, 10:19 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2007, 1:10 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I updated COM.ahk. The corresponding COM event functions now receive two parameters like Web_BeforeNavigate2(pDispParams, psink).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2007, 12:46 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2007, 6:05 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2007, 8:08 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
@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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2007, 1:15 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2007, 1:41 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2007, 2:41 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
The script is updated. Cdecl Fast options are added to the callback. Thanks to lexikos and Chris.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2007, 4:26 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2007, 10:01 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
:D

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2007, 7:18 am 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2007, 7:51 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 6th, 2007, 1:19 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 44  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: XX0 and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group