Sign in to follow this  
Followers 0
Shifthappens

Pixelsearch isn't working on the laptop

3 posts in this topic

I'm not sure, why, but it seems that Pixelsearch isn't working on my laptop. I tested it just to make sure, and it's definitely not working. Any idea if there's a function or something that will make the laptop recognize Pixelsearch or a different approach at pixelsearch? Here's the two codes I made to test it out.

First Code: If Pixel at X location is X color, MsgBox popup and function endloop.

HotKeySet("{1}","Start")
HotKeySet("{2}","Stop")
dim $i
dim $pos[2]
dim $check
Func Start()
   MsgBox(0,"Started","Started")
   for $i = 1 to 9999999999
 $check = PixelGetColor(345,344)
 if not @Error Then
if $check = 16756425 Then
MsgBox(0,"Worked","Worked")
ExitLoop
EndIf
 EndIf
  Next
   MsgBox(0,"Done","Done")
EndFunc
Func Stop()
   Exit
EndFunc
While 1
   Sleep(10)
WEnd

Second Code: If area around Pixel at X location is X color then MsgBox popup and function endloop.<-Doesn't work on laptop at all.

HotKeySet("{1}","Start")
HotKeySet("{2}","Stop")
dim $i
dim $pos[2]
dim $check
Func Start()
   MsgBox(0,"Started","Started")
   for $i = 1 to 9999999999
 $check = PixelSearch(300,400,300,400,16756425)
 if not @Error Then
if $check = 16756425 Then
MsgBox(0,"Worked","Worked")
ExitLoop
EndIf
 EndIf
  Next
   MsgBox(0,"Done","Done")
EndFunc
Func Stop()
   Exit
EndFunc
While 1
   Sleep(10)
WEnd

Share this post


Link to post
Share on other sites



i can find in help file that PixelGetColor can return @Error

never the less what does $check return on laptop? maybe it's some different color?

as for PixelSearch its litle dumb to call it "If area around Pixel"

if you have 300,400,300,400, there isnt any around on that coordinates, and PixelSearch return two-element array with coordinates and not color to compare it with something.


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

try this & see if it works: Its like autoit window info tool, but for pixelsearch.

Note that this code is not written by me & I do not know who made it, whoever it was, he didnt include anything in the script header.

In any case this is what I use when I need to do pixelsearch.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>
#include <Color.au3>
#include <Array.au3>
#Include <Misc.au3>
Global $Form1 = GUICreate("FLEXY", 321, 148, 340, 243, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
$Label1 = GUICtrlCreateLabel("Mouse Coordinates :", 16, 12, 101, 17)
$Label2 = GUICtrlCreateLabel("Hex Color :", 16, 36, 56, 17)
$Label3 = GUICtrlCreateLabel("Decimal Color :", 16, 60, 75, 17)
$Label4 = GUICtrlCreateLabel("RGB Color :", 16, 84, 60, 17)
$Label5 = GUICtrlCreateLabel("", 216, 34, 42, 40)
Global $Input1 = GUICtrlCreateInput("X", 120, 8, 65, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_READONLY))
$Input2 = GUICtrlCreateInput("Y", 192, 8, 65, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_READONLY))
$Input3 = GUICtrlCreateInput("", 120, 32, 89, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_READONLY))
$Input4 = GUICtrlCreateInput("", 120, 56, 89, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_READONLY))
$Input5 = GUICtrlCreateInput("Red", 120, 80, 41, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_READONLY))
$Input6 = GUICtrlCreateInput("Green", 168, 80, 41, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_READONLY))
$Input7 = GUICtrlCreateInput("Blue", 216, 80, 41, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_READONLY))
$Button1 = GUICtrlCreateButton("Copy", 264, 6, 41, 24, 0)
$Button2 = GUICtrlCreateButton("Copy", 264, 30, 41, 24, 0)
$Button3 = GUICtrlCreateButton("Copy", 264, 54, 41, 24, 0)
$Button4 = GUICtrlCreateButton("Copy", 264, 78, 41, 24, 0)
$Button5 = GUICtrlCreateButton("Copy All", 128, 112, 57, 25, 0)
$Button6 = GUICtrlCreateButton("Freeze", 16, 112, 57, 25, 0)
$Button7 = GUICtrlCreateButton("Hotkeys", 72, 112, 57, 25, 0)
$Button8 = GUICtrlCreateButton("Pixel Search", 184, 112, 81, 25, 0)
$Button9 = GUICtrlCreateButton("Exit", 264, 112, 41, 25, 0)
$2Form1 = GUICreate("FLEXY - Pixel Search", 321, 308, 340, 423, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
$2Label1 = GUICtrlCreateLabel("First Coordinate :", 16, 24, 83, 17)
$2Label2 = GUICtrlCreateLabel("Second Coordinate :", 16, 48, 101, 17)
$2Input1 = GUICtrlCreateInput("X", 128, 18, 65, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$2Input2 = GUICtrlCreateInput("Y", 200, 18, 65, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$2Input3 = GUICtrlCreateInput("X", 128, 42, 65, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$2Input4 = GUICtrlCreateInput("Y", 200, 42, 65, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$2Label3 = GUICtrlCreateLabel("Hex Color - Variation :", 16, 72, 106, 17)
$2Input5 = GUICtrlCreateInput("", 128, 66, 97, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$2Input6 = GUICtrlCreateInput("0", 232, 66, 33, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$2Button1 = GUICtrlCreateButton("C", 272, 18, 25, 21, 0)
GUICtrlSetTip(-1, "Copy here main window coordinates.")
$2Button2 = GUICtrlCreateButton("C", 272, 42, 25, 21, 0)
GUICtrlSetTip(-1, "Copy here main window coordinates.")
$2Button3 = GUICtrlCreateButton("C", 272, 66, 25, 21, 0)
GUICtrlSetTip(-1, "Copy here main window hex color.")
$2Button4 = GUICtrlCreateButton("Search 1", 16, 96, 65, 25, 0)
GUICtrlSetTip(-1, "Search and if found only show result.")
$2Button5 = GUICtrlCreateButton("Search 2", 88, 96, 65, 25, 0)
GUICtrlSetTip(-1, "Search and if found move mouse there.")
$2Button6 = GUICtrlCreateButton("Search 3", 160, 96, 65, 25, 0)
GUICtrlSetTip(-1, "Search and if found click there.")
$2Button7 = GUICtrlCreateButton("Search 4", 232, 96, 65, 25, 0)
GUICtrlSetTip(-1, "Search and if found click there and move mouse preceding position.")
$2Group1 = GUICtrlCreateGroup("Repeat search ?", 16, 168, 281, 41)
$2Radio2 = GUICtrlCreateRadio("No", 25, 185, 41, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "Normal search.")
$2Radio1 = GUICtrlCreateRadio("Yes", 67, 185, 41, 17)
GUICtrlSetTip(-1, "Search until press esc button.")
$2Radio8 = GUICtrlCreateRadio("Loop until error", 112, 185, 89, 17)
GUICtrlSetTip(-1, "Search until not find.")
$2Radio9 = GUICtrlCreateRadio("Loop until find", 204, 185, 89, 17)
GUICtrlSetTip(-1, "Search until find.")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$2Group2 = GUICtrlCreateGroup("Search where ?", 16, 210, 281, 41)
$2Radio3 = GUICtrlCreateRadio("Fullscreen search", 121, 227, 105, 17)
GUICtrlSetTip(-1, "Search in fullscreen.")
$2Radio4 = GUICtrlCreateRadio("Region search", 25, 227, 89, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "Search in your coordinates.")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$2Group3 = GUICtrlCreateGroup("Click which button ?", 16, 252, 281, 41)
$2Radio5 = GUICtrlCreateRadio("Left button", 25, 269, 73, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "For Search 3 and 4 methods using left mouse click.")
$2Radio6 = GUICtrlCreateRadio("Left button double", 183, 269, 105, 17)
GUICtrlSetTip(-1, "For Search 3 and 4 methods using double left mouse click.")
$2Radio7 = GUICtrlCreateRadio("Right Button", 100, 269, 81, 17)
GUICtrlSetTip(-1, "For Search 3 and 4 methods using right mouse click.")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$2Label4 = GUICtrlCreateLabel("Search Result ( Coordinate ) :", 16, 136, 143, 17)
$2Input7 = GUICtrlCreateInput("X", 160, 132, 65, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
$2Input8 = GUICtrlCreateInput("Y", 232, 132, 65, 21, BitOR($ES_CENTER, $ES_AUTOHSCROLL))
Global $pos, $colordec, $colorrgb, $colorhex, $position, $mousex, $mousey, $boxx, $boxy, $boxhex, $search, $search1x, $search1y, $search2x, $search2y, $searchcolor, $searchshade, $searcharray
Global $st1, $st2, $st3, $st4, $colorred, $colorgreen, $colorblue, $pause, $error, $s
Global Const $width = @DesktopWidth
Global Const $height = @DesktopHeight
HotKeySet("{PAUSE}", "pause")
HotKeySet("^!q", "copy1")
HotKeySet("^!w", "copy2")
HotKeySet("^!e", "copy3")
HotKeySet("^!r", "copy4")
HotKeySet("^!t", "copy5")
$key = "09" ;TAB key
GUISetState(@SW_SHOW, $Form1)
While 1
    $msg = GUIGetMsg(1)
    If $pause = 0 Then
        start()
    EndIf
    Select
        Case $msg[0] = $Button1
            copy1()
        Case $msg[0] = $Button2
            copy2()
        Case $msg[0] = $Button3
            copy3()
        Case $msg[0] = $Button4
            copy4()
        Case $msg[0] = $Button5
            copy5()
        Case $msg[0] = $Button6
            If $pause = 0 Then
                $pause = 1
            Else
                $pause = 0
            EndIf
        Case $msg[0] = $Button7
            MsgBox(0, "Hotkeys", "Pause/Break = Freeze or Unfreeze" & @CRLF & "Ctrl + Alt + Q = Copy Mouse Coordinates " & @CRLF & "Ctrl + Alt + W = Copy Hex Color" & @CRLF & "Ctrl + Alt + E = Copy Decimal Color" & @CRLF & "Ctrl + Alt + R = Copy RGB Color" & @CRLF & "Ctrl + Alt + T = Copy All Datas" & @CRLF & "TAB = Stop Pixel Search Repeat")
        Case $msg[0] = $Button8
            GUISetState(@SW_SHOW, $2Form1)
        Case $msg[0] = $Button9
            Exit
        Case $msg[0] = $2Button1
            $boxx = GUICtrlRead($Input1)
            GUICtrlSetData($2Input1, $boxx)
            $boxy = GUICtrlRead($Input2)
            GUICtrlSetData($2Input2, $boxy)
        Case $msg[0] = $2Button2
            $boxx = GUICtrlRead($Input1)
            GUICtrlSetData($2Input3, $boxx)
            $boxy = GUICtrlRead($Input2)
            GUICtrlSetData($2Input4, $boxy)
        Case $msg[0] = $2Button3
            $boxhex = GUICtrlRead($Input3)
            GUICtrlSetData($2Input5, $boxhex)
        Case $msg[0] = $2Button4
            key1()
        Case $msg[0] = $2Button5
            key2()
        Case $msg[0] = $2Button6
            key3()
        Case $msg[0] = $2Button7
            key4()
        Case $msg[0] = $GUI_EVENT_CLOSE
            If $msg[1] = $Form1 Then Exit
            If $msg[1] = $2Form1 Then GUISetState(@SW_HIDE, $2Form1)
    EndSelect
WEnd
Func start()
    Sleep(50)
    test1()
    test2()
    GUICtrlSetData($Input1, $mousex)
    GUICtrlSetData($Input2, $mousey)
    GUICtrlSetData($Input3, $colorhex)
    GUICtrlSetData($Input4, $colordec)
    GUICtrlSetData($Input5, $colorred)
    GUICtrlSetData($Input6, $colorgreen)
    GUICtrlSetData($Input7, $colorblue)
    GUICtrlSetBkColor($Label5, $colorhex)
EndFunc   ;==>start
Func test1()
    $pos = MouseGetPos()
    $colordec = PixelGetColor($pos[0], $pos[1])
    $colorhex = "0x" & Hex($colordec, 6)
    $colorred = _ColorGetRed($colordec)
    $colorgreen = _ColorGetGreen($colordec)
    $colorblue = _ColorGetBlue($colordec)
    $position = $pos[0] & ", " & $pos[1]
    $mousex = $pos[0]
    $mousey = $pos[1]
EndFunc   ;==>test1
Func test2()
    $st1 = StringFormat($pos[0] & ", " & $pos[1])
    $st2 = StringFormat($colorhex)
    $st3 = StringFormat($colordec)
    $st4 = StringFormat($colorred & " " & $colorgreen & " " & $colorblue)
EndFunc   ;==>test2
Func test3()
    $search1x = GUICtrlRead($2Input1)
    $search1y = GUICtrlRead($2Input2)
    $search2x = GUICtrlRead($2Input3)
    $search2y = GUICtrlRead($2Input4)
    $searchcolor = GUICtrlRead($2Input5)
    $searchshade = GUICtrlRead($2Input6)
EndFunc   ;==>test3
Func key1()
    $s = 1
    searchnow()
EndFunc   ;==>key1
Func key2()
    $s = 2
    searchnow()
EndFunc   ;==>key2
Func key3()
    $s = 3
    searchnow()
EndFunc   ;==>key3
Func key4()
    $s = 4
    searchnow()
EndFunc   ;==>key4
;test
Func kkey1()
    Sleep(2500)
    $s = 1
    searchnow()
EndFunc   ;==>kkey1
Func kkey2()
    Sleep(2500)
    $s = 2
    searchnow()
EndFunc   ;==>kkey2
Func kkey3()
    Sleep(2500)
    $s = 3
    searchnow()
EndFunc   ;==>kkey3
Func kkey4()
    Sleep(2500)
    $s = 4
    searchnow()
EndFunc   ;==>kkey4
Func searchnow()
    If GUICtrlRead($2Radio2) = $GUI_CHECKED Then
        searchnow2()
    Else
        If GUICtrlRead($2Radio1) = $GUI_CHECKED Then
            While 1
                searchnow2()
                If _IsPressed($key) Then ExitLoop
            WEnd
        Else
            If GUICtrlRead($2Radio8) = $GUI_CHECKED Then
                While 1
                    searchnow2()
                    If $error = 1 Then ExitLoop
                    If _IsPressed($key) Then ExitLoop
                WEnd
            Else
                While 1
                    searchnow2()
                    If $error = 0 Then ExitLoop
                    If _IsPressed($key) Then ExitLoop
                WEnd
            EndIf
        EndIf
    EndIf
EndFunc   ;==>searchnow
Func searchnow2()
    If $s = 1 Then
        search1()
    ElseIf $s = 2 Then
        search2()
    ElseIf $s = 3 Then
        search3()
    ElseIf $s = 4 Then
        search4()
    EndIf
EndFunc   ;==>searchnow2
Func search1()
    searchpixel()
    If $error = 0 Then
        $searcharray = $search
        GUICtrlSetData($2Input7, $searcharray[0])
        GUICtrlSetData($2Input8, $searcharray[1])
    EndIf
EndFunc   ;==>search1
Func search2()
    searchpixel()
    If $error = 0 Then
        $searcharray = $search
        MouseMove($searcharray[0], $searcharray[1], 0)
        GUICtrlSetData($2Input7, $searcharray[0])
        GUICtrlSetData($2Input8, $searcharray[1])
    EndIf
EndFunc   ;==>search2
Func search3()
    searchpixel()
    If $error = 0 Then
        $searcharray = $search
        buttons()
        GUICtrlSetData($2Input7, $searcharray[0])
        GUICtrlSetData($2Input8, $searcharray[1])
    EndIf
EndFunc   ;==>search3
Func search4()
    searchpixel()
    If $error = 0 Then
        $searcharray = $search
        buttons()
        MouseMove($pos[0], $pos[1], 0)
        GUICtrlSetData($2Input7, $searcharray[0])
        GUICtrlSetData($2Input8, $searcharray[1])
    EndIf
EndFunc   ;==>search4
Func searchpixel()
    Sleep(10)
    $error = 0
    test3()
    If $searchshade > 255 Then
        $error = 1
        MsgBox(0, "", "Variation need lower than 255", 5)
    Else
        If GUICtrlRead($2Radio4) = $GUI_CHECKED Then
            $search = PixelSearch($search1x, $search1y, $search2x, $search2y, $searchcolor, $searchshade)
            If @error Then $error = 1
        Else
            $searchcolor = GUICtrlRead($2Input5)
            $searchshade = GUICtrlRead($2Input6)
            $search = PixelSearch(0, 0, $width, $height, $searchcolor, $searchshade)
            If @error Then $error = 1
        EndIf
    EndIf
    If $error = 1 Then
        GUICtrlSetData($2Input7, "Not found!")
        GUICtrlSetData($2Input8, "Not found!")
    EndIf
EndFunc   ;==>searchpixel
Func buttons()
    If GUICtrlRead($2Radio5) = $GUI_CHECKED Then
        MouseClick("left", $searcharray[0], $searcharray[1], 1, 0)
    Else
        If GUICtrlRead($2Radio6) = $GUI_CHECKED Then
            MouseClick("left", $searcharray[0], $searcharray[1], 2, 0)
        Else
            MouseClick("right", $searcharray[0], $searcharray[1], 1, 0)
        EndIf
    EndIf
EndFunc   ;==>buttons
Func pause()
    If $pause = 0 Then
        $pause = 1
    Else
        $pause = 0
    EndIf
EndFunc   ;==>pause
Func copy1()
    ClipPut($st1)
EndFunc   ;==>copy1
Func copy2()
    ClipPut($st2)
EndFunc   ;==>copy2
Func copy3()
    ClipPut($st3)
EndFunc   ;==>copy3
Func copy4()
    ClipPut($st4)
EndFunc   ;==>copy4
Func copy5()
    ClipPut($st1 & " " & $st2 & " " & $st3 & " " & $st4)
EndFunc   ;==>copy5
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

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