AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1 ... 33, 34, 35, 36, 37, 38, 39 ... 44  Next
Author Message
 Post subject:
PostPosted: February 14th, 2010, 5:09 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I don't know why VB chose ~0 (:recall integer in VB is int16) as the true, but it happened. So, my recommendation in the early stage of COM.ahk was to use the string "true"/"false" as I was afraid that passing 1/0 (as VT_I4) might not work. And, I think I once encountered a case where actually passing 1 didn't work, only -1 did work. It should be in one of my scripts.

PS: Try HideCursor or AutoShow or Visible. Here it uses OATRUE/OAFALSE, which are -1/0 in VT_I4 (:OA stands for OLE Automation). Here passing 1 instead of -1 won't work.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2010, 1:23 pm 
Offline

Joined: June 20th, 2008, 12:40 pm
Posts: 47
The following line

Code:
pfi:=COM_Invoke(pfv,"Folder.ParseName",FolderName)


returns the wrong object reference when using a FolderName that is a digit and starts with zero, like these:
Code:
01
005
0123019023


In these cases, it returns the object references of the folders
Code:
1
5
123019023

if these exist, or '0' when folders of these names don't exist.

So I guess it's treating FolderName as int instead of char and therefore omits the zeros in front or something along those lines, but is there a way to get correct results the way COM_Invoke works atm?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2010, 1:34 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
majkinetor wrote:
If you want to do something, do it right. If compatibility can be achieved with that in mind its OK. If you have to redesign because of the old garbage it sucks because its soon becomes large set of special rules that those that are new to AHK can hardly follow (and as of this day AHK is full of them). Unicode version of AHK already broke compatibility badly IMO. Anything else apart from simple scripts must be converted. So, why not making it good now while opportunity is there.

quoted for truth

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2010, 4:15 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
maraskan_user wrote:
So I guess it's treating FolderName as int instead of char and therefore omits the zeros in front or something along those lines, but is there a way to get correct results the way COM_Invoke works atm?
Can you tell me whether the following is an integer or a string?
Code:
0x01234567

When in ambiguity, you have to clarify your intention. Pass them as a string, using COM_Invoke_ with AHK/COM, or using COM_Parameter with AHK_L/COM_L.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2010, 5:15 pm 
Offline

Joined: June 20th, 2008, 12:40 pm
Posts: 47
Sean wrote:
Can you tell me whether the following is an integer or a string?
Code:
0x01234567

When in ambiguity, you have to clarify your intention. Pass them as a string, using COM_Invoke_ with AHK/COM, or using COM_Parameter with AHK_L/COM_L.

The values given were supposed to be strings, I guess. They are the literal names of folders and were assigned to the variable FolderName as the output of
Code:
SplitPath,MyPath,FolderName,,,

I wasn't aware of the capability of COM_Invoke_ to specify type. From COM.ahk I could see that typ values like
Code:
8
0x400C
0x400E

get checked against, but didn't know what they meant, so started trying it with different values. As it happens,
Code:
pfi:=COM_Invoke_(pfv,"Folder.ParseName",8,FolderName)

gave the intended output.
Sean, thanks you for your help leading me into the right direction!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2010, 5:41 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Sean wrote:

I accidentally edited and deleted the original post. If there is a way to restore it, please let me know.

Here is the update. ComObjParameter is now included. I think now all absolutely necessary features are implemented. BTW, I highly discourage to abuse ComObjParameter as it's implemented with only very needed feature, i.e., named parameter is not included as it's not absolutely necessary, and passing a string via ComObjParameter is not supported either as passing a string is a piece of cake inside the engine of AHK.

Example of ComObjParameter:
Code:
MsgBox, % ShellDesktop()
Return

ShellDesktop()
{
   ControlGet, hWnd, hWnd,, SysListView321, ahk_class Progman   ; WorkerW (for Win7)
   If not   pacc := COM_AccessibleObjectFromWindow(hWnd)
   Return

   oAcc := ComObjEnwrap(COM_Unwrap(pacc))
   Loop, % COM_AccessibleChildren(pacc, oAcc.accChildCount, varChildren)
   If   NumGet(varChildren,(A_Index-1)*16)=3 && idChild:=NumGet(varChildren,A_Index*16-8)
   {
      sResult   .="[" A_Index "]`n"
         . "Name:`t" oAcc.accName(idChild) "`n"
         . "(l,t,r,b):`t" oAcc.accLocation(ComObjParameter(0x4003,&l:=0), ComObjParameter(0x4003,&t:=0), ComObjParameter(0x4003,&w:=0), ComObjParameter(0x4003,&h:=0), idChild)
         . "(" (l:=NumGet(l,0,"int")) "," (t:=NumGet(t,0,"int")) "," l+NumGet(w) "," t+NumGet(h) ")`n"
   }

   Return   sResult
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2010, 6:05 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Just to be sure, the last example is compatible only with the UNICODE version of COM_L?

EDIT: To clarify I can't run your above example by itself, I get this error:

Code:
Error: Call to nonexistent function.

Specifically: COM_Unwrap(pacc))

   Line#
   013: SetWorkingDir,%A_ScriptDir%
   016: MsgBox,ShellDesktop()
   017: Return
   020: {
   021: ControlGet,hWnd,hWnd,,SysListView321,ahk_class Progman
   022: if not   pacc := COM_AccessibleObjectFromWindow(hWnd)
   023: Return
--->   025: oAcc := ComObjEnwrap(COM_Unwrap(pacc))
   026: Loop,COM_AccessibleChildren(pacc, oAcc.accChildCount, varChildren)
   027: if NumGet(varChildren,(A_Index-1)*16)=3 && idChild:=NumGet(varChildren,A_Index*16-8)
   028: {
   029: sResult   .="[" A_Index "]
" . "Name:   " oAcc.accName(idChild) "
" . "(l,t,r,b):   " oAcc.accLocation(ComObjParameter(0x4003,&l:=0), ComObjParameter(0x4003,&t:=0), ComObjParameter(0x4003,&w:=0), ComObjParameter(0x4003,&h:=0), idChild) . "(" (l:=NumGet(l,0,"int")) "," (t:=NumGet(t,0,"int")) "," l+NumGet(w) "," t+NumGet(h) ")
"
   033: }
   035: Return,sResult
   036: }

The program will exit.
---------------------------
OK   
---------------------------


It only seems to work if I include the UNICODE version of COM_L; the ANSI version of COM_L produces a blank message box.

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 1:06 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
It's based on UNICODE build of AutoHotkey_L, it was on the original post. Now COM.ahk is not necessary although I called functions in it for simplicity, you can just copy-and-paste the needed functions from it. As a matter of fact, mixing ComObjEnwrap/ComObjUnwrap and COM_Enwrap/COM_Unwrap is rather unsafe, so better be discouraged.

As I didn't back-up the original post, here is again a summary of new functions.
Code:
ComObjCreate(ProgId/CLSID)
ComObjGet(name)
ComObjConnect(ComObj [, prefix]) ; will be Disconnect if prefix is omitted

; Active is polymorphic below
ComObjActive(ProgId/CLSID)
ComObjGetActive(ProgId/CLSID)
ComObjEnwrap(pdisp)
ComObjUnwrap(ComObj)
ComObjParameter(vt, val)
... ; any other form like ComObject(pdisp) etc


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 1:33 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Havent tested this out as well as i would like but so far pretty frakkin cool

_________________
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: February 16th, 2010, 2:20 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
tank wrote:
Havent tested this out as well as i would like but so far pretty frakkin cool
Thanks. when you have a time, please give it a shot.

UPDATE: A bug is fixed which will crash AHK by allowing NULL pointer to be assigned to the return string.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 2:35 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
not extensive testing but it seems to perform a bit faster
what i used to attribute to slowness opening an IE window to IE for instance almost a consistant second difference?
doesnt make any sense to me but then i havent compared with ahk_u so it may be the built in unicode support making the difference

one more thing
it FEELS so much more natural to write code in with COM built in

_________________
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: February 17th, 2010, 1:00 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Exactly how are you measuring the difference? I assumed that you started measuring the time at the start of the auto-execution section. One of the major difference is that now COM library is always initialized at the initializing stage of the script, i.e., before entering the auto-execution section. It can be one of the major factors for the difference.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2010, 1:36 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
that coould be it yes i was simply measuring by tickcount

_________________
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: February 20th, 2010, 1:05 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
AutoHotkey_COM Update: VariantToToken is separated into VariantToToken and AssignVariant internally.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2010, 12:53 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
I have started a collection of libraries for redestributing to the community. My only problem is, I dont know the license of this library. Would you specify any license for this? Even if it is public Domain, I need an explicit statement to this. I would like to see an official revision number also.

Is a redistribution allowed? And what should I assume at libraries where the license is not known?

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg and 10 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