AutoHotkey Community

It is currently May 26th, 2012, 9:48 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1 ... 11, 12, 13, 14, 15, 16, 17 ... 44  Next
Author Message
 Post subject:
PostPosted: September 15th, 2008, 9:43 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
http://msdn.microsoft.com/en-us/library/ms678543.aspx
Quote:
CoInitialize
Initializes the COM library on the current thread and identifies the concurrency model as single-thread apartment (STA). Applications must initialize the COM library before they can call COM library functions other than CoGetMalloc and memory allocation functions.

New applications should call CoInitializeEx instead of CoInitialize.

Copy Code
HRESULT CoInitialize(
LPVOID pvReserved
);

Parameter
pvReserved

[in] Reserved; must be NULL.

Return Values
This function supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:

S_OK

The COM library was initialized successfully on this thread.

S_FALSE

The COM library is already initialized on this thread.

RPC_E_CHANGED_MODE

A previous call to CoInitializeEx specified the concurrency model for this thread as multithread apartment (MTA). If running Windows 2000, this could also mean that a change from neutral-threaded apartment to single-threaded apartment occurred.
I would like to test if COM is already initialized in one of my scripts but
Code:
COM_CoInitialize()
doesnt actually seem to return any value. Am i looking at this wrong?

_________________
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: September 16th, 2008, 12:04 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
tank wrote:
Code:
COM_CoInitialize()
doesnt actually seem to return any value.

It returns values as documented in my system.
Code:
S_OK    := 0
S_FALSE := 1


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2008, 8:30 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
sorry i am a ninja of stupidity
i meant to go back and delete my pprevious post as my problem was a script typo

_________________
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: September 21st, 2008, 8:02 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
ok now i have a genuine issue Sean i hope you can help
I am trying to loose using javascript fro many of my DOM based scripts

Code:
setDomObj(pwb,obj,t)
{
/*********************************************************************
pwb   -   iwebbrowser2 interface pointer
obj   -   object reference optionally a comma delimited list of references a name, id, or index of all value can be used
t   -   text to replace existing contents with optionally a comma delimited list of references a name, id, or index of all value can be used
example of useage
the below will take a browser object and try get an object called username and set its value or innerHTML to john
setDomObj(pwb,"username","john")
This will cycle thru objects username pass and 3 and set them in that order to john sam and paul
setDomObj(pwb,"username,pass,3","john,sam,paul")


*/
   If not pwb is Integer
      Return   "Error"
;~    http://msdn.microsoft.com/en-us/library/ms531073(VS.85).aspx# document object
   IID_IHTMLWindow2   :=   "{332C4427-26CB-11D0-B483-00C04FD90119}"
   pwin    := COM_QueryService(pwb,   IID_IHTMLWindow2,   IID_IHTMLWindow2)
   pdoc    := COM_Invoke(pwin,   "Document")
   If not pdoc is Integer
   {
      COM_Release(pdoc),   VarSetCapacity(pdoc,   0),   COM_Release(pwin),   VarSetCapacity(pwin,   0)
      Return   "Error"   
   }
   col      :=   COM_Invoke(pdoc,   "all")
;~    MsgBox   %   t
   StringSplit,tt,t,`,
   Loop,Parse,obj,`,
   {
      If   itm      :=   COM_Invoke(col,   "Item",   A_LoopField)   ;if this fails there really isnt any need to do below
      {
;~          http://msdn.microsoft.com/en-us/library/ms534657(VS.85).aspx tagname property
         typ      :=   COM_Invoke(itm,   "tagName")
         inpt   :=   "BUTTON,INPUT,OPTION,SELECT,TEXTAREA" ; these things all have value attribute and is likely what i need instead of innerHTML
         
         COM_Invoke(itm,   v   :=   InStr(inpt,   typ)   ?   "Value="   :   "innerHTML=",   tt%A_Index%   "`n")
;~          release and clear out any objects
         COM_Release(itm),   VarSetCapacity(itm,   0)
      }
      Else
      {
         COM_Release(itm),   VarSetCapacity(itm,   0),   COM_Release(col),   VarSetCapacity(col,   0),COM_Release(pdoc),   VarSetCapacity(pdoc,   0),   COM_Release(pwin),   VarSetCapacity(pwin,   0)
         Return   "Error " A_LoopField " is not a valid obj reference"
      }
   }
   COM_Release(col),   VarSetCapacity(col,   0),   COM_Release(pdoc),   VarSetCapacity(pdoc,   0),   COM_Release(pwin),   VarSetCapacity(pwin,   0)
   Return
}
It may be that i am mistaken but i fear not
If i pass any integer to variable t longer than 10 or 12 digits something happens to the value unless i send text also
so im guessing that there is some sort of max integer size that i can pass to arg0
but the whole numput and numget thing is still greek to me
Code:
COM_Invoke(itm,   v   :=   InStr(inpt,   typ)   ?   "Value="   :   "innerHTML=",   tt%A_Index%   "`n")
if i concatenate any text or other non integer characters no problem if i remove the concatenated text
I need to pas numbers as large as 64 bit to a datastore without concatenating any characters
Code:
COM_Invoke(itm,   v   :=   InStr(inpt,   typ)   ?   "Value="   :   "innerHTML=",   "1234567890123456") ; same problem comes out 1015724736 unless i concatenate some text

_________________
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: September 22nd, 2008, 12:21 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
tank wrote:
If i pass any integer to variable t longer than 10 or 12 digits something happens to the value unless i send text also

Yes, you can not pass integers outside the range of 32bit (signed/unsigned) integer to COM_Invoke. They will be truncated. Use COM_Invoke_ instead and pass it as string:
Code:
COM_Invoke_(itm, "Value=", VT_BSTR:=8, "1234567890123456")

Or if it doesn't matter you may pass it as floating number to COM_Invoke:
Code:
COM_Invoke(itm, "Value=", "1234567890123456.0")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2008, 5:46 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Perfect thanks

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Nulls
PostPosted: October 2nd, 2008, 1:06 pm 
Offline

Joined: November 14th, 2006, 7:49 pm
Posts: 15
I found a funny problem: retrieving null values from database.

I used ADO objects and just a traditional SELECT. I retrieved the value this way:
Code:
vValue := COM_Invoke(COM_Invoke(oRecordSet,"Fields","someColumn"),"Value")

If the real database value is null, vValue might become a 4-digit string. Sometimes it's zero.

I haven't tried the alternative COM_Invoke_() yet.

_________________
I recommend AutoIt instead of AHK.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2008, 1:37 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
amokoura wrote:
I found a funny problem: retrieving null values from database.

What do you want to get in case of NULL value? Currently the behavior for VT_NULL is undefined as there exists no similar concept in AHK (:I suppose COM_Invoke() will return 0 mostly, but it can be any (meaningless) 32bit unsigned integer).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2008, 6:44 pm 
Offline

Joined: November 14th, 2006, 7:49 pm
Posts: 15
Sean wrote:
What do you want to get in case of NULL value? Currently the behavior for VT_NULL is undefined

Thanks for reply. It's nice to hear the reason because I had really hard debuggings without a solution.
I guess an empty string would be the closest to null you can get in ahk.

_________________
I recommend AutoIt instead of AHK.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2008, 12:30 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
amokoura wrote:
Thanks for reply. It's nice to hear the reason because I had really hard debuggings without a solution.
I guess an empty string would be the closest to null you can get in ahk.

IMO the ideal solution is to make the variable vt Global by adding in COM_Invoke/COM_Invoke_
Code:
Global vt

and check first if vt is equal to VT_NULL ( := 1) when querying database.

I'll not do it to the official COM.ahk as many users don't like to have Global variables in standard libraries and in fact no need of it for COM_Invoke in most cases.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2008, 12:33 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
I think thats pretty unique i for one wouldnt mind it being added and i am a heavy user at least for ADO and IE purposes

_________________
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: October 3rd, 2008, 1:16 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
tank wrote:
I think thats pretty unique i for one wouldnt mind it being added and i am a heavy user at least for ADO and IE purposes

In that case, I may make it Global after renaming vt to COM_VT.
Any other opinions?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2008, 3:04 pm 
Offline

Joined: November 14th, 2006, 7:49 pm
Posts: 15
Sean wrote:
tank wrote:
I think thats pretty unique i for one wouldnt mind it being added and i am a heavy user at least for ADO and IE purposes

In that case, I may make it Global after renaming vt to COM_VT.
Any other opinions?


I'd like a null checking function like VB has: COM_IsNull(checkVariable).
Don't know if it's possible but then a global wouldn't be necessary?

_________________
I recommend AutoIt instead of AHK.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2008, 4:50 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
also great but if we are gonna go there and implement is.. tests perhaps we should do
Code:
COM_Is(test="NULL",variable)
then we could do "is numberic" or "is object" "is string" "is error" "is empty" etc certainly numeric is something arguably not needed and posibly ambiguous with is integer in ahk but numeric covers floats and integers in one test and separates numbers passed as a string from numbers as literals

_________________
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: October 4th, 2008, 12:33 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
amokoura wrote:
I'd like a null checking function like VB has: COM_IsNull(checkVariable).
Don't know if it's possible but then a global wouldn't be necessary?

No, it's not possible with AHK's current implementation of variables. VB's Variable is Variant, and what IsNull etc does is just to check the VT field of the variable/variant which is a piece of cake.


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 ... 11, 12, 13, 14, 15, 16, 17 ... 44  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg, Yahoo [Bot] and 12 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