Sign in to follow this  
Followers 0
getafix

How to kill an AutoIT exe after itscompletion

6 posts in this topic

Hi Everyone ,

I am calling AutoIt scripts from my Java test code ( I am using selenium with java)

The scripts runs fine when i run my tyests

But everytime i need to manually kill the autoIT exe from the taskbar ( By right clicking on the AutoIT icon>exit)

How can i kill the exe from the Autoit code itself ?

very much appreciate your help !

----------------------------------------------My script is as below-------------------------------------------------------

; IE save as dialogue

AutoItSetOption("WinTitleMatchMode", "2")

WinWait("File Download")

$title = WinGetTitle("File Download")

WinActivate($title)

WinWaitActive($title)

Send("s")

WinWait("Save As")

$title = WinGetTitle("Save As")

WinActivate($title)

WinWaitActive($title)

$filename = ControlGetText($title, "", "Edit1")

$fullpath = "C:\Users\Documents\Vendor.html"

ControlSetText($title, "", "Edit1", $fullpath)

Send("{ENTER}")

ConsoleWrite($fullpath)

$title = WinGetTitle("Download Complete")

WinActivate($title)

WinWaitActive($title)

Send("{ENTER}")

WinClose($title)

Share this post


Link to post
Share on other sites



Hey,

Your code looks like it might be getting stuck on one of the WinWait or WinWaitActive.

you could use the optional timeout parameter to give your code a way out if something it is waiting for doesn't happen.

If WinWaitActive($title, "", 10) Then
    MsgBox(0, "Good", "It didn't time out so i can continue with the normal code")
Else
    MsgBox(0, "Doh", "It timed out , what should i do instead?, maybe just exit")
    Exit
EndIf

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Hey,

Your code looks like it might be getting stuck on one of the WinWait or WinWaitActive.

you could use the optional timeout parameter to give your code a way out if something it is waiting for doesn't happen.

If WinWaitActive($title, "", 10) Then
    MsgBox(0, "Good", "It didn't time out so i can continue with the normal code")
Else
    MsgBox(0, "Doh", "It timed out , what should i do instead?, maybe just exit")
    Exit
EndIf

Hi Yoriz,

Thanks Yoriz,

But my my script does not gets exited

Even after i added the following at the end of my code

WinClose($title)

Exit

Why is this ? Is there anything else i need to modify in my code

Thanks

Share this post


Link to post
Share on other sites

I believe what Yoriz is pointing out is the omission of the timeout parameter results in the script 'hanging there', in the WinWaitActive statement, which is before the script can execute the Exit statement. So basically, any commands after the WinWaitActive won't be run.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yes timeout is a issue. Have a look at the WinWaitDelay option.

Also

WinActivate($title)
WinWaitActive($title)
code is no good. One or the other. It is either already loaded or it will become active.

Try putting some error protection in too.

AutoItSetOption("WinTitleMatchMode", "2")
WinWait("File Download")
$title = WinGetTitle("File Download")
WinWaitActive($title)
If @error Then
    ConsoleWrite("Something went wrong")
    Exit
EndIf
Send("s")
WinWait("Save As")
$title = WinGetTitle("Save As")

WinWaitActive($title)
$filename = ControlGetText($title, "", "Edit1")
$fullpath = "C:\Users\Documents\Vendor.html"
ControlSetText($title, "", "Edit1", $fullpath)
Send("{ENTER}")
ConsoleWrite($fullpath)
$title = WinGetTitle("Download Complete")

WinWaitActive($title)
Send("{ENTER}")
WinClose($title)

Edit: minor code error

Edited by bo8ster

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

I believe what Yoriz is pointing out is the omission of the timeout parameter results in the script 'hanging there', in the WinWaitActive statement, which is before the script can execute the Exit statement. So basically, any commands after the WinWaitActive won't be run.

Hi ,

Thanks for the reply

Yeah i could see that when i commented my WinWaitActive statement at the end of my code the exe exits

Don't know why?

But yes there seems to be a timeout issue in the code

Many thanks

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