Unable to detect Checkbox control using Windows Spy

Get help with using AutoHotkey and its commands and hotkeys
curiouscoder
Posts: 5
Joined: 06 Nov 2016, 03:13

Unable to detect Checkbox control using Windows Spy

06 Nov 2016, 05:53

Hi,

I have this task of automating application setups on windows machines. I came across AutoHotkey and have found it very useful.

There is a situation where I am stuck in. I need to click on a checkbox on the installation wizard but Windows Spy cannot detect the checkbox.
I get the following details when I hover my mouse over the checkbox:

ClassNN: SWT_Window029
Text:
Color: 00004C (Red=00 Green=00 Blue=4C)
x: 37 y: 126 w: 1303 h: 325
Client: x: 33 y: 103 w: 1299 h: 321


I tried doing ControlClick using checkbox text and ClassNN name but nothing happens.

I then tried the following options:
- I used ImageSearch to get the checkbox coordinates and then clicked the checkbox using MouseClick. However for this my Window needs to be active and also ImageSearch does not work for me sometime :crazy: .
- I tries using PixelSearch but this did not help much. Probably because the ColorID is not unique.

I would like to understand what are the best alternatives available in this scenario if I need to click on the checkbox not detected by Window Spy.
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: Unable to detect Checkbox control using Windows Spy

06 Nov 2016, 07:07

Hi.

I would just try to use a combination of WinWait and WinActivate, to make sure that the window is active before reading pixel values and do mouseclick.
curiouscoder
Posts: 5
Joined: 06 Nov 2016, 03:13

Re: Unable to detect Checkbox control using Windows Spy

06 Nov 2016, 13:27

Thx for the response Almost_there. I am able to activate the setup wizard screen successfully. But I believe for PixelSearch to work accurately, the ColorID should be unique which is not the case here as checkbox has a very generic color.
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: Unable to detect Checkbox control using Windows Spy

06 Nov 2016, 18:24

Does the checkbox stay the same position every time or does it move along with other elements or window size?

If the checkbox position doesn't move, you could find a pixel position where the color changes when the checkbox status change. Use that.
curiouscoder
Posts: 5
Joined: 06 Nov 2016, 03:13

Re: Unable to detect Checkbox control using Windows Spy

07 Nov 2016, 07:26

@Almost_there, I believe PixelSearch can be done only if the ColorID is unique but that is not the case here. Also the checkbox position can move on the window. I need to click on the checkbox. Right now I am using ImageSearch but it is failing on few machines.
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: Unable to detect Checkbox control using Windows Spy

07 Nov 2016, 12:56

I hear you say that, but without a screenshot of your application I can only guess.
curiouscoder
Posts: 5
Joined: 06 Nov 2016, 03:13

Re: Unable to detect Checkbox control using Windows Spy

08 Mar 2017, 03:04

This task had gone on hold so I did not follow up for quite some time. I am updating now as it has come up again for completion. I have provided screenshots.

I need to automate the application setup wizard so that users can directly run the automation and the installation completes itself.

I need to click on a checkbox on the installation wizard but Windows Spy cannot detect the checkbox. I get the following details when I hover my mouse over the checkbox:

ClassNN: SWT_Window029
Text:
Color: 00004C (Red=00 Green=00 Blue=4C)
x: 37 y: 126 w: 1303 h: 325
Client: x: 33 y: 103 w: 1299 h: 321


I have tried the following options:
- I tried doing ControlClick using checkbox text and ClassNN name but nothing happens.
- I tries using PixelSearch but this did not help much. Probably because the ColorID is not unique.
- I cannot use mouseclick directly because control position is not certain. See the 2 screenshots below.
- I tried using ImageSearch using read only images but this mechanism is not very reliable as on some machines it is failing :? .This is because the image is changing slightly on different machines.

Please suggest the best alternative.
RSAClickIssue_Screen1.JPG
Click Issue Screen 2
RSAClickIssue_Screen1.JPG (170.73 KiB) Viewed 1252 times
RSAClickIssue_Screen2.JPG
Click Issue Screen 1
RSAClickIssue_Screen2.JPG (201.53 KiB) Viewed 1252 times
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: Unable to detect Checkbox control using Windows Spy

08 Mar 2017, 17:38

So which of the check boxes are you supposed to check? All of them or just some?
curiouscoder
Posts: 5
Joined: 06 Nov 2016, 03:13

Re: Unable to detect Checkbox control using Windows Spy

08 Mar 2017, 23:39

I would need to check any one of them based on user requirement but for now I am focusing on automating to check the checkbox in first screenshot (IBM Rational Software Architect - Version 9.1.2). I attached the second screenshot to show that the checkbox position is changing when RSA setup has more options to install. These options are added from configuration before starting the setup.
User avatar
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Unable to detect Checkbox control using Windows Spy

09 Mar 2017, 03:03

Acc might work. Use AccViewer to probe the program, and functions from Acc.ahk to write the code.

Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

Code: Select all

q:: ;Notepad find dialog, tick 'Match case' button
ControlGet, hCtl, Hwnd,, Button2, A
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hCtl)
MsgBox, % Format("0x{:x}", oAcc.accState)
if !(oAcc.accState & 0x10) ;comment out this line and the state is toggled
	oAcc.accDoDefaultAction(0)
oAcc := ""
return
Btw on the Button control, the state appeared to include 0x10, only when the button was ticked. But I could not find a reference to this value.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], TBDKHA and 167 guests