Jump to content
Sign in to follow this  
Caravelle

NotePad example in the Tutorial

Recommended Posts

Caravelle

I only downloaded and installed AutoIt yesterday so I may have got this all wrong... I tried the Hello World example in the Help file Tutorials. Of course it worked perfectly. Pleased with my small success I moved on to the second example:

Our complete script now looks like this:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "&Save")
Send("!n")

Run the script and you will see Notepad open, some text appear, then close! You should be able to use the techniques learned in this tutorial to automate many other applications.

But this doesn't work as advertised. It stops and waits for the user to press a key before closing. As far as I can see from one of the example scripts included with the download, notepad1.au3, if you want the NotePad window to close itself you need to look for "No", and also there is no need for "!n" - "n" will do nicely - the buttons respond to the normal keypresses, they don't need the ALT as the tutorial suggests.

It doesn't inspire confidence that the learning process is going to be easy, when the beginners' help is misleading. I hope someone will correct it.

I was attracted to AutoIt3 when I discovered it came with a sqlite wrapper: should be ideal for a small database reader/updater to live on a USB memory stick along with the data (I already use sqlite3). And I was actually Googling for a Delphi component to go to a website, enter a query and copy/paste the result into my database - hopefully AutoIt can do this without the Delphi overhead, but I can still call the DLL from Delphi if necessary. Lots of learning to do yet though and my grey matter is well-past its sell-by date. I may just need to ask a few questions here.

Caravelle

Share this post


Link to post
Share on other sites
Jos

It doesn't inspire confidence that the learning process is going to be easy, when the beginners' help is misleading. I hope someone will correct it.

WinXP I guess ? This one is made in Vista and is correct, not wrong.

Have you read the whole page and followed the steps ?

If so you would have found the different options (Yes,No,Cancel) in the "AutoIt Window Info" tool and use those findings...

:)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Jos

Welcome to the forum.

See this report:

http://www.autoitscript.com/forum/index.ph...st&p=392991

-MSP-

You proposal would defeat the shown steps using the Information found with AU3Info.exe.

We could change it to:

WinWaitActive("Notepad", "Cancel")
Which would make it work in both WinXP and Vista and still use the found information.

:)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
ssubirias3

WinXP I guess ? This one is made in Vista and is correct, not wrong.

Have you read the whole page and followed the steps ?

If so you would have found the different options (Yes,No,Cancel) in the "AutoIt Window Info" tool and use those findings...

:)

Back on August 6, 2007 I posted my casual observation about the notepad tutorial prior to sending an email to the folks in charge. I received the same response that it wasn't that the code was wrong, but rather it was written for Vista as the screenshots illustrate. As true as that may be, I think on some level it would be helpful to state that the notpad tutorial is scripted for Vista. Afterall the other code examples including the winzip tutorial work on XP without modification. Remember, nowhere on the screenshots or anywhere within the tutorial itself does it say Vista code. To expect anyone, especially a noob, who is doing the right thing and reading the Help file to immediately recognize the screenshots are Vista and not a possible theme is a bit ..... well, you get the point. Overall its not a big deal as much as the attitude being presented. It really wouldn't hurt anyone to say "good point <noob>, thanks for helping us catch that."... or would it?

And yes Vista is the latest version of Windows, however my guess would be its still in the minority of Windows operating systems in use today. If that's the philosophy then why is http://www.autoitscript.com/AutoIt/ still availabe, especially since AutoIt3 was released in (29th Feb, 2004) and we're halfway through 2007? All interesting stuff, but one thing's for sure its not worth getting bent out of shape about.

Share this post


Link to post
Share on other sites
Jos

Back on August 6, 2007 I posted my casual observation about the notepad tutorial prior to sending an email to the folks in charge. I received the same response that it wasn't that the code was wrong, but rather it was written for Vista as the screenshots illustrate. As true as that may be, I think on some level it would be helpful to state that the notpad tutorial is scripted for Vista. Afterall the other code examples including the winzip tutorial work on XP without modification. Remember, nowhere on the screenshots or anywhere within the tutorial itself does it say Vista code. To expect anyone, especially a noob, who is doing the right thing and reading the Help file to immediately recognize the screenshots are Vista and not a possible theme is a bit ..... well, you get the point. Overall its not a big deal as much as the attitude being presented. It really wouldn't hurt anyone to say "good point <noob>, thanks for helping us catch that."... or would it?

And yes Vista is the latest version of Windows, however my guess would be its still in the minority of Windows operating systems in use today. If that's the philosophy then why is http://www.autoitscript.com/AutoIt/ still availabe, especially since AutoIt3 was released in (29th Feb, 2004) and we're halfway through 2007? All interesting stuff, but one thing's for sure its not worth getting bent out of shape about.

Which attitude do you mean ?

I assume you mean you didn't felt taken serious or something ?

As far as I remember, I have written the answer and it was more or less the same as what I wrote here ... right ?

So which word in my response demonstrates this (wrong) attitude towards you or the OP ?


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
weaponx

I would expect it to prompt to save considering you've entered text, I would hate to be using Vista (which I hope never happens) editing 3000 lines of code in Notepad, accidentally click X and poof it's gone.

Share this post


Link to post
Share on other sites
Paulie

I have to agree with ssubirias3 here.

I just looked at the Notepad Automation page in the help, and nowhere in text is the word "Vista" even present.

Also, none of the other helpfile tutorials only function in Vista, so expecting someone to just assume that this one is specifically for vista based on the pictures is... well, stretching it... At least I know that it wouldn't be the first assumption I'd make.

Perhaps there should be two entries in the Tutorial section for Windows Notepad Automation.

  • Simple Notepad Automation (XP)
  • Simple Notepad Automation (Vista)
Because as Caravelle stated, from a new coder's perspective, learning the language would seem much harder than it really is if the first script you attempt to run from the helpfile errors out.

I don't see any harm in adding 1 word to the help in order to clarify the issue.

EDIT: @JdeB-

I believe the attitude he speaks of is that he feels your response to him was a little condescending. Maybe it came across as if you felt it should have been obvious and that he was just supposed to know that it was only for vista and wouldn't work on XP.

Personally, I see it as a valid question to pose to a "higher-up" (such as yourself, :)) If i were to run something from the helpfile and it were to not work as expected. Especially when nothing is documented or explained in regards to what might be causing the problem. And if I had, I would be rather put-off if I got chewed out for asking a supposedly "obvious" question.

Edited by Paulie

Share this post


Link to post
Share on other sites
herewasplato

You proposal would defeat the shown steps using the Information found with AU3Info.exe.

We could change it to:

WinWaitActive("Notepad", "Cancel")
Which would make it work in both WinXP and Vista and still use the found information.

:)

Good point - sadly, I only skimmed the tut and did not notice the [Window text] point being taught.

Edit in brackets[]

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
herewasplato

I would expect it to prompt to save considering you've entered text, I would hate to be using Vista (which I hope never happens) editing 3000 lines of code in Notepad, accidentally click X and poof it's gone.

Both Vista and XP offer to save what you have entered into Notepad... just XP's prompt offers Yes/No/Cancel and Vista offers Save/Don't Save/Cancel.

-MSP-


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
Jos

Good point - sadly, I only skimmed the tut and did not notice the point being taught.

Well... it looks like you are not the only one missing that and when trying to explain it 2 times it seems it was interpreted as having an attitude when the only point I was trying to make is that the example is "NOT WRONG" .... nothing else ... oh well .. Shit Happens :) Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Jos

EDIT: @JdeB-

I believe the attitude he speaks of is that he feels your response to him was a little condescending. Maybe it came across as if you felt it should have been obvious and that he was just supposed to know that it was only for vista and wouldn't work on XP.

Personally, I see it as a valid question to pose to a "higher-up" (such as yourself, :)) If i were to run something from the helpfile and it were to not work as expected. Especially when nothing is documented or explained in regards to what might be causing the problem. And if I had, I would be rather put-off if I got chewed out for asking a supposedly "obvious" question.

I write pretty strait forward English as I am Dutch and have not much emotions about "putting a wrapper and ribbon" around my text.

So my reply is "strait to the point" and replying to the fact where it is stated that the example is "wrong". Nothing more ..nothing less.


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Paulie

I write pretty strait forward English as I am Dutch and have not much emotions about "putting a wrapper and ribbon" around my text.

So my reply is "strait to the point" and replying to the fact where it is stated that the example is "wrong". Nothing more ..nothing less.

I understand... Perhaps a notification in the helpfile is in order then, to prevent further false accusations of helpfile incorrectness.

I think people now understand that the helpfile code works on Vista, however, nowhere does it say it requires vista. and as it seems, expecting people to assume that it is only for Vista based on the screenshots isn't quite cutting it.

Just my $0.02 cents.

Share this post


Link to post
Share on other sites
Jos

I understand... Perhaps a notification in the helpfile is in order then, to prevent further false accusations of helpfile incorrectness.

I think people now understand that the helpfile code works on Vista, however, nowhere does it say it requires vista. and as it seems, expecting people to assume that it is only for Vista based on the screenshots isn't quite cutting it.

Just my $0.02 cents.

I understand what you are asking but the statement remains that if you "work through" the whole example step by step you would have noticed that au3info shows something else on WinXP or any "None English" Windows version and thus needs changes as such.

I leave it to Jon to do what he thinks is best here since he wrote this tutorial and updated it to the current Vista version.

:)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Caravelle

Thanks for the quick responses.

JdeB wrote:

WinXP I guess ? This one is made in Vista and is correct, not wrong.

Have you read the whole page and followed the steps ?

If so you would have found the different options (Yes,No,Cancel) in the "AutoIt Window Info" tool and use those findings...

Do you mean that this version of the Help addresses only Vista, but the example scripts provided do not? In that case, is there an earlier version of the Help available which does address Windows XP? A person who has never used Vista simply does not know what the differences are likely to be, and is unlikely to know that there will be differences at this level. NotePad is NotePad is NotePad - except when someone tells you that a NotePad you have never seen is not NotePad.

Yes I read the whole page. Yes, I followed the steps, but I did not know why the illustrations differed from what I had on my screen.

Before retiring I spent many years writing instructions based on the law. The law changed frequently, so the instructions had to be rewritten, but people would still be dealing with cases under the old laws - it was possible for many different versions of the law to apply to the same case depending on how long it had taken to deal with. It was a key feature of the instructions that they should state clearly at the outset which set of laws they referred to - there could be serious consequences if the wrong law was applied. When the same situation needed different guidance because an older law applied to the case, the instructions would either explain the earlier guidance directly or refer to the relevant paragraph of the earlier instructions. This was especially necessary because new staff would not be aware of the old instructions otherwise. This is a long way of saying that the Tutorials should say that they are written for Vista, and when some code or an illustration ONLY applies to Vista there should be a warning and ideally alternative code/illustration or less ideally a reference to an older tutorial that works under earlier versions of Windows.

I don't wish to suggest that the entire set of Help is not an impressive document - it is brilliant by comparison with the Help in countless other packages, even the big commercial ones from the likes of Corel. But a beginner's tutorial needs to be crystal clear because you cannot assume that the people reading it understand either the background or the context, and there is no teacher present who can be asked to explain something one does not understand fully. This is especially so when the subject is technical and requires a grasp of detail. I have several Delphi components which I am sure will do exactly what I want if only I could understand how to make them work, but what help is provided does not start at the beginning, rather it assumes familiarity with the very thing one is trying to learn. I have come across this problem so many times over the years. It can be very frustrating and discouraging.

So thanks again for explaining - but if the Tutorial explained, you wouldn't have to. Maybe from this point on the Help is perfect :)

Caravelle

Share this post


Link to post
Share on other sites
Jos

Do you mean that this version of the Help addresses only Vista, but the example scripts provided do not? In that case, is there an earlier version of the Help available which does address Windows XP? A person who has never used Vista simply does not know what the differences are likely to be, and is unlikely to know that there will be differences at this level. NotePad is NotePad is NotePad - except when someone tells you that a NotePad you have never seen is not NotePad.

No, I meant that the Tutorials intend is to show how you use au3info.exe to display the Applications window information and how to use the found information in a script.

I understand that it only works on English version of Windows Vista. People that have an other OS or use a different language of Windows Vista will have to change the example to what Au3info is showing them in their system.

Lets see if Jon will make a remark about this in the Tutorial to inform people about it.

-snip-

So thanks again for explaining - but if the Tutorial explained, you wouldn't have to. Maybe from this point on the Help is perfect :)

I understand what you are saying and know its very very difficult to write tutorials that works for everybody, plus to me (and many other IT folks) documentation is a chore and always happens as a last (necessary evil) task.

;)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
ssubirias3

Which attitude do you mean ?

I assume you mean you didn't felt taken serious or something ?

As far as I remember, I have written the answer and it was more or less the same as what I wrote here ... right ?

So which word in my response demonstrates this (wrong) attitude towards you or the OP ?

Heheheee easy my brother. All's goovy on this side of the pond. Please understand my private and public comments on this topic were never intended to be an attack on you or your code. The word "attitude" can often be tricky yet reflects our state of mind. Attitudes can be positive, neutral, or negative. For example,

A possbile good attitude toward the matter:

... We could change it to:

WinWaitActive("Notepad", "Cancel")
Which would make it work in both WinXP and Vista and still use the found information.
A possible alternative toward the matter:

... the example is "NOT WRONG" .... nothing else ... oh well .. Shit Happens

My point is whenever someone, MVP or noob, makes a valid and factual observation it should be recognized as such and not rebutted with subjectivity. To say something is or is not wrong without contextual qualifiers, is purely subjective. In programming terms we can look at the Notepad Tutorial this way:

claim = existing code is wrong ... true or false?

If OS == Vista ... claim is false

If OS <> Vista ... claim is true

The attitude I was speaking about has to do with the actions taken to address this point, afterall actions speak louder than words... right? If everyone agrees that the tutorial could be improved by changing the code as JdeB suggested, that's positive, hence reflecting a positive attitude. On the other hand to only say "oh well .. Shit Happens" maybe that's a really positive attitude to have as subjective as that might be.

As I said originally,

... Overall its not a big deal .... All interesting stuff, but one thing's for sure its not worth getting bent out of shape about.

Edited by ssubirias3

Share this post


Link to post
Share on other sites
Caravelle

JdeB wrote:

No, I meant that the Tutorials intend is to show how you use au3info.exe to display the Applications window information and how to use the found information in a script.

I am afraid that the tutorial itself disagrees with you, and anyone reading it is told that the intent is something different.

The tutorial follows the good practice of stating its purpose. It says:

This tutorial explains how to automate the opening of Notepad, automatically type some text and then close Notepad. It is assumed that you are already familiar with creating and running AutoIt scripts as shown in the HelloWorld tutorial.

If what you say is correct then it would say:

This tutorial explains how you use au3info.exe to display the Applications window information and how to use the found information in a script.

This is really nothing to get upset about. Other contributors seem to have regarded your earlier reply as dismissive and off-putting but I did not feel "chewed out". Merely puzzled :) It is always wise to assume a degree of mutual incomprehension when corresponding with someone whose first language is not the same as one's own. I am English but my own grandchildren are French: even though we all speak both French and English, we often fail to understand each other. I have the same trouble with my friends in the USA ;) All that is happening here is that you were seeing the issue from a different perspective which is denied to anyone who just has the tutorial to rely on.

Let us move on and forget this. In any case, as I said originally, I succeeded in making NotePad close automatically by using the code in the script example.

But I still have questions which the tutorial does not answer. Here is the given script again:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "&Save")
Send("!n")

(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

Share this post


Link to post
Share on other sites
Jos

But I still have questions which the tutorial does not answer. Here is the given script again:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "&Save")
Send("!n")

(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?

Both will work but I also mostly use Alt+Letter since that's a common way of selecting Options in Windows. There is no right or wrong here, just multiple options. Use the one you feel is the best way of doing it.

(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.

Also here you have multiple options: The only important thing to consider here is to take a combination of WindowTitle and Text that makes the selection Unique. All your listed examples will work. The thing to remember is that when an ampersand is inside the text it needs to be included. For example when the option reads: "Save &As".

also basically both options in the Win???() commands are "optional" eg:

WinGetTitle("") ;==> get the active window's title.

WinGetTitle("","My Text") ;==> get the window's title that contains the text "My Text".

Another thing to consider is the Opt() setting you have active that will influence the behaviour of the Win???() functions:

Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect

Opt("WinSearchChildren", 1) ;0=no, 1=search children also

Opt("WinTextMatchMode", 1) ;1=complete, 2=quick

Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

:)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
ssubirias3

But I still have questions which the tutorial does not answer. Here is the given script again:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "&Save")
Send("!n")

(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.

Morning Caravelle. Not sure why the Wndows Info shows you somthing different on your version on Windows XP. Both of the next screenshots show &n and !n (Alt+n) is the correct key combination. There may be other key combinations that also work, however if following the example of using WinInfo then !n is correct. Basically use the information WinInfo gives you for your computer :). About WinWaitActive, the Help file says the text and and timeout parameters are optional. Hope this helps and Welcome to Autoit!

Screenshot from Notepad Tutiorial:

Posted Image

Screenshot of WinXP Pro WinInfo:

Posted Image

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.