akumar Posted November 22, 2010 Share Posted November 22, 2010 (edited) Hi AllI 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.htmCode: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.~ThanksAKUMAR Edited November 22, 2010 by akumar Link to comment Share on other sites More sharing options...
Tvern Posted November 22, 2010 Share Posted November 22, 2010 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? Link to comment Share on other sites More sharing options...
SadBunny Posted November 22, 2010 Share Posted November 22, 2010 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! Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
akumar Posted November 22, 2010 Author Share Posted November 22, 2010 (edited) 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 TvernThanks 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.~ThanksAKumar Edited November 22, 2010 by akumar Link to comment Share on other sites More sharing options...
Tvern Posted November 22, 2010 Share Posted November 22, 2010 Smart! 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") Link to comment Share on other sites More sharing options...
akumar Posted November 22, 2010 Author Share Posted November 22, 2010 (edited) 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 November 22, 2010 by akumar Link to comment Share on other sites More sharing options...
James Posted November 22, 2010 Share Posted November 22, 2010 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 Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
akumar Posted November 22, 2010 Author Share Posted November 22, 2010 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?JamesHi JamesThanks for your suggestion. ~ThanksAKUMAR Link to comment Share on other sites More sharing options...
Tvern Posted November 22, 2010 Share Posted November 22, 2010 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")withRun(@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. Link to comment Share on other sites More sharing options...
JoHanatCent Posted November 22, 2010 Share Posted November 22, 2010 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") Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 22, 2010 Share Posted November 22, 2010 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?JamesAh 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? .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
akumar Posted November 22, 2010 Author Share Posted November 22, 2010 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")withRun(@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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now