Jump to content

Need help with PixelSearch Reverse


Gissel
 Share

Recommended Posts

Hello out there on the forums, im new at this AutoIt so im here for some help :)

i was reading up on a tutorial trying to make a script for Bejeweled.

But as soon as it try to scan from Cornor 1 to Cornor 4, it never find the specified color in that cornor.

Hope you understand what im trying to explain.

_log("Searching top left position of playfield")
ToolTip('Searching top left position pixel with color ' & hex($CornerColor1, 6) , 0, 0)

$Corner1 = pixelSearch(0,0,@DesktopWidth,@DesktopHeight, $CornerColor1,0)
If @error Then
msgbox(0,"","Top Left pixel with color: " & hex($CornerColor1, 6) & " not found ")
exit
Else
MouseMove($corner1[0],$corner1[1])
endif

_log("Searching bottom right position of playfield")
ToolTip('Searching bottom right position pixel with color ' & hex($CornerColor4, 6) , 0, 0)

$Corner4=_pixelSearchReverse(0,0,@DesktopWidth,@DesktopHeight, $CornerColor4)
If @error Then
msgbox(0,"","Bottom Right pixel with color: " & hex($CornerColor4, 6) & " not found")
exit
Else
MouseMove($corner4[0],$corner4[1])
endif

Func _pixelSearchReverse($left,$top,$right,$bottom,$color)
$coordFoundColor=_ArrayCreate("-1","-1")
$i = 0
$j = 0

for $i = @DesktopWidth to 0 Step -1
for $j = @DesktopHeight to 0 Step -1

$currentcolor = PixelGetColor($i,$j)
if $currentcolor = $color then
$coordFoundColor[0] = $i
$coordFoundColor[1] = $j
return $coordFoundColor
endif

next
next
SetError(-1)
endFunc
Link to comment
Share on other sites

  • Moderators

Hi, Gissel, welcome to the forum. Unfortunately you seem to have missed the rules on the way in, especially the part about not discussing automation of games. Please read through the rules to see why you will not receive any assistance with this topic.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

Gissel,

JLogan3o13 is quite right - please read the Forum Rules - particularly the bit about not discussing game automation - before you post again. Thread locked. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...