Find and Close Window: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Created page)
 
Line 21: Line 21:
To detect and close Winamp (1.x, 2.x, 5.x) use the following script.
To detect and close Winamp (1.x, 2.x, 5.x) use the following script.
<highlight-nsis>Function CloseWinamp
<highlight-nsis>Function CloseWinamp
Push $5
Push $0
loop:
loop:
FindWindow $5 "Winamp v1.x"
FindWindow $0 "Winamp v1.x"
IntCmp $5 0 done
IntCmp $0 0 done
SendMessage $5 16 0 0
SendMessage $0 16 0 0
Sleep 100
Sleep 100
Goto loop
Goto loop
done:
done:
Pop $5
Pop $0
FunctionEnd</highlight-nsis>
FunctionEnd</highlight-nsis>


To close Winamp 3.x, use <highlight-nsis>FindWindow $5 "STUDIO"</highlight-nsis>
To close Winamp 3.x, use <highlight-nsis>FindWindow $0 "STUDIO"</highlight-nsis>

Revision as of 14:04, 26 March 2005

Description

Detect if an application is running and close it. Requires a valid Windows Class Name, which can be detected with tools like Win32Spy.


Function Code

Function CloseWindow
Push $0
loop:
FindWindow $0 "MyWindow" ;insert Windows Class Name
IntCmp $0 0 done
SendMessage $0 16 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd


Examples

To detect and close Winamp (1.x, 2.x, 5.x) use the following script.

Function CloseWinamp
Push $0
loop:
FindWindow $0 "Winamp v1.x"
IntCmp $0 0 done
SendMessage $0 16 0 0
Sleep 100
Goto loop
done:
Pop $0
FunctionEnd

To close Winamp 3.x, use

FindWindow $0 "STUDIO"