Problem accessing child window(s)

Started by KBaumGHS, December 16, 2013, 01:34:57 PM

Previous topic - Next topic

KBaumGHS

I am trying to use WinBatch and, more specifically, RoboScript to automate the data entry process of registering patients into an MS Windows-based software application and I'm having difficulties getting RoboScript to recognize the controls that are present on the screen where all the data is supposed to be input.  The process goes like this...

*  Launch the application.
*  A screen titled, "Registration" comes up and on that screen are a dozen different icons.
*  Left-click the icon on the top left portion of the screen.  At this point, the screen title still says, "Registration" but, below the menu bar at the top, a brand new screen appears.
*  It's at this point that I start RoboScript and drag the cross-hairs to an icon at the top of the new screen and tell RoboScript to do a left mouse-click.
*  The system responds by bringing up a new screen, under the initial menu bar, and the screen title still says, "Registration".
*  At this point I drag the cross-hairs to the first input field on this third screen, expecting RoboScript to add TextEntry to the list of available actions / radio buttons.  The options, however, remain unchanged.
*  As I drag the cross-hairs across the screen I keep an eye on the RoboScript screen and notice the control names reflect literals that are actually on the very first of these three screens, "beneath" the screen I currently see.

What do I need to do to get RoboScript to recognize that, even though the screen title remains the same, the screens that are displayed below the menu bar are actually changing so that I can then gain access to the controls on these subsequent screens?

Thank you!

Deana

Each window should have its own unique "window specification".

A window specification basically  is made up of:

  • Window class name
  • Module name
  • Child window ids

The RoboScripter tool will update based on where you have placed the crosshairs. 

However you are stating that when placing the crosshairs on a particular window you are not getting the correct information for that window? Not clear what could be going on.

I recommend selecting the OPTIONS button in RoboScripter and check the box 'Verbose script generation mode". On the main window, choose a default action ( i.e. Get Title) then save the script. Then record again yet this time access a default action on this third registration window. Save as a separate script. Compare the scripts. Pay close attention to the cWndByWndSpec parameters. Are the  same or different?

Screen shot might also be helpful.


Deana F.
Technical Support
Wilson WindowWare Inc.

KBaumGHS

Here are the three script excerpts...

;RoboScripter
; Made with
;   RoboScripter ver: 45
;   CtlMgr ver: 44039
AddExtender("wwctl44i.dll")

;Title: <untitled>
;ID: 1025
;Class: Button11
;Level: 4

; Default cWndByWndSpec seems OK here
window1=cWndByWndSpec("FNWND3125","registration",3,0,0,2000)
; window1=cWndByWndSpecName("Paragon Registration    Current User: DOE, JOHN E.         IT GENERAL MEDICAL CENTER IT","registration",3,0,0,2000)
; window1=DllHwnd('Paragon Registration    Current User: DOE, JOHN E.         IT GENERAL MEDICAL CENTER IT')
window2=cWndByID(window1,2000)
; or window2=cWndByClass(window1,`MDIClient`)
; or window2=cWndBySeq(window1,3)
window3=cWndByID(window2,200)
; or window3=cWndByName(window2,`Paragon Registration~`)
; or window3=cWndByClass(window2,`FNWND3125`)
; or window3=cWndBySeq(window2,1)
ControlHandle=cWndByID(window3,1025)
; or ControlHandle=cWndBySeq(window3,26)
result=cWndInfo(ControlHandle,0)     ;Reads the title/text of a control
Message("Window Title/Text",result)     ;TODO - Remove Message.  Add code.


;Title: <untitled>
;ID: 1029
;Class: Button11
;Level: 4

; Default cWndByWndSpec seems OK here
window1=cWndByWndSpec("FNWND3125","registration",3,0,0,2000)
; window1=cWndByWndSpecName("Paragon Registration    Current User: DOE, JOHN E.         IT GENERAL MEDICAL CENTER IT","registration",3,0,0,2000)
; window1=DllHwnd('Paragon Registration    Current User: DOE, JOHN E.         IT GENERAL MEDICAL CENTER IT')
window2=cWndByID(window1,2000)
; or window2=cWndByClass(window1,`MDIClient`)
; or window2=cWndBySeq(window1,3)
window3=cWndByID(window2,201)
; or window3=cWndByName(window2,`Person and Visit Selection~`)
; or window3=cWndBySeq(window2,1)
ControlHandle=cWndByID(window3,1029)
; or ControlHandle=cWndBySeq(window3,4)
result=cWndInfo(ControlHandle,0)     ;Reads the title/text of a control
Message("Window Title/Text",result)     ;TODO - Remove Message.  Add code.


;Title: <untitled>
;ID: 1000
;Class: pbdw125
;Level: 4

; Default cWndByWndSpec seems OK here
window1=cWndByWndSpec("FNWND3125","registration",3,0,0,2000)
; window1=cWndByWndSpecName("Paragon Registration    Current User: DOE, JOHN E.         IT GENERAL MEDICAL CENTER IT","registration",3,0,0,2000)
; window1=DllHwnd('Paragon Registration    Current User: DOE, JOHN E.         IT GENERAL MEDICAL CENTER IT')
window2=cWndByID(window1,2000)
; or window2=cWndByClass(window1,`MDIClient`)
; or window2=cWndBySeq(window1,3)
window3=cWndByID(window2,202)
; or window3=cWndByName(window2,`Person Maintenance - New~`)
; or window3=cWndBySeq(window2,1)
ControlHandle=cWndByID(window3,1000)
; or ControlHandle=cWndBySeq(window3,1)
result=cWndInfo(ControlHandle,0)     ;Reads the title/text of a control
Message("Window Title/Text",result)     ;TODO - Remove Message.  Add code.


Each "iteration" is one level deeper in the flow I had described earlier.  It is on this last screen, "Person Maintenance - New" that I want to do the data entry.  But, as I mentioned, when I drag the cross-hairs to the data entry fields, the RoboScript dialog box doesn't give me any different options that would allow me to input data, select from a drop-down box, etc...

Admittedly, I'm a WinBatch newbie so this could very well be something dumb that I'm doing, but whatever the cause, I really appreciate your help.

Thanks!

Deana

As expected the last 'control' that you held the cross hairs on is class:pbdw125. This control type is not a type supported by the RoboScripter/Control Manager Extender. You will probably need to send keystrokes.


UNDEBUGGED:

Code (winbatch) Select
parenttitle = 'Paragon Registration'
childwin = 'Person and Visit Selection~'
ret = WinWaitChild( parenttitle, childwin, 30)
if ret == 0 then
   Pause("Notice","Unable to locate the window to send the keystrokes to ":childwin)
   Exit
endif
SendKeysChild( parenttitle, childwin, "sendkeystring goes here" )

parenttitle = 'Paragon Registration'
childwin = 'Person Maintenance - New~'
ret = WinWaitChild( parenttitle, childwin, 30)
if ret == 0 then
   Pause("Notice","Unable to locate the window to send the keystrokes to ":childwin)
   Exit
endif
SendKeysChild( parenttitle, childwin, "sendkeystring goes here" )
exit

Deana F.
Technical Support
Wilson WindowWare Inc.

KBaumGHS

Thank you for the rapid reply!  When you say I will probably have to send keystrokes what, exactly, does that mean?  Do I need to set focus somewhere?  What keystrokes would I need?  These might be silly questions, but I am definitely a newbie at this, although the overall process seems quite fun... in a computer nerd sort of way.  :)

....IFICantBYTE

I would see if there is an API for this software before using sendkeys ... if there is, and you can use it, it will be much more accurate and reliable than sending keystrokes.
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

Deana

Quote from: KBaumGHS on December 16, 2013, 03:07:27 PM
Thank you for the rapid reply!  When you say I will probably have to send keystrokes what, exactly, does that mean?  Do I need to set focus somewhere?  What keystrokes would I need?  These might be silly questions, but I am definitely a newbie at this, although the overall process seems quite fun... in a computer nerd sort of way.  :)

The SendKeysTo function accepts a window name and the keystrokes to send. It first activates the window then sends the keystrokes. See the code sample I previously posted.

There are a number of different ways to communicate with third party apps. The method you chose depends on the application you are trying to automate. In your case the RoboScripter/Control Manager extender method may not be applicable. For more about the different ways WinBatch can communicate with third party applications please read: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/How~To+Communicate~with~a~Third-Party~Applications~Windows-dialogs.txt
Deana F.
Technical Support
Wilson WindowWare Inc.