Yathosho
4th September 2009 22:02 UTC
find/close
first of all, i'm well aware that my following question can easily be solved using KillProc or the Processes plugin.
however, i also know this function to close a running instance of winamp. can't i use the same FindWindow to detect if winamp is running in the first place?
my current script uses KillProc to detect that, but if it's possible without any plugins i'd prefer that!
DrO
4th September 2009 22:07 UTC
probably something like FindWindow $0 "Winamp v1.x" "" will work for that (is what other apps use)
-daz
jpderuiter
4th September 2009 22:13 UTC
Yes, sure you can.
Just remove the loop and replace the SendMessage call with the code you want to be executed when Winamp is running.
See http://nsis.sourceforge.net/Check_wh...uninstallation for another (generic) example.
Yathosho
4th September 2009 22:14 UTC
got it, the problem was using IntCmp instead of StrCmp. this works:
FindWindow $0 "Winamp v1.x"
StrCmp $0 0 notRunning Running
however, that makes me wonder why the function using IntCmp works perfectly.
Yathosho
4th September 2009 22:28 UTC
just for the record, i'm now using this to close winamp
${While} $0 != "0"
FindWindow $0 "Winamp v1.x"
SendMessage $0 ${WM_CLOSE} 0 0
Sleep 100
${EndWhile}
rather than the old code
loop:
FindWindow $0 $1
IntCmp $0 0 done
#SendMessage $0 ${WM_DESTROY} 0 0
SendMessage $0 ${WM_CLOSE} 0 0
Sleep 100
Goto loop
done: