AutoHotkey Community

It is currently May 27th, 2012, 1:49 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1 ... 31, 32, 33, 34, 35, 36, 37 ... 44  Next
Author Message
 Post subject:
PostPosted: January 10th, 2010, 2:57 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Lexikos wrote:
Sean, would you mind making COM_SysString an alias for COM_Unicode4Ansi in COM_L? It would make supporting COM_L and COM_U together easier. Actually, might be a good idea to add it to COM.ahk as well...
That should be very easy with COM_L, I'll probably make COM_Unicode4Ansi be an alias for COM_SysString. It may be also straightforward to do for COM.ahk for the official AHK, however, I deliberately stopped updating it to leave it inferior to COM_L/COM_U. But as the incorporation of AHK_L/AHK_U/Native COM support into the official build is indefinitely delayed without any mention from Chris about the future plan, I think I have to update it too.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2010, 1:02 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
A new function COM_SysString is added to COM_L/COM.ahk.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 20th, 2010, 12:21 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Just thought I'd report back on this one, Sean. There seemed to be multiple causes for the stall in COM_Invoke. Some of them were solved by adding Critical to the hotkeys, but I also found that IEReady() was colliding with a subsequent call to click a button once the page was loaded. I replaced the IEReady calls with one of the old readyState complete functions and now those hotkeys work fine.

I also found another bizarre instance, I've been using COM to generate an auto-populated Outlook email. The final line I used to display the email:

Code:
COM_Invoke(NewMail,"display",true)


Had caused no problems up until recently when it began running into the stall. I toyed around and found that if I deleted the true parameter that it would work fine:

Code:
COM_Invoke(NewMail,"display")


But before I found that out I toyed with some of the other lines in my code and found that if I condensed this code:

Code:
   Outlook:=COM_CreateObject("Outlook.Application")
   MailItem:=COM_CreateObject("Outlook.MailItem")
   NewMail:=COM_Invoke(Outlook,"CreateItem",MailItem)


Down to this:

Code:
   NewMail:=COM_Invoke(COM_CreateObject("Outlook.Application"),"CreateItem",COM_CreateObject("Outlook.MailItem"))


It would decrease the stall to a few seconds and finally complete, but it would not eliminate the stall entirely. I have no idea how one chunk of code decreases the stall and the other one eliminates it, but I thought I'd put it out there for you to peruse if you're interested.

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 20th, 2010, 6:18 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
sinkfaze wrote:
There seemed to be multiple causes for the stall in COM_Invoke.
No, all are rooted from one: AHK, especially GUI stuffs, will be irresponsive until return a com call to out-of-process servers like IE, Excel, etc. So:
1) do the best so that a call will be completed as soon as possible.
2) don't call ones which will be waiting indefinitely unless being prepared to programatically handle those yourself, like creating modal dialogs etc.
3) never screw up the chronological order, i.e., don't allow the call interrupted while being executed, like you did in your last post. It's highly likely to create nicely a dead lock.

Quote:
Code:
COM_Invoke(NewMail,"display",true)
It'll create a modal window. See 2).

Quote:
Code:
NewMail := COM_Invoke(COM_CreateObject("Outlook.Application"), "CreateItem", COM_CreateObject("Outlook.MailItem"))
Both the previous and this calls are wrong.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2010, 12:14 am 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
likely AHK is releasing for other processes thus 'stall' you see. Try setting batch lines to -1, etc.

(not tested)

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2010, 6:19 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
I'm trying to call a function from a registered txtrocx.dll (activeX dll).
Code:
; Documented VB example
; TxtrCtl1.Dest = C:\results.dat
COM_Init()
msgbox % value := COM_Invoke(TxtrCtl1, "Dest", "C:\results.dat")

I'm getting
Quote:
Function Name: "Dest"
ERROR: The COM Object may not be a valid Dispatch Object!
First ensure that COM Library has been initialized through COM_Init().
()

Will Continue?
Any ideas of why this is?

The ultimate goal is to be able to wrap all of the functions from the activeX control.

Thanks for any help.

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 26th, 2010, 6:56 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
You must first create an object
perhaps something like this
Code:
COM_init()
TxtrCtl1:=COM_CreateObject("txtrctl.txtrctl.1")
msgbox % value := COM_Invoke(TxtrCtl1, "Dest", "C:\results.dat")
not having or feeling like looking for any documentation on this DLL the above is a best guess and makes the assumption that Dest is avail directly to the base object

_________________
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 5th, 2010, 9:33 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Sean - since the primary AHKL release is now Unicode, do you plan on changing the names of the COM_L & COM_U libraries to avoid confusion? ( Or merge the two? )

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2010, 2:13 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
OK, I merged COM_L and COM_U into COM_L. There exist two subdirectories, ANSI and UNICODE.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 8:28 am 
Offline
User avatar

Joined: October 18th, 2008, 2:09 pm
Posts: 429
I'm looking for a way to auto-detect if connection to a certain network is made, after some looking around I thought maybe I could use COM and iSensNetwork (found here: http://msdn.microsoft.com/en-us/magazine/cc301850.aspx) to do what I want, but it's a bit above my current level of coding.

Am I barking up the wrong tree?

I've been doing the auto-detect by just doing a run command for ipconfig and read the output, but that has problems of its own :S

Hope you can (and will) help me.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 11:50 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Sean wrote:
Both the previous and this call are wrong.


I realized just how right you were when I was trying to troubleshoot this again today. I read a bit deeper into the VB reference and found I was taking a bizarre route to create a mail item when this was all I needed:

Code:
ol:=COM_GetActiveObject("Outlook.Application")
NewMail:=COM_Invoke(ol,"CreateItem",0) ; 0 is Outlook constant 'olMailItem'


I also resolved the problem with the errors associated with invoking the Display method; I needed to retrieve the Inspector object associated with the new mail item:

Code:
NewMail:=COM_Invoke(NewMail,"GetInspector")
COM_Invoke(NewMail,"Display")


One thing I haven't figured out is why retrieving the Inspector object for the new mail item prevents you from invoking the Send method. If I bypass retrieval of the Inspector object I can send the mail straight away without any warnings.

Thanks again for your help, Sean.

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


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

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Maestr0 wrote:
I thought maybe I could use COM and iSensNetwork
It's outside the scope of COM.ahk, although all needed ingredients for it are already in COM.ahk. You may try to adopt the functions in COM.ahk COM_CreateIDispatch/COM_DispInterface to your need.


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

Joined: October 18th, 2008, 2:09 pm
Posts: 429
Sean wrote:
Maestr0 wrote:
I thought maybe I could use COM and iSensNetwork
It's outside the scope of COM.ahk, although all needed ingredients for it are already in COM.ahk. You may try to adopt the functions in COM.ahk COM_CreateIDispatch/COM_DispInterface to your need.


Cool, thanks for the information.

Could you give me a working example? That would help me tremendously.
How would I find the pdisp required for those functions?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2010, 6:01 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Encouraged by this post, I tried to incorporate COM into AHK myself. It was my first coding in C++, so there could be many I missed/got wrong. It's based on (UNICODE) AutoHotkey_L45 and I also included the altered/new files in the zip.

DOWNLOAD AutoHotkey_COM.

The new functions are:
Code:
ComObjActive(ProgId/CLSID [/pdisp/ComObject]) ; <-> COM_GetActiveObject() [/COM_Enwrap()/COM_Unwrap()]
ComObjCreate(ProgId/CLSID) ; <-> COM_CreateObject()
ComObjGet(name) ; <-> COM_GetObject()
ComObjConnect(ComObject [ , prefix]) ; <-> COM_ConnectObject()/COM_DisconnectObject()

Not all in COM.ahk were translated yet like COM_Parameter/missing params. And instead of producing MsgBox, Invoke will assign its HRESULT to A_LastError, so an user can handle the error himself.

The most notable syntax change was on Enumerate and Connect to event. Now I'd like to demonstrate only about Enumerate, and later for others.

Example: Enumerate
Code:
oSet :=   ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_PhysicalMemory")

oEnum := oSet._NewEnum
While   oEnum[obj]
   MsgBox,   % obj.GetObjectText_


Last edited by Sean on March 10th, 2010, 1:17 am, edited 3 times in total.

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

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Thats great. I don't use COM much, but that will change if it gets into AHKL.

Thx for your work.

_________________
Image


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: oldbrother 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