Jump to content

PixelSearch Question


Sobiech
 Share

Recommended Posts

Hi :D Today i need help with clicking by Pixel Color

I am trying to use PixelSearch and i dont know hot to focus his attention on Paint window (example ofc ^^) or other windows. I tried this

#Include <Misc.au3>

$IC_Unique0 = 0x5C584D
$IC_Unique1 = 0x8E8478

HotKeySet("{F1}", "_Exit")

While 1
If _IsPressed(12) Then ; 12 = ALT
PixelSearch(>>HERE I must write something, what will focus coords to Paint window <<, $IC_Unique0 Or $IC_Unique1)
If @error Then
    MsgBox(0, ":)", "Found")
EndIf
EndIf
WEnd

Func _Exit()
    Exit
EndFunc

I think this isnt hard, but i dont have any idea ;\

This world is crazy

Link to comment
Share on other sites

What does the help file say under PixelSearch(), about the hwnd parameter...

:D

#Include <Misc.au3>

Opt("MouseCoordMode", 2)
Opt("PixelCoordMode", 2)

$IC_Unique0 = 0x5C584D
$IC_Unique1 = 0x8E8478
$Title = "Diablo II"

HotKeySet("{F1}", "_Exit")

While 1
If _IsPressed(12) Then 
Sleep(1000)
$coord = PixelSearch(0, 0, 800, 600, $IC_Unique0 Or $IC_Unique1, "", "", $title)
MouseClick("left", $coord[0], $coord[1])
If Not @Error Then
MsgBox(0, "Found...", "Unique")
EndIf
EndIf
WEnd

Func _Exit()
Exit
EndFunc

Example on Game Window :huggles:

But seems doesnt work

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\UserName\Desktop\Pickit.au3"    
C:\Users\Flames\Desktop\Pickit.au3 (21) : ==> Subscript used with non-Array variable.:
MouseClick("left", $coord[0], $coord[1])
MouseClick("left", $coord^ ERROR
>Exit code: 1    Time: 2.811

This world is crazy

Link to comment
Share on other sites

I don't care why it isn't working on a game, but you should always check the validity of a returned array before using it. Check the result with something like:

If @error = 0 Then
      ; ...
EndIf

- or - 

If IsArray($coord) Then
      ; ...
EndIf

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hmm where is difference between

If Not @error

or

If @error = 0

??

Anyway i know, this PixelSearch working good, but not finding color :mellow

I will try to change some values of color but now i must go away :D

Cu

This world is crazy

Link to comment
Share on other sites

The difference is you didn't check that until AFTER you tried to use the $coord array:

$coord = PixelSearch(0, 0, 800, 600, $IC_Unique0 Or $IC_Unique1, "", "", $title)
MouseClick("left", $coord[0], $coord[1])

Should have been:

$coord = PixelSearch(0, 0, 800, 600, $IC_Unique0 Or $IC_Unique1, "", "", $title)
If @error Then
     MsgBox(16, "Error", "Pixel not found")
Else
     MouseClick("left", $coord[0], $coord[1])
     
    ; ...

EndIf
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

First, you passed a string title instead of the handle to the hwnd parameter.

Second, it's a game. Probably has GameGuard or similar blocking on it.

Third, it's a game script. How did I let myself get sucked into this...?

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Second, it's a game. Probably has GameGuard or similar blocking on it.

Nope, i am 100% sure that method in this game can be done by AutoIT and Pixel colors : (there are many aplications for this in Au)

Third, it's a game script. How did I let myself get sucked into this...?

:D

I dont know ^^ Maybe you playied in games :D

Anyway thx for any help :huggles:

This world is crazy

Link to comment
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
 Share

  • Recently Browsing   0 members

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