Page 1 of 2

tool displaying win ids on mouseover

Posted: Thu Nov 20, 2003 6:38 pm
by spot
this could be of interest for any windows progammer. just found it in another forum:

"WinID allows to get the most important information about Windows control classes, styles, and window titles. All you need is to point mouse cursor to a window, or any of system or custom-created control."

http://dennisbabkin.com/php/download.php?what=WinID

Posted: Fri Nov 21, 2003 10:52 am
by freedimension

Posted: Fri Nov 21, 2003 3:56 pm
by RJP Computing
This is also very helpful.

http://www.windows-spy.com/

Re: tool displaying win ids on mouseover

Posted: Sat Nov 22, 2003 5:26 am
by PB
I personally like "ShoWin" because it shows details for ANY window, even
ones that "WinID" doesn't, and also "invisible" windows that are not seen:

http://www.foundstone.com/resources/proddesc/showin.htm

I'll have to check out the other suggestions to see how they fare. :)

Posted: Sat Nov 29, 2003 7:16 pm
by Hi-Toro
Weirdly enough, I wrote one of these in PB last night! Should be very easy to add more information to (and display the information in a better way than I'm doing here)...

Code: Select all


OpenWindow (0, 200, 200, 500, 200, #PB_Window_SystemMenu, "WindowInfo")

SetTimer_ (WindowID (), 0, 100, 0)

Repeat

    Select WaitWindowEvent ()
    
        Case #WM_TIMER
        
            GetCursorPos_ (@p.POINT)
            source = WindowFromPoint_ (p\x, p\y)
            If source <> WindowID ()
                GetWindowText_ (source, ReAllocateMemory (0, 255), 255)
                title$ = PeekS (MemoryID ())
                GetClassName_ (source, ReAllocateMemory (0, 255), 255)
                class$ = PeekS (MemoryID ())
                SetWindowText_ (WindowID (), title$ + " [Class: " + class$ + "]")
            Else
                SetWindowText_ (WindowID (), "WindowInfo's own window")
            EndIf
            
        Case #PB_Event_CloseWindow
        
            End
            
    EndSelect
    
ForEver

Posted: Sun Nov 30, 2003 5:05 am
by PB
> I wrote one of these in PB last night

Hi-Toro, your example doesn't get the details of all windows, whereas the
app I mentioned ("ShoWin") does. For example: (In Win 98 SE), open the
"Taskbar & Start Menu" item, select "Start Menu Programs", and try to get
the info of the buttons etc inside the FrameGadgets. Only ShoWin seems
to be able to get such info. I've been trying to also do this for ages, and I
was hoping your example could do it, but no. :( Anyone know how?

Posted: Sun Nov 30, 2003 8:11 am
by Hi-Toro
Well, you can get all windows like this:

Code: Select all

Procedure ListWindows (window, parameter)

    GetClassName_ (window, ReAllocateMemory (0, 255), 255)
    class$ = PeekS (MemoryID ())

    GetWindowText_ (window, ReAllocateMemory (0, 255), 255)
    title$ = PeekS (MemoryID ())

    FreeMemory (0)
    
    Debug Chr (34) + title$ + Chr (34) + " / Class: " + class$
    
    ProcedureReturn #TRUE
    
EndProcedure

EnumWindows_ (@ListWindows (), 0)

Posted: Mon Dec 01, 2003 5:01 am
by PB
> you can get all windows like this

Nope, still doesn't show all window classes and text. :( Thanks anyway.

Posted: Mon Dec 01, 2003 8:59 am
by Hi-Toro
You mean it doesn't show child windows (ie. 'gadgets')? I should be able to do that...

Posted: Mon Dec 01, 2003 10:51 pm
by Hi-Toro
This code lists all open windows, including hidden ones and sub-windows. Turn Debug on! Note that ListChildWindows is called recursively on each child-window, using the 'parameter' variable to track 'depth'...

General non-GUI code here...

Code: Select all


; List top-level windows' children (called by ListWindows)...

Procedure ListChildWindows (window, parameter)

    GetClassName_ (window, ReAllocateMemory (0, 255), 255) 
    class$ = PeekS (MemoryID ()) 

    GetWindowText_ (window, ReAllocateMemory (0, 255), 255) 
    title$ = PeekS (MemoryID ()) 

    FreeMemory (0) 
    
    For a = 1 To parameter
        sub$ = sub$ + "--------"
    Next
    
    Debug sub$ + ">" + Chr (34) + title$ + Chr (34) + " / Class: " + class$ 

    EnumChildWindows_ (window, @ListChildWindows (), parameter + 1)

    ProcedureReturn #TRUE
    
EndProcedure

; List top-level windows...

Procedure ListWindows (window, parameter) 

    GetClassName_ (window, ReAllocateMemory (0, 255), 255) 
    class$ = PeekS (MemoryID ()) 

    GetWindowText_ (window, ReAllocateMemory (0, 255), 255) 
    title$ = PeekS (MemoryID ()) 

    FreeMemory (0) 
    
    Debug ""
    Debug "------------------------------------------------------------------------"
    Debug Chr (34) + title$ + Chr (34) + " / Class: " + class$ 
    Debug "------------------------------------------------------------------------"
    
    EnumChildWindows_ (window, @ListChildWindows (), 1)
    
    ProcedureReturn #TRUE 
    
EndProcedure 

EnumWindows_ (@ListWindows (), 0)

GUI code with tiny fix (a bit hard-coded to this tree gadget, I'm afraid)...

Code: Select all


#TREEGADGET = 0

Procedure ListChildWindows (window, parameter)

    GetClassName_ (window, ReAllocateMemory (0, 255), 255) 
    class$ = PeekS (MemoryID ()) 

    GetWindowText_ (window, ReAllocateMemory (0, 255), 255) 
    title$ = PeekS (MemoryID ()) 

    If title$ = ""
        title$ = "[Unnamed]"
    EndIf

    FreeMemory (0) 

    OpenTreeGadgetNode (#TREEGADGET)
        AddGadgetItem (#TREEGADGET, -1, title$ + " [" + class$ + "]")
        EnumChildWindows_ (window, @ListChildWindows (), 0)
    CloseTreeGadgetNode (#TREEGADGET)
    
    ProcedureReturn #TRUE
    
EndProcedure

Procedure ListWindows (window, parameter) 

    GetClassName_ (window, ReAllocateMemory (0, 255), 255) 
    class$ = PeekS (MemoryID ()) 
    GetWindowText_ (window, ReAllocateMemory (0, 255), 255) 
    title$ = PeekS (MemoryID ()) 

    If title$ = ""
        title$ = "[Unnamed]"
    EndIf

    FreeMemory (0) 

    OpenTreeGadgetNode (#TREEGADGET)
        AddGadgetItem (#TREEGADGET, -1, title$ + " [" + class$ + "]")
        EnumChildWindows_ (window, @ListChildWindows (), 1)
    CloseTreeGadgetNode (#TREEGADGET)

    ProcedureReturn #TRUE 

EndProcedure 

Procedure WinHook (WindowID, Message, wParam, lParam)
    If Message = #WM_SIZE
        ResizeGadget (#TREEGADGET, 0, 0, WindowWidth (), WindowHeight () - 25)
        RedrawWindow_ (GadgetID (#TREEGADGET), #NULL, #NULL, #RDW_INVALIDATE)
        ResizeGadget (1, 0, WindowHeight () - 25, WindowWidth (), 25)
    EndIf
    ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

Procedure GetWindowTree ()
    ClearGadgetItemList (#TREEGADGET)
    OpenTreeGadgetNode (#TREEGADGET)
    AddGadgetItem (#TREEGADGET, -1, "All windows...")
    EnumWindows_ (@ListWindows (), 0)
    CloseTreeGadgetNode (#TREEGADGET)
EndProcedure

OpenWindow (0, 0, 0, 400, 300, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget, "All windows...")
CreateGadgetList (WindowID ())

TreeGadget (#TREEGADGET, 0, 0, WindowWidth (), WindowHeight () - 25)
GetWindowTree ()
SetGadgetItemState (0, 0, #PB_Tree_Expanded)

ButtonGadget (1, 0, WindowHeight () - 25, WindowWidth (), 25, "Update list...")

SetWindowCallback (@WinHook ())

Repeat

    Select WaitWindowEvent ()
        Case #PB_Event_CloseWindow
            End
        Case #PB_Event_Gadget
            If EventGadgetID () = 1
                GetWindowTree ()
                SetGadgetItemState (0, 0, #PB_Tree_Expanded)
            EndIf
    EndSelect
    
ForEver


Posted: Tue Dec 02, 2003 4:43 am
by PB
> You mean it doesn't show child windows (ie. 'gadgets')?

Yep, items inside FrameGadgets of other windows, etc.

> I should be able to do that...

(Checked new example): Yep, that's it! :D

Now I just have to get it working with WindowFromPoint and
I'm all done. Thanks heaps!

Posted: Tue Dec 02, 2003 8:55 am
by Hi-Toro
There are now two code sections in my previous post -- I've added a more general example to the above code section, as well as a tiny fix to the GUI version...

Posted: Tue Aug 16, 2005 1:29 am
by dc2000
Hey guys, did someone check this software http://dennisbabkin.com/php/download.php?what=WinID -- they seem to have a cool version now?

Posted: Tue Aug 16, 2005 8:01 am
by gnozal
Sysinternal's Process Explorer does it too. And much more. And it's free.
http://www.sysinternals.com/Utilities/P ... lorer.html

Posted: Fri Aug 19, 2005 6:25 am
by dc2000
I thought this WinID is also free, isn't it? At least it didn't show any warnings to me.

I checked your link. Thanx it's good too, although it's a little bit different, more like Task Manager.