Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Help: Effecting Keyboard keydown programatically (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: App for Adding Resources to Mac Bundle
Next thread: Re: RB thread "paused" whenever a GUI action such as window dragging or resize occurs - sign on to FR here...


FW: Special Valentine's Offer for Valentina - Beat the Price Increase!   -   Lynn Fredricks
  Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
   Re: Help: Effecting Keyboard keydown programatically   -   Sascha Schneppmueller
   Re: Help: Effecting Keyboard keydown programatically   -   joe strout.net
    Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
     Re: Help: Effecting Keyboard keydown programatically   -   Roger Clary
     Re: Help: Effecting Keyboard keydown programatically   -   Terry Ford
      Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
       Re: Help: Effecting Keyboard keydown programatically   -   Roger Clary
        Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
         Re: Help: Effecting Keyboard keydown programatically   -   Roger Clary
          Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
         Re: Help: Effecting Keyboard keydown programatically   -   Terry Ford
          Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
           Re: Help: Effecting Keyboard keydown programatically   -   Roger Clary
            Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
           Re: Help: Effecting Keyboard keydown programatically   -   Terry Ford
            Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
         Re: Help: Effecting Keyboard keydown programatically   -   joe strout.net
          Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
          Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
           Re: Help: Effecting Keyboard keydown programatically   -   Roger Clary
           Re: Help: Effecting Keyboard keydown programatically   -   Arnaud Nicolet
            Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
             Re: Help: Effecting Keyboard keydown programatically   -   Arnaud Nicolet
              Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
               Re: Help: Effecting Keyboard keydown programatically   -   Arnaud Nicolet
                Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
                 Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
                  Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
           Re: Help: Effecting Keyboard keydown programatically   -   joe strout.net
            Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob
             Re: Help: Effecting Keyboard keydown programatically   -   joe strout.net
              Re: Help: Effecting Keyboard keydown programatically   -   Lennox Jacob

Help: Effecting Keyboard keydown programatically
Date: 03.08.07 05:53 (Thu, 2 Aug 2007 21:53:54 -0700 (PDT))
From: Lennox Jacob
Hello,

I am using f.launch to launch a file, works great.

Now I want to save that file so I want to programatically effect a Keyboard Command-S combination programatically, how do I do that?

Or in the launched app (myApp) it has a Save Pushbutton how can I effect that SavePushbutton.Push action?

Thanks.

Lennox.

---------------------------------
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 11:13 (Fri, 3 Aug 2007 12:13:53 +0200)
From: Sascha Schneppmueller
I have no RB at hand right now...
I think you can archive this by using the "KeyDown" Event of the Window
which holds the Button.

2007/8/3, Lennox Jacob <<email address removed>>:
>
> Hello,
>
> I am using f.launch to launch a file, works great.
>
> Now I want to save that file so I want to programatically effect a
> Keyboard Command-S combination programatically, how do I do that?
>
> Or in the launched app (myApp) it has a Save Pushbutton how can I effect
> that SavePushbutton.Push action?
>
> Thanks.
>
> Lennox.
>
> ---------------------------------
> Building a website is a piece of cake.
> Yahoo! Small Business gives you all the tools to get online.
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 15:04 (Fri, 3 Aug 2007 08:04:00 -0600)
From: joe strout.net
On Aug 03, 2007, at 04:53 UTC, Lennox Jacob wrote:

> I am using f.launch to launch a file, works great.
>
> Now I want to save that file so I want to programatically effect a
> Keyboard Command-S combination programatically, how do I do that?

You mean, you want the other app (the one that was launched) to save
the file? If so, then certainly not by spoofing a keyboard press.
Instead, you should use an AppleScript, if the app is scriptable. If
it's not, you could try a "save" AppleEvent, but that may not work
either... at which point, it may be time to contact the author of that
app and talk about some rudimentary scripting support.

> Or in the launched app (myApp) it has a Save Pushbutton how can I
> effect that SavePushbutton.Push action?

No, but if this is an app you're writing, there are a zillion proper
ways to do it -- supporting a "save" AppleEvent might be the
best/easiest, but you could also use IPCSockets, or full-blown
AppleScript support.

Best,
- Joe

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 15:23 (Fri, 3 Aug 2007 07:23:54 -0700 (PDT))
From: Lennox Jacob
<email address removed> wrote:

You mean, you want the other app (the one that was launched) to save
the file? If so, then certainly not by spoofing a keyboard press.
Instead, you should use an AppleScript, if the app is scriptable. If
it's not, you could try a "save" AppleEvent, but that may not work
either... at which point, it may be time to contact the author of that
app and talk about some rudimentary scripting support.
Thanks Joe,

Yes, I am the author of both apps.

I know I have to do something like myApp.myMainWindow.SavePushbutton.push, but how do I call it?
I have

Dim w As window
Dim i As integer
Dim myApp As Application
w = myMainWindow
for ito WindowCount-1 'We will loop through open windows
w= myMainWindow(i) 'The "ith" window.
if w isA myMainWindow then
myMainWindow.SaveAsPushButton.push
end if
next

Any help with the above code (which I think may work) or any other suggestions?

Thanks.

Lennox

---------------------------------
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 15:52 (Fri, 3 Aug 2007 10:52:35 -0400)
From: Roger Clary

On Aug 3, 2007, at 10:23 AM, Lennox Jacob wrote:

> You mean, you want the other app (the one that was launched) to save
> the file? If so, then certainly not by spoofing a keyboard press.
> Instead, you should use an AppleScript, if the app is scriptable. If
> it's not, you could try a "save" AppleEvent, but that may not work
> either... at which point, it may be time to contact the author of that
> app and talk about some rudimentary scripting support.
> Thanks Joe,
>
> Yes, I am the author of both apps.
>
> I know I have to do something like
> myApp.myMainWindow.SavePushbutton.push, but how do I call it?
> I have
>
> Dim w As window
> Dim i As integer
> Dim myApp As Application
> w = myMainWindow
> for ito WindowCount-1 'We will loop through open windows
> w= myMainWindow(i) 'The "ith" window.
> if w isA myMainWindow then
> myMainWindow.SaveAsPushButton.push
> end if
> next

If I understand you correctly, you want App A to call f.launch on a
file which will then open in App B and you then want App B to save
that file.
If so, it appears you are trying to control App B from App A. The
only way to do that is through an AppleScript as Joe mentioned. You
can't get at App B by just calling myApp.myMainwindow... etc from App A
Apologies if I have completely misunderstood the situation


Roger M. Clary
Class One Software
http://www.classonesoftware.com
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 16:00 (Fri, 03 Aug 2007 08:00:48 -0700)
From: Terry Ford

On Aug 3, 2007, at 7:52 AM, Roger Clary wrote:

> If I understand you correctly, you want App A to call f.launch on a
> file which will then open in App B and you then want App B to save
> that file.
> If so, it appears you are trying to control App B from App A. The
> only way to do that is through an AppleScript as Joe mentioned. You
> can't get at App B by just calling myApp.myMainwindow... etc from
> App A
> Apologies if I have completely misunderstood the situation

I think that is what he wants to do. To boot, he wants to be able to
do this on Windows as well.

Terry

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 18:31 (Fri, 3 Aug 2007 10:31:36 -0700 (PDT))
From: Lennox Jacob
Hi Joe, Roger and Terry and Sacha,

Yes that is exactly what I want to do, but I only want to do it on Mac.
I would appreciate the help in Applescript, since I have no experience in Applescript.

Thanks again.

Lennox.

Terry Ford <<email address removed>> wrote:
I think that is what he wants to do. To boot, he wants to be able to
do this on Windows as well.

---------------------------------
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 18:36 (Fri, 3 Aug 2007 13:36:08 -0400)
From: Roger Clary

On Aug 3, 2007, at 1:31 PM, Lennox Jacob wrote:

> Yes that is exactly what I want to do, but I only want to do it on
> Mac.
> I would appreciate the help in Applescript, since I have no
> experience in Applescript.
>
> Thanks again.
>
> Lennox.
>
> Terry Ford <<email address removed>> wrote:
> I think that is what he wants to do. To boot, he wants to be able to
> do this on Windows as well.

I have not worked with AppleScript either, so I can't be much help
there.
But maybe you should rethink your approach. Why does App B need to be
the one to save this file. Why not open and save it with App A.
If it is to be a file that when double-clicked opens in App B, you
can have App A set its creator code when saving so that it is "owned"
by App B.

Just a thought

Roger M. Clary
Class One Software
http://www.classonesoftware.com
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 19:10 (Fri, 3 Aug 2007 11:10:25 -0700 (PDT))
From: Lennox Jacob
Hi Roger,

This is the problem, I have app B which I have been using all the time, I created several files about 3500 in all, I have made several modiifications to App B, added editfields, from time to time, so files have varying number of textlines, App B was modified to open all files created (backward compatible).

So I want to reduce my code in Opendocument of app B, Remember there is a 32k limit in OpenDocument?

So I need to launch app B from a new app app A which will open all files in a specified folder, save them, then close them, (thereby upgrading them one at a time in a Do loop).

I can then modify my code in Opendocument of app B.

If I am to do that manually it would really take a lot of time.

Any ideas or suggestions?

Lennox.

Roger Clary <<email address removed>> wrote:
On Aug 3, 2007, at 1:31 PM, Lennox Jacob wrote:

> Yes that is exactly what I want to do, but I only want to do it on
> Mac.
> I would appreciate the help in Applescript, since I have no
> experience in Applescript.
>
> Thanks again.
>
> Lennox.
>
> Terry Ford wrote:
> I think that is what he wants to do. To boot, he wants to be able to
> do this on Windows as well.

I have not worked with AppleScript either, so I can't be much help
there.
But maybe you should rethink your approach. Why does App B need to be
the one to save this file. Why not open and save it with App A.
If it is to be a file that when double-clicked opens in App B, you
can have App A set its creator code when saving so that it is "owned"
by App B.

Just a thought

Roger M. Clary
Class One Software
http://www.classonesoftware.com
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Shape Yahoo! in your own image. Join our Network Research Panel today!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 20:32 (Fri, 3 Aug 2007 15:32:53 -0400)
From: Roger Clary

On Aug 3, 2007, at 2:10 PM, Lennox Jacob wrote:

> This is the problem, I have app B which I have been using all the
> time, I created several files about 3500 in all, I have made
> several modiifications to App B, added editfields, from time to
> time, so files have varying number of textlines, App B was modified
> to open all files created (backward compatible).
>
I'm with you so far

> So I want to reduce my code in Opendocument of app B, Remember
> there is a 32k limit in OpenDocument?

Why not have OpenDocument call various methods, or put several
methods in a module, thus avoiding a 32K limit?
>
> So I need to launch app B from a new app app A which will open all
> files in a specified folder, save them, then close them, (thereby
> upgrading them one at a time in a Do loop).
>
Still don't understand why you need app A to launch App B. If App A
has work to do on the files, just have it do the work, save them,
then quit.

> I can then modify my code in Opendocument of app B.

Sounds like this will be necessary anyhow.

Roger M. Clary
Class One Software
http://www.classonesoftware.com
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 20:50 (Fri, 3 Aug 2007 12:50:20 -0700 (PDT))
From: Lennox Jacob
Hi Roger,

Roger Clary <<email address removed>> wrote: >I'm with you so far
Good

>Why not have OpenDocument call various methods, or put several
>methods in a module, thus avoiding a 32K limit?
Tried it before but did not get through, Will try again still.

>Still don't understand why you need app A to launch App B. If App A
>has work to do on the files, just have it do the work, save them,
>then quit.

No, app A will open file1, save it, then close it, open File2, save it then close it ..... open File3500, save it then close it, all in a do loop, thereby upgrading all 3500 files automatically.
I think the Applescript could be used in place of appA, but I don't know "Applescripting".

Lennox

---------------------------------
Pinpoint customers who are looking for what you sell.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 20:37 (Fri, 03 Aug 2007 12:37:28 -0700)
From: Terry Ford

On Aug 3, 2007, at 11:10 AM, Lennox Jacob wrote:

> Hi Roger,
>
> This is the problem, I have app B which I have been using all the
> time, I created several files about 3500 in all, I have made
> several modiifications to App B, added editfields, from time to
> time, so files have varying number of textlines, App B was modified
> to open all files created (backward compatible).
>
> So I want to reduce my code in Opendocument of app B, Remember
> there is a 32k limit in OpenDocument?
>
> So I need to launch app B from a new app app A which will open all
> files in a specified folder, save them, then close them, (thereby
> upgrading them one at a time in a Do loop).
>
> I can then modify my code in Opendocument of app B.
>
> If I am to do that manually it would really take a lot of time.
>
> Any ideas or suggestions?

I think I know the files you are referring to. :)

My suggestion is to do it all in one app (app A) as what you really
want to do is modify the format of each text file.

Open each file individually, make the necessary changes and save the
new file. If you Nil each reference as you go along you shouldn't
have a stack problem with reference counting.

A lot depends on how you intend to restructure each individual file
but, as they are all text items (IIRC), you should be able to create
a loop to automate it.

I think you might have confused some by implying that this would be
part of a continuing process as opposed to writing a little utility
app for a one shot affair.

Terry

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 21:06 (Fri, 3 Aug 2007 13:06:44 -0700 (PDT))
From: Lennox Jacob
Hi Terry,
Terry Ford <<email address removed>> wrote:
>My suggestion is to do it all in one app (app A) as what you really
>want to do is modify the format of each text file.
>Open each file individually, make the necessary changes and save the
>new file. If you Nil each reference as you go along you shouldn't
>have a stack problem with reference counting.

OK, I can just open and save, I dont't have to modify anything, they will be left blank, and all the new editfields will give empty readlines.
If each file takes a minute to double-click, open, click the Save pushbutton, then click the Close pushbutton that will be 3500 minutes nearyly 60 hours.at 8 hours/day that's one 7-days week, doing nothing else.

>A lot depends on how you intend to restructure each individual file
>but, as they are all text items (IIRC), you should be able to create
>a loop to automate it.
Yes they are all text files, no restructuring required.

I think you might have confused some by implying that this would be
part of a continuing process as opposed to writing a little utility
app for a one shot affair.
That's right its a one shot affair, and more than that a great learning exercise.

Lennox.

---------------------------------
Boardwalk for $500? In 2007? Ha!
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 21:20 (Fri, 3 Aug 2007 16:20:19 -0400)
From: Roger Clary

On Aug 3, 2007, at 4:06 PM, Lennox Jacob wrote:

> OK, I can just open and save, I dont't have to modify anything,
> they will be left blank, and all the new editfields will give empty
> readlines.
> If each file takes a minute to double-click, open, click the Save
> pushbutton, then click the Close pushbutton that will be 3500
> minutes nearyly 60 hours.at 8 hours/day that's one 7-days week,
> doing nothing else.

Why would you need to sit there and dbl-click each file. Automate
your app to do this. Can be done very quickly, even with 3500 files.

Roger M. Clary
Class One Software
http://www.classonesoftware.com
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 21:34 (Fri, 3 Aug 2007 13:34:31 -0700 (PDT))
From: Lennox Jacob
Hi Roger,
I am not saying I'll do that, I am saying if I had to do that how long it would take.
I need to get the Applescript going.
Lennox.

Roger Clary <<email address removed>> wrote:
On Aug 3, 2007, at 4:06 PM, Lennox Jacob wrote:

> OK, I can just open and save, I dont't have to modify anything,
> they will be left blank, and all the new editfields will give empty
> readlines.
> If each file takes a minute to double-click, open, click the Save
> pushbutton, then click the Close pushbutton that will be 3500
> minutes nearyly 60 hours.at 8 hours/day that's one 7-days week,
> doing nothing else.

Why would you need to sit there and dbl-click each file. Automate
your app to do this. Can be done very quickly, even with 3500 files.

Roger M. Clary
Class One Software
http://www.classonesoftware.com
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 21:33 (Fri, 03 Aug 2007 13:33:18 -0700)
From: Terry Ford

On Aug 3, 2007, at 1:06 PM, Lennox Jacob wrote:

> OK, I can just open and save, I dont't have to modify anything,
> they will be left blank, and all the new editfields will give empty
> readlines.
> If each file takes a minute to double-click, open, click the Save
> pushbutton, then click the Close pushbutton that will be 3500
> minutes nearyly 60 hours.at 8 hours/day that's one 7-days week,
> doing nothing else.

If your files are organised into a folder, you should be able to
create a temporary version of App B that contains a method that calls
the open routines and the save routines in the original file. If they
are in the MenuHandlers you will have to create copies of the code in
your temporary method(s).

You will need some way, such as an array or listbox of filenames, to
organise this. It really shouldn't take much extra code to do this.

Terry

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 23:13 (Fri, 3 Aug 2007 15:13:20 -0700 (PDT))
From: Lennox Jacob
Thanks Terry,
Never saw it that way, a simple pushbutton with the "Do loop" should work, I'll try that.
Thanks again.
Lennox.

Terry Ford <<email address removed>> wrote:
On Aug 3, 2007, at 1:06 PM, Lennox Jacob wrote:

> OK, I can just open and save, I dont't have to modify anything,
> they will be left blank, and all the new editfields will give empty
> readlines.
> If each file takes a minute to double-click, open, click the Save
> pushbutton, then click the Close pushbutton that will be 3500
> minutes nearyly 60 hours.at 8 hours/day that's one 7-days week,
> doing nothing else.

If your files are organised into a folder, you should be able to
create a temporary version of App B that contains a method that calls
the open routines and the save routines in the original file. If they
are in the MenuHandlers you will have to create copies of the code in
your temporary method(s).

You will need some way, such as an array or listbox of filenames, to
organise this. It really shouldn't take much extra code to do this.

Terry

_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 21:48 (Fri, 3 Aug 2007 14:48:00 -0600)
From: joe strout.net
On Aug 03, 2007, at 18:10 UTC, Lennox Jacob wrote:

> Hi Roger,
>
> This is the problem, I have app B which I have been using all the
> time, I created several files about 3500 in all, I have made several
> modiifications to App B, added editfields, from time to time, so
> files have varying number of textlines, App B was modified to open
> all files created (backward compatible).
>
> So I want to reduce my code in Opendocument of app B, Remember there
> is a 32k limit in OpenDocument?

There's a what?

> So I need to launch app B from a new app app A which will open all
> files in a specified folder, save them, then close them, (thereby
> upgrading them one at a time in a Do loop).
>
> I can then modify my code in Opendocument of app B.

OK, writing a second app to do this, especially given that app B isn't
already scriptable, is serious overkill. You just need to refactor:

1. Move the code out of OpenDocument into its own method.

2. If that method's really so long and ugly that you're hitting some
sort of compiler limitation, then you need to start breaking it up into
multiple helper methods. My own methods are almost never more than a
page long or so; I doubt yours need to be either.

3. Then, if you want code to update all the items in a folder, add this
to app B -- forget about app A. Just add a button or menu command that
calls SelectFolder, then iterates through that folder and calls your
Open and Save methods on each one. (Again, these should be *methods*,
not events -- the events just call the relevant methods, which is why
you can also call those methods from elsewhere in the code, as you'll
be doing here.)

If you don't want this update-folder button to appear in the real app,
then just put "me.visible = DebugBuild" in its Open event.

Best,
- Joe

Re: Help: Effecting Keyboard keydown programatically
Date: 03.08.07 23:15 (Fri, 3 Aug 2007 15:15:45 -0700 (PDT))
From: Lennox Jacob
Thanks Joe,
Similar to Terry's suggestion. I'll try it.
Lennox.

<email address removed> wrote: On Aug 03, 2007, at 18:10 UTC, Lennox Jacob wrote:

> Hi Roger,
>
> This is the problem, I have app B which I have been using all the
> time, I created several files about 3500 in all, I have made several
> modiifications to App B, added editfields, from time to time, so
> files have varying number of textlines, App B was modified to open
> all files created (backward compatible).
>
> So I want to reduce my code in Opendocument of app B, Remember there
> is a 32k limit in OpenDocument?

There's a what?

> So I need to launch app B from a new app app A which will open all
> files in a specified folder, save them, then close them, (thereby
> upgrading them one at a time in a Do loop).
>
> I can then modify my code in Opendocument of app B.

OK, writing a second app to do this, especially given that app B isn't
already scriptable, is serious overkill. You just need to refactor:

1. Move the code out of OpenDocument into its own method.

2. If that method's really so long and ugly that you're hitting some
sort of compiler limitation, then you need to start breaking it up into
multiple helper methods. My own methods are almost never more than a
page long or so; I doubt yours need to be either.

3. Then, if you want code to update all the items in a folder, add this
to app B -- forget about app A. Just add a button or menu command that
calls SelectFolder, then iterates through that folder and calls your
Open and Save methods on each one. (Again, these should be *methods*,
not events -- the events just call the relevant methods, which is why
you can also call those methods from elsewhere in the code, as you'll
be doing here.)

If you don't want this update-folder button to appear in the real app,
then just put "me.visible = DebugBuild" in its Open event.

Best,
- Joe

Re: Help: Effecting Keyboard keydown programatically
Date: 04.08.07 04:19 (Fri, 3 Aug 2007 20:19:36 -0700 (PDT))
From: Lennox Jacob


<email address removed> wrote: On Aug 03, 2007, at 18:10 UTC, Lennox Jacob wrote:

> Just add a button or menu command that
calls SelectFolder, then iterates through that folder and calls your
Open and Save methods on each one. (Again, these should be *methods*,
not events -- the events just call the relevant methods, which is why
you can also call those methods from elsewhere in the code, as you'll
be doing here.)
OK Joe,
I got that, so I created a pushbutton and used a "for loop".
So when I push the pushbutton I use f.launch to open the files in the folder that has all the files.
f.launch launches all the files.

Now immediately below f.launch and still within the "for loop" I tried to save then close each opened file before going on to the next one,(what I am trying to do is to launch, save then close each file before going on to the next file), I am not getting the save or close to work.
I even used a timer and use savepushbutton.push, still not getting pass the launching part.
Any suggestions?
Thankks.
Lennox

---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 04.08.07 18:19 (Sat, 4 Aug 2007 13:19:57 -0400)
From: Roger Clary

On Aug 3, 2007, at 11:19 PM, Lennox Jacob wrote:

>> Just add a button or menu command that
> calls SelectFolder, then iterates through that folder and calls your
> Open and Save methods on each one. (Again, these should be *methods*,
> not events -- the events just call the relevant methods, which is why
> you can also call those methods from elsewhere in the code, as you'll
> be doing here.)
> OK Joe,
> I got that, so I created a pushbutton and used a "for loop".
> So when I push the pushbutton I use f.launch to open the files in
> the folder that has all the files.
> f.launch launches all the files.
>
> Now immediately below f.launch and still within the "for loop" I
> tried to save then close each opened file before going on to the
> next one,(what I am trying to do is to launch, save then close each
> file before going on to the next file), I am not getting the save
> or close to work.
> I even used a timer and use savepushbutton.push, still not getting
> pass the launching part.

Forget f.launch.
That is used to open a file with another app. You don't need to do
that. Use either a textinputstream or a binary stream and to
f.openAsTextFile or f.openAsbinaryFile to open the file within your
program, perform whatever actions you wish, and then close the file.
All within your loop.

Roger M. Clary
Class One Software
http://www.classonesoftware.com
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 04.08.07 19:49 (Sat, 4 Aug 2007 20:49:49 +0200)
From: Arnaud Nicolet
Le 4 août 07 à 05:19 Matin, Lennox Jacob a écrit:

> I got that, so I created a pushbutton and used a "for loop".
> So when I push the pushbutton I use f.launch to open the files in
> the folder that has all the files.
> f.launch launches all the files.
>
> Now immediately below f.launch and still within the "for loop" I
> tried to save then close each opened file before going on to the
> next one,(what I am trying to do is to launch, save then close each
> file before going on to the next file), I am not getting the save
> or close to work.
> I even used a timer and use savepushbutton.push, still not getting
> pass the launching part.
> Any suggestions?
> Thankks.
> Lennox

If you ever want to implement an AppleEvent (so that you can
communicate from one app to another), you can do this (for example,
to add the save command):

Make sure both applications have a MacCreator identifier.

Put this code in the sending app:

dim ae As AppleEvent

ae=NewAppleEvent("aevt","save","app2") 'where "app2" is the
MacCreator code of the app which will receive the AppleEvent
ae.FolderItemParam("----")=f 'The file to save. Remove this line to
save the front document
if not ae.Send then
MsgBox "Is app2 running?"
end if

and this one in the receiving app, in app.HandleAppleEvent:

dim f As FolderItem
if eventclass="aevt" and eventid="save" then 'We receive a "save"
message
f=theEvent.FolderItemParam("----")

if f=nil then
'Save front document
else
'Save f
end if
return true
end if
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 04.08.07 20:57 (Sat, 4 Aug 2007 12:57:55 -0700 (PDT))
From: Lennox Jacob
Hi Arnaud,
I am trying it out but I need some more info.
Would changing save to saveas and close do the saveas and close routines too.
How to push a pushbutton named? SaveAsPushbutton
Thanks.
Lennox.

Arnaud Nicolet <<email address removed>> wrote: Le 4 août 07 à 05:19 Matin, Lennox Jacob a écrit:

> I got that, so I created a pushbutton and used a "for loop".
> So when I push the pushbutton I use f.launch to open the files in
> the folder that has all the files.
> f.launch launches all the files.
>
> Now immediately below f.launch and still within the "for loop" I
> tried to save then close each opened file before going on to the
> next one,(what I am trying to do is to launch, save then close each
> file before going on to the next file), I am not getting the save
> or close to work.
> I even used a timer and use savepushbutton.push, still not getting
> pass the launching part.
> Any suggestions?
> Thankks.
> Lennox

If you ever want to implement an AppleEvent (so that you can
communicate from one app to another), you can do this (for example,
to add the save command):

Make sure both applications have a MacCreator identifier.

Put this code in the sending app:

dim ae As AppleEvent

ae=NewAppleEvent("aevt","save","app2") 'where "app2" is the
MacCreator code of the app which will receive the AppleEvent
ae.FolderItemParam("----")=f 'The file to save. Remove this line to
save the front document
if not ae.Send then
MsgBox "Is app2 running?"
end if

and this one in the receiving app, in app.HandleAppleEvent:

dim f As FolderItem
if eventclass="aevt" and eventid="save" then 'We receive a "save"
message
f=theEvent.FolderItemParam("----")

if f=nil then
'Save front document
else
'Save f
end if
return true
end if
_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Shape Yahoo! in your own image. Join our Network Research Panel today!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 04.08.07 22:12 (Sat, 4 Aug 2007 23:12:31 +0200)
From: Arnaud Nicolet
Hi Lennox,

Once your second app receives the AppleEvent, you can simply use
PushButton1.Push in the "if EventClass..." part.

You know, AppleEvents don't rely on AppleScript (while the opposite
is not true). So if you make two apps running on Mac OS, you can
safely define your own AppleEvents (avoid redefining the ones already
defined, however), how they hold data, and simply send the message as
you like and receive it as well.

For instance, if you want to make just an AppleEvent to push a
button, you can use this (or any AppleEvent you make from scratch):

dim ae As AppleEvent

ae=newAppleEvent("haha","push","app2")
if not ae.sen then msgbox "app is not running."

The only thing that your second app must do is handle the AppleEvent
(whose class is "haha" and type is "push" in this example) using the
HandleAppleEvent event as I described.

Hope this helps.

Le 4 août 07 à 21:57 Soir, Lennox Jacob a écrit:

> Hi Arnaud,
> I am trying it out but I need some more info.
> Would changing save to saveas and close do the saveas and close
> routines too.
> How to push a pushbutton named? SaveAsPushbutton
> Thanks.
> Lennox.
>
> Arnaud Nicolet <<email address removed>> wrote: Le 4 août 07 à 05:19 Matin,
> Lennox Jacob a écrit:
>
>> I got that, so I created a pushbutton and used a "for loop".
>> So when I push the pushbutton I use f.launch to open the files in
>> the folder that has all the files.
>> f.launch launches all the files.
>>
>> Now immediately below f.launch and still within the "for loop" I
>> tried to save then close each opened file before going on to the
>> next one,(what I am trying to do is to launch, save then close each
>> file before going on to the next file), I am not getting the save
>> or close to work.
>> I even used a timer and use savepushbutton.push, still not getting
>> pass the launching part.
>> Any suggestions?
>> Thankks.
>> Lennox
>
> If you ever want to implement an AppleEvent (so that you can
> communicate from one app to another), you can do this (for example,
> to add the save command):
>
> Make sure both applications have a MacCreator identifier.
>
> Put this code in the sending app:
>
> dim ae As AppleEvent
>
> ae=NewAppleEvent("aevt","save","app2") 'where "app2" is the
> MacCreator code of the app which will receive the AppleEvent
> ae.FolderItemParam("----")=f 'The file to save. Remove this line to
> save the front document
> if not ae.Send then
> MsgBox "Is app2 running?"
> end if
>
> and this one in the receiving app, in app.HandleAppleEvent:
>
> dim f As FolderItem
> if eventclass="aevt" and eventid="save" then 'We receive a "save"
> message
> f=theEvent.FolderItemParam("----")
>
> if f=nil then
> 'Save front document
> else
> 'Save f
> end if
> return true
> end if
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 04.08.07 23:50 (Sat, 4 Aug 2007 15:50:06 -0700 (PDT))
From: Lennox Jacob
Hi Arnaud et al,

Let me explain what I want and what is happening.

What I want:
I want to open all the files in a given folder to be opened, saved then closed in that order and one file at a time.
So it goes File1 open, file1 save, file 1 close, file2 open, file2 save, file2 close... until lastfile open, lastFile save, lastFile close.

What is Happening.
I can open the files like this (Drag and Drop)
Do
item = obj.folderitem
f = item.parent

if f<>nil then
If f.name = ".DS_Store" or f.name = "" then

else
item.launch
end if
end if

Timer1.mode = 1

Loop Until Obj.NextItem = False

Window1.Timer1.Action

dim ae As AppleEvent

ae=NewAppleEvent("aevt","save","WXYZ") 'where "app2" is the MacCreator code of the app which will receive the AppleEvent
'ae.FolderItemParam("----")ð'The file to save. Remove this line to save the front document
if not ae.Send then
MsgBox "Is app2 save running?"
end if


App2 App.HandleAppleEvent

dim f As FolderItem
if eventclass="aevt" and eventid="save" then 'We receive a "save" message
App2.SaveAsPushbutton.Push
return true
end if

App2.Timer6.mode 

App2.Timer6.Action
App2.ClosePushbutton.Push

What happens is that I put 4 files in a folder and drag and drop them to an imagewell with the Do Loop

All four files are opened at once. (This should not happen since the code in the Do Loop is not completed) but next comes in to open the second, third and fourth files.
When the AppleEvent comes into action, a new empty document is opened because App2. SaveAsPushbutton.Push what should happen here is that only one of the four files should have opened, then the AppleEvent comes in and the pushbutton for App2 be pushed - SaveAsPushbutton.Push not App2.SaveAsPushbutton.Push

Any suggestions?

Thanks.
Lennox.



---------------------------------
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 05.08.07 09:35 (Sun, 5 Aug 2007 10:35:58 +0200)
From: Arnaud Nicolet
Le 5 août 07 à 00:50 Matin, Lennox Jacob a écrit:

> Hi Arnaud et al,
>
> Let me explain what I want and what is happening.
>
> What I want:
> I want to open all the files in a given folder to be opened, saved
> then closed in that order and one file at a time.
> So it goes File1 open, file1 save, file 1 close, file2 open, file2
> save, file2 close... until lastfile open, lastFile save, lastFile
> close.
>
> What is Happening.
> I can open the files like this (Drag and Drop)
> Do
> item = obj.folderitem
> f = item.parent
>
> if f<>nil then
> If f.name = ".DS_Store" or f.name = "" then
>
> else
> item.launch
> end if
> end if
>
> Timer1.mode = 1
>
> Loop Until Obj.NextItem = False
>
> Window1.Timer1.Action
>
> dim ae As AppleEvent
>
> ae=NewAppleEvent("aevt","save","WXYZ") 'where "app2" is the
> MacCreator code of the app which will receive the AppleEvent
> 'ae.FolderItemParam("----")=f 'The file to save. Remove this line
> to save the front document
> if not ae.Send then
> MsgBox "Is app2 save running?"
> end if
>
> App2 App.HandleAppleEvent
>
> dim f As FolderItem
> if eventclass="aevt" and eventid="save" then 'We receive a "save"
> message
> App2.SaveAsPushbutton.Push
> return true
> end if
>
> App2.Timer6.mode =1
>
> App2.Timer6.Action
> App2.ClosePushbutton.Push
>
> What happens is that I put 4 files in a folder and drag and drop
> them to an imagewell with the Do Loop
>
> All four files are opened at once. (This should not happen since
> the code in the Do Loop is not completed) but next comes in to open
> the second, third and fourth files.
> When the AppleEvent comes into action, a new empty document is
> opened because App2. SaveAsPushbutton.Push what should happen here
> is that only one of the four files should have opened, then the
> AppleEvent comes in and the pushbutton for App2 be pushed -
> SaveAsPushbutton.Push not App2.SaveAsPushbutton.Push
>
> Any suggestions?

In your loop, you are opening all files one by one. You should open
one file, save it, close it and repeat with the next one.

So you should move the timer code in the loop:

dim ae As AppleEvent

Do
item = obj.folderitem
f = item.parent

if f<>nil then
If f.name = ".DS_Store" or f.name = "" then

else

ae=newAppleEvent("aevt","odoc","WXYZ") 'open the file; automatically
recognized by RB and fires an OpenDocument event
ae.folderitemparam("----")=f
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

ae=NewAppleEvent("aevt","save","WXYZ") 'Save the frontmost
document; you handle it yourself
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

ae=NewAppleEvent("aevt","clos","WXYZ") 'Close the frontmost
document; you handle it yourself
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

end if
end if

Loop Until Obj.NextItem = False
>
And you must also handle the "aevt", "clos" AppleEvent in the app2 to
close the document.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 05.08.07 15:48 (Sun, 5 Aug 2007 07:48:07 -0700 (PDT))
From: Lennox Jacob
Thanks Arnaud,

Did exactly as you "said", works as you "said", but with one problem.

It opens the first file, the file opend and the contents of it was displayed, then the saving part, said it was saving the file, the file was saved, then a new empty file appeared, then it said it was closing the file and the new empty file was closed,
The opened file with its contents correctly displayed remained on the desktop.

Then the same happened for the second file.

Then the two opened files with their contents correctly displayed remained on the desktop.

What is happening is that it opened the correct files f <> nil.
but when it comes to Save f=nil, so that new file appears, it is not "seeing" that already opened file to save it then close it.

Any suggestions?

Thanks.

Lennox.

Arnaud Nicolet <<email address removed>> wrote: Le 5 août 07 à 00:50 Matin, Lennox Jacob a écrit:

> Hi Arnaud et al,
>
> Let me explain what I want and what is happening.
>
> What I want:
> I want to open all the files in a given folder to be opened, saved
> then closed in that order and one file at a time.
> So it goes File1 open, file1 save, file 1 close, file2 open, file2
> save, file2 close... until lastfile open, lastFile save, lastFile
> close.
>
> What is Happening.
> I can open the files like this (Drag and Drop)
> Do
> item = obj.folderitem
> f = item.parent
>
> if f<>nil then
> If f.name = ".DS_Store" or f.name = "" then
>
> else
> item.launch
> end if
> end if
>
> Timer1.mode = 1
>
> Loop Until Obj.NextItem = False
>
> Window1.Timer1.Action
>
> dim ae As AppleEvent
>
> ae=NewAppleEvent("aevt","save","WXYZ") 'where "app2" is the
> MacCreator code of the app which will receive the AppleEvent
> 'ae.FolderItemParam("----")=f 'The file to save. Remove this line
> to save the front document
> if not ae.Send then
> MsgBox "Is app2 save running?"
> end if
>
> App2 App.HandleAppleEvent
>
> dim f As FolderItem
> if eventclass="aevt" and eventid="save" then 'We receive a "save"
> message
> App2.SaveAsPushbutton.Push
> return true
> end if
>
> App2.Timer6.mode =1
>
> App2.Timer6.Action
> App2.ClosePushbutton.Push
>
> What happens is that I put 4 files in a folder and drag and drop
> them to an imagewell with the Do Loop
>
> All four files are opened at once. (This should not happen since
> the code in the Do Loop is not completed) but next comes in to open
> the second, third and fourth files.
> When the AppleEvent comes into action, a new empty document is
> opened because App2. SaveAsPushbutton.Push what should happen here
> is that only one of the four files should have opened, then the
> AppleEvent comes in and the pushbutton for App2 be pushed -
> SaveAsPushbutton.Push not App2.SaveAsPushbutton.Push
>
> Any suggestions?

In your loop, you are opening all files one by one. You should open
one file, save it, close it and repeat with the next one.

So you should move the timer code in the loop:

dim ae As AppleEvent

Do
item = obj.folderitem
f = item.parent

if f<>nil then
If f.name = ".DS_Store" or f.name = "" then

else

ae=newAppleEvent("aevt","odoc","WXYZ") 'open the file; automatically
recognized by RB and fires an OpenDocument event
ae.folderitemparam("----")=f
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

ae=NewAppleEvent("aevt","save","WXYZ") 'Save the frontmost
document; you handle it yourself
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

ae=NewAppleEvent("aevt","clos","WXYZ") 'Close the frontmost
document; you handle it yourself
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

end if
end if

Loop Until Obj.NextItem = False
>
And you must also handle the "aevt", "clos" AppleEvent in the app2 to
close the document.
_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 05.08.07 16:50 (Sun, 5 Aug 2007 08:50:49 -0700 (PDT))
From: Lennox Jacob
OK Arnaud,
This is why it was saving and closing even though f =nil

I have this
f=theEvent.FolderItemParam("----")

if f=nil then
App2.SaveFile Title,True
else
App2.SaveFile Title,True
end if
return true
end if

and

if eventclass="aevt" and eventid="clos" then 'We receive a "save" message

f=theEvent.FolderItemParam("----")

if f=nil then
App2.App2Close f
else
App2.App2Close f
end if
return true
end if

should have been this

in the App.HandleAppleEvent
f=theEvent.FolderItemParam("----")
if f=nil then

else
App2.SaveFile Title,True
end if
return true
end if

and

if eventclass="aevt" and eventid="clos" then 'We receive a "save" message
f=theEvent.FolderItemParam("----")

if f=nil then

else
App2.App2Close f
end if
return true
end if

but then nothing would have happened in the save and close calls.

I think I can remember reading posts on the list where someone was referring to myOpenWindow so instead of

if f=nil then


else
App2.App2Close f
end if
return true
end if

it should be something like this, but I am not sure about the code

Dim myOpenWindow, App2Mainwindow as window
Dim i As integer
for i=0 to WindowCount-1 'We will loop through open windows
myOpenWindow=Window(i) 'The "ith" window.
if myOpenWindow isA App2Mainwindow
myOpenWindow = f
next

if f=nil then

else
App2.App2Close f
end if
return true
end if


Any suggestions?

Thanks.
Lennox

Lennox Jacob <<email address removed>> wrote: Thanks Arnaud,

Did exactly as you "said", works as you "said", but with one problem.

It opens the first file, the file opend and the contents of it was displayed, then the saving part, said it was saving the file, the file was saved, then a new empty file appeared, then it said it was closing the file and the new empty file was closed,
The opened file with its contents correctly displayed remained on the desktop.

Then the same happened for the second file.

Then the two opened files with their contents correctly displayed remained on the desktop.

What is happening is that it opened the correct files f <> nil.
but when it comes to Save f=nil, so that new file appears, it is not "seeing" that already opened file to save it then close it.

Any suggestions?

Thanks.

Lennox.

Arnaud Nicolet wrote: Le 5 août 07 à 00:50 Matin, Lennox Jacob a écrit:

> Hi Arnaud et al,
>
> Let me explain what I want and what is happening.
>
> What I want:
> I want to open all the files in a given folder to be opened, saved
> then closed in that order and one file at a time.
> So it goes File1 open, file1 save, file 1 close, file2 open, file2
> save, file2 close... until lastfile open, lastFile save, lastFile
> close.
>
> What is Happening.
> I can open the files like this (Drag and Drop)
> Do
> item = obj.folderitem
> f = item.parent
>
> if f<>nil then
> If f.name = ".DS_Store" or f.name = "" then
>
> else
> item.launch
> end if
> end if
>
> Timer1.mode = 1
>
> Loop Until Obj.NextItem = False
>
> Window1.Timer1.Action
>
> dim ae As AppleEvent
>
> ae=NewAppleEvent("aevt","save","WXYZ") 'where "app2" is the
> MacCreator code of the app which will receive the AppleEvent
> 'ae.FolderItemParam("----")=f 'The file to save. Remove this line
> to save the front document
> if not ae.Send then
> MsgBox "Is app2 save running?"
> end if
>
> App2 App.HandleAppleEvent
>
> dim f As FolderItem
> if eventclass="aevt" and eventid="save" then 'We receive a "save"
> message
> App2.SaveAsPushbutton.Push
> return true
> end if
>
> App2.Timer6.mode =1
>
> App2.Timer6.Action
> App2.ClosePushbutton.Push
>
> What happens is that I put 4 files in a folder and drag and drop
> them to an imagewell with the Do Loop
>
> All four files are opened at once. (This should not happen since
> the code in the Do Loop is not completed) but next comes in to open
> the second, third and fourth files.
> When the AppleEvent comes into action, a new empty document is
> opened because App2. SaveAsPushbutton.Push what should happen here
> is that only one of the four files should have opened, then the
> AppleEvent comes in and the pushbutton for App2 be pushed -
> SaveAsPushbutton.Push not App2.SaveAsPushbutton.Push
>
> Any suggestions?

In your loop, you are opening all files one by one. You should open
one file, save it, close it and repeat with the next one.

So you should move the timer code in the loop:

dim ae As AppleEvent

Do
item = obj.folderitem
f = item.parent

if f<>nil then
If f.name = ".DS_Store" or f.name = "" then

else

ae=newAppleEvent("aevt","odoc","WXYZ") 'open the file; automatically
recognized by RB and fires an OpenDocument event
ae.folderitemparam("----")=f
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

ae=NewAppleEvent("aevt","save","WXYZ") 'Save the frontmost
document; you handle it yourself
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

ae=NewAppleEvent("aevt","clos","WXYZ") 'Close the frontmost
document; you handle it yourself
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

end if
end if

Loop Until Obj.NextItem = False
>
And you must also handle the "aevt", "clos" AppleEvent in the app2 to
close the document.
_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.
_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 05.08.07 18:54 (Sun, 5 Aug 2007 10:54:32 -0700 (PDT))
From: Lennox Jacob
OK, I got it now, I had to use windowcount to find the open window. All is well now.
Thanks to all that gave their input.
Lennox.

Lennox Jacob <<email address removed>> wrote: OK Arnaud,
This is why it was saving and closing even though f =nil

I have this
f=theEvent.FolderItemParam("----")

if f=nil then
App2.SaveFile Title,True
else
App2.SaveFile Title,True
end if
return true
end if

and

if eventclass="aevt" and eventid="clos" then 'We receive a "save" message

f=theEvent.FolderItemParam("----")

if f=nil then
App2.App2Close f
else
App2.App2Close f
end if
return true
end if

should have been this

in the App.HandleAppleEvent
f=theEvent.FolderItemParam("----")
if f=nil then

else
App2.SaveFile Title,True
end if
return true
end if

and

if eventclass="aevt" and eventid="clos" then 'We receive a "save" message
f=theEvent.FolderItemParam("----")

if f=nil then

else
App2.App2Close f
end if
return true
end if

but then nothing would have happened in the save and close calls.

I think I can remember reading posts on the list where someone was referring to myOpenWindow so instead of

if f=nil then


else
App2.App2Close f
end if
return true
end if

it should be something like this, but I am not sure about the code

Dim myOpenWindow, App2Mainwindow as window
Dim i As integer
for i=0 to WindowCount-1 'We will loop through open windows
myOpenWindow=Window(i) 'The "ith" window.
if myOpenWindow isA App2Mainwindow
myOpenWindow = f
next

if f=nil then

else
App2.App2Close f
end if
return true
end if


Any suggestions?

Thanks.
Lennox

Lennox Jacob wrote: Thanks Arnaud,

Did exactly as you "said", works as you "said", but with one problem.

It opens the first file, the file opend and the contents of it was displayed, then the saving part, said it was saving the file, the file was saved, then a new empty file appeared, then it said it was closing the file and the new empty file was closed,
The opened file with its contents correctly displayed remained on the desktop.

Then the same happened for the second file.

Then the two opened files with their contents correctly displayed remained on the desktop.

What is happening is that it opened the correct files f <> nil.
but when it comes to Save f=nil, so that new file appears, it is not "seeing" that already opened file to save it then close it.

Any suggestions?

Thanks.

Lennox.

Arnaud Nicolet wrote: Le 5 août 07 à 00:50 Matin, Lennox Jacob a écrit:

> Hi Arnaud et al,
>
> Let me explain what I want and what is happening.
>
> What I want:
> I want to open all the files in a given folder to be opened, saved
> then closed in that order and one file at a time.
> So it goes File1 open, file1 save, file 1 close, file2 open, file2
> save, file2 close... until lastfile open, lastFile save, lastFile
> close.
>
> What is Happening.
> I can open the files like this (Drag and Drop)
> Do
> item = obj.folderitem
> f = item.parent
>
> if f<>nil then
> If f.name = ".DS_Store" or f.name = "" then
>
> else
> item.launch
> end if
> end if
>
> Timer1.mode = 1
>
> Loop Until Obj.NextItem = False
>
> Window1.Timer1.Action
>
> dim ae As AppleEvent
>
> ae=NewAppleEvent("aevt","save","WXYZ") 'where "app2" is the
> MacCreator code of the app which will receive the AppleEvent
> 'ae.FolderItemParam("----")=f 'The file to save. Remove this line
> to save the front document
> if not ae.Send then
> MsgBox "Is app2 save running?"
> end if
>
> App2 App.HandleAppleEvent
>
> dim f As FolderItem
> if eventclass="aevt" and eventid="save" then 'We receive a "save"
> message
> App2.SaveAsPushbutton.Push
> return true
> end if
>
> App2.Timer6.mode =1
>
> App2.Timer6.Action
> App2.ClosePushbutton.Push
>
> What happens is that I put 4 files in a folder and drag and drop
> them to an imagewell with the Do Loop
>
> All four files are opened at once. (This should not happen since
> the code in the Do Loop is not completed) but next comes in to open
> the second, third and fourth files.
> When the AppleEvent comes into action, a new empty document is
> opened because App2. SaveAsPushbutton.Push what should happen here
> is that only one of the four files should have opened, then the
> AppleEvent comes in and the pushbutton for App2 be pushed -
> SaveAsPushbutton.Push not App2.SaveAsPushbutton.Push
>
> Any suggestions?

In your loop, you are opening all files one by one. You should open
one file, save it, close it and repeat with the next one.

So you should move the timer code in the loop:

dim ae As AppleEvent

Do
item = obj.folderitem
f = item.parent

if f<>nil then
If f.name = ".DS_Store" or f.name = "" then

else

ae=newAppleEvent("aevt","odoc","WXYZ") 'open the file; automatically
recognized by RB and fires an OpenDocument event
ae.folderitemparam("----")=f
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

ae=NewAppleEvent("aevt","save","WXYZ") 'Save the frontmost
document; you handle it yourself
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

ae=NewAppleEvent("aevt","clos","WXYZ") 'Close the frontmost
document; you handle it yourself
if not ae.Send then
MsgBox "Is app2 save running?"
return
end if

end if
end if

Loop Until Obj.NextItem = False
>
And you must also handle the "aevt", "clos" AppleEvent in the app2 to
close the document.
_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.
_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.
_______________________________________________
Unsubscribe or switch delivery mode:

Search the archives:



---------------------------------
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 05.08.07 02:15 (Sat, 4 Aug 2007 19:15:04 -0600)
From: joe strout.net
On Aug 04, 2007, at 03:19 UTC, Lennox Jacob wrote:

> > Just add a button or menu command that
> calls SelectFolder, then iterates through that folder and calls your
> Open and Save methods on each one. (Again, these should be
> *methods*, not events -- the events just call the relevant methods,
> which is why you can also call those methods from elsewhere in the
> code, as you'll be doing here.)
> OK Joe,
> I got that, so I created a pushbutton and used a "for loop".

Go so far.

> So when
> I push the pushbutton I use f.launch to open the files in the folder
> that has all the files. f.launch launches all the files.

No. Forget about f.Launch; you don't need it and it leads you astray.
Just open the files directly, by calling the same method that you're
now calling from your OpenDocument event. (And then, immediately call
whatever method does the "save" functionality.)

Best,
- Joe

Re: Help: Effecting Keyboard keydown programatically
Date: 05.08.07 04:41 (Sat, 4 Aug 2007 20:41:16 -0700 (PDT))
From: Lennox Jacob
Thanks Joe,

This is what I did:
I added a Pushbutton and added this code:

dim f, File As FolderItem
dim i As Integer

fÞsktopFolder.Child("Old Files")
for ito f.Count 'Every file in the folder
FileðtrueItem(i)
if File<>nil then
If File.name = ".DS_Store" then

else
app.Opendocument File //(open the file)

MyAppMainWindow.SaveAsPushButton.Push //(Save the file)

MyAppMainWindow.ClosePB.Push //(Close the file)
end if
end if
next

I put 2 files in DesktopFolder.Child("Old Files")

When updateFiles pushbutton is pushed the first opened, the save dialog box appeared and when I clicked OK a file was created, that file had no data, then the second file opened, the save dialog box appeared again, clicking OK just overwrote the first file, and again had no data. The files were not closed, they remained on the desktop.

Any other suggestions?

Lennox.



---------------------------------
Shape Yahoo! in your own image. Join our Network Research Panel today!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Help: Effecting Keyboard keydown programatically
Date: 06.08.07 15:56 (Mon, 6 Aug 2007 08:56:48 -0600)
From: joe strout.net
On Aug 05, 2007, at 03:41 UTC, Lennox Jacob wrote:

> app.Opendocument File //(open the file)
>
> MyAppMainWindow.SaveAsPushButton.Push //(Save the file)
>
> MyAppMainWindow.ClosePB.Push //(Close the file)

The problem here is probably that you're only referring to the implicit
instance of MyAppMainWindow. I wouldn't expect that to work in a
document-oriented application, because your app.OpenDocument code
probably doesn't open the given file into the implicit instance, but
instead probably creates a new instance of MyAppMainWindow.

Also, I don't understand why you're mucking around with UI elements
like the SaveAsPushButton and the ClosePB. Those UI elements should do
nothing but call some methods to do their work; here, you should call
the same methods directly.

So, the guts of this loop, in one of my apps, would look like this:

Dim w as New MyAppMainWindow
w.LoadFromFile file
w.SaveToDisk
w.Close

And that's it. LoadFromFile and SaveToDisk are methods I'd write which
do the obvious things, and Close is the standard Window method.

Best,
- Joe

Re: Help: Effecting Keyboard keydown programatically
Date: 06.08.07 16:54 (Mon, 6 Aug 2007 08:54:02 -0700 (PDT))
From: Lennox Jacob
Thanks Joe,

I got it eventually.
I did what you suggested ;
I did not bother with f.Launch
I use app.OpenDocument to open the file
I used WindowCount to access the open window and once the window was accessed then I used
FileSave to save the file
and close to close the file,
so I did not have to create new methods.

The problem was that I was using folderitem instead of Window to access the contents of the open window, and that is why a new empty document was opening, saving and closing and leaving the opened windows with data on the desktop.

Thanks again.
Lennox

<email address removed> wrote: On Aug 05, 2007, at 03:41 UTC, Lennox Jacob wrote:

> app.Opendocument File //(open the file)
>
> MyAppMainWindow.SaveAsPushButton.Push //(Save the file)
>
> MyAppMainWindow.ClosePB.Push //(Close the file)

The problem here is probably that you're only referring to the implicit
instance of MyAppMainWindow. I wouldn't expect that to work in a
document-oriented application, because your app.OpenDocument code
probably doesn't open the given file into the implicit instance, but
instead probably creates a new instance of MyAppMainWindow.

Also, I don't understand why you're mucking around with UI elements
like the SaveAsPushButton and the ClosePB. Those UI elements should do
nothing but call some methods to do their work; here, you should call
the same methods directly.

So, the guts of this loop, in one of my apps, would look like this:

Dim w as New MyAppMainWindow
w.LoadFromFile file
w.SaveToDisk
w.Close

And that's it. LoadFromFile and SaveToDisk are methods I'd write which
do the obvious things, and Close is the standard Window method.

Best,
- Joe