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 ... 35, 36, 37 ... 42, 43, 44  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sun Feb 14, 2010 4:09 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
maraskan_user



Joined: 20 Jun 2008
Posts: 47

PostPosted: Sun Feb 14, 2010 12:23 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Sun Feb 14, 2010 12:34 pm    Post subject: Reply with quote

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! <--
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sun Feb 14, 2010 3:15 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
maraskan_user



Joined: 20 Jun 2008
Posts: 47

PostPosted: Sun Feb 14, 2010 4:15 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Mon Feb 15, 2010 4:41 pm    Post subject: Reply with quote

Sean wrote:
DOWNLOAD AutoHotkey_COM

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
}
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Mon Feb 15, 2010 5:05 pm    Post subject: Reply with quote

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.
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Tue Feb 16, 2010 12:06 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Tue Feb 16, 2010 12:33 am    Post subject: Reply with quote

Havent tested this out as well as i would like but so far pretty frakkin cool
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Tue Feb 16, 2010 1:20 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Tue Feb 16, 2010 1:35 pm    Post subject: Reply with quote

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
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed Feb 17, 2010 12:00 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Wed Feb 17, 2010 12:36 am    Post subject: Reply with quote

that coould be it yes i was simply measuring by tickcount
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Sat Feb 20, 2010 12:05 am    Post subject: Reply with quote

AutoHotkey_COM Update: VariantToToken is separated into VariantToToken and AssignVariant internally.
Back to top
View user's profile Send private message
Tuncay



Joined: 07 Nov 2006
Posts: 1886
Location: Germany

PostPosted: Sun Feb 21, 2010 11:53 am    Post subject: Reply with quote

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! <--
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 35, 36, 37 ... 42, 43, 44  Next
Page 36 of 44

 
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