Find and Close Window: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(FA: Identation to code. FA: "Page author" line.) |
m (Updated author links.) |
||
Line 1: | Line 1: | ||
{|align=right | |||
|<small>Author: [[{{ns:2}}:Jan|Jan]] ([[{{ns:3}}:Jan|talk]], [[{{ns:-1}}:Contributions/Jan|contrib]])</small> | |||
|} | |||
<br style="clear:both;"> | |||
== Description == | == Description == | ||
Line 41: | Line 45: | ||
FindWindow $0 "STUDIO" | FindWindow $0 "STUDIO" | ||
</highlight-nsis> | </highlight-nsis> | ||
Revision as of 02:57, 30 April 2005
Author: Jan (talk, contrib) |
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"