help with notepad's save as

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
bhogue
Newbie
Posts: 9
Joined: Fri Jul 08, 2005 5:25 pm

help with notepad's save as

Post by bhogue » Tue Jul 12, 2005 8:28 pm

I need help with this subject. I have some Macro Scheduler code for
ALT-F
ALT-A
Send>my output filename
Unfortunately, it does not work. My output filename ends up on a line in the notepad.

Even ALT-F followed by ALT-X does not work. My last try was 1) recording a macro doing these steps and 2) running the macro. The macro looks like you would expect. However, the macro does the same thing ... the output filename ends up on a line in the notepad.

I am running Windows XP. Are there any known issues with Macro Scheduler and WinXP?

-brian

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Jul 12, 2005 11:09 pm

No issues with Windows XP - Macro Scheduler 7.3 was developed on it.

Have you read the beginners guide? Post your script if you would like help fixing it. Here's working code to do File/Save As in Notepad:

SetFocus>Notepad*
Press ALT
Send>fa
Release ALT
WaitWindowOpen>Save As
Send>c:\myfolder\newfilename.txt
Press Enter
WaitWindowClosed>Save As

That will save the current Notepad file to c:\myfolder\newfilename.txt

Don't send keystrokes without focusing a window first. After issuing an action which invokes a new window make sure you allow time for that window to be active before sending more keystrokes - use WaitWindowOpen/WaitWindowClosed.

All this is explained in the beginners guide in the help file.
MJT Net Support
[email protected]

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jul 12, 2005 11:11 pm

Brian,

Have you tried searching the forum for answers to your problems? There is a fair amount of discussion on this type of subject.

You may be having syntax problems which is a learning issue. Even if your code is correct you may also be having problems with application windows not opening at the same speed every time you open them. This occurs whether you are using Macro Scheduler or performing tasks manually. And it occurs when you record a macro and everything went fast and play it back and maybe things don't open as quickly. The macro doesn't know your window didn't open it just keeps plugging along sending keystrokes into databit heaven.. To resolve this you need to learn about the WaitWindowXXX functions. Occationally, you will learn, you have to throw in a "Wait" just for good measure. There isn't any way that I or anyone else on the forum can anticipate all possible problems. Therefore, it is helpful to include malfunctioning code in your posts.

This sample runs fine on my computer which is WinXP.
------------script starts below----------

// filename=c:\test.txt

//Next open notepad
run>notepad.exe

//WWO is short for WaitWindowOpen, the script will pause until notepad is actually open and available for input
wwo>Notepad*

//press alt to get the notepad menu
Press ALT

//send an "f" to get "File" from the notepad menu
send>f

//release the alt key just as you would do manually
Release ALT

//Send an "a" for "Save As" in the notepad file menu
send>a

//WaitWindowOpen for the Save As window so that we don't just send the filename text to the next line of our text file
wwo>Save As*

//Send the predefined filename to the "Save As" window's filename field
send>%filename%

//Wait half a sec just to make sure that the name is entered in the field before pressing "Enter", 1/2 second may or may not be long enough,
//you might have to make it 2 seconds in order to be sure that it will work every time
Wait>0.5

Press Enter

------------script ends above----------
If you cut and paste this be sure to remove any trailing spaces.

Trust me, I understand your frustration. I'm trying to learn to do some simple stuff in Visual Basic in Excel. It boggles the mind. I'm sure I'll catch on eventually but right now I know so little I can't even ask an intelligent question.

Hope this helps,
Dick

bhogue
Newbie
Posts: 9
Joined: Fri Jul 08, 2005 5:25 pm

Post by bhogue » Wed Jul 13, 2005 6:01 pm

Thanks for your help (both of you). I used your suggestions to complete this piece.

-brian

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