Jump to content

SciTE Editor works, but running from .exe does not?


QAson
 Share

Go to solution Solved by Nine,

Recommended Posts

I have been reading AutoIt documentation and watching tutorials to get an understanding of where it could be a good automation tool for my purposes. 
Step 1 was obviously a "hello world" so I have this which works fine when ran from the SciTE Editor or from .exe :

#include <MsgBoxConstants.au3>
MsgBox($MB_ICONINFORMATION, "Get pranked", "You can't code")


So I moved on to something more advance and got this going: 

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("*Untitled - Notepad")
WinWaitActive("Notepad", "Save")
Send("{ENTER}")
Send("test.txt")
Send("{ENTER}")


All this is supposed to to is open Notepad, wait for it to be open and active, write a small message, close, and ENTER through the default save location with the "test.txt" file name. This DOES work when ran in the SciTE Editor from Tools > Go. However, it DOES NOT work when I compile and run the .exe or use the .exe converter tool and nearly locks up my computer. I managed, one time, to open task manager and see that nearly a hundred notepads opened up in the background processes though nothing appeared to be occurring on screen. My mouse would just be stuck and flashing the loading/mouse icon.

Any ideas? I went in as much detail as I could :)  

Link to comment
Share on other sites

  • Developers

Let me guess: you called the script notepad.au3 , hence the compiled script is called notepad.exe?

Get it? ;)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

17 minutes ago, Jos said:

Let me guess: you called the script notepad.au3 , hence the compiled script is called notepad.exe?

Get it? ;)

I did.... I assume that is bad? I'm a new guy here, I don't understand 

Link to comment
Share on other sites

  • Developers

You are starting your own compiled script which then shell your own compiled script... which then......etc etc..

Call it something different. ;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Solution
13 minutes ago, QAson said:

Renaming the .au3 didn't work for me but renaming the .exe worked fine! Thanks y'all 

Ya, I was assuming you would delete any trace of the old script exe.  But let me explain why it did work.  In your head, Notepad.exe IS the editor from Microsoft.  But, but, but, you created (when compiled) a new Notepad.exe exactly in  the same directory of your script.  So running that exe is running your script, and it searches for Notepad.exe, and found one directly in the same directory.  So instead of calling the editor from MS, you were calling yourself, which was calling yourself, which was calling yourself, infinitely until you have no more memory left...

Learning is the greatest thing of all the things human can do !

Edited by Nine
Link to comment
Share on other sites

3 hours ago, QAson said:

I managed, one time, to open task manager and see that nearly a hundred notepads opened up in the background processes though nothing appeared to be occurring on screen.

Bonus question:
Now let’s imagine, when in this state with a hundred notepads running, you were to start a real Notepad editor…

What would be the contents of test.txt?

Code hard, but don’t hard code...

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