AutoHotkey Community

It is currently May 27th, 2012, 4:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1 ... 34, 35, 36, 37, 38, 39, 40 ... 44  Next
Author Message
 Post subject:
PostPosted: February 22nd, 2010, 1:01 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
You can redistribute COM.ahk, preferably as it is.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 6:35 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Hey Sean,

I'm trying to rewrite some functions to work with AHK_L and after several attempts and conulting with jethrow, I'm stuck. Can you create a call to COM_Invoke in COM_L combined with ternary? This is the line I'm trying to translate:

Code:
res:=COM_Invoke(pWin,"document.all.tags[table].item[" t "]"
     . ((row < 0) ? ".rows" : "rows[" r "].cells")
     . ".length")


I'm having absolutely zero luck making something that will produce a result. I tried this:

Code:
pWin["document.all.tags[table].item[" t "]" (( row<0 ) ? "rows" : "rows[" r "].cells" ) ".length"]


That produces no errors but also no result. I also tried this (at jethrow's somewhat suggestion):

Code:
pWin.document.all.tags("table").item[t] ((row < 0) ? .rows : .rows[r].cells) .length


But again no luck. Am I missing something in how the syntax is implemented or is ternary not possible in the new implmentation?

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 10:51 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
When I run your second code, I get this message:
Quote:
COM Error Notification
---------------------------
Function Name: "item[1]rows.length."
ERROR: No COM Dispatch Object!
()
It's missing a dot. However, I got "no errors but also no result" at first because I was using GetWebBrowser() and wasn't calling COM_Init(). It's only called automatically by COM_CreateObject().

Your third code has a syntax error. When you write ] (, it is implicitly concatenation; i.e.
Code:
pWin.document.all.tags("table").item[t] . ((row < 0) ? .rows : .rows[r].cells) .length
I suppose there are two ways:
Code:
table := pWin.document.all.tags("table").item[t]
MsgBox % r < 0 ? table.rows.length : table.rows[r].cells.length
Code:
MsgBox % pWin.document.all.tags("table").item[t][(r < 0) ? "rows.length" :  "rows[" r "].cells.length"]
I didn't know what the usage of 'row' vs 'r' was, so I used 'r' in both. I think that passing the entire COM expression in a string via [] or COM_Invoke() is actually more efficient, as it doesn't need to wrap each intermediate COM object in an AHKL object.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 12:36 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Sorry for the confusion Lexikos, that snippet of code is being used inside a function. Probably no sooner than I had figured that out on my own, you had posted it. So that I have working, but I still have a problem. I'm trying to retrieve a type of data from a table cell on a website, but I need to keep the type optional in the COM call. For example this:

Code:
COM_Invoke(pwb,"document.all[q].innerText")


Would be like this:

Code:
type:="innerText"

COM_Invoke(pwb,"document.all[q]." type)


And the above works. So if I want to pull data from a cell on the forum main page (using iWeb_getWin to obtain the window handle), the code would look something like this:

Code:
type:="innerText"
pwb:=iWeb_getWin("AutoHotkey Community - Mouse and Keyboard Macros and Hotkeys")
MsgBox % pwb.document.all.tags[table].item[4].rows[2].cells[1].(type)


But that produces nothing. How would I pass the type in the call the same way I pass it in the 'traditional' call?

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 1:02 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
sinkfaze wrote:
Code:
type:="innerText"
pwb:=iWeb_getWin("AutoHotkey Community - Mouse and Keyboard Macros and Hotkeys")
MsgBox % pwb.document.all.tags[table].item[4].rows[2].cells[1].(type)
Which build of AHK_L are you using? This code should produce a syntax error in older builds, and no syntax error with the latest build but I suppose the last call will be effectively COM_Release(). Use:
Code:
MsgBox % pwb.document.all.tags[table].item[4].rows[2].cells[1][type]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 10:04 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
sinkfaze wrote:
MsgBox % pwb.document.all.tags[table].item[4].rows[2].cells[1].(type)
If the documentation is inadequate, I am open to suggestions...

FYI, obj[anything] should be equivalent to COM_Invoke(obj,anything). Using [] indirectly calls COM_Invoke, but you can still call it directly with COM_L. However, I think that including the "dotted expression" in a string isn't supported in AutoHotkey_COM, and I don't intend to change this when I integrate it into AHKL.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 2:07 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Lexikos wrote:
However, I think that including the "dotted expression" in a string isn't supported in AutoHotkey_COM, and I don't intend to change this when I integrate it into AHKL.
BTW, I think I got completely wrong about aResultToken.marker of SYM_STRING. What allocator/deallocator (:seems to be malloc/free?) should I use to pass the result string? I directly passed the resultant BSTR's (and freed them shortly after), and it worked so far by pure chance, due to the caching of BSTR's by COM.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 11:02 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Sean wrote:
What allocator/deallocator (:seems to be malloc/free?) should I use to pass the result string?
Use TokenSetResult. If the string is <=MAX_NUMBER_LENGTH it uses a stack-allocated buffer which is passed to built-in functions via aResultToken.buf, so you must make sure that hasn't been overwritten. Otherwise it uses malloc and returns it via aResultToken.circuit_token and its length via aResultToken.buf. aResultToken.marker is set in both cases, but circuit_token tells ExpandExpression that malloc was used, and to free the memory later.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 10:37 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Lexikos wrote:
Use TokenSetResult.
Thanks, now I changed to use it.

AutoHotkey_COM Update: A new function ComObjType is added.

Code:
; ComObjType(ComObj, "name" / "iid")

obj := ComObjCreate("htmlfile")
MsgBox % ComObjType(obj, "name") " : " ComObjType(obj, "iid")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2010, 1:44 pm 
Hello AHK Community,

i'm searching a way to comunicate with my tool virtual dj.
On the plugin devloper site http://www.virtualdj.com/wiki/Developers.html stands,

"Plugins in VirtualDJ look a lot like COM objects, so any languages that can create COM objects can create a plugin for VirtualDJ (Visual Basic, C#, etc).
Still, we highly recommend to use C++, since that's the native language of the header files, and that's also the language in which you'll find all the help on the forums here."

But how can i communicate to the program over ahk?

On the SDK Site i have found a C++ Header file. That can be found on http://www.virtualdj.com/developers/vdjPlugin.h

I have seen in 2 Main mehtods to communicate and become callbacks

Code:

// callback functions to communicate with VirtualDJ
HRESULT (VDJ_API *SendCommand)(char *command,int deck); // send a command to VirtualDJ
HRESULT (VDJ_API *GetInfo)(char *query,void *result); // get infos from VirtualDJ


Is it possible to comunicatw over the ahk com.ahk to virtual dj?

Thx for your help


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 5:27 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Sean wrote:
And, although I also implemented COM error handling through a new ComError Object which is a singleton, I didn't include it either as, telling from the past experiences, most users didn't care about the error messages, even the error itself. If it's desirable, however, I'll include it.

... The concern is that we must keep minimal the size of newly added codes, otherwise, AHK can be easily bloated. So, codes which will be rarely used by few members better not be included. Nevertheless, as the error handling is very important I'll think about it again.

Just a thought, but how about having COM Error messages available throught the COM library. Then calling COM_Error(1) could turn this functionallity on. This shouldn't be too much trouble for users who know about & use the error messages.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 5:43 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
if im not mistaken jethrow thats already the case
i commonly turn errors on and off within scripts

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 5:52 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
I suppose I should clarify. I mean with AutoHotkey_COM, which currently doesn't display COM Error messages. We discussed this back on page 35. I tried putting COM_Error( 1 ) at the beginning of my script, but with AutoHotkey_COM, the COM Error message still doesn't display.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2010, 5:58 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
ah i see i didnt realise you were speaking of the ahk_com.exe
by sean

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2010, 1:08 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I haven't decided yet whether to include it or not. As you have to explicitly enable the error notification, through ComObjConnect(func_name), and write the error handling function yourself, I'm a little dubious about the usability of it, judging from the past experience on the average programming skills of the users in the forum.

For example, here is my own implementation. Err()/Err("") will turn on/off the error notification.
Code:
; ERR.ahk in lib subdirectory
err(err="err")
{
   if not   IsObject(err)
   return   ComObjConnect(err)
   MsgBox   4, COM Error, % "Name:`t" err.Name "`n" err.Number ":`t" err.Message "`nSource:`t" err.Source "`nDescription:`t" err.Description "`nHelp:`t" err.HelpFile "," err.HelpContext
   IfMsgBox  Yes,   ExitApp
}


jethrow wrote:
Just a thought, but how about having COM Error messages available throught the COM library. Then calling COM_Error(1) could turn this functionallity on. This shouldn't be too much trouble for users who know about & use the error messages.
That can be done, but you still have to have included the function already in the script, via any means, and the function name and its parameters should be aleady-agreed ones, possibly ComError(name, hr, pei) (:I don't think COM_Error is a good candidate and currently it can be leaking memory when error notification is turned off).


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 ... 34, 35, 36, 37, 38, 39, 40 ... 44  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 8 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