Jump to content

pixelsearch *Need help to fix pixelsearch with variables*


Recommended Posts

Hello,

Can any1 help my fix my code.

What code have to do is. If i mouseclick some location, it have to save location cordinates and its clolor and use it later on-.

It would be better if it is able to find pixel colour cordinates +-10 pixels and +-10 color difference

PixelSearch($TestBlock[0], $TestBlock[1], $TestBlock[0] 10, $TestBlock[1] 10, $iColor, 10)

If i use code

 GUICtrlSetData($info, " Color code is  " & $iColor & " Cordinates are  " & $TestBlock)

it does not show any of cordinate or pixel color

Func _DC()
 PixelSearch($TestBlock[0], $TestBlock[1], $TestBlock[0], $TestBlock[1], $iColor)
If Not @error Then
Sleep(10)
Else
MsgBox(52, "error", $iColor & "Block not found")


EndIf
EndFunc

Func _TestBlock()
GUICtrlSetColor($info, $COLOR_BLUE)
If Not _IsPressed("01") Then
Sleep(10)
GUICtrlSetData($info, "Select Controll Block")
GUICtrlSetColor($info, $COLOR_RED)
GUICtrlSetFont($info, 18)
_TestBlock()
Else
Sleep(200)
$iColor = PixelGetColor
$TestBlock = MouseGetPos()
Sleep(50)
GUICtrlSetData($info, "Block Selected")
Sleep(50)
EndIf
EndFunc

 

Edited by dersiniar
Link to comment
Share on other sites

1 hour ago, dersiniar said:

Hello,

Can any1 help my fix my code.

What code have to do is. If i mouseclick some location, it have to save location cordinates and its clolor and use it later on-.

It would be better if it is able to find pixel colour cordinates +-10 pixels and +-10 color difference

PixelSearch($TestBlock[0], $TestBlock[1], $TestBlock[0] 10, $TestBlock[1] 10, $iColor, 10)

If i use code

 GUICtrlSetData($info, " Color code is  " & $iColor & " Cordinates are  " & $TestBlock)

it does not show any of cordinate or pixel color

Func _DC()
 PixelSearch($TestBlock[0], $TestBlock[1], $TestBlock[0], $TestBlock[1], $iColor)
If Not @error Then
Sleep(10)
Else
MsgBox(52, "error", $iColor & "Block not found")


EndIf
EndFunc

Func _TestBlock()
GUICtrlSetColor($info, $COLOR_BLUE)
If Not _IsPressed("01") Then
Sleep(10)
GUICtrlSetData($info, "Select Controll Block")
GUICtrlSetColor($info, $COLOR_RED)
GUICtrlSetFont($info, 18)
_TestBlock()
Else
Sleep(200)
$iColor = PixelGetColor
$TestBlock = MouseGetPos()
Sleep(50)
GUICtrlSetData($info, "Block Selected")
Sleep(50)
EndIf
EndFunc

 

I figured out with help of google. 

Ill paste my code that works, maybe it will help someone in future ;)

Func _DC()
 PixelSearch($TestBlock[1], $TestBlock[0], $TestBlock[1]+10, $TestBlock[0]+10, $iColor, 10)

If Not @error Then
    GUICtrlSetData($info, " Color code is  " & $iColor & " Cordinates are  " & $TestBlock)
Sleep(10)
Else
MsgBox(52, "error", $iColor & "Block not found")


EndIf
EndFunc

Func _TestBlock()
GUICtrlSetColor($info, $COLOR_BLUE)
If Not _IsPressed("01") Then
Sleep(10)
GUICtrlSetData($info, "Select Controll Block")
GUICtrlSetColor($info, $COLOR_RED)
GUICtrlSetFont($info, 18)
_TestBlock()
Else
Sleep(200)
$TestBlock = MouseGetPos()
$iColor = PixelGetColor($TestBlock[0], $TestBlock[1])
Sleep(50)
GUICtrlSetData($info, "Block Selected")
Sleep(50)
EndIf
EndFunc

 

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...