Edit file for Keywords setup

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Sep 02, 2003 2:04 am

To troubleshoot:
A) Maybe put in a Wait>60 after each TP macro is run so you can manually look at results, then allow macro to continue? Be sure not to lose focus during the Wait> period.

Or

B) Save the file after each macro with different name to see results before and after each TP macro? Run entire MS macro then look at 3 saved files. Do every time until can see difference when it fails.

Or

C) Run the process manually in TextPad 3-5 times to see results. Use same keystrokes as in the MS macro.

And/Or

D) Turn on MS logging and verify that all steps are being executed. I suspect you will not see anything here though, this does sound like a race condition or memory issue.

=============================

Possible solution without troubleshooting:
Perhaps need a Wait>1 or WaitReady>1 after each TP macro before going to top of document again? And/Or a Wait>.5 after every Press and Send>Command.

=============================
Possible soolution #2:
May actually want to split Send>MD into

Press ALT
Send>M
Wait>.5
Send>D
Wait>.5
Release ALT

This would be typical for the three sections that are calling TP macros.

Now that I think about this, I would actually try doing that first. If that does not work, then do some diagnostics and troubleshooting.

Go for it, you are almost there!

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Tue Sep 02, 2003 2:12 am

Bob...cross fingers I had just figured to come here to say that the likely issue was not enough time waiting between operations.

I noticed that operations were being conducted out of order, sometime not and sometimes yes, etc. and for different samples in different ways...

I added a 3 second wait between each major step and it seems to be working more consistantly

I do not want this to be a computer problem please!!!

Again thanks, I will test this a little bit more thoroughly before posting again...I think I have used up my allotment of space today!
Best Wishes!
mo

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Tue Sep 02, 2003 8:42 pm

OK, I have used this in some relatively heavy-going real-life situations and it seems to hold together with the 3 second waits (maybe excessive, but I have some longish and complex documents and would rather play it safe...three seconds is not intollerable.)

There are still some things going on here that are not right.

1. It seems like a good idea that MS get terminated (while keeping the TextPad file it has created open and in focus) after running this script. With MS running certain keystrokes seem to produce strange behavior...

2. at the end of editing the file, occasionally hitting the delete button to get rid of an extra line of copy, or an extra comma, will insert a line of text...some of it looking like machine code.

3. pressing the back button several times (one beyond the number of changes) results in the file being closed (luckily it is saved and can be re-opened)

4. the "Remove all 'air'" macro still does not work for me in this script. I tried re-inserting it after some stability seemed to have returned to running the script, and very strange behavior resulted. It opens the Macros menu and selects record, or some other item. No harm, but it also doesn't do what it is supposed to do. This may be because I believe I changed the name of the macro when I initially set it up. I am going to reinstall the macro and see what happens.

5. it seems reasonable, but I do not have the patience to try it just now, that Bob's closing routine will work now that the rest of the script is stable.

Here is the stable version of the script as I have been using it today:

===========================

//
//Variables
//
Let>WW_TIMEOUT=5
Let>WindowName=TextPad*
Let>FileName=E:\All Webs\Buddha Dust\BuddhaDust\backmatter\glossology\edit4keywords_temp.txt
CapsOff

//Run program and wait for it to be active
Change Directory>F:\Program Files\TextPad 4
Run Program>F:\Program Files\TextPad 4\TextPad.exe
WaitWindowOpen>%WindowName%
SetFocus>%WindowName%
Wait>1

//Paste from Clipboard
Press CTRL
Send>v
Release CTRL
Wait>1

//Select All
Press CTRL
Send>a
Release CTRL

//Move All to Left Margin (4 back tabs)
Press Shift
Press Tab *4
Wait>3

//Go to Beginning of First Line of text.
Press CTRL
Press Home
Release CTRL

//Run TP 'Strip Tags' Macro ALT+MS
Press ALT
Send>MS
Release ALT
Wait>3

//Go to Beginning of First Line of text
Press CTRL
Press Home
Release CTRL

//Run TP "Remove Blank Lines" macro ALT+MD
Press ALT
Send>MD
Release ALT
Wait>3

//Save As edit4keywords_temp.txt
Press ALT
Send>fa
Release ALT
WaitWindowOpen>Save As
Wait>0.16
Send>%FileName%
Wait>1.5
Press Enter
Wait>1.5
//OK Replace file
Press CTRL
Wait>0.5
Send>y
Wait>0.5
Release CTRL
Wait>0.5
=====================
Best Wishes!
mo

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Thu Sep 04, 2003 3:13 pm

Well this has had some reasonably heavy-duty use at this point and is doing just fine.

Second thoughts about the additional routines are that (I have given some look see at the documentation) unless there is a way to indefinately pause MS, this will need to be in two separate macros. The time to edit the copy varies all over the map, and is sometimes interrupted for long periods while other things are going on. I didn't see a way to do this ... pause MS indefinately... say by bringing up a check box that said Ok to resume, or something like that which would almost be as much work as startiing up a macro from a shortcut.

The problems at the end of the file are still a mystery. They do not appear at all times, and making saves regularly seems to either eliminate the problem or reduce it (can't quite tell yet).

This may be a too highly specialized script for general use, but maybe not...any webmaster interested in boosting ratings is well advised (so I hear) to make individual meta tag descriptsions for each page as well as true keywords for the page. This has saved me hours and hours of work already in this task.
Best Wishes!
mo

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Sat Sep 13, 2003 3:58 pm

Hello again,

I have been using this script every day, several times a day now and it is saving me vast amounts of time.

The one issue I continue to have is the insertion of garbage text at the end of the file in certain circumstances which I have pretty convincingly narrowed down to being cause by the combination of MS being open while this script is being edited in TextPad.

I am able to consistantly (so far) eliminate the problem by closing MS as soon as the TextPad file has been created.

So the next issue is: is there a good sequence to use to close MS after it completes a macro ... (or can it even be done from within a macro? isn't it needed to be open to close itself?...you see my problem with this issue.)
Best Wishes!
mo

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Sep 13, 2003 5:05 pm

If I am not mistaken, you are running Macro Scjheduler from a Tool within TextPad? If Yes, I suspect that is causing your problems.

When a macro ends, by itself, which it usually does unless you messed up the script creating a loop or an indefinite Wait, the system returns to the same condition it was before the macro. So it you had Macro Scheduler opened as a TextPad Tool, and then called a macro from there, you probably would still see Macro Scheduler open.

For diagnostic purposes here:
What if you open Macro Scheduler by itself, open the file, edit and save. Do you still get the extra gargabe lines?

When you run the Macro from the systray icon does Macro Scheduler stay open then?

Remember you are choosing to use TextPad to edit, but it is not designed to run macros in a diagnostic mode. If you want to persist on using TextPad, let me suggest that you edit and save as *.scp in TextPad, then open a separated instance Macro Scheduler to open the file in Macro Scheduler Editor to Test Run.

Just a few of my immediate thoughts, not completely thought out yet.

Hope this was helpful................good luck,
Bob

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Sat Sep 13, 2003 6:11 pm

Thanks for the think, Robert, but no, I only use MS from within TP to edit scripts. I havn't got to the point where I have any MS scripts that I use on existing textpad files. This is running MS from a shortcut on my desktop (I dislike items in my systray; or any background-running processes that I don't need). The relationship is only through the clipboard. Click the shortcut to MS, Run Now the macro, which Opens a new instance of TP, paste the contents of the clipboard, act on the contents, save the file, stop.

The MS temporary icon in the systray does stop blinking when the script is done, but it needs to be "Quit" to insure (at least as far as I have been able to see) that the eof problem doesn't happen.
Best Wishes!
mo

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Sep 13, 2003 6:43 pm

Three other suggestions for you to run that macro:

1. Instead of a desktop icon for Macro Scheduler, try right click on the systray icon for Macro Scheduler, left click on Quick Launch, then left click on Macro to run.

Even better:
2. Open Macro Scheduler, right click on the macro to run and left click on desktop shortcut. Now click on that vs. icon to open Macro Scheduler.

Possibly best:
3. Open Macro Scheuler, right click on the macro, and left click on Macro Properties. Go to Hot Key tab and create a hot key. Be sure to put a checkmark in the box. Apply, and OK. Now you can close Macro Scheduler. Now no icon is needed at all.

Hope this was helpful.................good luck,
Bob

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Sep 13, 2003 7:00 pm

Also, let me see if I can restate your problem for myself.

1. You copy something to the clipboard.
2. You click on desktop icon to open Macro Scheduler.
3. You highlight macro to run and click on Run icon.
4. Macro opens TextPad, pastes from clipboard, edits/parses per macro instructions, saves the file in TextPad, and ends the macro.
5. So you are now in TextPad. macro is stopped.
6. If you close the file you just saved, and then open the file, it has extra lines added to it.

Do I have this correct?

When you save the file, what extension are you using? Are you using the TextPad default class or another one?

Can you provide sample of info that was copied to clipboard?
Can you provide Macro Scheduler script to go with it?

I use TextPad, so I can probably clone the process on my system to see if I can duplicate the problem.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Sep 13, 2003 7:12 pm

You asked earlier:
unless there is a way to indefinately pause MS, this will need to be in two separate macros.
In addition to a Dialog box with OK, or a MessageModal> tool, there are a number of other tools you can use to "pause" a macro.

Some quick suggestions for you to consider:
1. You could modify your main macro to add a line to an INI file when certain phases are completed. You could set up a loop to periodically read an INI file and wait until a certain phase has happend before proceeding.

2. You could also loop until a certain file exists or doesn't exist any
longer, or until a file date/time/size has changed.

3. You can wait until a certain window opens/closes.

Lots of loops and waits can be made with some default timeouts.

It should be remembered though, that while the macro is "paused" it is consuming some resources while it loops or passes time to default timeouts, etc. It may be an insignificant amount, but that importance will vary for every user, only you can make that call.

Hope this gives you some ideas to explore..............good luck,
Bob

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Sat Sep 13, 2003 7:25 pm

Best Wishes!
mo

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Thu Sep 18, 2003 11:50 am

I think this problem has been solved. TextPad support suggested an upgrade of my video card (after seeing my screenshot of TextPad displaying an image). I have done a few "real" edits since and also a few tests and have not had the problem again.

PS: It's not very convenient to copy and paste the sample text in the above post even in TextPad...first without using TextPad's "Paste html" feature what is pasted is the BBs version of html which of course does not work in the macro; and second using TP's "paste html" numerous characters are converted to plain text making the file very difficult to read.
Best Wishes!
mo

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Sep 18, 2003 11:47 pm

Hi mo.......

1. Glad to hear it was solved. But done by changing video card? who have thunk it? Not me, for sure.

2. I totally missed your detailed response on 9/13 that I offered to try to duplicate. :oops: Sorry about that. But now that I hear about the cause, I guess I am lucky I missed it. Imagine all that time trying to resolve the impossible!

3. And I see how you are using Macro Scheduler along with TextPad macros. I also have found that to be a much better method than using TP macros to do this type of work.

4. Finally, a reminder that you still might want to eliminate the TP macros and use Macro Scheduler to send the keystrokes to do the same thing (in your spare time, I guess). That will provide you with the ability to modify/edit if needed. And you can at least read the script in Macro Scheduler, while you may have no idea what is going on in the TP macros.

Congratulations, I don't expect that any more of your posts here will be in the Beginner section. Nice work..... :D

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts