Jump to content

PixelSearch Quadruple Checks before continue...


Recommended Posts

I have four pixelsearchs what I need any 3 or more to exist before it actually does something otherwise it needs to do nothing..

$COpenTopBlack = PixelSearch(105, 792, 105, 792, 0x010101, 2)
$COpenTopBrown = PixelSearch(105, 793, 105, 793, 0x594838, 2)
$COpenBottomBlack = PixelSearch(105, 814, 105, 814, 0x010101, 2)
$COpenBottomBlack = PixelSearch(105, 813, 105, 813, 0x594838, 2)

Usually I would do something like this:

$COpenBottomBlack = PixelSearch(105, 813, 105, 813, 0x594838, 2)
If Not @error Then
;Do stuff here if COpen Black is found
Else
; Do nothing as COpen Black was not found
EndIf

However I'm not sure how to make it work so it requires 3 of them to return true before doing stuff..

Any help would be appreciated.

Edited by XxXGoD
Link to comment
Share on other sites

try this " @error = 0 " hope this helps :oops:

$COpenBottomBlack = PixelSearch(105, 813, 105, 813, 0x594838, 2)
If @error = 0 Then
MsgBox(64, "Check", "there's no errors :D")
Else
MsgBox(16, "Check", "There's an error :(")
EndIf

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Link to comment
Share on other sites

try this " @error = 0 " hope this helps :oops:

$COpenBottomBlack = PixelSearch(105, 813, 105, 813, 0x594838, 2)
If @error = 0 Then
MsgBox(64, "Check", "there's no errors :D")
Else
MsgBox(16, "Check", "There's an error :(")
EndIf

That works exactly how my other script works, I'm trying to make it so if two of the searchs return 0 and two return 1 then it doesn't run, but if it returns three or four 0's then it runs.
Link to comment
Share on other sites

I can't solve it :bye:, sorry.. wait other users to help you :oops:

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Link to comment
Share on other sites

  • Moderators

XxXGoD,

I'm not sure how to make it work so it requires 3 of them to return true before doing stuff

If you only want to find any 3 of the 4 then you could do something like this: :bye:

$iCount = IsArray(_PixelSearch(coord1...)) + IsArray(_PixelSearch(coord2...)) + IsArray(_PixelSearch(coord3...)) + IsArray(_PixelSearch(coord4...))
If $iCount > 2 Then
    ; Code for 3 or 4 found
Else
    ; Code for 0, 1, or 2 found
EndIf

Any help? :oops:

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

Thanks M23, that works perfectly I have another PixelSearch question.

If I have a start position of: 130, 100 and an end position of 170, 100

I want to adjust alone the area with a percent... so if I set $VPercent = 30% it would use the coordinates: 145,100

How is this achievable?

Link to comment
Share on other sites

  • Moderators

XxXGoD,

Basic maths? :oops:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $iRange = 40, $iStart = 130

$hGUI = GUICreate("Test", 500, 500)

$cSlider = GUICtrlCreateSlider(10, 10, 200, 20)
$hSlider = GUICtrlGetHandle($cSlider)

GUICtrlCreateLabel("Percent:", 10, 40, 80, 20)
$cLabel_1 = GUICtrlCreateLabel(0, 90, 40, 200, 20)

GUICtrlCreateLabel("Delta:", 10, 70, 80, 20)
$cLabel_2 = GUICtrlCreateLabel(0, 90, 70, 200, 20)

GUICtrlCreateLabel("Search 130 to", 10, 100, 80, 20)
$cLabel_3 = GUICtrlCreateLabel("", 90, 100, 100, 20)

GUISetState()

GUIRegisterMsg($WM_HSCROLL, "_WM_HSCROLL")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func _WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg

    If $lParam = $hSlider Then
        If _WinAPI_LoWord($wParam) = 5 Then ;$SB_THUMBTRACK
            $iPercent = GUICtrlRead($cSlider)
            GUICtrlSetData($cLabel_1, $iPercent)
            $iDelta = Int($iRange * $iPercent / 100)
            GUICtrlSetData($cLabel_2, $iDelta)
            GUICtrlSetData($cLabel_3, $iStart + $iDelta)
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc   ;==>_WM_HSCROLL

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

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