Hi everybody
For some time I have been working on an UI testing application. The application under test was developed in C#, and my application has been developed in C# as well. I do not have a source code of the application under test, so I use Win API messages and methods. I faced the following problem:
The application under test contains a check box:
Class: WindowsForms10.BUTTON
Text: "Some text"
Style: "Some styles"
After I get a handle to the check box ( I am sure I have the correct handle ) I use SendMessage to retrieve the check box state: -
-
-
private const int BM_GETSTATE = 0x00F2;
-
private const int BM_GETCHECK = 0x00F0;
-
private const int BST_UNCHECKED = 0x0000;
-
private const int BST_CHECKED = 0x0001;
-
-
int result;
-
-
result = SendMessage(correctHandle, BM_GETSTATE, 0, 0);
-
-
or
-
-
result = SendMessage(correctHandle, BM_GETCHECK, 0, 0);
-
-
My problem is that both SendMessage methods from above always return 0, even if a check box is checked.
Can anybody tell me what is wrong with the code above?
Thanks in advance.
22 13842
Hi tbarto,
Me too finding the same problem..if you got its solution, please post it here...i'll be very thankful if you give some time for that.
Hi everybody
For some time I have been working on an UI testing application. The application under test was developed in C#, and my application has been developed in C# as well. I do not have a source code of the application under test, so I use Win API messages and methods. I faced the following problem:
The application under test contains a check box:
Class: WindowsForms10.BUTTON
Text: "Some text"
Style: "Some styles"
After I get a handle to the check box ( I am sure I have the correct handle ) I use SendMessage to retrieve the check box state: -
-
-
private const int BM_GETSTATE = 0x00F2;
-
private const int BM_GETCHECK = 0x00F0;
-
private const int BST_UNCHECKED = 0x0000;
-
private const int BST_CHECKED = 0x0001;
-
-
int result;
-
-
result = SendMessage(correctHandle, BM_GETSTATE, 0, 0);
-
-
or
-
-
result = SendMessage(correctHandle, BM_GETCHECK, 0, 0);
-
-
My problem is that both SendMessage methods from above always return 0, even if a check box is checked.
Can anybody tell me what is wrong with the code above?
Thanks in advance.
Hi tbarto,
Me too finding the same problem..if you got its solution, please post it here...i'll be very thankful if you give some time for that.
Hi amitjul
As far as now I haven't found the solution. I've been working on some other issues. If I am able to get the solution, I will post it here.
Regards
SammyB 807
Recognized Expert Contributor
Hi tbarto,
Me too finding the same problem..if you got its solution, please post it here...i'll be very thankful if you give some time for that.
Googling for SendMessage, I found out the the Net checkbox will always return 0 because it has an extended style of '0000000B'. He later posted that he solved the problem with AccessibleObjectFromWindow but that it was difficult because of poor documentation. He did not post a solution :mad:
AccessibleObjectFromWindow documentation is http://msdn2.microsoft.com/en-us/library/ms696137.aspx
Finally, googling AccessibleObjectFromWindow "C#" shows some working code, but very ugly. If this helps you get a solution, please post it here. Thanks! --Sam
Gentleman
I have found how to get access to an UI component with AccessibleOblectFromWindow, however it still does not work for me: -
-
private const int OBJID_WINDOW = 0;
-
-
[DllImport("oleacc.dll", PreserveSig = false)]
-
[return: MarshalAs(UnmanagedType.Interface)]
-
public static extern object AccessibleObjectFromWindow(IntPtr hwnd, uint dwId, ref Guid riid);
-
-
Guid uid = new Guid("618736e0-3c3d-11cf-810c-00aa00389b71");
-
-
IAccessible accObj = (IAccessible)AccessibleObjectFromWindow(hwnd, OBJID_WINDOW,
-
ref uid);
-
-
object o = accObj.get_accValue(0); //always 0
-
-
object o1 = accObj.get_accName(0); // works fine
-
-
About the code above: the get_accName works fine for me, it returns a text that the checxbox contains. Unfortunately, get_accValue always returns 0, even if the checkbox is checked. Perhaps any of You can see that there is something wrong?
SammyB 807
Recognized Expert Contributor
Gentleman
I have found how to get access to an UI component with AccessibleOblectFromWindow, however it still does not work for me: -
-
private const int OBJID_WINDOW = 0;
-
-
[DllImport("oleacc.dll", PreserveSig = false)]
-
[return: MarshalAs(UnmanagedType.Interface)]
-
public static extern object AccessibleObjectFromWindow(IntPtr hwnd, uint dwId, ref Guid riid);
-
-
Guid uid = new Guid("618736e0-3c3d-11cf-810c-00aa00389b71");
-
-
IAccessible accObj = (IAccessible)AccessibleObjectFromWindow(hwnd, OBJID_WINDOW,
-
ref uid);
-
-
object o = accObj.get_accValue(0); //always 0
-
-
object o1 = accObj.get_accName(0); // works fine
-
-
About the code above: the get_accName works fine for me, it returns a text that the checxbox contains. Unfortunately, get_accValue always returns 0, even if the checkbox is checked. Perhaps any of You can see that there is something wrong?
So each control has a GUID? How do you figure out what it is?
So each control has a GUID? How do you figure out what it is?
Hi
This is what I've been trying to figure out. I have found that: - Guid g = new Guid("618736e0-3c3d-11cf-810c-00aa00389b71");
when googling, but I do not exactly understand the "618736e0-3c3d-11cf-810c-00aa00389b71" identifier. I have tried to change that identifier and run the code, but it caused an exception. Since I am not experienced in working with "Guid" I did not find the answer for Your question so far.
Hi Guys,
That Guid is the constant which you can't change (i dont know the reason :) ). and AccessibleObjectFromWindow is working with preety weird way. i tried to decode it but i failed. ne way, i just found a good solution.
IAccessible accObj = (IAccessible)AccessibleObjectFromWindow(hwnd, OBJID_WINDOW,
ref uid);
In above code, instead of passing OBJID_WINDOW , try with OBJID_CLIENT
accObj.get_accState(0) will return you some integer value like as below:
public const long UNCHECKED = 1048576;
public const long CHECKED = 1048592;
public const long UNCHECKED_FOCUSED = 1048580; // if control is focused
public const long CHECKED_FOCUSED = 1048596; // if control is focused
so based on that you can easily distiguish that which one is checked (checkbox/radionbutton). Its weird but deadlines are there so.... :)
Thanks for the info You've provided. I will try work on that, unfortunately next week, because tomorrow my vacation days start :-)
Thanks one more time for Your help
SammyB 807
Recognized Expert Contributor
Hi Guys,
That Guid is the constant which you can't change (i dont know the reason :) ). and AccessibleObjectFromWindow is working with preety weird way. i tried to decode it but i failed. ne way, i just found a good solution.
IAccessible accObj = (IAccessible)AccessibleObjectFromWindow(hwnd, OBJID_WINDOW,
ref uid);
In above code, instead of passing OBJID_WINDOW , try with OBJID_CLIENT
accObj.get_accState(0) will return you some integer value like as below:
public const long UNCHECKED = 1048576;
public const long CHECKED = 1048592;
public const long UNCHECKED_FOCUSED = 1048580; // if control is focused
public const long CHECKED_FOCUSED = 1048596; // if control is focused
so based on that you can easily distiguish that which one is checked (checkbox/radionbutton). Its weird but deadlines are there so.... :)
So, it all came out guid and you get the t-shirt.! :D
Plater 7,872
Recognized Expert Expert
Are you trying to capture the checked state of a checkbox in another application that is not your own? Sneaky sneaky.
I am trying to get the state of checkbox/radiobutton/button from a C# application to C# application. so both are different application and both are mine. :)
Where is the T-shirt ?? :)
Are you trying to capture the checked state of a checkbox in another application that is not your own? Sneaky sneaky.
Hi Guys, does anyone knows how to fire any keys. I mean if i want to press ESC key to unload one particular dialog/form How to send message using API in C# ??
I am trying to get the state of checkbox/radiobutton/button from a C# application to C# application. so both are different application and both are mine. :)
Where is the T-shirt ?? :)
No one knows ???? :(
Hi Guys, does anyone knows how to fire any keys. I mean if i want to press ESC key to unload one particular dialog/form How to send message using API in C# ??
No one knows ???? :(
Hi Amitjul
Here is probably a solution You've been looking for. You may use:
System.Windows.Forms.SendKeys.SendWait(keys);
method in the follwing way: -
-
-
[DllImport("user32.dll")]
-
[return: MarshalAs(UnmanagedType.Bool)]
-
private static extern bool SetForegroundWindow(IntPtr hWnd);
-
-
-
IntPtr _handle; //handle to the destination control
-
-
public void SendKeys(string keys, int delay) {
-
-
-
if(!(SetForegroundWindow(_handle)))
-
throw new ExternalException("SetForegroundWindow failed");
-
-
System.Windows.Forms.SendKeys.SendWait(keys);
-
Thread.Sleep(delay);
-
}
-
-
More info about the keys that can be sent to an active control and about SendKeys.SendWait(keys) method You will find here: http://msdn2.microsoft.com/en-us/lib....sendkeys.aspx
Hi Guys,
That Guid is the constant which you can't change (i dont know the reason :) ). and AccessibleObjectFromWindow is working with preety weird way. i tried to decode it but i failed. ne way, i just found a good solution.
IAccessible accObj = (IAccessible)AccessibleObjectFromWindow(hwnd, OBJID_WINDOW,
ref uid);
In above code, instead of passing OBJID_WINDOW , try with OBJID_CLIENT
accObj.get_accState(0) will return you some integer value like as below:
public const long UNCHECKED = 1048576;
public const long CHECKED = 1048592;
public const long UNCHECKED_FOCUSED = 1048580; // if control is focused
public const long CHECKED_FOCUSED = 1048596; // if control is focused
so based on that you can easily distiguish that which one is checked (checkbox/radionbutton). Its weird but deadlines are there so.... :)
Hi
When running the code i get 0 when a checkbox is unchecked and 16 when it is checked. The values are not exactly the same as in Your code, however I am able to determine if a checkbox is checked or not.
Thanks a lot!!!
Hi
When running the code i get 0 when a checkbox is unchecked and 16 when it is checked. The values are not exactly the same as in Your code, however I am able to determine if a checkbox is checked or not.
Thanks a lot!!!
Sorry,
My fault. Amitjul - everything works exactly as in Your code.
Thanks
I was just wondering. Perhaps any of You Guys knows a way to get access to the PropertyGrid component? The problem is that I am unable to find an info about that. E.g: http://msdn.microsoft.com/library/de...divcontrol.asp
Under the link above there is an info about many UI components, unfortunately nothing about PropertyGrid :-(
I have found some differences in types on object returend by AccessibleObjectFromWindow. What I mean is that when working on Win XP, the type of the object is System._ComObject , but as I tried on Win 2000 the type was System.Runtime.Remoting.Proxies._TransparentProxy . Obviously, I was unable to cast that type to IAccessible, which caused an exception. Does anybody have any idea about those differences?
Thanks
Hello guys,
I'm working in .net C# to get the URL from IE and Firefox. The IE part was over and I'm stuck up at firefox.
I can't drill down to its address bar(combobox) to get its value. So can anybody help me this problem.
I've gone through your above discussion but not getting what I want.
Ive used accExplorer 2.0 to see the hierarchy of the firefox, and I can see the address bar there but problem is how to access it.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Rich |
last post by:
I have a form with 2 check boxes. One of the check boxes is used to
specify that the user is a "primary contact." When I check the
primary contact box I want a second box for "standard contact"...
|
by: vncntj |
last post by:
i want to enable one listbox and disable the other depending on if i
check winter_gala (checkbox)
here is my code.
<script type="text/javascript">
function check()
{
if...
|
by: Jim in Arizona |
last post by:
I'm having dificulty figuring out how to process multiple check boxes on a
web form.
Let's say I have three check boxes:
cbox1
cbox2
cbox3
The only way I can think of to code the...
|
by: Jim in Arizona |
last post by:
I'm having dificulty figuring out how to process multiple check boxes on a
web form.
Let's say I have three check boxes:
cbox1
cbox2
cbox3
The only way I can think of to code the...
|
by: technocrat |
last post by:
I am trying to laod 2 tables and set integrtiy on them, but the second
tables fails ( both are related and SET INTEGRITY ion first table
succeeds) saying constraint violation....is there a way to...
|
by: starke1120 |
last post by:
Im creating a check in – check out database for RF guns. I have a
table that contains models.
ID (primary key)
Model
A table that contains Gun Details
ID (primary key)
Model_id...
|
by: ak |
last post by:
Recently at an interview i was asked the following question :
Assuming the function lookupName is defined, what's wrong with this
code (hint: 2 bugs)?
const char *getName(const char *c) {...
|
by: Ryanfromscotland |
last post by:
Hey there everyone, this is my first post so be nice :-) I have wrote quite a bit so the actual question is written out at the end if you want to skip on and see if you can answer it without the rest...
|
by: Dennis |
last post by:
I am wanting to set the Find window to not have the 'Search Fields As
Formatted' check box checked. I un-check it but when I close and go
back in it is checked again. Is there a way to make it...
|
by: ghjk |
last post by:
my php page has 7 check boxes. I stored checked values to database and retrive as binary values. This is the result array
Array ( => 0 => 1 => 0 => 1 => 0 => 0 => 1 )
1 means checked....
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |