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 Helper
Goto page Previous  1, 2, 3 ... , 9, 10, 11  Next
 
This topic is locked: you cannot edit posts or make replies.    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed Aug 22, 2007 10:48 pm    Post subject: Reply with quote

Titan wrote:
I like the updates, Invoke() and ActiveXObject() will make things a lot easier. Could you also add garbage collection during uninitialization so we don't have to manually release each object.

Release() is for garbage collection in COM. How is it in .NET?
BTW, although I've never confirmed it in an official source, I think only calling CoUninitialize() would be enough in most cases when exiting the script. I even suspect CoUninitialize() is neither necessary, just for a graceful exit.
All resources allocated by the process will be freed when the process is terminated anyway.

The cases it would cause memory leakage etc may be when the COM servers reside in other processes, like InternetExplorer and Excel. However, those COM objects usually have a method Quit which terminates the process it resides. So, call Quit() additionally for the remote COM server when it's no longer needed.
Back to top
View user's profile Send private message
polyethene



Joined: 11 Aug 2004
Posts: 5248
Location: UK

PostPosted: Thu Aug 23, 2007 8:45 am    Post subject: Reply with quote

.NET does it automatically. There is a manual obj.Dispose() method however I think the host can often ignore such instructions for performance reasons.

Speaking of which I noticed that my COM routines are like 5-10 times slower than they should be. One reason for this could be because you use variable addresses and NumGet() numerous times when it would be more practical to cache them first instead. I know this may not seem important but when these few extra milliseconds add up to minutes it becomes a problem. Do you ever plan to optimize at least parts of your script? I'm willing to help if it's too much.
_________________
GitHubScriptsIronAHK Contact by email not private message.
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: Thu Aug 23, 2007 10:17 am    Post subject: Reply with quote

Titan wrote:
Speaking of which I noticed that my COM routines are like 5-10 times slower than they should be. One reason for this could be because you use variable addresses and NumGet() numerous times when it would be more practical to cache them first instead. I know this may not seem important but when these few extra milliseconds add up to minutes it becomes a problem. Do you ever plan to optimize at least parts of your script? I'm willing to help if it's too much.

I'm not so sure if I have to optimize the code. As I usually don't comment the script, I try to leave it at least follow-able. So, I adopt the long name as it is and/or keep the indirections like introducing new variables minimal etc. And, more importantly, I never felt the slow-down of the procedures myself, even with the current Invoke() function, which made me rather surprised. I didn't, and still not quite, like the Invoke() function as it requires too many indirections.

Anyway, looks like you're dealing with huge database or alike. If so, I'd rather code in VTBL interface than in DISPATCH interface.


Last edited by Sean on Thu Aug 23, 2007 10:40 am; edited 1 time in total
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Thu Aug 23, 2007 10:28 am    Post subject: Reply with quote

Titan wrote:
.NET does it automatically. There is a manual obj.Dispose() method however I think the host can often ignore such instructions for performance reasons.

BTW, how does .NET make a decision whether the object should be cleaned or not?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Thu Aug 23, 2007 12:30 pm    Post subject: Reply with quote

From the GC Class page on MSDN:
Quote:
Periodically, the garbage collector performs garbage collection to reclaim memory allocated to objects for which there are no valid references. Garbage collection happens automatically when a request for memory cannot be satisfied using available free memory. Alternatively, an application can force garbage collection using the Collect method.
Usually only objects that implement IDisposable have the Dispose() method. It is used to release unmanaged resources (this has to be explicitly coded into the class), and does not actually delete/garbage-collect the object.

The IDisposable Interface page on MSDN has a (kind of) explanation:
Quote:
The garbage collector automatically releases the memory allocated to a managed object when that object is no longer used, however, it is not possible to predict when garbage collection will occur. Furthermore, the garbage collector has no knowledge of unmanaged resources such as window handles, or open files and streams.

Use the Dispose method of this interface to explicitly release unmanaged resources in conjunction with the garbage collector. The consumer of an object can call this method when the object is no longer needed.
(Also note the bit in bold; I guess garbage collection also happens at other unpredictable intervals.)

Dispose() is usually called by the finalizer (~Classname() in C# or Finalize() in VB), though iirc this is up to the programmer.
MSDN: Finalize Method wrote:
Application code should not call this method; an object's Finalize method is automatically invoked during garbage collection, unless finalization by the garbage collector has been disabled by a call to the SuppressFinalize method.
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Thu Aug 23, 2007 2:42 pm    Post subject: Reply with quote

IMO, garbage collection is ilusional thing here.

You can't compare C#'s GC or any other with some ideas about that in AHK.

Furthermore, it would be very hard to design such GC taking into account poor AHK capabilities comparing to mainstreem langauges.
_________________
Back to top
View user's profile Send private message
tank



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

PostPosted: Tue Jan 08, 2008 2:42 pm    Post subject: Reply with quote

I am trying to understand, and forgive me here
on the invoke function
what are the values possible for "sName"
or perhaps you can point me at a good source of documentation for a noob such as myself
_________________

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
tank



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

PostPosted: Wed Jan 09, 2008 12:20 am    Post subject: Reply with quote

or restated the question is what are the functions that can be usedis ther a list a definitions somewhere
_________________

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
Joy2DWorld



Joined: 04 Dec 2006
Posts: 561
Location: Galil, Israel

PostPosted: Mon Jan 21, 2008 6:53 pm    Post subject: Reply with quote

something like this may help you see what's going on ..:

think of the OBJECT, PROPERTY, METHOD, etc.. invoked upon the referenced object/property/method pointer...

Take a look at some MS visual basic doc to get a feel of how that all works.


It is essentially the same as Java, so that doc would help explain as well...



or...


everything is an object,

and you can invoke an object's property, or perform a method upon the object, etc....
_________________
Joyce Jamce
Back to top
View user's profile Send private message
tank



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

PostPosted: Mon Jan 21, 2008 7:25 pm    Post subject: Reply with quote

im familiar with vis basic Smile
the things im getting lost on are in some cases its been used with "execscript"
Never seen anything like that in vb
"Navigate" i understand
"execscript" well this is a void to me
such usage i have seen in ahklerners script
Code:

COM_Invoke(pwin, "execscript", JS_to_Inject)

_________________

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
tank



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

PostPosted: Mon Jan 21, 2008 7:29 pm    Post subject: Reply with quote

ding dong call me an idiot i swear i had a bone head moment when i looked before i found that method now it was un familiar to me
_________________

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
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Tue Jan 22, 2008 12:18 am    Post subject: Reply with quote

I'm not sure what that last post was supposed to mean, but if you just google "execScript", the very first link should take you to its documentation.
Quote:
Executes the specified script in the provided language.
Back to top
View user's profile Send private message Visit poster's website
tank



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

PostPosted: Wed Jan 23, 2008 1:58 pm    Post subject: Reply with quote

yea like i said i found it this time when i searched
sorry for the idiots confusion
i mean just look at the big idiot sign on my forhead
Smile Very Happy
_________________

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
weiterbilder



Joined: 30 Oct 2008
Posts: 33

PostPosted: Fri Oct 31, 2008 10:10 pm    Post subject: Reply with quote

How to translate these delphi-lines

Code:
Uses ComObj;
-
Procedure TForm1.BtTestClick(Sender: TObject);
Var rec : Variant;
Begin
    // Create instance
    rec:= CreateOleObject('HBDao.HB_Recordset');
    -

Code:
Uses HbDAO_TLB;
-
Procedure TForm1.BtTestClick(Sender: TObject);
Var rec : THB_Recordset;
Begin
    // Create instance


    rec:= THB_RecordSet.Create(Self);
    -
End;

Code:
Uses ComObj;

Procedure TForm1.BtTestClick(Sender: TObject);
Var rec : Variant;
Begin
    // Create instance
    -

    // Open table
    rec.OpenTable('ZZZZ_MyTable.pdb', 'MyTable.hbx');

    // Use table
    -

    // Close table
    rec.Close;
End;

Code:
Uses ComObj;

// Table DIGEST
// This constant is generated by HB++
// Menu TABLE->Generate Table Digest
// and represent HBX table format
Const csMyTableDigest = 'fnyzGYung=a7eoi=NbnCknjiBgtGglXJBi3YoCUSvIVMcu';
-
Procedure TForm1.BtTestClick(Sender: TObject);
Var rec : Variant;
Begin
    // Create instance
    -

    // Open table
    rec.OpenTable('ZZZZ_MyTable.pdb', csMyTableDigest);

    // Use table
    -

    // Close table
    rec.Close;
End;

Code:
Uses ComObj;
-

// Table DIGEST
-

Procedure TForm1.BtTestClick(Sender: TObject);
Var rec : Variant;
Begin
    // Create instance
    -

    // Open table
    -

    // Use table
    rec.Field['Name'] := 'Kevin S';// To modify a String
    rec.Field['Age'] := 33;// To modify a numeric field
    rec.Field['BirthDate'] := Now;   // To modify a Date
    ShowMessage rec.Field['Name'] + ' (' + rec.Field['BirthDate'] + ')';   // To Read a value

    // Close table
    -
end;


Into AHK using CoHelper?
Back to top
View user's profile Send private message
dcornel
Guest





PostPosted: Fri Jul 30, 2010 2:38 pm    Post subject: MMkeys.dll Reply with quote

What your trying to do is use a mutimedia keyboard to control itunes when itunes is not the primary appliation in focus. Everything you want to know can be found here
http://www.everythingitunes.com/os/windows/2008-01-04/mmkeysdll/
Back to top
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies.    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... , 9, 10, 11  Next
Page 10 of 11

 
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