Jump to content

Script continues to run after Exit


korvkorv
 Share

Recommended Posts

Hi!

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" )

OnAutoItExitRegister("Cleanup")

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)
GUISetState(@SW_SHOW)

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

Func Cleanup()
    _DebugOut("Doing cleanup")
    GUIDelete($ret2)
    GUIDelete($ret1)
    GUIDelete($hwnd)
    _DebugOut("Cleanup done")
EndFunc
Link to comment
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)
        Exit
        consolewrite("i ahve been here 2" & @CRLF)

EDIT BTW: GuiDelete() solved my problem.

Edited by lsakizada

Be Green Now or Never (BGNN)!

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