Skip to content
⌘ NSIS Forum Archive

Get Windows ClassName and TitleName With Application Process.exe Name

3 posts

r2du-soft#

Get Windows ClassName and TitleName With Application Process.exe Name

Get Windows ClassName and TitleName With Application Process.exe Name

Suppose we do not know the ClassName or TitleName for the notepad.exe
for now we use from the other apps (for sample autoit) for find the applications ClassName and TitleName...

this code give me ClassName and TitleName but just show class and title the windows focused on that!

Section

Loop:

Sleep 555 
System::Call user32::GetForegroundWindow()i.r1 
System::Call 'USER32::GetClassName(ir1,t.r2,i ${NSIS_MAX_STRLEN})' 
System::Call 'USER32::GetWindowText(ir1,t.r3,i ${NSIS_MAX_STRLEN})' 


SetDetailsPrint both
DetailPrint "($1)($2)($3)"
SetDetailsPrint none


Goto Loop


SectionEnd

now i try all ways to do it,but i failed
for sample i try this:

System::Call user32::GetForegroundWindow(notepad.exe)i.r1 
System::Call 'USER32::GetClassName(ir1,t.r2,i ${NSIS_MAX_STRLEN})' 
System::Call 'USER32::GetWindowText(ir1,t.r3,i ${NSIS_MAX_STRLEN})' 
but i o access to ClassName and TitleName notepad.exe
Anders#
GetForegroundWindow only gets the window the user is working in, you cannot pass a module name to it.

Call user32::EnumWindows to enumerate all top-level windows on the desktop.
r2du-soft#
Originally Posted by Anders View Post
GetForegroundWindow only gets the window the user is working in, you cannot pass a module name to it.

Call user32::EnumWindows to enumerate all top-level windows on the desktop.
thanks Anders

!include LogicLib.nsh
showinstdetails show

Section

System::Get "(i.r1) iss"
Pop $R0
System::Call "user32::EnumWindows(k R0,i) i.s"
loop:
    Pop $0
    StrCmp $0 "callback1" 0 done
    ;System::Call "user32::IsWindowVisible(ir1)i.r2"
    ;${If} $2 <> 0
        System::Call "user32::GetWindowText(ir1,t.r2,i ${NSIS_MAX_STRLEN})"
        System::Call "user32::GetClassName(ir1,t.r3,i ${NSIS_MAX_STRLEN})"
		System::Call "user32::GetWindowModuleFileName(ir1,t.r4,i ${NSIS_MAX_STRLEN})"
		System::Call "user32::GetWindowThreadProcessId(ir1,*i.r5)" 
		;-----------------------------
		DetailPrint "____________________________________"
		DetailPrint "callback1!: [$0]"
		DetailPrint "Num: [$1]"
		DetailPrint "Class Name: [$2]"
		DetailPrint "Title Name: [$3]"
		DetailPrint "ModuleFileName: [$4]"
		DetailPrint "Pid Number: [$5]"
		DetailPrint "x2: [$6]"
		DetailPrint "____________________________________"
		Push 1 # callback's return value
		System::Call "$R0"
		Pop $0
	;${EndIf}
Goto loop
  done:
  System::Free $R0
;Dumpstate::Debug


SectionEnd