Sign in to follow this  
Followers 0
cemclellan

Using AutoIt with Windows 7 pro

6 posts in this topic

I just downloaded and installed AutoIt v3.3.8.1.

I am running it on a Windows 7 Pro 64 bit system.

Wonderful document you put together for the newbie!

I am using the wonderful tutorial posted under - Learning to To Script with AutoIt V3.

I am having trouble with the second example, the notepad automation.

It will open notepad just fine, but does not send the text to notepad.

Any ideas on how to make it work in Windows 7?

Here is my code (from the tutorial):

Run("notepad.exe")
WinActive("Untitled - Notepad")
SendKeepActive("Untitled - Notepad", "This is some text.")

Share this post


Link to post
Share on other sites



Either change WinActive to WinWaitActive (so the script waits until the window is active) or check the window title of Notepad - maybe the title has changed with Windows 7.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I am also on Win 7 64 bit.  I think you are using "sendkeepactive" by accident.  Try "send" as in the help file to actually send the text.

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")

The sendkeepactive function is just to keep the window open during send ... not to send text.

1 person likes this

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

and use

WinWaitActive("[CLASS:Notepad]")

Otherwise, non English systems will wait forever
In German locale e.g., the title is "Unbenannt - Editor"
 
This code runs perfectly on my German machine

Run("notepad")
WinActivate("[CLASS:Notepad]")
WinWaitActive("[CLASS:Notepad]")
SendKeepActive("[CLASS:Notepad]")
Send("This is some text.")
Edited by Exit
1 person likes this

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Thanks to everyone who responded!

It is now working, the revised code is:

Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
Send("This is some text.")

I have 2 follow on questions:

1) Why does SendKeepActive not work?

2) While this works, I get aUser Account Control popup where I have to click on "Yes" to proceed. Any ideas on how to avoid the UAC popup?

Share this post


Link to post
Share on other sites

Please refer to my earlier post as to why SendKeepActive does not work.  That is not the intended use of that function.  It is also not what is in the tutorial example you were trying to follow.  You accidentally used the wrong function.  Perhaps you were using Scite and it auto-completed the command for you and you?  Either way, please read the help file.  It explains what each function does.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

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  
Followers 0