[futurebasic] re: Layer Manager

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 1999 : Group Archive : Group : All Groups

From: Jamin <benjamen@...>
Date: Tue, 17 Aug 1999 07:39:30 +1000
I am behind in this thread, so excuses the quotes from different messages...

> Can I use the Layer Manager in an extension? Since the Layer Manager was
> dropped by Apple, mabye it isn't the way to go (?). I have been advised
> to use the Window Manager (WindowPeek) to find my window. However, I also
> need to get a PSN (Process Serial Number) to the window's application.
> Without this PSN, I can't bring the application to the foreground. Does
> anyone have any recommendations?

If you can get anything to work from a _scripting_ extension 'osax', you are a smarter man than I :-).  The Layer Manager was never dropped by Apple because it never exisited, it is just what Apple themselves used to do tricky stuff.  I suggest you look for the window that you want to 'fiddle' with by using the jGNE code.  Just look for a WindowRefresh event, grab the Window pointer from the event record, and peek a look at its title/name.  If its "Untitled 1", and the _currApName contains "SimpleText", then you are probarly safe to send it a Window Close message.

If you really want to use the LayerManager, then put everything into a background only app.  Then from AppleScript, it is an easy job to send an 'open' to the background app, then send it another custom AppleEvent to return  you the Front Process and its respective Windows.  This works for me (At least up to 8.5.1).

> You can use the layer manager in an extension, but you can't use a
> DCOD (or other external resources). Extensions are completely self
> contained and don't use their own resources after they load and
> detach themselves. Course I could be wrong on that, but its not easy
> so far as I remember.

If you really want to go down this path, then manually load the DCOD resource, detach it, dereference it, copy to a new sysheap pointer, and remember that address.  Then you can just do a JSR to it (with the stack all organized) (Don't you love that massive gloss-over).  Beacuse it is undocumented, assume it moves memory.  ..and I love Mel's quote, so I'll put it in again:

> ...but its not easy so far as I remember.

>  When Apple
> discontinues a project, they usually leave an alternative, so I bet there
> is a way to get a PSN from a window record... Or to get a list of windows
> from a PSN. However, I'm clueless.

Remember, _not_ discontinued, it was an X-File to start with.  A Window record is a Layer record. The specific layer data (PSN etc) lives in the refcon field.

You might want to take a look at KeyQuencer, it can do all this sort of thing, and best of all, you can send it an AppleEvent with scripts like:

SwitchApp "SimpleText"
Menu "File" "Save As" partial
WaitWindow dialog 60 seconds
Button "Save"
WaitWindow dialog 10 seconds continue
Button "Replace"
WaitWindow dialog 10 seconds continue
Button "OK"