Jump to content
Sign in to follow this  

Script continues to run after Exit

Recommended Posts



This is my first post so please be gentle :D

I'm trying to attach to a 3:rd party window and add a checkbox. When the 3:rd party program ends, my script should also end. That's the background. It works correctly if the 3:rd party program is e.g. Explorer, Calculator etc. But for the program I actually want to hang on to it doesn't work. That program is called Spotify (music streaming SW, can be found here www.spotify.com )

When attaching to Spotify the checkbox is shown and when exiting Spotify the script passes thru the OnAutoItExitRegister function and the tray icon disappears. BUT the process is still running when I look in the Task Manager and it consumes 50% of the cpu resources!

Why? Am I doing anything wrong? I've also tried using the anygui UDF but same result. The situation is similar to ticket #1319 but still not identical.

Any advice is welcome!

The script is attached below. Explorer/Spotify must be running and the corresponding ControlGetHandle line must be uncommented if you want to try.

Many thanks!

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Debug.au3>

; Write debug to file
_DebugSetup ( Default, False, 4, ".\errLog.txt" )


Global $hwnd = ControlGetHandle("[CLASS:ExploreWClass]", "", "[CLASS:SysListView32; INSTANCE:1]")
;Global $hwnd = ControlGetHandle("[CLASS:SpotifyMainWindow]", "", "")
Global $ret1 = GUICreate("", 200, 200, 50, 50, $WS_CHILD, -1, $hwnd)
Global $ret2 = GUICtrlCreateCheckbox("", 0, 0, 400, 100, -1, $WS_EX_TRANSPARENT)

While WinExists($hwnd)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
    If Not WinExists($hwnd) Then Exit

Func Cleanup()
    _DebugOut("Doing cleanup")
    _DebugOut("Cleanup done")

Share this post

Link to post
Share on other sites

Just off the top of my head it looks likes hanging at Cleanup() check if inserting a extra exit will do the trick.

Sorry, but it didn't make a difference. Thanks anyway!

Share this post

Link to post
Share on other sites

Hi, I am having same problem. I think its a problem with the new beta as of today. because my scripts used to work fine until i upgraded autoit beta yesterday.

When the app call to 'Exit' function then the application still keeping running.

Behave somhow like hang occurs.

I put a debug console and its not pass to the line after the Exit function...

consolewrite("i ahve been here 1" & @CRLF)
        consolewrite("i ahve been here 2" & @CRLF)

EDIT BTW: GuiDelete() solved my problem.

Edited by lsakizada

Be Green Now or Never (BGNN)!

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.