Sign in to follow this  
Followers 0
tiveria

AutoIt exe vanishes

14 posts in this topic

Good morning,

I'm trying to have a very simple script that reads in a file and creates an e-mail with it.

The text file is called email.txt and will look like:

to-address@domain.com;cc-address@domain.com;subject text goes here;body text goes here.

The script itself works when I run it inside of SciTE. When I compile it into an exe file and then run exe, the exe disappears. I've tried searching on the forum, in the bug reports and in google without any luck. Originally the script was set to take parameters instead of a text file, but that did the same thing.

If I hard-code the e-mail information, the exe runs and works.

Any ideas would be wonderful. Thank you!

#include <File.au3>

Global $file = fileOpen("email.txt",0)

While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    $temp = StringSplit($line,";")
    $Toaddress = $temp[1]
    $CCAddress = $temp[2]
    $subject = $temp[3]
    $body = $temp[4]
Wend
WinActivate("[CLASS:rctrl_renwnd32]")
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "^n" )
WinWait("Untitled - Message")
ControlSetText ( "[CLASS:rctrl_renwnd32]", "", "[CLASS:RichEdit20WPT; INSTANCE:1]", $Toaddress)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSetText("[CLASS:rctrl_renwnd32]","","[CLASS:RichEdit20WPT; INSTANCE:2]",$CCAddress)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "[ID:4101]", $subject)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "Message", "[CLASS:_WwG; INSTANCE:1;]", $body )

Share this post


Link to post
Share on other sites



Maybe your antivirus software is off the leash. Try compiling some other script and run that. If that exe disappears then you (should) know what's causing the issue.

Compile this for example:

MsgBox(0, "Title", "Not title")

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Maybe your antivirus software is off the leash. Try compiling some other script and run that. If that exe disappears then you (should) know what's causing the issue.

Compile this for example:

MsgBox(0, "Title", "Not title")

That ran from the .exe.

Share this post


Link to post
Share on other sites

That ran from the .exe.

What about vanishing effect?

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

What about vanishing effect?

The exe did not vanish.

Also, the e-mail script doesn't appear to run at all. I added a Msgbox at the end at one point, and it never pops up.

Share this post


Link to post
Share on other sites

So add few more at different places in the script. That's how you'll know when it stops to work. That's called debugging.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

So add few more at different places in the script. That's how you'll know when it stops to work. That's called debugging.

Thank you for the suggestion. I understand what debugging is as I'm a programmer. I've had other programmers at my office also take a look at it, and we're all confused why it's not working.

It's strange that the exe disappears, but it works without any errors when I run the script on its own. The script itself appears to work. I'm wondering if there's some strange bug in the compilation of the code that's causing it to change.

I came here to see if those who are more familiar with autoIt saw something blatent that me and my co-workers were missing.

I added another msgbox at the beginning of the script, and it's not appearing. It's reacting as if the code is never getting executed.

Share this post


Link to post
Share on other sites

What else have you tried while debugging it?

Originally I had meant for the code to be based on parameters. I'm building a C# app that will use a bunch of autoIt mini-scripts to do things in the background of the C# app. (ie you select something, and it e-mails your team). While I can do much of what I want it to do in C#, I like the way AutoIt typical tends to handle things. So my original script looked like:

If $CmdLine[0] = 4 Then
$Toaddress = $CmdLine[1]
$CCAddress = $CmdLine[2]
$subject = $CmdLine[3]
$body = $CmdLine[4]
Else
    ;MsgBox(0,"Invalid # of args","This program requires 4 arguments. To Address, CC address, subject and body.")
    ;Exit
    $Toaddress = "toaddr@domain.com"
    $CCAddress = "ccaddr@domain.com"
    $subject = "subject"
    $body = "bodytext"
EndIf
WinActivate("[CLASS:rctrl_renwnd32]")
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "^n" )
;Send("^n")
WinWait("Untitled - Message")
ControlSetText ( "[CLASS:rctrl_renwnd32]", "", "[CLASS:RichEdit20WPT; INSTANCE:1]", $Toaddress)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSetText("[CLASS:rctrl_renwnd32]","","[CLASS:RichEdit20WPT; INSTANCE:2]",$CCAddress)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "[ID:4101]", $subject)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "Message", "[CLASS:_WwG; INSTANCE:1;]", $body )

It ran in the SciTE, but disappeared as an EXE file.

I then tried getting rid of my If..Then..Else, and hard coded my values. When compiled, this exe runs.

$Toaddress = "toaddr@domain.com"
    $CCAddress = "ccaddr@domain.com"
    $subject = "subject"
    $body = "bodytext"
WinActivate("[CLASS:rctrl_renwnd32]")
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "^n" )
;Send("^n")
WinWait("Untitled - Message")
ControlSetText ( "[CLASS:rctrl_renwnd32]", "", "[CLASS:RichEdit20WPT; INSTANCE:1]", $Toaddress)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSetText("[CLASS:rctrl_renwnd32]","","[CLASS:RichEdit20WPT; INSTANCE:2]",$CCAddress)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "[ID:4101]", $subject)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "Message", "[CLASS:_WwG; INSTANCE:1;]", $body )

So I said ok - maybe something is wrong with the parameter reading, and ended up with the file input method instead. (Always more than one way to skin a cat, right?)

#include <File.au3>

Global $file = fileOpen("email.txt",0)

While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    $temp = StringSplit($line,";")
    $Toaddress = "ToAdd@domain.com"
    $CCAddress = "CCAdd@domain.com"
    $subject = "some subject text"
    $body = "some body text"
Wend
WinActivate("[CLASS:rctrl_renwnd32]")
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "^n" )
WinWait("Untitled - Message")
ControlSetText ( "[CLASS:rctrl_renwnd32]", "", "[CLASS:RichEdit20WPT; INSTANCE:1]", $Toaddress)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSetText("[CLASS:rctrl_renwnd32]","","[CLASS:RichEdit20WPT; INSTANCE:2]",$CCAddress)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "[ID:4101]", $subject)
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "", "", "{TAB}" )
ControlSend ( "[CLASS:rctrl_renwnd32]", "Message", "[CLASS:_WwG; INSTANCE:1;]", $body )

But it didn't work. I've inserted msgboxes in every line of code. When the exe disappears, I never get any of them.

Share this post


Link to post
Share on other sites

It's strange that the exe disappears, but it works without any errors when I run the script on its own. The script itself appears to work. I'm wondering if there's some strange bug in the compilation of the code that's causing it to change.

Everything is possible but what you suggest is extremely unlikely.

You have at least one "bomb" in your script that could cause it to act unexpectedly. It's below FileReadLine line. Deal with that properly and then ask again if there would be problems afterwards.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Everything is possible but what you suggest is extremely unlikely.

You have at least one "bomb" in your script that could cause it to act unexpectedly. It's below FileReadLine line. Deal with that properly and then ask again if there would be problems afterwards.

I want to be clear which line you're referring to, as I don't see it at the moment. Are you referring to the line directly below FileReadLine:
If @error = -1 Then ExitLoop
?

Thank you again for your replies.

Share this post


Link to post
Share on other sites

What have you named your script? what does the exe file name look like? notepad.au3? notepad.exe compiled? I know it is not, but I am familiar with mysterious problems being related to quarky script naming.

Lar.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites

What have you named your script? what does the exe file name look like? notepad.au3? notepad.exe compiled? I know it is not, but I am familiar with mysterious problems being related to quarky script naming.

Lar.

I found the quirk. I hadn't checked to see if the file itself existed before opening it. (Since my program would always generate it..sigh I know better.) It ran, but it didn't like it in the exe file.

Thank you again for all of your help everyone!

Share this post


Link to post
Share on other sites

I found the quirk. I hadn't checked to see if the file itself existed before opening it. (Since my program would always generate it..sigh I know better.) It ran, but it didn't like it in the exe file.

Thank you again for all of your help everyone!

Ohhh... what a great team of programmers! No offense but this was weird... You need some holidays now I think. Take breaks man, don't work too long.

I was wondering and struggling on it because it was running without any problem on my side (I created "email.txt" file first thought :blink:)

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