Detecting ClassName without "System Windows" tool?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Detecting ClassName without "System Windows" tool?

Post by rullbandspelare » Tue Sep 24, 2013 7:52 am

Hi!

Is it possible to detect the Class Name of a object in a window within a compiled macro?

If You open notepad.exe then
GetControlText>Notepad ,Edit,1,strText
Will get You the text in ClassName Edit #1

But if You dont know the ClassName You cant get the text.
I my case I had to open "System Windows" tool to find out it was "ThunderRT6TextBox" classname.
This was running on a remote customers PC. So I had to go there and install MachroSceduler to be able to know what the ClassName was.

Any ideas?

Thanks!

User avatar
Grovkillen
Automation Wizard
Posts: 1132
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Tue Sep 24, 2013 8:32 am

Haven't tried it myself but Snoop might be of use? Or Win32Spy? Or Microsofts (abandoned) UISpy?
Let>ME=%Script%

Running: 15.0.27
version history

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Post by rullbandspelare » Tue Sep 24, 2013 9:30 am

Tack för tipsen!

Good tools.

win32spy was very easy to use. I could just include it and let the remote user run it as a part of the first investigation process.

User avatar
Grovkillen
Automation Wizard
Posts: 1132
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Tue Sep 24, 2013 9:46 am

Lugnt dä! :)
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Sep 24, 2013 12:46 pm


User avatar
Grovkillen
Automation Wizard
Posts: 1132
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Tue Sep 24, 2013 12:54 pm

JRL,

I think Rullbandspelare wanted to have a remote user provide him with this information by just point at it using the mouse cursor...
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Sep 24, 2013 2:02 pm

Compile and distribute.

Code: Select all

OnEvent>Key_Down,VK1,0,Process
OnEvent>Key_Down,VK27,0,Quit

message>Select a window
Wait>2
CloseWindow>Macro Scheduler Message

Label>Loop
Wait>0.01
Goto>Loop

SRT>Process
  Wait>0.5
  Let>WIN_USEHANDLE=1
    GetActiveWindow>WinHndl,WinX,WinY
    GetWindowNames>WinHndl,WinTitle,WinClass
  Let>WIN_USEHANDLE=0
  MDL>Window NAme - %WinTitle%%crlf%Window Handle - %WinHndl%%crlf%Window Class - %WinClass%
  message>Select a window or press Esc to quit
  Wait>2
  CloseWindow>Macro Scheduler Message
END>Process

SRT>Quit
  message>Goodbye
  Wait>2
  Exit>0
END>Quit

User avatar
Grovkillen
Automation Wizard
Posts: 1132
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Tue Sep 24, 2013 2:39 pm

Almost perfect... I ended up in a small loop when trying to Quit after running it UNcompiled. :)
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Sep 24, 2013 3:25 pm

Hmmm. I see what you mean, the message windows are messing with the Esc key press.

So this is more complicated but it works for me. Let me know if you have issues.

Edit - Changed the script so you must hold the CTRL key while you select a window with the mouse.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 479
  Top = 128
  HelpContext = 5000
  AutoSize = True
  BorderIcons = []
  Caption = 'Message'
  ClientHeight = 187
  ClientWidth = 317
  Color = 15460798
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  Position = poScreenCenter
  TextHeight = 13
  object Label1: TLabel
    Left = 0
    Top = 0
    Width = 48
    Height = 20
    Caption = 'Label1'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -16
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
  object MSButton1: tMSButton
    Left = 119
    Top = 133
    Width = 75
    Height = 25
    Caption = 'Ok'
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
    Visible = False
  end
end
EndDialog>Dialog1


OnEvent>Key_Down,VK1,2,Process
OnEvent>Key_Down,VK27,0,Quit

AddDialogHandler>Dialog1,,OnKeyPress,Quit2
AddDialogHandler>Dialog1,msButton1,OnKeyPress,Quit2
AddDialogHandler>Dialog1,msButton1,OnClick,CloseD1
SetDialogProperty>Dialog1,Label1,Caption,Select a window
Show>Dialog1
Wait>2
CloseDialog>Dialog1


Label>Loop
Wait>0.01
Goto>Loop

SRT>Process
  Let>WIN_USEHANDLE=1
    GetActiveWindow>WinHndl,WinX,WinY
    GetWindowNames>WinHndl,WinTitle,WinClass
  Let>WIN_USEHANDLE=0
  SetDialogProperty>Dialog1,msButton1,Visible,True
  SetDialogProperty>Dialog1,Label1,Caption,Window Name - %WinTitle%%crlf%Window Handle - %WinHndl%%crlf%Window Class - %WinClass%
  ResizeWindow>Message,0,0
  GetWindowSize>Message,WinX,WinY
  Let>ButtonXPos={(%Winx%/2)-38}
  SetDialogProperty>Dialog1,msButton1,Left,ButtonXPos
  Show>Dialog1,
  SetDialogProperty>Dialog1,msButton1,Visible,False
  SetDialogProperty>Dialog1,Label1,Caption,Select a window or press Esc to quit
  ResizeWindow>Message,0,0
  Show>Dialog1
  Wait>2
  CloseDialog>Dialog1
END>Process

SRT>CloseD1
  CloseDialog>Dialog1
END>CloseD1

SRT>Quit
  SetDialogProperty>Dialog1,msButton1,Visible,False
  SetDialogProperty>Dialog1,Label1,Caption,GoodBye
  ResizeWindow>Message,0,0
  Show>Dialog1
  Wait>2
  Exit>0
END>Quit

SRT>Quit2
  If>Quit2_Key=27
    SetDialogProperty>Dialog1,msButton1,Visible,False
    SetDialogProperty>Dialog1,Label1,Caption,GoodBye
    ResizeWindow>Message,0,0
    Show>Dialog1
    Wait>2
    Exit>0
  EndIf
END>Quit2
Last edited by JRL on Tue Sep 24, 2013 5:22 pm, edited 1 time in total.

User avatar
Grovkillen
Automation Wizard
Posts: 1132
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Post by Grovkillen » Tue Sep 24, 2013 4:10 pm

Looking good JRL! :) Worked like a charm.
Let>ME=%Script%

Running: 15.0.27
version history

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Sep 24, 2013 5:21 pm

The previous post in this thread only gives window info. This script gives window and object info.

I'm pretty sure I've posted this before. Start this then hold the CTRL key while selecting a window with the mouse. You will acquire object information about the objects in the selected window.

Code: Select all

OnEvent>Key_Down,VK1,2,Process
Dialog>Dialog1
object Dialog1: TForm
  Left = 447
  Top = 247
  HelpContext = 5000
  Anchors = [akLeft, akTop, akRight]
  BorderIcons = [biSystemMenu]
  Caption = 'Object Display List'
  ClientHeight = 177
  ClientWidth = 451
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  DesignSize = (
    451
    177)
  PixelsPerInch = 96
  TextHeight = 13
  object MSMemo1: tMSMemo
    Left = 0
    Top = 24
    Width = 448
    Height = 150
    Anchors = [akLeft, akTop, akRight, akBottom]
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -15
    Font.Name = 'Courier'
    Font.Style = []
    ParentFont = False
    ScrollBars = ssBoth
    TabOrder = 0
    WordWrap = False
    ExplicitWidth = 889
    ExplicitHeight = 822
  end
  object MSMemo2: tMSMemo
    Left = 0
    Top = 3
    Width = 432
    Height = 22
    Anchors = [akLeft, akTop, akRight]
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Courier'
    Font.Style = []
    ParentFont = False
    TabOrder = 1
    ExplicitWidth = 873
  end
end
EndDialog>Dialog1

Let>counter=0
Let>file1=%temp_dir%Window_Object_List.txt
DeleteFile>file1
Let>ProcessFlag=0
Let>Header=Z-Order%TAB%X pos%TAB%Y pos%TAB%Width%TAB%Height%TAB%Handle%TAB%%TAB%Class%TAB%%TAB%%TAB%%TAB%%TAB%Name
SetDialogProperty>Dialog1,MSMemo2,Text,To view objects, hold the CTRL key while selecting a window.
AddDialogHandler>Dialog1,,OnClose,Quit
Show>Dialog1

Label>Loop
  Wait>0.01
  //GoSub>Process
  If>ProcessFlag>0
    Add>ProcessFlag,1
    If>ProcessFlag>10
      Let>ProcessFlag=0
    EndIf
  EndIf
Goto>Loop

SRT>Quit
  DeleteFile>file1
  Exit>0
END>Quit

SRT>Process
  If>ProcessFlag=0
    Let>ProcessFlag=1
    Add>counter,1
    DeleteFile>file1
    Let>WIN_USEHANDLE=1
    Let>GWres=
    GetActiveWindow>hwnd,Xvar,Yvar
    If>%hwnd%=%Dialog1.Handle%
      Goto>SkipProcess
    EndIf
    GetWindowNames>hwnd,title,class
    GoSub>Print,0,hwnd,class,title
    Let>kk=1

    LibFunc>user32,GetWindow,GWres,hwnd,5
    GetWindowNames>GWres,title,class

    GoSub>Print,%kk%,GWres,class,title
    Let>Window_%kk%=%GWres%

    Repeat>GWres
      Add>kk,1
      LibFunc>user32,GetWindow,GWres,%GWres%,2
      Let>Window_%kk%=%GWres%
      GetWindowNames>GWres,title,class
      Let>WinName=Window_Name_%kk%
      GoSub>Print,%kk%,GWres,class,title
    Until>GWres=0

    ReadFile>File1,data
    SetDialogProperty>Dialog1,MSMemo2,Text,Header
    SetDialogProperty>Dialog1,MSMemo1,Text,data
    SetDialogProperty>Dialog1,,Caption,Object Display List - Selection %counter%
    Label>SkipProcess
  EndIf
Let>ProcessFlag=1

SRT>Print
  Let>WIN_USEHANDLE=1
  If>GWres=0,SkipWrite
    GetWindowPos>%Print_var_2%,PosX,PosY
    If>%Print_var_2%<>%hwnd%
      Sub>PosX,%Xvar%
      Sub>PosY,%Yvar%
    EndIf
    GetWindowSize>%Print_var_2%,SizeW,SizeH
    Length>%Print_var_2%,len
    If>len>7
      Let>spacing=%TAB%
    Else
      Let>spacing=%TAB%%TAB%
    EndIf
    Writeln>file1,wres,%ProcessFlag%-%Print_var_1%%TAB%%PosX%%TAB%%PosY%%TAB%%SizeW%%TAB%%SizeH%%TAB%%Print_var_2%%spacing%%Print_var_3%%TAB%%TAB%%TAB%%TAB%%Print_var_4%
  Label>SkipWrite
END>Print
END>Process


armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Sep 25, 2013 10:02 am

Jag letade efter svaret också. Tack så mycket.

rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Post by rullbandspelare » Thu Sep 26, 2013 10:39 am

Thanks JRL!
It works verywell with windows that have their text in a object in a top most level in the windows tree. Like the Edit #1 object in Notepad.exe.

But Sometimes You have to drill down into a object to actualy find the text You are looking for. This is hiden from Your tool.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Sep 26, 2013 1:12 pm

rullbandspelare wrote:But Sometimes You have to drill down into a object to actualy find the text You are looking for. This is hiden from Your tool.
You are correct. The script will only find objects at the second level of a window (assuming the window itself is the first level). Each object could have sub objects and those sub objects could have their own sub objects etc. and this script will not find those sub objects. I've rarely had the need to find the lower level objects so I haven't taken the time to write the script to iterate through all of the possibilities. It makes my brain hurt just thinking about how to do that.

Perhaps someone could post an example of how to accomplish iteration through an unknown maze of tree structure. Maybe with an example, some scripter might take some time and rewrite the above script and make it function such that it would find ALL objects in a selected window?

Ok, took a couple of years to get around to it but here is a script that will provide similar information as "View System Windows" for a selected window.

Code: Select all

/*
Enumerate All Windows in a Selected Windows.scp
James Richard Lockey - October 27, 2017
Similar to "View System Windows" tool.
Initially displays relative level, window handle, window name,
window class and window process.  Double clicking on a line additionally
displays the window size, window location and window process id
in a message dialog.  Double click on the message dialog also puts
the line information to the clipboard in the order:
Level, Handle, Name, Class, Xpos,Ypos, Width,Height, Process Id, Process
*/


OnEvent>Key_Down,VK1,2,Process


Dialog>Dialog1
object Dialog1: TForm
  Left = 243
  Top = 108
  Width = 1500
  Height = 813
  HelpContext = 5000
  AutoScroll = True
  BorderIcons = [biSystemMenu]
  Caption = 'All Windows'
  Color = 16777200
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  DesignSize = (
    1425
    775)
  PixelsPerInch = 96
  TextHeight = 13
  object MSStringGrid1: tMSStringGrid
    Left = 10
    Top = 10
    Width = 1461
    Height = 757
    Anchors = [akLeft, akTop, akRight, akBottom]
    BiDiMode = bdLeftToRight
    Ctl3D = True
    DefaultRowHeight = 17
    DrawingStyle = gdsGradient
    FixedColor = 8388863
    FixedCols = 0
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    Options = [goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goDrawFocusSelected, goColSizing, goRowSelect, goFixedColClick, goFixedRowClick, goFixedHotTrack]
    ParentBiDiMode = False
    ParentCtl3D = False
    ParentFont = False
    ParentShowHint = False
    ShowHint = True
    TabOrder = 0
    ExplicitWidth = 845
    ExplicitHeight = 740
    ColWidths = (
      27
      150
      350
      350
      550)
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSStringGrid1,OnDblClick,GetProcess

Dialog>Dialog2
object Dialog2: TForm
  Left = 436
  Top = 239
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  BorderStyle = bsNone
  Caption = ' '
  ClientHeight = 150
  ClientWidth = 300
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 0
    Top = 0
    Width = 300
    Height = 150
    Align = alClient
    Alignment = taCenter
    BiDiMode = bdLeftToRight
    Caption = 'qqq'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clNavy
    Font.Height = -20
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentBiDiMode = False
    ParentFont = False
    Layout = tlCenter
    ExplicitWidth = 33
    ExplicitHeight = 25
  end
end
EndDialog>Dialog2

SetDialogProperty>Dialog2,Label1,Caption,Building Window List%crlf%Please Wait...

Dialog>Dialog3
object Dialog3: TForm
  Left = 436
  Top = 239
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  BorderStyle = bsToolWindow
  Caption = ' '
  ClientHeight = 211
  ClientWidth = 476
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object LabelHeader: TLabel
    Left = 12
    Top = 12
    Width = 11
    Height = 20
    Caption = '  '
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -16
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label1: TLabel
    Left = 12
    Top = 32
    Width = 59
    Height = 25
    Caption = 'Label1'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlue
    Font.Height = -20
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
    object Label2: TLabel
    Left = 157
    Top = 32
    Width = 59
    Height = 25
    Caption = 'Label1'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlue
    Font.Height = -20
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
  object Label3: TLabel
    Left = 300
    Top = 32
    Width = 59
    Height = 25
    Caption = 'Label1'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlue
    Font.Height = -20
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
  object Label4: TLabel
    Left = 446
    Top = 32
    Width = 59
    Height = 25
    Caption = 'Label1'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlue
    Font.Height = -20
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
  end
  object LabelTop: TLabel
    Left = 0
    Top = 0
    Width = 10
    Height = 25
    Caption = '  '
  end
  object LabelBottom: TLabel
    Left = 0
    Top = 75
    Width = 10
    Height = 25
    Caption = '  '
  end
end
EndDialog>Dialog3

AddDialogHandler>Dialog3,,OnDblClick,PutToClipboard
AddDialogHandler>Dialog3,LabelHeader,OnDblClick,PutToClipboard
AddDialogHandler>Dialog3,Label1,OnDblClick,PutToClipboard
AddDialogHandler>Dialog3,Label2,OnDblClick,PutToClipboard
AddDialogHandler>Dialog3,Label3,OnDblClick,PutToClipboard
AddDialogHandler>Dialog3,Label4,OnDblClick,PutToClipboard


Dialog>Dialog4
object Dialog4: TForm
  Left = 367
  Top = 150
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 96
  ClientWidth = 402
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 40
    Top = 16
    Width = 324
    Height = 20
    Caption = 'Press and hold CTRL key while selecting'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -16
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label2: TLabel
    Left = 100
    Top = 49
    Width = 192
    Height = 20
    Caption = 'Window to be evaluated'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -16
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
  end
end
EndDialog>Dialog4

AddDialogHandler>Dialog4,,OnClose,Quit
Show>Dialog4

  Let>WIN_USEHANDLE=1
    MoveWindow>Dialog4.handle,1300,10
  Let>WIN_USEHANDLE=0

Timer>vStartTime
Let>ContinueFlag=0
Let>ProcessFlag=0
Label>IdleLoop
  Wait>0.01
  If>ContinueFlag=1
    Goto>LeaveIdleLoop
  EndIf
  Timer>vEndTime
Goto>IdleLoop
Label>LeaveIdleLoop

SRT>Process
  If>ProcessFlag=0
    Let>ProcessFlag=1
    GetActiveWindow>vTitle,Xvar,Yvar
    Let>WIN_USEHANDLE=1
      GetActiveWindow>hwnd,Xvar,Yvar
    Let>WIN_USEHANDLE=0
    Let>ContinueFlag=1
  EndIf
END>Process


DeleteFile>%temp_dir%childwindowlist.csv
Writeln>%temp_dir%childwindowlist.csv,wres,"Lev.","Handle","Name","Class","Process"

Let>WindowCount=0
Let>Level=0
Let>WIN_USEHANDLE=1

//Get and write data for top window
//LibFunc>user32,GetDesktopWindow,hwnd
GetWindowNames>hwnd,title,class
GoSub>Print,hwnd,title,class

//Initial jump down to first top level child window.
Let>Level=1
LibFunc>user32,GetWindow,GWres,hwnd,5
GetWindowNames>GWres,title,class
GoSub>Print,GWres,title,class
Let>Window_%Level%=GWres
Let>DoNextFlag=0

Label>StepDown
  If>DoNextFlag=0
    GoSub>GetChild,GWres
    If>{(%GWChildRes%<>0)or(%DoNextFlag%=1)}
      GoTo>StepDown
    Else>
      Sub>Level,1
      Let>LastWindow=Window_%Level%
      GoSub>GetNext,LastWindow
      Goto>StepDown
    EndIf
  Else>
    GoSub>GetNext,GWres
    GoTo>StepDown
  EndIf

SRT>Quit
  Exit>0
END>Quit

SRT>GetChild
  LibFunc>user32,GetWindow,GWChildRes,GetChild_var_1,5
  If>GWChildRes<>0
    Add>Level,1
    Let>Window_%Level%=GWChildRes
    GetWindowNames>GWChildRes,title,class
    GoSub>Print,GWChildRes,title,class
    Let>GWRes=GWChildRes
  Else
      GoSub>GetNext,GetChild_var_1
  EndIf
END>GetChild

SRT>GetNext
  LibFunc>user32,GetWindow,GWRes,GetNext_var_1,2
  If>GWres<>0
    Let>Window_%Level%=GWRes
    Let>GWChildRes=1
    GetWindowNames>GWRes,title,class
    GoSub>Print,GWRes,title,class
    Let>DoNextFlag=0
  Else
    Sub>Level,1
    Let>GWRes=Window_%Level%
    Let>DoNextFlag=1
  EndIf
  If>Level=0
    ReadFile>%temp_dir%childwindowlist.csv,vData
    SetDialogProperty>Dialog1,MSStringGrid1,LoadFromCSV,vData
    SetDialogProperty>Dialog1,,Caption,All %WindowCount% Windows
    CloseDialog>Dialog2
    Wait>0.2
    SetDialogProperty>Dialog4,,AlphaBlend,True
    SetDialogProperty>Dialog4,,AlphaBlendValue,0
    Show>Dialog1,
    Exit>0
  EndIf
END>GetNext


SRT>Print
  If>GWres=0,SkipWrite
    StringReplace>Print_var_2,crlf,space,Print_var_2
    StringReplace>Print_var_2,cr,space,Print_var_2
    StringReplace>Print_var_2,lf,space,Print_var_2
      GetWindowProcess>Print_var_1,ProcID,ProcName
    Let>Spaces=
    If>Level>0
      Let>SPkk=0
      Repeat>SPkk
        Add>SPkk,1
        ConCat>Spaces,%space%%space%%space%%space%
      Until>SPkk=level
    EndIf
    Add>WindowCount,1
    Writeln>%temp_dir%childwindowlist.csv,wres,"%Level%","%Spaces%%Print_var_1%","%Print_var_2%","%Print_var_3%","%ProcName%"
  Label>SkipWrite
END>Print


SRT>GetProcess
  GetTextInit
  GetCursorPos>CurX,CurY

  Let>GTaP=0
  Repeat>GTaP
  Wait>0.1
    Add>GTaP,1
    GetTextAtPoint>CurX,CurY,WindowData,vCharPos
    If>vCharPos>0
      Let>GTaP=100
    EndIf
  Until>GTaP=100

  Separate>WindowData,space,vItem

  Let>vI=1
  Repeat>vI
    Add>vI,1
    Let>value=vItem_%vI%
    If>value=
    Else
      Let>vI=vItem_Count
      Let>WinHandle=value
    EndIf
  Until>vI=vItem_Count


  Trim>WinHandle,WinHandle
  Let>WIN_USEHANDLE=1
  GetWindowProcess>WinHandle,ProcID,ProcName
  GetWindowPos>WinHandle,vWinX,vWinY
  GetWindowSize>WinHandle,vWinW,vWinH
  SetDialogProperty>Dialog3,,Caption,vItem_3
  SetDialogProperty>Dialog3,LabelHeader,Caption,Window Handle%Tab%XPos,YPos%Tab%Width,Height%Tab%Process ID%space%%space%
  SetDialogProperty>Dialog3,Label1,Caption,%WinHandle%
  SetDialogProperty>Dialog3,Label2,Caption,%vWinX%,%vWinY%
  SetDialogProperty>Dialog3,Label3,Caption,%vWinW%,%vWinH%
  SetDialogProperty>Dialog3,Label4,Caption,%ProcID%
  SetDialogProperty>Dialog3,Label1,AutoSize,True
  SetDialogProperty>Dialog3,,AutoSize,False
  SetDialogProperty>Dialog3,Label1,AutoSize,True
  SetDialogProperty>Dialog3,,AutoSize,True
  Let>WIN_USEHANDLE=1
    ResizeWindow>Dialog3.handle,1000,100
  Let>WIN_USEHANDLE=0
  SetDialogProperty>Dialog3,,Position,poScreenCenter
  Show>Dialog3,
END>GetProcess

SRT>PutToClipboard
  ReadFile>%temp_dir%childwindowlist.csv,vHandleData
  Separate>vHandleData,WinHandle,vHndData
  Separate>vHndData_2,crlf,vHndLine
  Separate>vHndLine_1,"%comma%",vHndItem
  Separate>vHndData_1,crlf,vHndLine
  Let>vLastLine=vHndLine_%vHndLine_Count%
  StringReplace>vLastLine,"%comma%",,vLastLine
  StringReplace>vLastLine,",,CBVar
  StringReplace>vHndItem_4,",,vHndItem_4
  Concat>CBVar,%comma%%Space%%WinHandle%
  Concat>CBVar,%comma%%Space%%vHndItem_2%
  Concat>CBVar,%comma%%Space%%vHndItem_3%
  Concat>CBVar,%comma%%Space%%vWinX%%comma%%vWinY%
  Concat>CBVar,%comma%%Space%%vWinW%%comma%%vWinH%
  Concat>CBVar,%comma%%Space%%ProcID%
  Concat>CBVar,%comma%%Space%%vHndItem_4%
  PutClipBoard>CBVar
  SetDialogProperty>Dialog2,Label1,Caption,Data placed in Clipboard
  Show>Dialog2
  Wait>0.5
  CloseDialog>Dialog2
END>PutToClipboard

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts