After some tests I know more of the return values of PixelSearch and ControlGetPos.
- Test1:
I made a test script that shows the position and the size of a control using ControlGetPos with a titlebar - I added a button
- I put the info of the control ControlGetPos found, in a message box
Test2: same as Test1, now without a titlebar.
Results:
The info the function returned, matches with the size and positions I gave to the control.
Test3:
I made a test script that shows where it matches a certain color using PixelSearch - I added an empty label
- gave the label a white background color
- I put the info PixelSearch returned in a message box
- with a title bar
Test4:
Same as Test3, now without a titlebar
Results:
PixelSearch returned different positions of the label/white color
Before I started testing I was disappointed that in my original script, the PixelSearch function didn't work well.
Because it was the first time I started using the function.
For your information, here's the PixelSearch test script.
#include <GUIConstants.au3> AutoItSetOption("TrayIconHide", 1) AutoItSetOption("PixelCoordMode", 0) AutoItSetOption("ExpandVarStrings", 1) AutoItSetOption("WinTitleMatchMode", 4) ;Initialize variables Global $style1 Global $IniFile Global $GUIWidth Global $GUIHeight $GUIWidth = 250 $GUIHeight = 250 $IniFile = @ScriptDir & "\" & StringTrimRight(@ScriptName, 3) & "ini" ;Only a close button: ;$style1 = BitOR($WS_POPUP, $WS_CAPTION, $WS_SYSMENU) ;GUICreate("New GUI", $GUIWidth, $GUIHeight, -1, -1, $style1) ;GUI with title bar $Window = GUICreate("New GUI", $GUIWidth, $GUIHeight) ;GUI without titlebar ;$Window = GUICreate("New GUI", $GUIWidth, $GUIHeight, -1, -1, $WS_POPUP) If @error Then MsgBox(16, "AutoIt Error", "Window could not be created!") ConsoleWrite("---------- AutoIt Error ----------" & @LF) ConsoleWrite('"Window could not be created!"') Exit 1 EndIf $Quit_btn = GUICtrlCreateButton("Test", 0, 0, 70, 20) $Test_label = GUICtrlCreateLabel("", 100, 100, 100, 10) GUICtrlSetBKColor(-1, 0xffffff) GUISetState() Global $Pressed = 0 While 1 $Msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Exit Case $msg = $Quit_btn If $Pressed = 0 Then $Pressed = 1 GUICtrlSetData($Quit_btn, "Quit") TestThis() ElseIf $Pressed = 1 Then GUIDelete() Exit EndIf EndSelect WEnd Func TestThis() $Col = PixelSearch(25, 25, 250, 150, 0xffffff) If IsArray($Col) Then $x = $Col[0] $y = $Col[1] MsgBox(0, "Test", "Matched the white color at:@CRLF@x: $x$ y: $y$") Else MsgBox(0, "Test", "White color is not found!") EndIf EndFunc





