Jump to content
Sign in to follow this  
akumar

Script is not working properly.

Recommended Posts

akumar

Hi All

I am new for 'AutoIt' and recently I started exploring the tool. I am facing an issue while executing the script.

From the help file I copied Notepad script and pasted it in a Notepad and save it as script1.au3.

URL : http://www.autoitscript.com/autoit3/docs/tutorials/notepad/notepad.htm

Code:

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

Send("This is some text.")

WinClose("Untitled - Notepad")

WinWaitActive("Notepad", "Do you want to save")

Send("!n")

ISSUE:

For execution I am using Run Script option from right click menu. Instead of executing the script,it was opening multiple instance in the taskbar and due to this machine stopped responding. Due to this everytime I need to restart the machine.

summary is script is not executing.

I have installed 'AutoIt Full Installation'. I have Vista OS.

Please help me in resolving this issue.

~Thanks

AKUMAR

Edited by akumar

Share this post


Link to post
Share on other sites
Tvern

Did you, by any chance, compile the script as notepad.exe, and is there now a file called "notepad.exe" in the same directory as script1.au3?

Share this post


Link to post
Share on other sites
SadBunny

Did you, by any chance, compile the script as notepad.exe, and is there now a file called "notepad.exe" in the same directory as script1.au3?

Smart! :graduated:


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
akumar

Did you, by any chance, compile the script as notepad.exe, and is there now a file called "notepad.exe" in the same directory as script1.au3?

Hi Tvern

Thanks for your reply.

No I have just created the script having extension Script1.au3. Then from right click option I selected 'Run Script'.

By the way just for curiosity is there any problem if I have *.exe and *.au3 file in the same directory?

As I am in learning phase thats why I ask this question.

~Thanks

AKumar

Edited by akumar

Share this post


Link to post
Share on other sites
Tvern

Smart! :graduated:

By the way just for curiosity is there any problem if I have *.exe and *.au3 file in the same directory?

No that's fine, but when you give run a filename, rather than a full filepath, it will look in a number of standard directories for a file with a matching name. It starts in the folder you're running the script from, so just check that folder to see if there is a file called notepad.exe in there.

The problem should be fixed if you supply Run() with the full path to the executable like this: Run(@SystemDir & "\notepad.exe")

Share this post


Link to post
Share on other sites
akumar

Hi Tvern

So the solution is I have to execute the script through command prompt by using "Run(@SystemDir & "\notepad.exe")".

Thanks again for the solution. I will update my code and then try to execute.

~Thanks

AKumar

Edited by akumar

Share this post


Link to post
Share on other sites
James

The problem should be fixed if you supply Run() with the full path to the executable like this: Run(@SystemDir & "\notepad.exe")

I see what you're doing there, but notepad.exe should be pretty generic in the terms everybody knows Notepad is a Windows default. And Run() I believe, looks in the path first?

James

Share this post


Link to post
Share on other sites
akumar

I see what you're doing there, but notepad.exe should be pretty generic in the terms everybody knows Notepad is a Windows default. And Run() I believe, looks in the path first?

James

Hi James

Thanks for your suggestion.

~Thanks

AKUMAR

Share this post


Link to post
Share on other sites
Tvern

I'm lost. You seem to understand eachother, but I'm not sure if I have been clear in my advise:

So the solution is I have to execute the script through command prompt by using "Run(@SystemDir & "\notepad.exe")".

The solution would be to open script1.au3 and:

Replace line 1:

Run("notepad.exe")
with
Run(@SystemDir & "\notepad.exe")

Then run the script like you did before.

I see what you're doing there, but notepad.exe should be pretty generic in the terms everybody knows Notepad is a Windows default. And Run() I believe, looks in the path first?

Are you referring to the option "Run..." in the start menu, or the AutoIt function Run()? And what path do you mean?

To my knowledge the AutoIt function Run() starts looking in @ScriptDir when no full path is supplied, then moves to standard windows locations.

Share this post


Link to post
Share on other sites
JoHanatCent

By right Menu you mean from Explorer?

I'd think you run your script and when it closes a message pops up if you want to save you then cancel?.

(This is probably because it lost focus.)

This would mean your script never complete and is waiting for the

WinWaitActive("Notepad", "")

When you run it again from your right menu it opens another script ... and so on ... and so on.

Try this:

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

If WinActive("Notepad") Then
    MsgBox(0, "", "Window was active")
EndIf

WinWaitActive("Notepad", "")
Send("!n")

Share this post


Link to post
Share on other sites
AdmiralAlkex

I see what you're doing there, but notepad.exe should be pretty generic in the terms everybody knows Notepad is a Windows default. And Run() I believe, looks in the path first?

James

Ah yes, no matter what we do we want the system to load some random file that we doesn't even know exist.

Are you sure about that? :graduated:

Share this post


Link to post
Share on other sites
akumar

I'm lost. You seem to understand eachother, but I'm not sure if I have been clear in my advise:

The solution would be to open script1.au3 and:

Replace line 1:

Run("notepad.exe")
with
Run(@SystemDir & "\notepad.exe")

Then run the script like you did before.

Are you referring to the option "Run..." in the start menu, or the AutoIt function Run()? And what path do you mean?

To my knowledge the AutoIt function Run() starts looking in @ScriptDir when no full path is supplied, then moves to standard windows locations.

Hi Tvern

Sorry for my mistake. I understood your point.

~Thanks

akumar

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.