Jump to content

NotePad example in the Tutorial


Recommended Posts

(1) No-one has addressed the issue of "!n" as opposed to "n" to trigger the negative button. I have spoken to a friend who has Vista and she confirms that NotePad in Vista does not require ALT+N either. The plain n key works just fine. So Vista, XP or whatever, why do you use "!n" ? Is it recommended practice to use the ALT key even if the plain key works?

(2) Why "WinWaitActive("Notepad", "&Save")"?

Why not: "WinWaitActive("Notepad", "&No")" ?

Why not "WinWaitActive("Notepad", "No")" ? The example script Notepad1.au3 (which specifically states that it is for Win 9X/NT, by the way) says "WinWaitActive("Notepad", "No")" without the ampersand. And that works in XP too. And having checked the help on WinWaitActive, I discover that the second parameter is optional anyway! So

Why not "WinWaitActive("Notepad") ?. It works.

In order to understand what I am doing I need to know if it matters whether or not the exclamation marks and ampersands are included and if it matters which bit of Window text (if any) is pointed to by the WinWaitActive("Notepad", ...) statement. Only then can I start writing my own scripts with any confidence that they will do what I want. I know from Delphi programming that the details can make a huge difference. I will not take offence if someone points me to a part of the Help I have not discovered yet.

Thank you in advance.

Caravelle

Sorry if your new experience seems bugged.

For (1), I am surprised that Notepad allows just "n" and is a easy way to lose information as weaponx has mentioned. :)

For (2),

  • "&Save" exists in the picture in the tutorial.
  • "&No" does not exist in the picture in the tutorial.
  • "No" does not exist in the picture in the tutorial.
  • Notepad1.au3 does not work here in Vista.
  • Using "Notepad" alone may work but is not explicit. Thus it teaches using no text as a parameter which can be a bad habit to use often. It is perhaps better in this case though.
I try to add whatever information is available. You must surely understand that adding text that does not exist in the tutorial is more confusing and incorrect to it then what it is meant to achieve. The code reflects the information contained in the pictures. No where is it mentioned that the tutorial extends to all windows versions so you were mistaken for the failed operation of the copied script without checking. If you would have interactively made your script a long with the tutorial then you would have noticed the differences and would have created a script that works and would have learnt from it.

If Microsoft changes these buttons around in different windows OSes then, yes, automation can be made differcult to manage. Automating Notepad is a lesson that hopefully you will not need to repeat again as more efficient methods exist to handle text files directly. I am not going to lie to you that automation is simple, and sometimes it may frustrate you at times, but the benefits from being able to manipulate the windows gui does have some good rewards.

I always specify the exclamation marks and ampersands as following AutoItInfo Tool always gives you correct information normally. Normally what AutoItInfo sees is what AutoIt sees.

;)

Link to comment
Share on other sites

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

Send("This is some text.")

WinClose("Untitled - Notepad")

Send("n")

Works on XP.

You are sending "n" to which window? and do not say the "Notepad" window as it may not exist when the send happens.
Link to comment
Share on other sites

Morning Caravelle. Not sure why the Wndows Info shows you somthing different on your version on Windows XP.

Puzzled again, but I'm spending far too much time on Forum messages and not enough time on getting started writing my scripts. so I'll leave it.

Thanks for both your messages. Again I think it's all a matter of taking what the Tutorial actually says as Gospel and trying to draw conclusions from it - which is all a beginner can do. If I hadn't had the initial trouble, then I wouldn't have discovered that the text and the exclamation point were options for specific cases, and used in this example even though it isn't such a case. And which bit of text you choose is irrelevant so long as it's unique. Great, it's good to have options like this. But the tutorial could have been a bit more illuminating on the subject.

Basically then, the answers to my whys are "because we chose to do it that way - we didn't have to and neither do you". No programming reason at all.

Oh well, never mind.

Thanks again

Caravelle

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...