I was messing around with findwindow and findwindowEX so far I have not found any useful use for this but I do need a windows class name ....
how to obtain this?
http://www.autohotkey.com/docs/commands/WinGetClass.htm
.data
WindowName db "<WindowName>",0 ;caption of the window
ClassName db "<ClassName>",0 ;ClassName of the window
Invoke FindWindow, addr ClassName , addr WindowName
Do we have a way to obtain a classname ?
I found this little bit :
Buffer db 256 dup (0)
invoke GetClassName, eax, ADDR Buffer, 256
http://msdn.microsoft.com/en-us/library/ms633582(VS.85).aspx
does anybody have an example like this ?
Get the handle, and use GetClassName...
Mozilla's top window is MozillaUIWindowClass
include \masm32\MasmBasic\MasmBasic.inc ; download (http://www.masm32.com/board/index.php?topic=12460)
.data?
buffer db 100 dup(?)
Init
.if WinByTitle("- Mozilla Firefox", 4)
mov esi, offset buffer
invoke GetClassName, eax, esi, 100
Inkey "Mozilla's top window is ", esi
.else
Inkey "No such window..."
.endif
Exit
end start
I am trying to use GetClassName to find the windows class name which is unknown to me
Yes, I know. WinByTitle returns the handle that GetClassName needs. Unfortunately, Windows doesn't provide a straightforward way to find a window's handle... you could launch Olly to find out how WinByTitle finds it. Warning - it's hilariously complicated.
lol
so what window are you trying to get a handle for
EnumWindows/EnumChildWindows are not that bad
the one window type i have had a hard time with is tool tips
but, i learned today that they are always child of desktop, no matter how you create them
that means i can get the handle :P
let me re-phrase the question....
what info about the window do you have and what info about the window are you trying to get
any window that I do not designate a classname for it ....
for example :
If I make a window call it testapp.exe and I title it "TestApp"
and I give it a class name like "DLGCLASS"
than I can use :
WindowName db "TestApp",0
ClassName db "DLGCLASS",0
Invoke FindWindow, addr ClassName , addr WindowName
To get the widow handle for it ...but If I have a window with out a designated classname than it is some other value ..that is what I am trying to get
what do I need to do hook into the window or map PE so I can use some thing like:
Buffer db 256 dup (0)
invoke GetClassName, eax, ADDR Buffer, 256
I am looking at this page http://www.masm32.com/board/index.php?PHPSESSID=da4bde24ad966130fa729426201c92a9&topic=16958.0
ok - i am still confused about what you are trying to do - lol
if you created the window with CreateWindowEx, then you probably have the handle, as it is returned in EAX :P
if it's a control that is a child of your main window, then you can use GetDlgItem,hWnd,ControlID
also - system defined controls all have predefined strings as classnames
so - i am assuming you are trying to get the handle for some other window ???
what info about that window do you have to begin with ???
is it a control ?
is it a child of your window ?
; For system-defined controls, these classes are already
;registered and have system-internal WndProc routines:
;
; Control Type String
;---------------------------------------------------
; Button Control 'Button'
; Edit Box 'Edit'
; Static Control 'Static'
; List Box 'Listbox'
; Scroll Bar 'Scrollbar'
; Combo Box 'ComboBox'
; Header Control 'SysHeader32'
; List View 'SysListView32'
; Tree View 'SysTreeView32'
; Hot Key 'msctls_hotkey32'
; Up-Down Control 'msctls_updown32'
; Animation Control 'SysAnimate32'
; Extended Combo Box 'ComboBoxEx32'
; Tab Control 'SysTabControl32'
; Month Calendar Control 'SysMonthCal32'
; Progress Bar 'msctls_progress32'
; ReBar Control 'ReBarWindow32'
; Tool Tip 'tooltips_class32'
; Track Bar 'msctls_trackbar32'
; Status Bar 'msctls_statusbar32'
; Tool Bar 'ToolbarWindow32'
; Date/Time Picker 'SysDateTimePick32'
; IP Address Control 'SysIPAddress32'
; Page Scroller Control 'SysPager'
; Drag List Message String 'commctrl_DragListMsg'
;
;There are a few others, but the list represents
;most of the ones used by programmers today.
there are also a number of system-internal classname strings
Note: if you are comparing strings, be careful of case
"Button" is the same class name as "button"
Quote from: dedndave on April 11, 2012, 11:40:54 PM
ok - i am still confused about what you are trying to do - lol
if you created the window with CreateWindowEx, then you probably have the handle, as it is returned in EAX :P
if it's a control that is a child of your main window, then you can use GetDlgItem,hWnd,ControlID
so - i am assuming you are trying to get the handle for some other window ???
what info about that window do you have to begin with ???
only the window title ...all I need is the window class name ....
I really need to stop looking at sources online I saw this stupid source for Findwindow so I decided to make the source work ...how ever I find that it works if you make the target app that you are trying to get the window handle of ...and you have to add a classname for it ... now I want to find the window's handle with findwindow but I need the classname ....
Invoke findwindow, NULL , addr windowname
does not work ! I need
Invoke findwindow, addr classname , addr windowname
I wish I was home I would upload that stuipd findwindow exercise
So basically I need a window's classname
you are still not giving me direct answers to my questions
to get the title of a window, use GetWindowText
Quotewhat info about that window do you have to begin with ???
is it a control ?
is it a child of your window ?
Quote from: dedndave on April 11, 2012, 11:52:36 PM
you are still not giving me a direct answer to my questions
to get the title of a window, use GetWindowText
I am trying to retrive any windows name of the class to which the specified window belongs.
This :
http://msdn.microsoft.com/en-us/library/ms633582(v=vs.85).aspx
use EnumWindows/EnumChildWindows
inside the callback function, use GetClassName
if you EnumChildWindows using HWND_DESKTOP (0), you will get all windows
then, in the callback proc, filter out the ones you want
Quote from: dedndave on April 11, 2012, 11:54:47 PM
use EnumWindows/EnumChildWindows
inside the callback function, use GetClassName
I don't know how to do that I am looking at bomz thread http://www.masm32.com/board/index.php?PHPSESSID=da4bde24ad966130fa729426201c92a9&topic=16958.0
Found this I will take a closer look at it http://www.masm32.com/board/index.php?PHPSESSID=9326fa8758332c91f3ae352a5077ee2e&topic=15687.0
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633494%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633493%28v=vs.85%29.aspx
EnumChildProc PROTO :HWND,LPARAM
;
;this makes it happen, captain
;
INVOKE EnumChildWindows,HWND_DESKTOP,EnumChildProc,NULL
;
;replace the NULL above if you like
;you can pass a value to the EnumChildProc through lParam
;
;
;
EnumChildProc PROC hwnd:HWND,lParam:LPARAM
;the OS calls this routine once with the hwnd of each window
;that is a child of the desktop (i.e., all windows)
;if you exit with EAX = 1, enumeration continues until all child windows are done
;if you exit with EAX = 0, enumeration stops
ret
EnumChildProc ENDP
if you want top-level windows only, use EnumWindows instead of EnumChildWindows - very similar
INVOKE EnumWindows,EnumProc,NULL
and how do I get the class name to display in a textbox or an edit widow doing this?
you can do whatever testing or filtering you like inside the callback proc
for example, i might only be interested in butttons
so - i might do that by getting the classname for each hwnd and doing a case-insensitive compare against "button",0
(actually easier by looking at the style bits)
try this code...
INCLUDE \masm32\include\masm32rt.inc
EnumChildProc PROTO :HWND,:LPARAM
;-----------------------------------------------------
.CODE
;let's make it happen, captain
start: INVOKE EnumChildWindows,HWND_DESKTOP,EnumChildProc,NULL
INVOKE ExitProcess,0
;-----------------------------------------------------
EnumChildProc PROC hwnd:HWND,lParam:LPARAM
LOCAL szBuf[256]:BYTE
INVOKE GetClassName,hwnd,addr szBuf,sizeof szBuf
INVOKE MessageBox,0,addr szBuf,0,0
ret
EnumChildProc ENDP
;-----------------------------------------------------
END start
Thank you I will give it a shot Tonight
this version will be more fun :P
INCLUDE \masm32\include\masm32rt.inc
EnumChildProc PROTO :HWND,:LPARAM
;-----------------------------------------------------
.CODE
;let's make it happen, captain
start: INVOKE EnumChildWindows,HWND_DESKTOP,EnumChildProc,NULL
INVOKE ExitProcess,0
;-----------------------------------------------------
EnumChildProc PROC hwnd:HWND,lParam:LPARAM
LOCAL szBuf1[256]:BYTE
LOCAL szBuf2[256]:BYTE
INVOKE GetWindowText,hwnd,addr szBuf1,sizeof szBuf1
INVOKE GetClassName,hwnd,addr szBuf2,sizeof szBuf2
lea edx,szBuf1
INVOKE MessageBox,0,addr szBuf2,edx,MB_OKCANCEL
and eax,1
ret
EnumChildProc ENDP
;-----------------------------------------------------
END start
notice that when you press "Ok" on MessageBox, it exits with EAX = 1
when you press "Cancel", it exits with EAX = 2
we AND that result with 1
so, we get either 0 or 1
If you know the class name OR the text on the title bar whats wrong with using,
HWND FindWindow(
LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
);
:U
Quote from: hutch-- on April 12, 2012, 04:27:09 AM
If you know the class name OR the text on the title bar whats wrong with using,
HWND FindWindow(
LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
);
That what this was all about ... finding the "lpClassName" and "lpWindowName" of a window so I can use "FindWindow".....
by the way it worked great dedndave :U I noticed that windows that did not have an assigned lpClassName by default I got "#32770" as the lpClassName Wierd?
that is the pre-defined system class for dialog boxes
or - i should say, "one of the" - there are several, depending on the type of dialog
ms finally ran out of words - lol - so they gave it a number :P
Quote from: dedndave on April 12, 2012, 04:40:45 PM
that is the pre-defined system class for dialog boxes
Oh....
I am assuming ( I did not have time with this yet ) that If I want a specific window's info for example "targetwindow.exe"
that instead of
INVOKE EnumChildWindows,HWND_DESKTOP,EnumChildProc,NULL
I would use
.data
appName db "targetwindow.exe"
INVOKE EnumChildWindows,addr appName,EnumChildProc,NULL
In any case I love the way you did this dedndave
There is a toy in the masm32 examples that enumerates running applications. This method gives you the classname if it is in fact unique.
Have a look at \masm32\examples\enumerate\...........
There are a few techniques for enumerating different things.
"targetwindow.exe" is not going to work, unless it happens to be the caption
that is a process name - more accurately, a program file name
Hutch...
that little tool that Iczelion has in tutorial #24 looks like fun, too :P
http://www.masm32.com/board/index.php?topic=18679.msg157788#msg157788
i generally use ms Spy++ for such things
Quote from: dedndave on April 12, 2012, 04:53:28 PM
"targetwindow.exe" is not going to work, unless it happens to be the caption
that is a process name - more accurately, a program file name
Hutch...
that little tool that Iczelion has in tutorial #24 looks like fun, too :P
http://www.masm32.com/board/index.php?topic=18679.msg157788#msg157788
i generally use ms Spy++ for such things
that is what I meant , a program file name like notepad.exe for example .....
I have a few examples of ways to hook into programs ...but then you would get the handle of the window and would be no scene in using "Findwindow"
i am guessing you are only interested in top-level windows
no need to go through all the child windows
so - you'd use EnumWindows
for each hwnd, call GetWindowThreadProcessId
that will get you the PID
call OpenProcess with the SYNCHRONIZE access flag
that will get you a handle to the process
call GetModuleFileNameEx to get the filename
use CloseHandle to close the process handle when you are done
ok - i had to use GetProcessImageFileName instead of GetModuleFileNameEx
not sure why that is - the other should work, too
oh well - give this a play...
It seems to do as the previous example you had ...
I think I want to make it with an open file so I can open a file and display it's info
try it on several windows
it should give the full path, usually :P
what OS are you using ?
may have to diddle with the OpenProcess access rights flags
Quote from: dedndave on April 12, 2012, 07:16:08 PM
try it on several windows
it should give the full path, usually :P
what OS are you using ?
may have to diddle with the OpenProcess access rights flags
Windows XP .....
by the way I meet with this woman from Microsoft she had windows 8 on her tablet ....http://windows8beta.com/
(http://www.masm32.com/board/index.php?action=dlattach;topic=18681.0;id=10555)
Quote from: dedndave on April 12, 2012, 07:22:15 PM
(http://www.masm32.com/board/index.php?action=dlattach;topic=18681.0;id=10555)
ya that is what it does for me but I do not need that
(http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/24.gif)
ok - i will go center a window - something i can handle :bg
LOL I meant I do not need to show the paths
ohhhhhhhh
well - it's easy to strip the path off
start at the end of the string and work backwards
stop when:
1) you find a backslash
2) you find a colon
3) you get to the start of the string
Quote from: dedndave on April 12, 2012, 05:41:59 PM
i am guessing you are only interested in top-level windows
no need to go through all the child windows
so - you'd use EnumWindows
for each hwnd, call GetWindowThreadProcessId
that will get you the PID
call OpenProcess with the SYNCHRONIZE access flag
that will get you a handle to the process
call GetModuleFileNameEx to get the filename
use CloseHandle to close the process handle when you are done
I treid fro two days I think something is wrong becuase I keep enumerating all the windows and not the file that I want .... I wander if there is a need for enumerate proc or just "INVOKE GetClassName,FileHandle,addr lpClassName,64"
Also I noticed that the file needs to be runing ... I tried Execute Window ...but no luck .... I tried a hook .... here are my attempts ...
I also found some examples that might have some useful ideas in it
Google "INVOKE GetClassName,FileHandle,addr lpClassName,64"
For obvious reasons I don't think I can post this here ...but the first result has an example that has this in it :
call GetForegroundWindow; get handle for currently used window ( specific to NT and after )
cmp [hCurrentWindow], eax; if its not different to last one saved..
je no_window_change ; bypass all the headings
mov [hCurrentWindow], eax; save it for use now and compare later
push 64 ; get the class name
lea esi, [lpClassName]
push esi
push [hCurrentWindow]
call GetClassName
would this work?
This thread is a bit confusing: what are you exactly trying to work out?
Why you can't simply use FindWindowEx()?
If you look at my attachment 2nd post up ...I am trying to make a tool that gets a "windows class name" and "window name"
Quote from: hfheatherfox07 on April 16, 2012, 11:15:35 PM
I am trying to make a tool that gets a "windows class name" and "window name"
ok - so you have the window handle thus you can use GetClassName() and GetWindowText() - where is the problem?
Quote from: qWord on April 16, 2012, 11:23:47 PM
Quote from: hfheatherfox07 on April 16, 2012, 11:15:35 PM
I am trying to make a tool that gets a "windows class name" and "window name"
ok - so you have the window handle thus you can use GetClassName() and GetWindowText() - where is the problem?
For you .....
I am not that good yet ... I thought I got the window handle but no luck I don't know if that app needs to run or at list how to create an open process , or should I use enumerate proc or not ....
I was up till 5AM and the better oart of today with this
From what window do you want to get the information?
Reading your post, it is not clear what you are exactly trying to do - that's make it difficult to help.
Quote from: qWord on April 16, 2012, 11:34:27 PM
From what window do you want to get the information?
Reading your post, it is not clear what you are exactly trying to do - that's make it difficult to help.
First off let me start by thanking you ...you have helped me a lot so I always appropriate your time and this forum ...... :U
I wish to open any window and be able to to that .... I have added some silly "tragetwindows" in my attachments ......
For example notepad.exe..... I made 2 of the test in my attachment with ofn so Ian open any window ....
I was just going between this and the CRC project that I got trying to open any file and get crc32 for it
Quote from: hfheatherfox07 on April 16, 2012, 11:39:47 PMI wish to open any window and be able to to that .... I have added some silly "tragetwindows" in my attachments ......
For example notepad.exe..... I made 2 of the test in my attachment with ofn so Ian open any window ....
so you want to create a process and then get the information (handle, calssname, ...) of the main-window or dialog?
Quote from: qWord on April 16, 2012, 11:49:27 PM
Quote from: hfheatherfox07 on April 16, 2012, 11:39:47 PMI wish to open any window and be able to to that .... I have added some silly "tragetwindows" in my attachments ......
For example notepad.exe..... I made 2 of the test in my attachment with ofn so Ian open any window ....
so you want to create a process and then get the information (handle, calssname, ...) of the main-window or dialog?
Yes I guess
what ever the sense, the attached example use ShellExecuteEx to 'open' a file and then search for a TLW.
Quote from: qWord on April 17, 2012, 01:17:51 AM
what ever the sense, the attached example use ShellExecuteEx to 'open' a file and then search for a TLW.
Thank you! :bg
... I wonder if you can set mov se.nShow,SW_SHOWNORMAL to not show the window ...
I will mess with this when I get home tonight
Thank you again !
I can't call my self a programer yet until I can do what you and others can ... took you no time ...and I struggled with this