Sign in to follow this  
Followers 0
Myicq

Can PixelSearch use "approximate" color (for difficult checkboxes)

10 posts in this topic

Following up on the topic from yesterday with >difficult checkboxes appearing as a listbox (spy++ did not give extra information), I have thought of an idea:

  • The checkbox will always in same area. I only need to check 3 different
  • The color in a certain area of the checkbox will be different with a checkmark set

Now, while this should work, the actual color seems to depend on the skin / OS version used in Windows. Different from XP / Win7 / Vista and various themes.

So, my question: is it possible to calculate "color read a pixel (x,y) is between  values a  and  b" (yes/no). Meaning that various shades of grey will be different from green/blue checkmarks.

Or alternative: count unique colors used

This is perhaps a pretty unorthodox way of checking for checkbox status. Is the idea too far-fetched ?

I will have a look at PixelSearch UDFs around.  Never worked with it before, so happy to get ideas for this. Assume for example's case that checkbox is at 100,200 relative to child window. Size of checkbox 10x10 px.

- myicq


I am just a hobby programmer, and nothing great to publish right now.

Share this post


Link to post
Share on other sites



Myicq,

That idea is not stupid at all - I have used it on occasion to find out if recalcitrant checkboxes are checked or not. ;)

However, I found using PixelCheckSum to be a better way to do it - always assuming you have some other checkboxes that you know are checked or not to compare with the one in which you are interested. That way you need not worry about differences between machines/themes as you are always looking at the same colors. So, do you have other checkboxes in this GUI from which you can get a template? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

help file shade-variation variable: PixelSearch ( left, top, right, bottom, color [, shade-variation [, step [, hwnd]]] )

shade-variation [optional] A number between 0 and 255 to indicate the allowed number of shades of variation of the red, green, and blue components of the colour. Default is 0 (exact match).

Maybe it's possible to get controls within the listbox?  a stretch, but try this:

consolewrite(WinGetClassList($hListView) & @crlf)

I know some controls within a window can have child controls...but generally, those are the classes starting with #

edit:  another long shot, _GUICtrlListBox_GetSelItemsText

Seems the selection and checked can be the same state

Looks like someone needs to make a UDF for CheckedListBox

http://www.functionx.com/vb/controls/checkedlistbox.htm

The CheckedListBox class is derived from the ListBox class. This means that the checked list box possesses all the public (and protected) characteristics of the list box and its parent the ListControl class. This control also uses the HorizontalScrollbar and the HorizontalExtent properties that behave exactly as we reviewed for the list box. It also uses the SelectionMode property with the same behavior as that of the list box.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

@Melba: this is an excellent idea, and actually I do have a checkbox of the 3 (at least) that is never checked. So I can just compare to that one and be done.

@jdelaney: look at the link to my previous post. I posted a picture there. Do not think it's a list per se, as I get no scroll. In any case, it's just 2 boxes that can vary so I think I will handle it.

But yes: there should be some way of using checkmarks with a listbox type.


I am just a hobby programmer, and nothing great to publish right now.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

>>>> Control <<<< Class: ListBox
Instance: 1 ClassnameNN:ListBox1
Name:
Advanced (Class): [CLASS:ListBox; INSTANCE:1]
ID: 1008
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

From what research I've done on this, the listboxes with checkboxes are using an image list with 2 different images that are toggled between the 2, there's no actual checkbox control from what I can find. Not sure how you'd determine it other than trying to find out the imagelist item that's currently being used. No idea how to do that though.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

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 editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

There are three states for the checkboxes, on, off indeterminate...and they do look a little diff in the windows environments...the answer is definitely in (google it) CheckedListBox:

http://msdn.microsoft.com/en-us/library/system.windows.forms.checkedlistbox.aspx

But, I have no idea what to do with it.

Specifically, loop through the full count on this list, against:

http://msdn.microsoft.com/en-us/library/system.windows.forms.checkedlistbox.getitemchecked.aspx

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Aha, so it's a .Net control, funny how that never showed up in the searches I did. Must have used the wrong search terms. :)


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

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 editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Indeed my little list does look exactly like CheckedlistBox

(as shown here: http://www.dotnetperls.com/checkedlistbox )

Hope someone with deeper insight than me is able to get contstants for this type of control.


I am just a hobby programmer, and nothing great to publish right now.

Share this post


Link to post
Share on other sites

I just tried suggestion from Melba23. The suggested works beautifully :

; example to evaluate checkboxes that can't be read


AutoItSetOption("PixelCoordMode", 0)  ; relative to WINDOW
; work on Properties window..
$WinTitle = "Properties"
WinWait($WinTitle)
WinActivate($WinTitle)

; my values, measured before.
$chkOff = "79385235"
$chkOn = "1984572738"

$bold_status = PixelChecksum(277, 94, 287, 104)
$italic_status = PixelChecksum(277, 108, 287, 118)

if $bold_status = $chkOn then 
    consoleWrite ("Bold is ON & @cr)
endif

only problem with this method is that the status can't be read directly from checksum, so it's necessary to test for values that are known in advance. And, of course, I can't directly manipulate checkboxes.


I am just a hobby programmer, and nothing great to publish right now.

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  
Followers 0