Press enter command

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Ianw
Junior Coder
Posts: 26
Joined: Mon Jan 29, 2007 8:37 pm
Location: UK

Press enter command

Post by Ianw » Sat Feb 10, 2007 11:08 am

I have upgraded Macro Scheduler from V7 to V9. I'm using Vista business (the "features suit me").
The 3 commands below are from a macro that works in V7, there are 100 commands in the script that are similar except for the number of the file in the complete macro. What it does is "unzip" the file and place it in the correct folder in Pinnacle Studio 10. That was in windows XP.
There are no other windows open.

what doesn't work is the Press Enter command in either V9 or in Vista - in V9 I'd say.
In V7 it succesfully closes the windows after showing the progress of the file.
In V9, the window does not close.
In help in V9, it states :-
--------------------
All commands starting with Press facilitate the sending of non-character keys. To issue a Press command more than once add the '*' symbol followed by the number of times to issue the command at the end of the line:

Press Key * n

E.g.:

Press Tab * 5
-------------------------------------
What I'm asking, ( the text "..... issue the command at the end of the line")
Is "Press enter" now placed at the end of the line ? I'm not sure about that as that
instruction may be only for repeat key presses.
However, I need "Press Enter" to follow "Wait>6" to allow the unzipping to finish.

I can't experiment as I don't have Studio installed as it won't work in Vista -yet.
Can you advise please. I'd like to have it ready.
With my very limited knowledge of programming, none of the commands available appear to be suitable.

----------------------------------------------------
ExecuteFile>I:\Programs Video\Studio 9\Hollywood FX Effects\Declic FX\1.hfz
Wait>6
Press Enter
ExecuteFile>I:\Programs Video\Studio 9\Hollywood FX Effects\Declic FX\2.hfz
Wait>6
Press Enter
ExecuteFile>I:\Programs Video\Studio 9\Hollywood FX Effects\Declic FX\3.hfz
Wait>6
Press Enter
- ------------------------------
Many thanks
Ianw

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Feb 10, 2007 1:09 pm

First, I can assure you that there are absolutely no problems with Press Enter in either v9 or Vista! Nothing has changed that would stop Press Enter working and we have dozens of scripts working here that routinely issue Press Enter and they all work in Vista. Press Enter is such a commonly used command that I think we would have been flooded with reports during beta testing and after if there really was an issue.

Looking at your script I strongly suspect this is a timing issue. I say this because you have hardcoded wait times between commencing running a file and then trying to press enter. This is very unreliable. For example, with the following code you are assuming that after *starting* the execution of 1.hfz that 6 seconds is sufficient to put the target window in a state that it can accept the Enter key. If this used to work in XP but no longer works in Vista then it is most certainly because this change of operating systems has changed the timing.

ExecuteFile>I:\Programs Video\Studio 9\Hollywood FX Effects\Declic FX\1.hfz
Wait>6
Press Enter

ExecuteFile *STARTS* execution of the file using the system file association. It fires, forgets and moves on. The Wait>6 statement after ExecuteFile will start processing NANOseconds after ExecuteFile has STARTED 1.hfz executing. What if it takes 10 seconds before visual studio has fully loaded 1.hfz? Press Enter would then not get where you expect it to.

What you should do is avoid using static wait times and instead find a way to tell the script to wait until the target window is ready. The most common way to do this is to use the WaitWindowOpen command. But there are many other ways and commands that can be used to tell the script to wait until ready rather than wait a static amount of time, which is unreliable. And you may need more than just a WaitWindowOpen. Look at WaitReady, also look at Run Program and the RP_WAIT=2 setting as an alternative to ExecuteFile. If all else fails use WaitScreenImage. Bottom line - find a way to make the script wait until it knows the target window is definitely ready for input.

Secondly, you have no SetFocus command. So you aren't even trying to tell the script WHERE to send the enter key. As it stands the script starts a file association action, waits 6 seconds and then just presses enter to whatever window happens to have the focus at that point. It is possible that under Vista something changes the sequence of window focus compared to XP, leaving Visual Studio not focused by the time your script has waited 6 seconds. That could also explain why you are seeing a difference. But if your script uses SetFocus and a better way to wait for the target window to be ready you would be much less likely to see a difference in operation between XP and Vista.

So, you need at least WaitWindowOpen and SetFocus, possibly something else.

Regarding the * n, you would use this to press a key more than once. E.g.:

Press Enter * 5

Would press enter 5 times in a row.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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 Feb 10, 2007 3:31 pm

Hi Marcus

The Help file does not show a RESULT for RP_WAIT=2.

Can you provide info, is it the same as =1 ?

And maybe update the help file with next release.
Missed this one during beta tests.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Feb 10, 2007 4:00 pm

Bob,

It says the following in the "Run Program" topic:

"Set RP_WAIT to 2 if you want the script to wait until it thinks the program is idle and ready for input. This only works for GUI applications and may not be appropriate for all applications. Some applications may appear ready for input before they really are. See WaitWindowOpen and WaitReady for other ways to wait until an application is ready."
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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 » Sun Feb 11, 2007 7:22 am

Hi Marcus.

I saw that. I was not clear, sorry. I am referring to result of Run Program as referenced on that page.

It shows RP_RESULT codes for RP_WAIT 0 and 1, but not for 2.
Does this mean there is no result code, or is 2 identical to 0 or 1 result codes?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Feb 11, 2007 8:26 am

Ah I see. If RP_WAIT is 2 result codes will be same as for 1. This needs adding to the help file. Thanks.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Ianw
Junior Coder
Posts: 26
Joined: Mon Jan 29, 2007 8:37 pm
Location: UK

Post by Ianw » Sun Feb 11, 2007 12:27 pm

Marcus,
thank you very much, I did indeed think it was down to vista in some way but I don't know enough about all this "programming" to say if it was or not.

Before I posted and long after I posted I looked at the possibilites of other commands, Set focus looked a candidate for inclusion, but no other windows are open.

Now I have something to work on.

again,Many thanks to you & Bob Hansen.
Many thanks
Ianw

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Feb 11, 2007 2:13 pm

>but no other windows are open.

That cannot be true. At least three other visible windows must be open:

- Program Manager (Windows Desktop)
- Macro Scheduler
- The Task Bar
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Ianw
Junior Coder
Posts: 26
Joined: Mon Jan 29, 2007 8:37 pm
Location: UK

Post by Ianw » Sun Feb 11, 2007 3:51 pm

Oh dear, I clean forgot about those 3 "windows" you mentioned.
sorry about that.
---------------------------------------
Anyway,

I've been at this for 3 hours & getting nowhere. I've tried all the combination's of the commands you suggested above that I can come up with. I changed the location of the files to simplify it a lot.
I think I've narrowed it down to the title in the window's in question when the file is being processed ( I think !!!).

Because I entered in a script =

Message>all done
Wait>2
Press Enter

It worked.
then I changed the 2 to an 8 and the time between the window closing changed accordingly.

The Run Program command won't work because the files are restricted to a few extensions and *.hfz "extension is not recognised.

In the Window that opens when the file is processed,
the title bar shows :- " Installing I:\Video\Declic FX\1.hfz "

Exactly what should I enter in the command "WaitWindowsOpen>", or in the SetFocus that I tried, and the others you mentioned above.

I tried "Installing I:\Video\Declic FX\1.hfz"
"I:\Video\DeclicFX\1.hfz"
and " I:\Video\DeclicFX\* " - all without the asteriks.


ExecuteFile>I:\Video\Declic FX\1.hfz
WaitWindowOpen>Installing I:\Video\Declic FX\1.hfz
Press Enter

I have just remembered, the MSched icon in the sys tray is blinking indicating it is processing the script, it does that with all the files in the script in question. Even when I close the files window it continues untill I stop MSched in the sys tray. I also clicked on the titlebar in some Windows after the script had finished & I stopped MSched, the windows were active, clicking on them made them inactive.

I have other scripts :
copy file to location
Wait>4
etc etc

they all work perfectly.

Does that give a pointer to the name in the title bar in the windows as I gave above.

sorry to trouble you Marcus but I just can't get this at all.
Many thanks
Ianw

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Feb 11, 2007 4:15 pm

Run the process manually. When the window is in a state ready for the keyboard input, what does it say at the top of the window?

The window title is the text that appears in the top border of the window.

If you are not sure, post a screen shot.

What you say about Run Program makes no sense. If ExecuteFile works then Run Program should also work. Why? Because Execute File executes a Windows file association. By executing a .hfz file what Windows does is execute the program associated with .hfz, passing the .hfz file as a parameter. Therefore running the program directly, with the .hfz file on the command line will do the same thing.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Ianw
Junior Coder
Posts: 26
Joined: Mon Jan 29, 2007 8:37 pm
Location: UK

Post by Ianw » Sun Feb 11, 2007 4:59 pm

Re. the run command, it states in Help & in the Manual for MSched that I bought,
"Executes a specified file. files that can be executed are .exe .bat and .com files.

the error message states :-
error executing I:\video\DeclicFX\1.hfz (11)

Image

In the manual it states for 11 :-
"The executable file was invalid. It was either not a windows based application or there was an error in the .exe image"
It happens with other of the files.

I just ran the path to one of the files in Start / run & it worked.
I:\video\DeclicFX\1.hfz


The title bar :-
Image
Last edited by Ianw on Sun Feb 11, 2007 7:13 pm, edited 2 times in total.
Many thanks
Ianw

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Feb 11, 2007 6:30 pm

>Re. the run command, it states in Help & in the Manual for
>MSched that I bought, "Executes a specified file. files
>that can be executed are .exe .bat and .com files.

Correct. A .exe file is an application. Some application is used to process these .hfz files. What application do these files belong to? What do you do with them? Looks like something to do with "Hollywood FX"? What is that? Once the .hfz file is open what application are you looking at?

That application will have a .exe file. You run it with Run Program and pass the .hfz file to it:

Run>"c:\somewhere\some.exe" "c:\someplace\some.hfz"

Anyway, the window title is: "Installing I:\Video\DeclicFX\9.hfz" in this case. However, it looks like you need to wait until it has finished installing before you can continue? Am I right? I am guessing that if you were to do this manually you would want to wait until it says "Installation complete" before you can press enter and continue?

If I am right we need to find some way of determining when it has finished processing so that we know when we are able to send keystrokes. Worst case we simply wait a static amount of time, if we can be sure that it never takes longer than the time given. E.g.:

Code: Select all

ExecuteFile>I:\Video\DeclicFX\9.hfz
WaitWindowOpen>Installing I:\Video\DeclicFX\9.hfz
Wait>20
SetFocus>Installing I:\Video\DeclicFX\9.hfz
Press Enter
This starts the application that processes .hfz files (whatever that is?), waits for the window entitled "Installing I:\Video\DeclicFX\9.hfz", then waits 20 seconds, then focuses the window, then presses Enter. If 20 seconds is sufficient to allow the process to complete then all should be well.

Looking at this screen shot I think the best and easiest way to know when it says Installation Complete might be to use WaitScreenImage. That would be more reliable and more efficient than a static delay.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Ianw
Junior Coder
Posts: 26
Joined: Mon Jan 29, 2007 8:37 pm
Location: UK

Post by Ianw » Sun Feb 11, 2007 7:54 pm

I may have found the problem, but not the cure.

The process window is not active, nor is your script making it active.

How I found this out (if it actually is this) is I went in to personalize windows and set the desktop to windows Standard (XP). No difference.

then I set it to Windows Classic & that's when I noticed it.

The title bar is not changing colour to indicate the window is active, it does so only when I click on it, then I press enter & the window goes away. However, the MSched icon in the sys. tray continues to blink untill I stop it.

I tried it a few more times just now with the same result.

I'll mention this, but it's not a problem to me now, only that it may be a pointer to something, or it may not.

When I first installed V9 I put my scripts in the install folder.
Then I imported them, then I did this and that, in other words I don't remember what exactly. I ended up with 2 imported sets of my macros.
the second set had a 1 added on at the end. Off I went holding down the Ctrl key and selecting the macros to delete. Oh boy, but did MSched flash or what. It was flashing at a fast rate. I did get them deleted. I don't get that now because I am aware of what can happen when I install again.

OK, I 've just returned the desktop to the vista version. the progress window does not indicate if it is active or not, I click on it when the file has been processed and press enter & off it goes.

Now, the thing is, is it me or vista or perhaps MSched.

I have an idea. I have Msched 7, I'll install it & see what happens. then I'll report back. Nope, same as with my MSched 9 Std.
Many thanks
Ianw

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Feb 11, 2007 8:37 pm

It is possible that there is more than window with the same title. The application could have a hidden window with that title. Try adding this line to the start of the script:

Let>WF_TYPE=2

This will restrict WaitWindowOpen and SetFocus to working on visible windows only.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Ianw
Junior Coder
Posts: 26
Joined: Mon Jan 29, 2007 8:37 pm
Location: UK

Post by Ianw » Sun Feb 11, 2007 10:47 pm

I use Ghost to make images of my system, I restored a previous one & installed Studio Plus 10 on (the remote ) possibility it might have worked, but no.

ExecuteFile>I:\Video\DeclicFX\1.hfz
Wait>6
SetFocus>Installing I:\Video\DeclicFX\1.hfz
Press Enter

The above brings up this error, but the path is correct, I erased the paths in the script and entered them again, not once but three times. =

Image



This one, it executes the file, the open window stays open, it seems to hand when it has processed the Execute File line, I was "messing about with it" just before your last post when I discovered this, and it seems it's still doing that, untill I press the enter Key when the Start menu opens ( I have it set in the Classic style), the window closes when I press enter a second time and the sys tray icon blinks untill I stop MSched, one time I let it actually blink for 15 minutes then I stopped it.

ExecuteFile>I:\Video\DeclicFX\2.hfz
WaitWindowOpen>Installing I:\Video\DeclicFX\2.hfz
Wait>20
SetFocus>Installing I:\Video\DeclicFX\2.hfz
Press Enter

Placing this at the start of the script made no difference.
Let>WF_TYPE=2 made no difference.
Many thanks
Ianw

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