Wabiloo
8th June 2006 14:56 UTC
Find Window with Partial Name
Hi!
Is there any way of finding a window when only knowing part of its title?
Eg. I have a window called "Microsoft Word - This Document - Bla". I'd like to find that window, only knowing part of that title, ie. "Microsoft Word"
Otherwise, is there any way in NSIS to enumerate the open windows?
CancerFace
8th June 2006 15:06 UTC
From the System Plugin readme:
SetPluginUnload alwaysoff
System::Get "(i.r1, i) iss"
Pop $R0
System::Call "user32::EnumChildWindows(i $HWNDPARENT, k R0, i) i.s"
loop:
        Pop $0
        StrCmp $0 "callback1" 0 done
        System::Call "user32::GetWindowText(ir1,t.r2,i${NSIS_MAX_STRLEN})"
        System::Call "user32::GetClassName(ir1,t.r3,i${NSIS_MAX_STRLEN})"
        IntFmt $1 "0x%X" $1
        DetailPrint "$1 - [$3] $2"
        Push 1 # callback's return value
        System::Call "$R0"
        Goto loop
done:
SetPluginUnload manual
System::Free $R0
      More info on 
EnumWindows .
      Try also 
FindWindowEx.
      
      I am not sure if the internal NSIS FindWindow command achieves what you are after ...
      
      CF
    
      Takhir
      8th June 2006 15:34 UTC
      FindCloseTerminate not returnes handle, but can find by name part and close or terminate (with optional MessageBox popup).