Jump to content



Photo

Interacting with checkboxes on another application


  • Please log in to reply
12 replies to this topic

#1 raoul

raoul

    Seeker

  • Active Members
  • 6 posts

Posted 25 December 2011 - 08:20 AM

I have been working with AutoItX for a while now. I needed to write a program in VB.NET that would interact with multiple other windows programs. So far, I have had no trouble working with the various controls - getting / setting text from textboxes, clicking buttons, moving sliders, etc. I thought I was about finished and the last things I have to do is be able to interact with checkboxes (and radiobuttons). I thought it would be fairly straightforward, but I haven't been able to figure it out, and searching around this forum hasn't solved it for me yet. I would appreciate any help that I can get. I figure this must be a standard thing to want to do, so I must be missing something.

What I thought I needed to do was a command like

Dim state As Integer

state = AutoIt.ControlTreeView(MainName, "", 1073, "IsChecked", "", "")


and then just evaluate state to see if it is a -1,0,1. This doesn't seem to do anything though. MainName is the title of the form and the checkbox handle is 1073. I am not sure about putting the extra1 and extra2 as "", "" - but it gives me a syntax error if I don't put something for the optional extras.

I must be missing something. I thought I should be able to toggle the state by using the following to click on it (just like a button), but it doesn't do anything either.

AutoIt.ControlClick(MainNameThermoTrak, "", 1073)


So, the last things I need to work out is how to check the state of checkboxes and radiobuttons in a different windows application, and how to check / uncheck them.



On a side question: From what I can tell, the AutoItX.dll doesn't have the fully library of controls in it. Is there a way to add them and gain the full functionality of the AutoIt library when using the DLL inside a vb.net program?





#2 raoul

raoul

    Seeker

  • Active Members
  • 6 posts

Posted 26 December 2011 - 09:58 PM

Any thoughts on this? I have been working very hard on this, but not able to come up with a solution yet.

I have been using some basic window API calls, that I assume AutoIt is doing in the background. For some reason, the ID of the checkbox seems to change. However, I have been able to call functions from the User32.lib like FindWindow and FindWindowEx and get the proper handle of the control. Then I am able to use Sendmessage(hWnd,BM_click,0,0) to click on the checkboxes and radiobuttons just fine. However, when I try to use sendmessage(hWnd,BM_GetCheck,0,0) to see if they are checked or not, it fails and always returns 0.

Searching around the net, this appears to be a common thing since they moved on to the latest versions of .NET. Now you are recommended to use Iaccessible to interact with these controls. However, I have not been successful in working out how to do it, so I am still hoping there is a way to do it in AutoIt and someone will show me how.

-R

#3 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 27 December 2011 - 12:52 AM

Look at ControlCommand() + IsChecked/Check/UnCheck in Autoit.
But I have no experience with AutoitX.

Edited by Zedna, 27 December 2011 - 12:52 AM.


#4 raoul

raoul

    Seeker

  • Active Members
  • 6 posts

Posted 27 December 2011 - 06:28 PM

Look at ControlCommand() + IsChecked/Check/UnCheck in Autoit.
But I have no experience with AutoitX.


Thanks Zedna for the response. I don't think the AutoitX part matters. I was thinking about moving the question out to the general help and questions forum, as if someone can show me an example of it working, then I will worry about the autoitX part.

Anyway, I tried your suggestion, and it still does the same thing. For whatever reason, the checked state of checkboxes and radiobuttons doesn't seem to be easily accessible anymore. I think it will work on older applications, but anything written in the last few years in .NET doesn't seem to work. As a test, i made a simple application which has nothing but a checkbox on it. I can see if the checkbox is visible or not, so I seem to be interacting with it ok. However, i cannot query if it is checked or not. If someone can give me a line of script that does this (even if not autoitX) I would very much appreciate it!!!

My sub that does NOT work trying ControlCommand

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim state As Integer = Nothing
Dim formname As String = "TestFormName"

AutoIt.WinActivate(formname)

state = AutoIt.ControlCommand(formname, "", 1115520, "IsChecked", "")

MessageBox.Show(CStr(state))
End Sub


#5 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 27 December 2011 - 08:03 PM

Autoit can interact only with standard Windows controls.
In your case you are probably dealing with non-standard ones.

#6 raoul

raoul

    Seeker

  • Active Members
  • 6 posts

Posted 27 December 2011 - 09:14 PM

Autoit can interact only with standard Windows controls.
In your case you are probably dealing with non-standard ones.


It is as standard as it can be. I made the test application myself and all I did was drag a standard checkbox on to the form. No frills...

#7 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,822 posts

Posted 27 December 2011 - 09:26 PM

Instead of hard coding the controlID number, you should probably be trying to access it with one of the alternate controlID methods as shown in the help file. Look under ControlCommand for ways of accessing the checkbox controlID.

How to ask questions the smart way!

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.

Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.

_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#8 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 27 December 2011 - 10:04 PM

It is as standard as it can be. I made the test application myself and all I did was drag a standard checkbox on to the form. No frills...


What ClassNameNN show Au3Info?

#9 raoul

raoul

    Seeker

  • Active Members
  • 6 posts

Posted 27 December 2011 - 10:57 PM

Thanks guys for trying to help me through this. It

Instead of hard coding the controlID number, you should probably be trying to access it with one of the alternate controlID methods as shown in the help file. Look under ControlCommand for ways of accessing the checkbox controlID.


I hardcoded it just for this example. I have tried to access it using ClassnameNN and even the hWnd, but it behaves the same. i am 100% certain that I am accessing it correctly using the controlID, because I can use the same ControlCommand using "IsVisible" and it works perfectly. That is, i made a button on the test application that makes it visible or not, and the ControlCommand gets it right every time.



What ClassNameNN show Au3Info?


Au3Info shows:

WindowsForms10.BUTTON.app.0.2bf8098_r20_ad14

#10 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 28 December 2011 - 12:11 AM

Au3Info shows:
WindowsForms10.BUTTON.app.0.2bf8098_r20_ad14


This is non-standard control. It can't be controled by standard Win32 API.
There are topics on this forum about WindowsForms (.NET) controls but I have no experience with it.
As far as I can remember Jon wanted to add some support to Autoit for it but it wasn't solved/finished?
Try to search ...

#11 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 9,692 posts

Posted 28 December 2011 - 12:46 AM

No, people like Manadar and myself were interested in adding .Net support.

#12 raoul

raoul

    Seeker

  • Active Members
  • 6 posts

Posted 28 December 2011 - 05:03 PM

This is non-standard control. It can't be controled by standard Win32 API.
There are topics on this forum about WindowsForms (.NET) controls but I have no experience with it.
As far as I can remember Jon wanted to add some support to Autoit for it but it wasn't solved/finished?
Try to search ...


Yes, it is definitely a .NET control. I made it myself as a test bed for checkbox controls using VS.2010 .NET.

So, AutoIt doesn't work completely with .NET controls. That is unfortunate as more-and-more applications are written in .NET, so this will become a major issue. I have searched the forums and found posts where people are running into the same problem, but I haven't found a solution yet. *sigh* I am not sure where to go next on this problem. I have even contemplated examining the pixels at the checkbox location to see if it is checked or not, but it doesn't seem very robust. There has to be a solution, but it might not be through AutoIt unfortunately.

#13 automateseeker

automateseeker

    Seeker

  • Active Members
  • 11 posts

Posted 12 April 2012 - 06:57 PM

I have the same problem as well and still searching for a solution. What I have experienced so far with ControlCommand() is following:

ControlCommand("Title","text", "IsChecked","") --> this always return 0 no matter the botton is check or not
ControlCommand("Title","text", "UnCheck","") --> this is also not working for my case

But...

ControlCommand("Title","text", "Check","") --> this look like is working, I can get unchecked box to get a check thus not sure if you have try this for your case.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users