Drew, Your question got me thinking is there another way to solve this - ran across this article: http://blogs.msdn.com/b/oldnewthing/archive/2010/12/30/10110077.aspx
Which suggested WindowFromPoint may be able to solve your problem. I never
would have thought about using it for this purpose. I ran a test against a
simple application and it did differentiate between a enabled vs a disabled
button. So I think it may do the same thing for your visible vs not visible
ones.
Be careful though and try when the button is or isn't visible.
Very interested in knowing if this works or not!
Dim cgw As New CGetWindow
Dim lw As New CListWindows
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long,
ByVal yPoint As Long) As Long
Dim xX As Long
Dim yY As Long
'This you need to change to reflect your application
Sub testIsDisabled()
Connect "Customer", stWindows
Debug.Print isUsable("*Save*") ' Button has Save in its viewable text
End Sub
Function isUsable(sText As String) As Boolean
Dim pHwnd As Long
For Each h In lw.InProcess(hWnd)
If View(h) Like sText Then
cgw.GetWindowPosition h, xX, yY
pHwnd = WindowFromPoint(xX + 2, yY + 2)
If h <> pHwnd Then
Debug.print classname(pHwnd),window(pHwnd) 'may
be the overall form?
isUsable = True
Exit Function
End If
End If
Next h
End Function
Thom C. Blackwell, VP Technical Services
Boston Software Systems, Inc.
Phone: 866.653.5105 x807
Mobile: 508.423.8463
Fax: 508.319.3015
www.bostonsoftwaresystems.com<http://www.bostonsoftwaresystems.com/>
Healthcare Automation - Revolutionizing How You Work.
The information contained in this message may be confidential and legally
protected under applicable law. The message is intended solely for the
addressee(s). If you are not the intended recipient, you are hereby notified
that any use, forwarding, dissemination, or reproduction of this message is
strictly prohibited and may be unlawful. If you are not the intended recipient,
please contact the sender by return e-mail and destroy all copies of the
original message.
From: [email protected] [mailto:[email protected]]
Sent: Tuesday, July 30, 2013 11:09 AM
To: Talk
Subject: RE:[talkbws] InProcess Loop Click
Thank you. I've tried both methods and still no luck. The application that I
am using is PenRad. The script goes into one routine, it runs through several
patients and then goes back to the main Administration menu. I have been
trying to find the best way for the script to recognize that it is back at the
Administration screen before clicking another button. The way the application
is built, it appears that buttons are always "visible" and even clickable even
though I can't see the button. So when I checked to see if the button is
visible, meaning the first routine finished, is not helping. It still clicks
the second button while still in the first routine. I tried using "If
cgw.IsStyle(styVISIBLE,getParent( h))" and added a few additional getParent's,
but this did not help either. The smart suggestion always showed the button as
"visible" also. Are there any other options that I could try besides OCR?
Thanks again for your help!
Thanks,
Drew Glaser
Data Programmer Analyst
CareTech Solutions /
Blanchard Valley Health System
Office: (419) 429-7614
[cid:[email protected]]<http://www.caretech.com/>
Helping extraordinary people do extraordinary things
Best in KLAS
Extensive IT Outsourcing
2008, 2009 & 2010
Top 20 Best in KLAS Awards
www.KLASresearch.com<http://www.klasresearch.com/>
[cid:[email protected]]
From: [email protected]<mailto:[email protected]> [mailto:[email protected]]
Sent: Tuesday, July 30, 2013 9:32 AM
To: [email protected]<mailto:[email protected]>
Subject: RE:[talkbws] InProcess Loop Click
There are two methods for detecting visibility of a particular control:
cGetWindow.IsStyle()
and
Smart.StateText
Here is a bare bones example of cGetWindow.IsStyle
Dim cgw As New CGetWindow
Dim lw As New CListWindows
Sub ClickButton(sText As String)
For Each h In lw.InProcess(hWnd)
If View(h) Like "sText" Then
If cgw.IsStyle(styVISIBLE, h) Then
Click h, False, False
Exit Sub
End If
End If
Next h
End Sub
Important note: the visibility of something may be controlled by a parent
control, or the parent's parent, or parent's parent's parent. Here you'd need
to explore your application to see if it's doing such a thing:
If cgw.IsStyle(styVISIBLE,getParent( h))
Smart can also be useful to detect visibility
Adding the below to the loop as above, you could see what the StateText is.
Smart.Create h, 2, 2
Debug.Print Smart.StateText
Similar to cGetWindow.IsStyle how this returns is based on the behavior of your
application.
Thom C. Blackwell, VP Technical Services
Boston Software Systems, Inc.
Phone: 866.653.5105 x807
Mobile: 508.423.8463
Fax: 508.319.3015
www.bostonsoftwaresystems.com<http://www.bostonsoftwaresystems.com/>
Healthcare Automation - Revolutionizing How You Work.
The information contained in this message may be confidential and legally
protected under applicable law. The message is intended solely for the
addressee(s). If you are not the intended recipient, you are hereby notified
that any use, forwarding, dissemination, or reproduction of this message is
strictly prohibited and may be unlawful. If you are not the intended recipient,
please contact the sender by return e-mail and destroy all copies of the
original message.
From: [email protected]<mailto:[email protected]> [mailto:[email protected]]
Sent: Tuesday, July 30, 2013 9:18 AM
To: Talk
Subject: RE:[talkbws] InProcess Loop Click
I haven't tested this, but in other programs I've done, this seems to be the
logic:
ClickFunction ("OK")
Function ClickFunction(strClick)
Dim L As New CListWindows
For Each h In L.InProcess(R.hWnd)
If h.visible = true then
If View(h) = strClick Then
Click (h)
End if
End If
Next h
End Function
From: [email protected]<mailto:[email protected]> [mailto:[email protected]]
Sent: Tuesday, July 30, 2013 9:13 AM
To: [email protected]<mailto:[email protected]>
Subject: [talkbws] InProcess Loop Click
Below is what I use to click a button in a windows application. It cycles
through all of the buttons in the app instead of just the current visible ones.
Does anyone know if there is a way to get it to only look to the visible
buttons?
ClickFunction ("OK")
Function ClickFunction(strClick)
Dim L As New CListWindows
For Each h In L.InProcess(R.hWnd)
If View(h) = strClick Then
Click (h)
End If
Next h
End Function
Thanks,
Drew Glaser
Data Programmer Analyst
CareTech Solutions /
Blanchard Valley Health System
Office: (419) 429-7614
[cid:[email protected]]<http://www.caretech.com/>
Helping extraordinary people do extraordinary things
Best in KLAS
Extensive IT Outsourcing
2008, 2009 & 2010
Top 20 Best in KLAS Awards
www.KLASresearch.com<http://www.klasresearch.com/>
[cid:[email protected]]
--- To post a message to this list, send mail to:
[email protected]<mailto:[email protected]> You are currently subscribed as:
[email protected]<mailto:[email protected]> Unsubscribe in the
customer center on our website:
http://www.bostonsoftwaresystems.com/Customers/ListServe.aspx
--- To post a message to this list, send mail to:
[email protected]<mailto:[email protected]> You are currently subscribed as:
[email protected]<mailto:[email protected]> Unsubscribe in
the customer center on our website:
http://www.bostonsoftwaresystems.com/Customers/ListServe.aspx
--- To post a message to this list, send mail to:
[email protected]<mailto:[email protected]> You are currently subscribed as:
[email protected]<mailto:[email protected]> Unsubscribe in
the customer center on our website:
http://www.bostonsoftwaresystems.com/Customers/ListServe.aspx
--- To post a message to this list, send mail to:
[email protected]<mailto:[email protected]> You are currently subscribed as:
[email protected]<mailto:[email protected]> Unsubscribe in
the customer center on our website:
http://www.bostonsoftwaresystems.com/Customers/ListServe.aspx
--- To post a message to this list, send mail to: [email protected] You are
currently subscribed as: [email protected] Unsubscribe in the
customer center on our website:
http://www.bostonsoftwaresystems.com/Customers/ListServe.aspx<<inline: image001.gif>>
<<inline: image002.gif>>
