AutoHotkey Community

It is currently May 27th, 2012, 3:45 am

All times are UTC [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 156 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11  Next
Author Message
 Post subject:
PostPosted: August 22nd, 2007, 11:48 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2007, 9:45 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
.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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2007, 11:17 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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 August 23rd, 2007, 11:40 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2007, 11:28 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2007, 1:30 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2007, 3:42 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 8th, 2008, 3:42 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
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

_________________
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: January 9th, 2008, 1:20 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
or restated the question is what are the functions that can be usedis ther a list a definitions somewhere

_________________
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: January 21st, 2008, 7:53 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2008, 8:25 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
im familiar with vis basic :)
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)

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

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
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

_________________
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: January 22nd, 2008, 1:18 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2008, 2:58 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
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
:) :D

_________________
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 31st, 2008, 11:10 pm 
Offline

Joined: October 30th, 2008, 12:03 pm
Posts: 33
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: MMkeys.dll
PostPosted: July 30th, 2010, 3:38 pm 
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/wind ... mmkeysdll/


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 156 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11  Next

All times are UTC [ DST ]


Who is online

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