Sign in to follow this  
Followers 0
lemondoo

AutoIt Magnifier Tool from Window Info is Broken!

35 posts in this topic

I was trying to create a program that would use PixelSearch correctly so that it would click on the specified color that I selected.

After trying for hours to make it work and thinking Pixelsearch was the problem, I decided to look at the magnifier tool on Window Info - to find that the MAGNIFIER doesn't even magnify the right pixels!!!! Here is a screenshot of what I am talking about - notice how it magnifies on a completely different color (different part of the window, than where the mouse is pointed at!) 

This is stupid frustrating - I have uninstalled and reinstalled many different versions of this program to no avail - as it always points to an offset location on the screen!

I believe the offset is northwest of where I actually point it at (after testing for awhile)

 

I have also reinstalled and installed both x64 and x86 bit settings on this PC for different versions. None of which solve the problem.

I am running Windows 10 x64 bit on a laptop with very good CPU and GPU. I don't believe my computer is the issue here. Please help!

Share this post


Link to post
Share on other sites



here are screenshots

urgh.png

urgh2.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The magnifier window does NOT show where the image is coming from, the image is taken from where the mouse pointer tip is and the magnifier is offset down and to the right from there. Your screen shots don't show the mouse pointer so there's no way of telling where you're looking at. Also, just use the color from the summary screen, it's whatever color is under the tip of the mouse pointer at that time.

Edited by BrewManNH

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

There is no question that PixelSearch, along with similar functions, are not the most reliable. My first question would be why are you trying to build an application around that rather than the much more reliable methods of interacting with Windows? What is preventing you from using Control* methods or WinAPI functions, which would doubtlessly save you headaches down the road?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

What are Control* methods? Can it find certain RGB tones and click on them? 

 

Also to give a better picture of what i mean

betteridea.jpg

Share this post


Link to post
Share on other sites

Also the question in part is not PixelSearch, but actually the magnifier tool itself not being able to work! I looked up tutorials online and they all had a correct looking magnifier tool that magnified where their cursor pointed to. This SEEMS to be the root of all my problems

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Control commands would be like ControlClick, ControlSend, etc., which are for interacting with an application window's controls, not finding RGB patterns. As you haven't been real clear about exactly what you're trying to do, I threw that out as a suggestion for manipulating application windows; much more stable than PixelSearch.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I feel pixelsearch is much easier for what I am trying to do - creating a bot that will click on certain colors when they appear. I don't want to interact with controls on the window. I just want to click on colors. But again that isn't the main problem as I can't even get it to click on the right thing...

Share this post


Link to post
Share on other sites

What's your DPI setting in Windows set to?


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

#10 ·  Posted

I'll step out then, and let someone who knows more about PixelSearch and the magnifier tool try to help. I will throw out that I hope you've read our forum rules, especially when it comes to game automation. The forum is happy to help as long as your question remains inside the rules.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#11 ·  Posted

Also automation of this forum is frowned upon for good reason.

Share this post


Link to post
Share on other sites

#12 ·  Posted

For clarification, I'm making automation for a clicker for a button I am making on a web app I'm developing. I have not played games in a long time so I have no interest in that stuff.

 

I've been trying to fiddle around with the offset and found that it is AROUND 200 by 100 pixels OFF from where the cursor is. I have tried adjusting but what i mean by AROUND is because it changes EACH TIME! I measured it 6 times and they all gave me very different results for different areas of my screen, which is VERY ODD, because I know I placed my cursor on the correct pixel each time to measure the difference between where my mouse magnifier should be and where it actually is.

 

Here is a text file of all the different offsets. I am confused as hell.

offset.txt

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Unfortunately, I also don't have much experience using PixelSearch(), and I didn't know there was a magnifier tool. :> I just took a look at it.

Edited by czardas

Share this post


Link to post
Share on other sites

#15 ·  Posted

Does yours work as intended? As in show the pixels of where your cursor is?

Share this post


Link to post
Share on other sites

#16 ·  Posted

Here is a really nice script from @jokke Took me forever to find, but it has helped me out a lot with my pixel search projects.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\icons\pixel_icons.ico
#AutoIt3Wrapper_Outfile=..\programs\Pixel Search.exe
#AutoIt3Wrapper_Run_Tidy=y
#Tidy_Parameters=/tc 4 /reel
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

; ---------------------------------------------
; PixelSearch Helper.
;
; Version    : 1.0
;
; Written by : Jokke
; Date       : 2008.02.17
; Contact    : joachim.nordvik@gmail.com
; ---------------------------------------------
#NoTrayIcon
#include <GUIConstants.au3>
#include <Misc.au3>
#include <GuiListView.au3>
#include <array.au3>

HotKeySet("!c", "Color_Set")

Opt("MouseCoordMode", 1)

Global $version = "1.0"
Global $wintitle = "Pixel-Search Helper V." & $version

Dim $GUI, $Left, $Top, $Right, $Bottom

$GUI_MAIN = GUICreate($wintitle, 210, 300, -1, -1)
;Color
$color_label = GUICtrlCreateEdit('Hover mouse over selected color, press Alt+C to set color. Or write hex color into input box.', 5, 5, 200, 50, $ES_READONLY)
$color_graphic = GUICtrlCreateGraphic(5, 60, 100, 50)
$color_input = GUICtrlCreateInput("FFFFFF", 110, 60, 95, 22)
$color_change = GUICtrlCreateButton("Set color", 110, 86, 95, 22)
GUICtrlSetBkColor($color_graphic, 0xffffff)
;Code.
$code_label = GUICtrlCreateEdit('Draw search area when you select draw area. Step 1 find start position top-left area press Alt, Step 2 find bottom-right area, press Alt. Done.', 5, 115, 200, 60, $ES_READONLY)
$code_button = GUICtrlCreateButton("Draw Area", 5, 180, 100, 22)
Dim $code_array
;Search.
$search_times = 0
$search_success = 0
$search_label = GUICtrlCreateEdit('Test a search here, remeber to draw area first. You have tested search ' & $search_times & ' times this session. Search have succeeded ' & $search_success & ' times this session.', 5, 205, 200, 60, $ES_READONLY)
$search_button = GUICtrlCreateButton("Test search", 5, 270, 100, 22)
;Output Code.
$output_button = GUICtrlCreateButton("Create code", 110, 270, 97, 15)
;Ontop
$ontop_label = GUICtrlCreateLabel("Keep me on top", 112, 285)
$ontop_check = GUICtrlCreateCheckbox("", 194, 287, 12, 12)
GUISetState(@SW_SHOW)

GUICtrlSetState($ontop_check, $GUI_CHECKED)
WinSetOnTop($wintitle, "", 1)

While 1
    $msg = GUIGetMsg($GUI_MAIN)
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ontop_check
            If BitAND(GUICtrlRead($ontop_check), $GUI_CHECKED) = 1 Then
                WinSetOnTop($wintitle, "", 1)
            Else
                WinSetOnTop($wintitle, "", 0)
            EndIf
        Case $color_change
            $color = Dec(GUICtrlRead($color_input))
            GUICtrlSetBkColor($color_graphic, $color)
        Case $code_button
            If UBound($code_array) > 0 Then
                GUIDelete($GUI)
                GUIDelete($Top)
                GUIDelete($Left)
                GUIDelete($Right)
                GUIDelete($Bottom)
            EndIf

            $code_array = Draw_Area()
        Case $search_button
            If UBound($code_array) > 0 Then
                TestSearch($code_array, Dec(GUICtrlRead($color_input)))
            Else
                MsgBox(64, "Error", "Remember to draw search area before you test search.", 10)
            EndIf
        Case $output_button
            If UBound($code_array) > 0 Then
                Create_Code($code_array, Dec(GUICtrlRead($color_input)))
            Else
                MsgBox(64, "Error", "Remember to draw search area before you create code.", 10)
            EndIf
    EndSwitch
WEnd

Func Create_Code($array, $color)

    $GUI_Output = GUICreate($wintitle & " generated code.", 500, 400)

    GUISetFont(9, 400, 0, "Lucida Console")

    $console = GUICtrlCreateEdit("", 5, 5, 490, 350)
    GUICtrlSetData($console, ";------------------------------" & @CRLF, 1)
    GUICtrlSetData($console, "; " & $wintitle & " generated code." & @CRLF, 1)
    GUICtrlSetData($console, ";" & @CRLF, 1)
    GUICtrlSetData($console, "; Version   : " & $version & @CRLF, 1)
    GUICtrlSetData($console, "; Generated : " & @HOUR & ":" & @MIN & ":" & @SEC & " - " & @YEAR & "." & @MON & "." & @MDAY & @CRLF, 1)
    GUICtrlSetData($console, ";" & @CRLF, 1)
    GUICtrlSetData($console, "; Created by: Joachim Nordvik" & @CRLF, 1)
    GUICtrlSetData($console, "; Contact   : Joachim.Nordvik@gmail.com" & @CRLF, 1)
    GUICtrlSetData($console, ";------------------------------" & @CRLF, 1)
    GUICtrlSetData($console, "" & @CRLF, 1)
    GUICtrlSetData($console, "" & @CRLF, 1)
    GUICtrlSetData($console, "" & @CRLF, 1)
    GUICtrlSetData($console, "While 1" & @CRLF, 1)
    GUICtrlSetData($console, "  $search = PixelSearch(" & $array[1] & "," & $array[0] & "," & $array[2] & "," & $array[3] & "," & $color & ",5)" & @CRLF, 1)
    GUICtrlSetData($console, "  If Not @error Then" & @CRLF, 1)
    GUICtrlSetData($console, '      ;This is where you add your own code.' & @CRLF, 1)
    GUICtrlSetData($console, '      ConsoleWrite("Found pixel matching color, X: "&$search[0]&" Y: "&$search[1]&@crlf)' & @CRLF, 1)
    GUICtrlSetData($console, '  EndIf' & @CRLF, 1)
    GUICtrlSetData($console, '  Sleep(25)' & @CRLF, 1)
    GUICtrlSetData($console, 'Wend' & @CRLF, 1)

    $output_copy = GUICtrlCreateButton("Copy code", 5, 365, 100, 22)

    GUISetState(@SW_SHOW)

    While 1
        $msg2 = GUIGetMsg($GUI_Output)
        Switch $msg2
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $output_copy
                ClipPut(GUICtrlRead($console))
        EndSwitch
    WEnd

    GUIDelete($GUI_Output)

EndFunc   ;==>Create_Code

Func TestSearch($array, $color)

    MsgBox(0, "Search", "Searching for color: " & Hex($color), 5)

    $search_times += 1
    Local $success = 0
    Local $timer[2] = [TimerInit(), 2000] ;Test search for 1 secound.

    While 1
        $search = PixelSearch($array[1], $array[0], $array[2], $array[3], $color, 10)
        If Not @error Then
            $search_success += 1
            $success = 1
            ExitLoop
        EndIf

        If TimerDiff($timer[0]) > $timer[1] Then
            ExitLoop
        EndIf
    WEnd

    If $success = 1 Then
        MsgBox(0, "Search succeeded.", "Found color @ X: " & $search[0] & " Y: " & $search[1], 10)
        MouseMove($search[0], $search[1], 1)
    Else
        MsgBox(0, "Search failed.", "Unable to find color.", 10)
    EndIf

    GUICtrlSetData($search_label, 'Test a search here, remeber to draw area first. You have tested search ' & $search_times & ' times this session. Search have succeeded ' & $search_success & ' times this session.')

EndFunc   ;==>TestSearch

Func Draw_Area()

    ; ---------------------------------------------------------------------
    ; Thanks to Manadar who wrote parts of this consept, once upon a time.
    ; ---------------------------------------------------------------------

    Do
        $pos = MouseGetPos()
        ToolTip("Click Alt to set." & @CRLF & "top: " & $pos[1] & " left: " & $pos[0])
        Sleep(25)
    Until _IsPressed(12)
    ToolTip("")

    Local $ScanWidth = 1, $ScanHeight = 1
    Local $positions[4]
    $x = $pos[0]
    $y = $pos[1]
    $GUI = GUICreate("", 0, 0, $x, $y, $WS_POPUP)
    $Top = GUICreate("Top Line", $ScanWidth, 2, $x, $y, $WS_POPUP, -1, $GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Left = GUICreate("Left Line", 2, $ScanHeight, $x, $y, $WS_POPUP, -1, $GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Right = GUICreate("Right Line", 2, $ScanHeight, $x + $ScanWidth - 2, $y, $WS_POPUP, -1, $GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    $Bottom = GUICreate("Bottom Line", $ScanWidth, 2, $x, $y + $ScanHeight, $WS_POPUP, -1, $GUI)
    GUISetBkColor(0xFF0000)
    GUISetState()
    Sleep(800)

    Do
        $MousePos = MouseGetPos()
        ToolTip("Click Alt to set." & @CRLF & "bottom: " & $MousePos[1] - $y & " right: " & $MousePos[0] - $x)
        WinMove($Top, "", $x, $y, $ScanWidth, 2)
        WinMove($Left, "", $x, $y, 2, $ScanHeight)
        WinMove($Right, "", $x + $ScanWidth - 2, $y, 2, $ScanHeight)
        WinMove($Bottom, "", $x, $y + $ScanHeight, $ScanWidth, 2)
        If Not (($MousePos[0] - $x) <= 0) Then
            $ScanWidth = $MousePos[0] - $x + 1
        EndIf
        If Not (($MousePos[1] - $y) <= 0) Then
            $ScanHeight = $MousePos[1] - $y - 1
        EndIf
    Until _IsPressed(12)

    $positions[0] = $y
    $positions[1] = $x
    $positions[2] = $MousePos[0] ; - $y
    $positions[3] = $MousePos[1] ; - $x

    ToolTip("")

    Return $positions
EndFunc   ;==>Draw_Area

Func Color_Set()
    $color = PixelGetColor(MouseGetPos(0), MouseGetPos(1))
    GUICtrlSetBkColor($color_graphic, $color)
    $color = Hex($color)
    GUICtrlSetData($color_input, $color)
EndFunc   ;==>Color_Set

 


 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Share this post


Link to post
Share on other sites

#17 ·  Posted

Thank you, I'm reading it - but again, the entire problem lies in the magnifier tool. It can't even find the right pixel for where my mouse is, so that's why all the other functions are not working. 

I'm trying to change layout and everything but nothing seems to work here

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I'm not sure that combining this magnifier tool with Pixel functions is either the intention or reliable. To get the pixel colour of the current mouse location this should work:

Local $aCoords = MouseGetPos()
Local $iColor = PixelGetColor($aCoords[0], $aCoords[1])
MsgBox(0, "Colour", $iColor)

Edit: The magnifier tool seems to behave in a strange way. I need to play around with it and I don't have much time right now.

Edited by czardas

Share this post


Link to post
Share on other sites

#19 ·  Posted

You might want to take a look at internet explorer functions. Search for the characters _IE on the Index tab of the help file.

Share this post


Link to post
Share on other sites

#20 ·  Posted

It is still the issue. I have tried to locate certain pixels where the color is red, and it has found the red pixels and targeted them, but the cursor points below the target.

 

How do I know that it found the red pixel? Because the magnifier actually shows it clicking on the red pixel, but the cursor is offset. So I know pixelsearch works, but magnifier does not. At least the cursor is somehow off (and it VARIES like I said, not just offset by a static number of pixels).

 

I hate this. I might just use some other program, but I have found it works fine for other people (they have all used windows 7 or below tho, as far as I can tell)

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