Sign in to follow this  
Followers 0
Vicate

Using a ControlID in PixelSearch?

2 posts in this topic

Hello!

I need help in finding a way to quickly change coordinates using the PixelSearch function.

I am working with a combo box and would like the PixelSearch coordinates to change according to the selection made in the combo box.

What it seems I have to do:

$DropBox = GuiCtrlCreateCombo("Select", 5, 60, 110, 30)
GUICtrlSetData(-1, "1|2|3")

Func _TestA() 
    If GUICtrlRead($DropBox) = "1" Then
        $Coord = PixelSearch(100, 200, 100, 200, 0x40BE44, 30)
    EndIf
    If GUICtrlRead($DropBox) = "2" Then
        $Coord = PixelSearch(150, 250, 150, 250, 0x40BE44, 30)
    EndIf
    If GUICtrlRead($DropBox) = "3" Then
        $Coord = PixelSearch(175, 275, 175, 275, 0x40BE44, 30)
    EndIf
EndFunc

Func _TestB()
    If GUICtrlRead($DropBox) = "1" Then
        $Coord = PixelSearch(300, 400, 300, 400, 0x40BE44, 30)
    EndIf
    If GUICtrlRead($DropBox) = "2" Then
        $Coord = PixelSearch(350, 450, 350, 450, 0x40BE44, 30)
    EndIf
    If GUICtrlRead($DropBox) = "3" Then
        $Coord = PixelSearch(375, 475, 375, 475, 0x40BE44, 30)
    EndIf
EndFunc

Func _TestD()
    If GUICtrlRead($DropBox) = "1" Then
        $Coord = PixelSearch(500, 600, 500, 600, 0x40BE44, 30)
    EndIf
    If GUICtrlRead($DropBox) = "2" Then
        $Coord = PixelSearch(550, 650, 550, 650, 0x40BE44, 30)
    EndIf
    If GUICtrlRead($DropBox) = "3" Then
        $Coord = PixelSearch(575, 675, 575, 675, 0x40BE44, 30)
    EndIf
EndFunc

Func _TestC() 
    If GUICtrlRead($DropBox) = "1" Then
        $Coord = PixelSearch(700, 800, 700, 800, 0x40BE44, 30)
    EndIf
    If GUICtrlRead($DropBox) = "2" Then
        $Coord = PixelSearch(750, 850, 750, 850, 0x40BE44, 30)
    EndIf
    If GUICtrlRead($DropBox) = "3" Then
        $Coord = PixelSearch(775, 875, 775, 875, 0x40BE44, 30)
    EndIf
EndFunc

Something like I would like to do:

(I know it doesn't work)

$CoordTestA = ''
$CoordTestB = ''
$CoordTestD = ''
$CoordTestC = ''

$DropBox = GuiCtrlCreateCombo("Select", 5, 60, 110, 30)
GUICtrlSetData(-1, "1|2|3")

Func _DropBox()
    If GUICtrlRead($DropBox) = "1" Then
        $CoordTestA = '100, 200, 100, 200'
        $CoordTestB = '300, 400, 300, 400'
        $CoordTestD = '500, 600, 500, 600'
        $CoordTestC = '700, 800, 700, 800'
    EndIf
    If GUICtrlRead($DropBox) = "2" Then
        $CoordTestA = '150, 250, 150, 250'
        $CoordTestB = '350, 450, 350, 450'
        $CoordTestD = '550, 650, 550, 650'
        $CoordTestC = '750, 850, 750, 850'
    EndIf
    If GUICtrlRead($DropBox) = "3" Then
        $CoordTestA = '175, 275, 175, 275'
        $CoordTestB = '375, 475, 375, 475'
        $CoordTestD = '575, 675, 575, 675'
        $CoordTestC = '775, 875, 775, 875'
    EndIf
EndFunc


Func _TestA()
    $Coord = PixelSearch($CoordTestA, 0x40BE44, 30)
EndFunc

Func _TestB()
    $Coord = PixelSearch($CoordTestB, 0x40BE44, 30)
EndFunc

Func _TestD()
    $Coord = PixelSearch($CoordTestD, 0x40BE44, 30)
EndFunc

Func _TestC()
    $Coord = PixelSearch($CoordTestC, 0x40BE44, 30)
EndFunc

Considering I am adding multiple functions, I would find the second option preferable for when I go back to add more(I intend to keep adding to the script), and keeping each section more orderly.

If there is a working way similar to the second option, I would greatly appreciate it!

Thank you all for your time :]

-Vicate

Share this post


Link to post
Share on other sites



Nevermind, I figured it out!

(On the off-chance that someone has this same problem) :huh2:

You can use the ControlID only to apply to a single number it seems

ex:

$Number = '175, 275, 175, 275'
$Coord = PixelSearch($Number, 0x40BE44, 30)

would not work, however

$Number1 = 175
$Number2 = 275
$Coord = PixelSearch($Number1, $Number2, $Number1, $Number2, 0x40BE44, 30)

works!

Thanks anyway, guys!

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