Controling objects in a Map application

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Auto_Rudolf
Newbie
Posts: 4
Joined: Thu Sep 02, 2010 11:03 am

Controling objects in a Map application

Post by Auto_Rudolf » Thu Sep 02, 2010 11:30 am

Hi,

I have a Map application. There are objects on the Map layer.
A right click will give access to options on the object.

Example
Object: Vehicle
Right Click: Different Actions available for object.

Since the Object is a moving entity. And looks the same on map but each has it's own identifier, Vehicle Plate No.

Is there any way for Macro Scheduler to select the the specific object?

Thanks!

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Thu Sep 02, 2010 12:18 pm

Is this a browser based application?

If so, parsing the HTML that renders the page may be a better
solution than trying to do image recognition, which would not work anyway if all the images look alike. In HTML each "object" most likely has a unique "tag" or attributes which might let you identify it uniquely.

Auto_Rudolf
Newbie
Posts: 4
Joined: Thu Sep 02, 2010 11:03 am

Post by Auto_Rudolf » Thu Sep 02, 2010 12:24 pm

Hi adroege,
It is an application coded in C sharp.


Thanks!

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

Post by JRL » Thu Sep 02, 2010 1:01 pm

Just a thought.
Is it possible the "vehicle" objects each have their own handle?

While the application is running use the Macro Scheduler "View System Windows" utility (found under the "Tools" menu item) to look for the "vehicle" objects. I don't know what type of object they might show up as, but first thing is look and see if they are somehow identifiable. If they are, then you might be able to use the GetWindowList> and GetWindowName> functions in conjunction with the GetWindow Window's API function to isolate the "Vehicle" handles. Once you get the handles you can set focus to them using the SetFocus> function OR get their screen position to hover the mouse over them.

If they are not easily identifiable, there still might be techniques you could use to get the object handles.

If they are not objects with handles, obviously this thought ends.

Auto_Rudolf
Newbie
Posts: 4
Joined: Thu Sep 02, 2010 11:03 am

Post by Auto_Rudolf » Thu Sep 02, 2010 1:53 pm

Hi JRL,
Tried the "View System Windows" utility but did not find any identifiable objects.

Thanks!

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Thu Sep 02, 2010 2:48 pm

How would a human accomplish this task?

Is there a "search" function that given a plate # will highlight
the correct map object?

Otherwise I see no other course of action other than to have to right click and get the properties of *EVERY* map object until the desired one is found. If this is indeed the case, then it is possible for Macro Scheduler to emulate this behavior. Highly inefficient, but possible. The code would not be simple either.

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

Post by JRL » Thu Sep 02, 2010 3:29 pm

Another thought... After re-reading your original post.
Since the Object is a moving entity. And looks the same on map but each has it's own identifier, Vehicle Plate No.
Does the Vehicle Plate No. make the object visually identifiable. If yes, perhaps theres still a chance that image recognition can be used.


Along the same line as I mentioned before.

Below is a script that I've been meaning to clean up, comment and post. This script requires Macro Scheduler version 12 minimum. If you run this you will get a dialog to display window object information. To acquire the information to populate the dialog, hold the CTRL key and use the mouse to click on the window whose object information you want to acquire.

What I'm suggesting is that you run your program then start this script. Hold the control key and pick on your program's window. You should see a list of window object information display in the dialog. Part of the information is the X and Y coordinates of each object. If the vehicle objects move on screen, I would expect they could be identified by changes in their coordinates.

Assuming the script functions as planned, let us know if you see objects whose coordinates change (I assume you see the vehicles move)

If neither of these are possible, I agree with Alan.


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,Select a window to view objects
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


**BREAKPOINT**

  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




/*
GetWindow function parameters
GW_HWNDFIRST        0
GW_HWNDLAST         1
GW_HWNDNEXT         2
GW_HWNDPREV         3
GW_OWNER            4
GW_CHILD            5
*/

Auto_Rudolf
Newbie
Posts: 4
Joined: Thu Sep 02, 2010 11:03 am

Post by Auto_Rudolf » Fri Sep 03, 2010 2:13 am

Hi JRL.

Your script is amazing.
The Vehicle Plate No. is not visually identifiable.

I used your script but the vehicle objects is not identifiable.

At least I know it is not feasible or might be too tedious to implement at this moment.

Thanks JRL and adroege for the help!

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