Jump to content
Sign in to follow this  
Lococobra

.NET Framework Controls not Cooperating

Recommended Posts

Lococobra

I am writing some automation for an application (I have no control over the target application or how it is written). I know that the application is written using the .NET Framework.

I have had (for the most part) no trouble writing to the controls in the target app. I can.. for example.. check a checkbox, click a button, focus controls, change a control's background color, etc... but writing is only half the battle.

Almost every control thus far has resisted being read from. Examples:

  • ControlCommand "IsChecked" always returns 0.
  • ListViews will return the number of elements (rows), but will not return any text from their fields.
  • StatusBars will not return text
I've tried every method I've found to make this work, I've of course tried all of the standard control methods built in (ControlGetText, ControlCommand, ControlListView, etc..), and I've also tried using many of the alternative methods (_GUICtrlStatusBar_GetText, _GUICtrlButton_GetCheck, and a bunch of others I don't remember). Nothing works.

What you're probably thinking is:

  • You must be doing it wrong.
  • Note: AutoIt only works with standard Microsoft controls - some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment!
Well at least for #1: I've worked with AutoIt for more than two years. I have done this exact kind of automation with other applications and had no issues.

I fully expect the answer here to be "It is impossible", but I would love to be proven wrong. I must not be the only one! Has anyone figured out how to work with these damn .NET GUI controls?

Edited by Lococobra

Share this post


Link to post
Share on other sites
Lococobra

bump...

Share this post


Link to post
Share on other sites
Lococobra

Reckon you need to post some code of what you've tried.

Your post suggests you have tried everything, so its difficult to suggest anything.

Well the question is really.. Is there anything I am just obviously completely unaware of? I've done extensive searching through the forums as well looked for non-autoit solutions and I'm out of things to try. As you say, I do believe I've tried everything.

So yeah, any out of the box methods of automating windows controls?

Edited by Lococobra

Share this post


Link to post
Share on other sites
monoscout999

still no code... so still no help

Share this post


Link to post
Share on other sites
Lococobra

Okay... don't take my word for it then.

So for example, here are some of my attempts to evaluate the status of a checkbox.

Local $HWND = WinGetHandle("Testing123")
Local $CTRL = ControlGetHandle($HWND, "", "[NAME:chkSelectAll_8]")

WinActivate($HWND) ;Works
ControlCommand($HWND, "", $CTRL, "Check") ;Works but toggles the checkbox instead of setting it to checked ("UnCheck" has no effect at all)
Sleep(1000)

;The obvious way of doing it..
MsgBox(0, '', ControlCommand($HWND, "", $CTRL, "IsChecked", ""))

;No dice... lets try this instead?
MsgBox(0, '', _GUICtrlButton_GetCheck($CTRL))

;Maybe there's a bug in the _GUICtrlButton_GetCheck implementation?
Local Const $MY_BM_GETCHECK = 0xF0
Local $ret = DLLCall("user32.dll","int","SendMessage", _
            "hwnd",$CTRL, _
            "int",$BM_GETCHECK)

If @error Then
    MsgBox(0, '', 'error: '&@error)
Else
    MsgBox(0, '', $ret[0])
EndIf

All of the above return "0" if the checkbox is checked or unchecked.

Edited by Lococobra

Share this post


Link to post
Share on other sites
Lococobra

I dont know if this is how it works, but I know Autoit3 cannot access the .Net framework.

Yes, this would certainly seem to be the case, which is why I'm asking for other answers.

Sounds as though its acting more like a

Although I have no control over the application, I have talked to its developers a handful of times and I know with 100% certainty that it is written entirely using the .NET framework.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×