News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Do we have WinGetClass in MASM ?

Started by hfheatherfox07, April 11, 2012, 10:52:24 PM

Previous topic - Next topic

hfheatherfox07

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 ?

hfheatherfox07

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 ?

jj2007

Get the handle, and use GetClassName...

Mozilla's top window is MozillaUIWindowClass

include \masm32\MasmBasic\MasmBasic.inc   ; download
.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

hfheatherfox07

I am trying to use GetClassName to find the windows class name which is unknown  to me

jj2007

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.

dedndave

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

hfheatherfox07

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

dedndave

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 ?

dedndave

;  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"

hfheatherfox07

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

dedndave

you are still not giving me direct answers to my questions
to get the title of a window, use GetWindowText


dedndave

Quotewhat info about that window do you have to begin with ???
is it a control ?
is it a child of your window ?

hfheatherfox07

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

dedndave

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

hfheatherfox07

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