Closing ALL Browsers Windows: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Created page with 'Inspired by Closing ALL Internet Explorer Windows I wrote a function that can close all browsers var hadBrowsers Function closeAllBrowsers FindWindow $0 "IEFrame" …')
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Inspired by [[Closing ALL Internet Explorer Windows]] I wrote a function that can close all browsers  
Inspired by [[Closing ALL Internet Explorer Windows]] I wrote a function that can close all browsers  
 
<highlight-nsis>
var hadBrowsers
var hadBrowsers
Function closeAllBrowsers
Function closeAllBrowsers
  FindWindow $0 "IEFrame"
  IntCmp $0 0 0 closeAll
  FindWindow $0 "MozillaUIWindowClass"
  IntCmp $0 0 0 closeAll
  FindWindow $0 "Chrome_WidgetWin_0"
  IntCmp $0 0 done closeAll
  closeAll:
  MessageBox MB_OK "Please close your browsers or press ok to close them all automatically"
  ;Closing all IE Windows
  loop:
    FindWindow $0 "IEFrame"
    IntCmp $0 0 skipIE
    IsWindow $0 0 skipIE
    System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
    StrCpy $hadBrowsers "1"
    skipIE:
    FindWindow $0 "MozillaUIWindowClass"
    IntCmp $0 0 skipFF
    IsWindow $0 0 skipFF
    System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
    StrCpy $hadBrowsers "1"
    skipFF:
    FindWindow $0 "Chrome_WidgetWin_0"
    IntCmp $0 0 skipGC
    IsWindow $0 0 skipGC
    System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
    StrCpy $hadBrowsers "1"       
    skipGC:
     FindWindow $0 "IEFrame"
     FindWindow $0 "IEFrame"
     IntCmp $0 0 0 closeAll
     IntCmp $0 0 0 wait
     FindWindow $0 "MozillaUIWindowClass"
     FindWindow $0 "MozillaUIWindowClass"
     IntCmp $0 0 0 closeAll
     IntCmp $0 0 0 wait
     FindWindow $0 "Chrome_WidgetWin_0"
     FindWindow $0 "Chrome_WidgetWin_0"
     IntCmp $0 0 done closeAll
     IntCmp $0 0 done wait
    closeAll:
  wait:
    MessageBox MB_OK "Please close your browsers or press ok to close them all automatically"
     Sleep 100
    ;Closing all IE Windows
    goto loop
    loop:
  done:
        FindWindow $0 "IEFrame"
  ;MessageBox MB_OK $hadBrowsers
        IntCmp $0 0 skipIE
  StrCmp $hadBrowsers "1" 0 +1         
        IsWindow $0 0 skipIE
    Sleep 2000
        System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
FunctionEnd
        StrCpy $hadBrowsers "1"
</highlight-nsis>
        skipIE:
 
        FindWindow $0 "MozillaUIWindowClass"
[[Category:System Plugin Examples]]
        IntCmp $0 0 skipFF
        IsWindow $0 0 skipFF
        System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
        StrCpy $hadBrowsers "1"
        skipFF:
        FindWindow $0 "Chrome_WidgetWin_0"
        IntCmp $0 0 skipGC
        IsWindow $0 0 skipGC
        System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
        StrCpy $hadBrowsers "1"       
        skipGC:
        FindWindow $0 "IEFrame"
        IntCmp $0 0 0 wait
        FindWindow $0 "MozillaUIWindowClass"
        IntCmp $0 0 0 wait
        FindWindow $0 "Chrome_WidgetWin_0"
        IntCmp $0 0 done wait
     wait:
        Sleep 100
        goto loop
    done:
    ;MessageBox MB_OK $hadBrowsers
    StrCmp $hadBrowsers "1" 0 +1         
        Sleep 2000
FunctionEnd

Latest revision as of 15:25, 15 June 2015

Inspired by Closing ALL Internet Explorer Windows I wrote a function that can close all browsers

var hadBrowsers
Function closeAllBrowsers
  FindWindow $0 "IEFrame"
  IntCmp $0 0 0 closeAll
  FindWindow $0 "MozillaUIWindowClass"
  IntCmp $0 0 0 closeAll
  FindWindow $0 "Chrome_WidgetWin_0"
  IntCmp $0 0 done closeAll
  closeAll:
  MessageBox MB_OK "Please close your browsers or press ok to close them all automatically"
  ;Closing all IE Windows
  loop:
    FindWindow $0 "IEFrame"
    IntCmp $0 0 skipIE
    IsWindow $0 0 skipIE
    System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
    StrCpy $hadBrowsers "1"
    skipIE:
    FindWindow $0 "MozillaUIWindowClass"
    IntCmp $0 0 skipFF
    IsWindow $0 0 skipFF
    System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
    StrCpy $hadBrowsers "1"
    skipFF:
    FindWindow $0 "Chrome_WidgetWin_0"
    IntCmp $0 0 skipGC
    IsWindow $0 0 skipGC
    System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
    StrCpy $hadBrowsers "1"        
    skipGC:
    FindWindow $0 "IEFrame"
    IntCmp $0 0 0 wait
    FindWindow $0 "MozillaUIWindowClass"
    IntCmp $0 0 0 wait
    FindWindow $0 "Chrome_WidgetWin_0"
    IntCmp $0 0 done wait
  wait:
    Sleep 100
    goto loop
  done:
  ;MessageBox MB_OK $hadBrowsers
  StrCmp $hadBrowsers "1" 0 +1        
    Sleep 2000
FunctionEnd